/* ==========================================================================
   QUANTUM UI — Login, Asisten AI, Telepon
   Satu warna aksen (biru-abu dari logo), garis tipis, tanpa gradient/glow.
   Pakai icon "ph" (regular) saja — font bold tidak dimuat di aplikasi ini.
   ========================================================================== */

:root {
  --q-brand: #3f5b72;
  --q-brand-dark: #33495c;
  --q-brand-tint: #eef2f5;
  --q-brand-tint-2: #e1e8ed;
  --q-ink: #1f2933;
  --q-ink-2: #52606d;
  --q-muted: #8a949e;
  --q-line: #e3e6e9;
  --q-line-strong: #d3d8dd;
  --q-paper: #f7f7f5;
  --q-danger: #a8403a;
  --q-danger-dark: #8f3530;
  --q-ok: #4c7a5f;
  --q-warn: #b7791f;
  --q-font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* --------------------------------------------------------------------------
   Pengaman: semua elemen AI tidak ada sama sekali kalau belum login.
   -------------------------------------------------------------------------- */
body:not(.is-logged-in) .q-dock,
body:not(.is-logged-in) .quantum-ai-widget,
body:not(.is-logged-in) #quantum-live-call-wrapper,
body.is-unauthenticated .q-dock,
body.is-unauthenticated .quantum-ai-widget,
body.is-unauthenticated #quantum-live-call-wrapper {
  display: none !important;
}

/* ==========================================================================
   LOGIN
   ========================================================================== */
.lg {
  min-height: 100vh;
  display: flex;
  font-family: var(--q-font);
  color: var(--q-ink);
  background: #ffffff;
}

/* Kolom kiri: warna rata, satu kalimat, satu motif dari logo */
.lg-side {
  flex: 0 0 38%;
  max-width: 520px;
  background: var(--q-brand);
  color: #ffffff;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 40px 44px;
}

.lg-side-name {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  opacity: 0.85;
  position: relative;
  z-index: 1;
}

.lg-side-copy {
  position: relative;
  z-index: 1;
}

.lg-side-copy p {
  font-size: 24px;
  line-height: 1.35;
  font-weight: 500;
  letter-spacing: -0.015em;
  max-width: 17em;
  margin: 0 0 14px;
}

.lg-side-copy small {
  display: block;
  font-size: 13px;
  line-height: 1.5;
  opacity: 0.65;
}

/* Segitiga dari logo, dipotong di pojok — hanya garis, nyaris tak terlihat */
.lg-side-mark {
  position: absolute;
  right: -90px;
  bottom: -70px;
  width: 360px;
  height: 360px;
  opacity: 0.1;
  pointer-events: none;
}

/* Kolom kanan: form rata kiri, tanpa kartu */
.lg-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
}

.lg-box {
  width: 100%;
  max-width: 340px;
}

.lg-logo {
  display: block;
  height: 30px;
  width: auto;
  margin-bottom: 36px;
}

.lg-title {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
  color: var(--q-ink);
}

.lg-lead {
  font-size: 14px;
  color: var(--q-ink-2);
  margin: 0 0 26px;
  line-height: 1.5;
}

.lg-field {
  margin-bottom: 16px;
}

.lg-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--q-ink);
  margin-bottom: 6px;
}

.lg-input-wrap {
  position: relative;
}

.lg-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  font-family: inherit;
  font-size: 14.5px;
  color: var(--q-ink);
  background: #ffffff;
  border: 1px solid var(--q-line-strong);
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.lg-input::placeholder {
  color: #aab2ba;
}

.lg-input:focus {
  outline: none;
  border-color: var(--q-brand);
  box-shadow: 0 0 0 3px rgba(63, 91, 114, 0.12);
}

.lg-input.has-toggle {
  padding-right: 78px;
}

.lg-toggle {
  position: absolute;
  top: 0;
  right: 0;
  height: 42px;
  padding: 0 12px;
  background: none;
  border: none;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--q-ink-2);
  cursor: pointer;
}

.lg-toggle:hover {
  color: var(--q-ink);
}

.lg-submit {
  width: 100%;
  height: 42px;
  margin-top: 6px;
  font-family: inherit;
  font-size: 14.5px;
  font-weight: 600;
  color: #ffffff;
  background: var(--q-brand);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.lg-submit:hover {
  background: var(--q-brand-dark);
}

.lg-submit:disabled {
  opacity: 0.65;
  cursor: default;
}

.lg-error {
  margin: 14px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--q-danger);
}

.lg-error.hidden {
  display: none;
}

.lg-foot {
  margin: 36px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--q-muted);
}

@media (max-width: 860px) {
  .lg-side {
    display: none;
  }
  .lg-main {
    align-items: flex-start;
    padding: 56px 24px 32px;
  }
  .lg-logo {
    margin-bottom: 28px;
  }
}

/* ==========================================================================
   TOMBOL AI (dock kecil di pojok kanan bawah)
   ========================================================================== */
.q-dock {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9998;
  display: flex;
  background: #ffffff;
  border: 1px solid var(--q-line-strong);
  border-radius: 10px;
  box-shadow: 0 1px 2px rgba(31, 41, 51, 0.05), 0 6px 18px rgba(31, 41, 51, 0.08);
  overflow: hidden;
  font-family: var(--q-font);
}

.q-dock .quantum-call-fab,
.q-dock .quantum-ai-fab {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 15px;
  background: transparent;
  border: none;
  color: var(--q-ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.q-dock .quantum-call-fab {
  border-right: 1px solid var(--q-line);
}

.q-dock .quantum-call-fab:hover,
.q-dock .quantum-ai-fab:hover {
  background: var(--q-paper);
}

.q-dock .quantum-ai-fab.is-open {
  background: var(--q-brand-tint);
}

.q-dock i {
  font-size: 17px;
  color: var(--q-brand);
}

@media (max-width: 768px) {
  .q-dock {
    right: 12px;
    bottom: calc(66px + env(safe-area-inset-bottom, 0px));
    z-index: 10001;
  }
  .q-dock .quantum-call-fab,
  .q-dock .quantum-ai-fab {
    width: 42px;
    height: 42px;
    padding: 0;
    justify-content: center;
  }
  .q-dock .q-dock-label {
    display: none;
  }
  .q-dock i {
    font-size: 19px;
  }
}

/* ==========================================================================
   PANEL CHAT
   ========================================================================== */
.quantum-ai-widget {
  position: fixed;
  right: 24px;
  bottom: 76px;
  width: 380px;
  height: 560px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 100px);
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid var(--q-line-strong);
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(31, 41, 51, 0.04), 0 16px 40px rgba(31, 41, 51, 0.14);
  z-index: 9999;
  overflow: hidden;
  font-family: var(--q-font);
  color: var(--q-ink);
  animation: qFadeUp 0.16s ease-out;
}

@keyframes qFadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.ai-widget-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 10px 13px 18px;
  border-bottom: 1px solid var(--q-line);
  background: #ffffff;
}

.ai-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--q-ink);
}

.ai-status {
  font-size: 12px;
  color: var(--q-muted);
  margin-top: 1px;
}

.ai-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.ai-header-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: var(--q-ink-2);
  font-size: 17px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.ai-header-btn:hover {
  background: var(--q-paper);
  color: var(--q-ink);
}

/* Isi percakapan */
.ai-widget-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #ffffff;
}

.ai-msg {
  display: flex;
  flex-direction: column;
  font-size: 13.5px;
  line-height: 1.6;
  animation: qFadeUp 0.14s ease-out;
}

/* Balasan asisten: teks polos tanpa balon */
.ai-msg.assistant {
  align-items: flex-start;
  max-width: 100%;
}

.ai-msg.assistant .ai-bubble {
  color: var(--q-ink);
  padding: 0;
  background: none;
}

/* Pesan kita: balon tipis berwarna biru-abu muda */
.ai-msg.user {
  align-items: flex-end;
  max-width: 86%;
  align-self: flex-end;
}

.ai-msg.user .ai-bubble {
  background: var(--q-brand-tint-2);
  color: var(--q-ink);
  padding: 9px 13px;
  border-radius: 12px 12px 3px 12px;
}

.ai-bubble p { margin: 0 0 6px !important; line-height: 1.6 !important; }
.ai-bubble p:last-child { margin-bottom: 0 !important; }
.ai-bubble ul, .ai-bubble ol { margin: 4px 0 6px !important; padding-left: 18px !important; }
.ai-bubble li { margin-bottom: 3px; }
.ai-bubble strong { font-weight: 600; color: var(--q-ink); }
.ai-bubble code { background: var(--q-paper) !important; border: 1px solid var(--q-line); }

.ai-time {
  font-size: 11px;
  color: var(--q-muted);
  margin-top: 4px;
}

/* Indikator mengetik */
.ai-typing-indicator {
  display: flex;
  gap: 4px;
  padding: 6px 0;
}

.ai-typing-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--q-muted);
  animation: qDot 1.1s infinite ease-in-out;
}

.ai-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.ai-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes qDot {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

/* Topik cepat */
.ai-widget-chips {
  display: flex;
  gap: 6px;
  padding: 8px 18px 10px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  background: #ffffff;
}

.ai-widget-chips::-webkit-scrollbar { display: none; }

.ai-chip-btn {
  flex-shrink: 0;
  padding: 5px 11px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--q-ink-2);
  background: #ffffff;
  border: 1px solid var(--q-line-strong);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.ai-chip-btn:hover {
  background: var(--q-paper);
  color: var(--q-ink);
}

/* Kolom ketik */
.ai-widget-footer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--q-line);
  background: #ffffff;
}

.ai-input {
  flex: 1;
  resize: none;
  max-height: 110px;
  padding: 9px 12px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--q-ink);
  background: #ffffff;
  border: 1px solid var(--q-line-strong);
  border-radius: 8px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.ai-input::placeholder { color: #aab2ba; }

.ai-input:focus {
  outline: none;
  border-color: var(--q-brand);
  box-shadow: 0 0 0 3px rgba(63, 91, 114, 0.1);
}

.ai-btn-send {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--q-brand);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 17px;
  cursor: pointer;
  transition: background 0.15s;
}

.ai-btn-send:hover { background: var(--q-brand-dark); }
.ai-btn-send:disabled { opacity: 0.4; cursor: default; }

@media (max-width: 768px) {
  .quantum-ai-widget {
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
    z-index: 100005;
  }
  .ai-widget-header {
    padding-top: calc(13px + env(safe-area-inset-top, 0px));
  }
  .ai-widget-footer {
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }
  .ai-input { font-size: 16px; } /* cegah zoom otomatis iOS */
}

/* ==========================================================================
   TELEPON (layar panggilan)
   ========================================================================== */
.qlc-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--q-font);
  animation: qFadeIn 0.16s ease-out;
}

@keyframes qFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.qlc-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(31, 41, 51, 0.4);
}

.qlc-card {
  position: relative;
  width: 380px;
  max-width: calc(100vw - 32px);
  background: #ffffff;
  border: 1px solid var(--q-line-strong);
  border-radius: 14px;
  box-shadow: 0 2px 4px rgba(31, 41, 51, 0.04), 0 20px 50px rgba(31, 41, 51, 0.22);
  color: var(--q-ink);
  overflow: hidden;
}

.qlc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 12px 14px 20px;
  border-bottom: 1px solid var(--q-line);
}

.qlc-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--q-ink);
}

.qlc-sub {
  font-size: 12px;
  color: var(--q-muted);
  margin-top: 1px;
}

.qlc-btn-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: var(--q-ink-2);
  font-size: 17px;
  cursor: pointer;
  transition: background 0.15s;
}

.qlc-btn-icon:hover { background: var(--q-paper); }

.qlc-body {
  padding: 30px 24px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* Lingkaran suara: satu inti + dua cincin tipis yang mengikuti volume */
.qlc-orb-container {
  position: relative;
  width: 124px;
  height: 124px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.qlc-orb-pulse-outer,
.qlc-orb-pulse-middle {
  position: absolute;
  border-radius: 50%;
  border: 1px solid var(--q-brand);
  background: none;
  opacity: 0.18;
  transition: transform 0.1s ease-out, opacity 0.2s, border-color 0.2s;
}

.qlc-orb-pulse-outer  { width: 124px; height: 124px; }
.qlc-orb-pulse-middle { width: 98px;  height: 98px;  opacity: 0.3; }

.qlc-orb-core {
  position: relative;
  z-index: 2;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: var(--q-brand);
  color: #ffffff;
  font-size: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.25s;
}

.qlc-orb-core.orb-idle,
.qlc-orb-core.orb-listening  { background: var(--q-brand); }
.qlc-orb-core.orb-speaking   { background: var(--q-brand-dark); }
.qlc-orb-core.orb-thinking,
.qlc-orb-core.orb-querying   { background: var(--q-muted); }

.pulse-listening { opacity: 0.35 !important; }
.pulse-speaking  { opacity: 0.55 !important; }
.pulse-querying  { opacity: 0.2 !important; border-style: dashed !important; }

/* Status + durasi */
.qlc-status-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--q-ink-2);
}

.qlc-status-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  background: none;
  border: none;
  padding: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--q-ink-2);
}

.qlc-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--q-muted);
  animation: none;
  box-shadow: none;
}

.qlc-status-badge.status-connected .qlc-status-dot,
.qlc-status-badge.status-listening .qlc-status-dot { background: var(--q-ok); }
.qlc-status-badge.status-speaking .qlc-status-dot  { background: var(--q-brand); }
.qlc-status-badge.status-querying .qlc-status-dot  { background: var(--q-warn); }
.qlc-status-badge.status-error .qlc-status-dot     { background: var(--q-danger); }

.qlc-timer {
  font-size: 13px;
  color: var(--q-muted);
  font-variant-numeric: tabular-nums;
  padding-left: 10px;
  border-left: 1px solid var(--q-line);
}

/* Teks percakapan */
.qlc-captions-container {
  width: 100%;
  margin-top: 22px;
  max-height: 190px;
  overflow-y: auto;
  text-align: left;
}

.qlc-caption-box {
  padding: 12px 0;
  border-top: 1px solid var(--q-line);
}

.qlc-caption-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--q-muted);
  margin-bottom: 3px;
}

.qlc-caption-text {
  font-size: 14px;
  line-height: 1.55;
  color: var(--q-ink);
}

.qlc-caption-text.text-muted {
  color: var(--q-muted);
}

.qlc-caption-text a {
  color: var(--q-brand);
  font-weight: 600;
}

/* Tombol kontrol */
.qlc-footer {
  display: flex;
  gap: 10px;
  padding: 14px 20px 20px;
}

.qlc-control-btn {
  flex: 1;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.qlc-control-btn i { font-size: 17px; }

.qlc-control-btn.btn-mute {
  color: var(--q-ink);
  background: #ffffff;
  border: 1px solid var(--q-line-strong);
}

.qlc-control-btn.btn-mute:hover { background: var(--q-paper); }

.qlc-control-btn.btn-mute.muted {
  color: var(--q-danger);
  border-color: var(--q-danger);
  background: #fbf3f2;
}

.qlc-control-btn.btn-hangup {
  color: #ffffff;
  background: var(--q-danger);
  border: 1px solid var(--q-danger);
}

.qlc-control-btn.btn-hangup:hover {
  background: var(--q-danger-dark);
  border-color: var(--q-danger-dark);
}

/* Panggilan diperkecil */
.qlc-pill {
  position: fixed;
  right: 24px;
  bottom: 76px;
  z-index: 99999;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 8px 8px 14px;
  background: #ffffff;
  border: 1px solid var(--q-line-strong);
  border-radius: 10px;
  box-shadow: 0 2px 4px rgba(31, 41, 51, 0.05), 0 10px 28px rgba(31, 41, 51, 0.14);
  font-family: var(--q-font);
  color: var(--q-ink);
  cursor: pointer;
}

.qlc-pill-orb {
  position: relative;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--q-ok);
  flex-shrink: 0;
}

.qlc-pill-orb i,
.qlc-pill-pulse { display: none; }

.qlc-pill-info {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.qlc-pill-title {
  font-size: 13px;
  font-weight: 600;
}

.qlc-pill-status {
  font-size: 12px;
  color: var(--q-muted);
}

.qlc-pill-timer {
  font-size: 12.5px;
  color: var(--q-ink-2);
  font-variant-numeric: tabular-nums;
}

.qlc-pill-actions {
  display: flex;
  gap: 2px;
}

.qlc-pill-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 7px;
  color: var(--q-ink-2);
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.qlc-pill-btn:hover { background: var(--q-paper); }
.qlc-pill-btn.qlc-pill-hangup { color: var(--q-danger); }
.qlc-pill-btn.qlc-pill-hangup:hover { background: #fbf3f2; }

@media (max-width: 768px) {
  .qlc-pill {
    right: 12px;
    left: 12px;
    bottom: calc(118px + env(safe-area-inset-bottom, 0px));
    justify-content: space-between;
    z-index: 100002;
  }
  .qlc-card {
    width: calc(100vw - 24px);
  }
  .qlc-footer {
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  }
}
