/* Widget agent suara (salinan inkey). Variabel tema inkey dipetakan ke palet landing Rekan Bot (gelap, aksen merah). */
.agent-widget {
  --surface: #141416; --surface-2: #1c1c20; --surface-3: #26262b; --border: rgba(255, 255, 255, 0.12);
  --border-strong: rgba(255, 255, 255, 0.24); --text: #f4f4f5; --text-2: #d4d4d8; --text-3: #a1a1aa;
  --primary-bg: #ef233c; --accent-2: #ef233c; --focus: #ef233c; --ok: #22c55e; --bad: #f87171;
  --font: Inter, system-ui, sans-serif; --mono: ui-monospace, monospace;
  color: var(--text); font-family: var(--font);
}
/* Landing tidak punya aturan global [hidden] seperti inkey (app.css). */
.agent-widget [hidden] { display: none !important; }
/* Agen suara inkey: tombol telepon mengambang dan modal panggilan. Semua warna memakai token tema. */
.agent-widget {
  position: fixed;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 80;
}

.agent-bubble {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(145deg, #ef2b3d, #c4162a);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 12px 26px -8px rgba(225, 29, 46, .65), 0 2px 6px rgba(11, 18, 32, .18);
  transition: transform .18s ease, box-shadow .18s ease;
}
.agent-bubble:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 16px 30px -8px rgba(225, 29, 46, .7), 0 3px 8px rgba(11, 18, 32, .2); }
.agent-bubble:active { transform: translateY(0) scale(.98); }
.agent-bubble:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
.agent-bubble-icon { position: relative; z-index: 1; width: 25px; height: 25px; fill: currentColor; }
.agent-bubble-pulse {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: 50%;
  background: rgba(225, 29, 46, .38);
  pointer-events: none;
  animation: agent-bubble-pulse 2.8s ease-out infinite;
}

.agent-modal {
  position: fixed;
  inset: 0;
  z-index: 95;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.agent-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 12, 20, .58);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.agent-card {
  position: relative;
  width: min(360px, 100%);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 26px 24px 20px;
  border: 1px solid var(--border);
  border-radius: 24px;
  background: var(--surface);
  color: var(--text);
  text-align: center;
  box-shadow: 0 30px 80px -24px rgba(8, 12, 20, .55);
  animation: agent-card-in .22s ease-out;
}
.agent-card:focus { outline: none; }
.agent-card:focus-visible { outline: none; }

.agent-close {
  position: absolute;
  top: 12px;
  right: 12px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.agent-close:hover { background: var(--surface-2); color: var(--text); }
.agent-close:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.agent-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.agent-avatar-wrap {
  position: relative;
  display: grid;
  place-items: center;
  width: 92px;
  height: 92px;
  margin: 4px auto 14px;
}
.agent-ring {
  position: absolute;
  inset: 0;
  border: 2px solid rgba(225, 29, 46, .38);
  border-radius: 50%;
  animation: agent-ring 2.6s ease-out infinite;
  pointer-events: none;
}
.agent-ring-2 { animation-delay: .85s; }
.agent-ring-3 { animation-delay: 1.7s; }
.agent-avatar {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 78px;
  height: 78px;
  border-radius: 50%;
  background: linear-gradient(150deg, #ef2b3d, #b81225);
  color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 10px 22px -12px rgba(225, 29, 46, .8);
}
.agent-avatar svg { width: 34px; height: 34px; fill: currentColor; }
.agent-online {
  position: absolute;
  right: 5px;
  bottom: 7px;
  z-index: 2;
  width: 14px;
  height: 14px;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--ok);
}
.agent-card[data-state="idle"] .agent-online,
.agent-card[data-state="error"] .agent-online { background: var(--text-3); }

.agent-name { font-size: 20px; line-height: 1.2; font-weight: 750; letter-spacing: -.01em; }
.agent-sub { margin-top: 3px; font-size: 12px; color: var(--text-3); }

.agent-status { min-height: 21px; margin-top: 14px; font-size: 13.5px; color: var(--text-2); }
.agent-card[data-state="connected"] .agent-status { color: var(--ok); font-weight: 600; }
.agent-card[data-state="error"] .agent-status { color: var(--bad); font-weight: 600; }

.agent-timer {
  margin-top: 4px;
  font: 600 24px/1.2 var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: .06em;
}
.agent-error {
  max-width: 280px;
  margin: 10px auto 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--bad);
}

.agent-actions {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin-top: 18px;
}
.agent-call {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-2);
  font: inherit;
  cursor: pointer;
}
.agent-call:disabled { opacity: .45; cursor: not-allowed; }
.agent-call:focus-visible { outline: none; }
.agent-call:focus-visible .agent-call-icon { outline: 3px solid var(--focus); outline-offset: 3px; }
.agent-call-icon {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--text);
  transition: background .15s ease, transform .15s ease;
}
.agent-call:hover:not(:disabled) .agent-call-icon { transform: translateY(-1px); background: var(--surface-3); }
.agent-call svg { width: 24px; height: 24px; fill: currentColor; }
.agent-call-label { font-size: 11.5px; font-weight: 600; }
.agent-call.is-muted .agent-call-icon { background: var(--text); color: var(--surface); }
.agent-mute-slash { display: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.agent-call.is-muted .agent-mute-slash { display: block; }
.agent-call-end .agent-call-icon { border-color: var(--primary-bg); background: var(--primary-bg); color: #fff; }
.agent-call-end:hover:not(:disabled) .agent-call-icon { background: var(--accent-2); }
.agent-call-end svg { transform: rotate(135deg); }

.agent-retry {
  min-height: 40px;
  margin: 14px auto 0;
  padding: 0 18px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: 600 13px var(--font);
  cursor: pointer;
}
.agent-retry:hover { background: var(--surface-2); }
.agent-retry:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.agent-note { margin-top: 16px; font-size: 10.5px; line-height: 1.45; color: var(--text-3); }

.agent-card[data-state="connected"] .agent-ring { border-color: rgba(18, 161, 80, .35); animation-duration: 3.2s; }
.agent-card[data-state="error"] .agent-ring { display: none; }

@keyframes agent-bubble-pulse {
  0% { transform: scale(1); opacity: .55; }
  70%, 100% { transform: scale(1.5); opacity: 0; }
}
@keyframes agent-ring {
  0% { transform: scale(.82); opacity: .75; }
  70%, 100% { transform: scale(1.38); opacity: 0; }
}
@keyframes agent-card-in {
  from { transform: translateY(10px) scale(.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

@media (max-width: 420px) {
  .agent-widget { right: 14px; bottom: 14px; }
  .agent-modal { align-items: flex-end; padding: 10px; }
  .agent-card { width: 100%; max-height: calc(100dvh - 20px); padding: 24px 16px 16px; border-radius: 22px; }
  .agent-actions { gap: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  .agent-bubble,
  .agent-bubble-pulse,
  .agent-ring,
  .agent-card,
  .agent-call-icon,
  .agent-close { animation: none !important; transition: none !important; }
  .agent-bubble:hover { transform: none; }
  .agent-bubble-pulse { display: none; }
}
