/* =========================================================================
   Ashan — Landing 3D + suara (tema gelap elegan, violet #8B5CF6 / cyan #4FD1FF)
   Semua selector memakai id/atribut kanonik "ashan-*" yang dibuat/dipakai
   oleh assets/js/app.js. Responsif mobile, tanpa framework.
   ========================================================================= */

/* ===== Token & reset ===== */
:root {
  --violet: #8B5CF6;
  --cyan: #4FD1FF;
  --teal: #2DD4BF;
  --bg-1: #0b0f1e;
  --bg-2: #131a33;
  --teks: #e9f2ff;
  --teks-redup: rgba(207, 230, 255, 0.6);
  --kaca: rgba(19, 26, 51, 0.55);
  --garis: rgba(255, 255, 255, 0.09);
  --radius: 16px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  overflow: hidden;
  font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  color: var(--teks);
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(139, 92, 246, 0.14), transparent 60%),
    radial-gradient(120% 90% at 50% 110%, rgba(79, 209, 255, 0.10), transparent 60%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

input,
textarea {
  font: inherit;
  color: inherit;
}

/* ===== Kanvas 3D full-screen ===== */
#ashan-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 0;
  touch-action: none;
}

/* ===== Overlay umum ===== */
#ashan-overlay {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none; /* hanya elemen interaktif yang menerima klik */
}

/* Vignette untuk kedalaman */
#ashan-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 42%, transparent 52%, rgba(5, 8, 18, 0.55) 100%);
}

/* Scrim tipis di atas untuk keterbacaan wordmark */
#ashan-overlay::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 110px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(5, 8, 18, 0.55), transparent);
}

/* ===== Wordmark kiri-atas ===== */
#ashan-wordmark {
  position: fixed;
  top: 20px;
  left: 24px;
  z-index: 4;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  opacity: 0.9;
  animation: muncul 0.9s ease both;
}

/* ===== Dock bawah-tengah (subtitle, hint, teks, mic, chip) ===== */
#ashan-dock {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(680px, 94vw);
}

/* ===== Bar subtitle 2 baris ===== */
#ashan-subtitle {
  display: none;
  width: 100%;
  text-align: center;
  pointer-events: none;
}

#ashan-subtitle.aktif {
  display: block;
  animation: muncul 0.45s ease both;
}

#ashan-line-user,
#ashan-line-ai {
  margin: 0 auto;
  max-width: 640px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow-wrap: break-word;
  text-shadow: 0 2px 14px rgba(5, 8, 18, 0.9);
}

#ashan-line-user {
  font-size: 14px;
  font-style: italic;
  color: var(--teks-redup);
  min-height: 1.3em;
}

#ashan-line-ai {
  margin-top: 6px;
  font-size: 16px;
  line-height: 1.5;
  color: var(--teks);
  min-height: 1.5em;
}

/* ===== Hint ===== */
#ashan-hint {
  display: none;
  font-size: 13px;
  letter-spacing: 0.04em;
  color: rgba(233, 242, 255, 0.55);
  text-align: center;
}

#ashan-hint.tampil {
  display: block;
  animation: nafas 2.6s ease-in-out infinite;
}

/* ===== Chip status tengah-bawah ===== */
#ashan-chip {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: 999px;
  background: var(--kaca);
  border: 1px solid var(--garis);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 12.5px;
  letter-spacing: 0.06em;
  color: var(--teks-redup);
  pointer-events: none;
}

#ashan-chip.tampil {
  display: inline-flex;
  animation: muncul 0.35s ease both;
}

#ashan-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cyan);
  animation: denyutDot 1.4s ease-in-out infinite;
}

body[data-agent="listening"] #ashan-chip-dot { background: var(--cyan); }
body[data-agent="thinking"] #ashan-chip-dot { background: var(--violet); animation-duration: 0.8s; }
body[data-agent="speaking"] #ashan-chip-dot { background: var(--teal); animation-duration: 1s; }

/* ===== Tombol mikrofon bulat besar ===== */
#ashan-mic {
  pointer-events: auto;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #cfe6ff;
  background:
    radial-gradient(circle at 30% 25%, #1c2547 0%, #0d1226 70%);
  border: 1px solid rgba(79, 209, 255, 0.35);
  box-shadow:
    0 0 0 6px rgba(79, 209, 255, 0.05),
    0 0 34px rgba(79, 209, 255, 0.28),
    0 0 70px rgba(139, 92, 246, 0.18),
    inset 0 0 18px rgba(79, 209, 255, 0.08);
  transition: transform 0.18s ease, box-shadow 0.4s ease, border-color 0.4s ease;
}

#ashan-mic:hover {
  transform: scale(1.05);
  border-color: rgba(79, 209, 255, 0.6);
}

#ashan-mic:active {
  transform: scale(0.94);
}

#ashan-mic svg {
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 0 6px rgba(79, 209, 255, 0.55));
}

/* Glow per state */
body[data-agent="listening"] #ashan-mic {
  border-color: rgba(79, 209, 255, 0.7);
  animation: denyutCyan 1.6s ease-in-out infinite;
}

body[data-agent="thinking"] #ashan-mic {
  border-color: rgba(139, 92, 246, 0.7);
  animation: denyutViolet 1.15s ease-in-out infinite;
}

body[data-agent="speaking"] #ashan-mic {
  border-color: rgba(45, 212, 191, 0.7);
  animation: denyutTeal 1.4s ease-in-out infinite;
}

/* ===== Input teks fallback ===== */
#ashan-textform {
  display: none;
  width: 100%;
  gap: 8px;
  pointer-events: auto;
}

#ashan-textform.tampil {
  display: flex;
  animation: muncul 0.45s ease both;
}

#ashan-textinput {
  flex: 1;
  min-width: 0;
  padding: 13px 20px;
  border-radius: 999px;
  background: rgba(13, 18, 38, 0.82);
  border: 1px solid rgba(79, 209, 255, 0.28);
  color: var(--teks);
  outline: none;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

#ashan-textinput::placeholder {
  color: rgba(207, 230, 255, 0.4);
}

#ashan-textinput:focus {
  border-color: rgba(79, 209, 255, 0.75);
  box-shadow: 0 0 0 3px rgba(79, 209, 255, 0.16), 0 0 22px rgba(79, 209, 255, 0.2);
}

#ashan-textsend {
  padding: 0 22px;
  border-radius: 999px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  box-shadow: 0 4px 18px rgba(139, 92, 246, 0.4);
  transition: transform 0.18s ease, filter 0.18s ease;
}

#ashan-textsend:hover {
  filter: brightness(1.12);
  transform: translateY(-1px);
}

#ashan-textsend:active {
  transform: scale(0.96);
}

/* ===== Link kecil: kontak (kiri-bawah) & Admin (kanan-bawah) ===== */
#ashan-contact-link,
#ashan-admin-link {
  position: fixed;
  bottom: 20px;
  z-index: 4;
  pointer-events: auto;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 12.5px;
  letter-spacing: 0.05em;
  color: rgba(233, 242, 255, 0.6);
  background: rgba(13, 18, 38, 0.6);
  border: 1px solid var(--garis);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  text-decoration: none;
  transition: color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

#ashan-contact-link { left: 20px; }
#ashan-admin-link { right: 20px; }

#ashan-contact-link:hover,
#ashan-admin-link:hover {
  color: var(--cyan);
  border-color: rgba(79, 209, 255, 0.45);
  box-shadow: 0 0 18px rgba(79, 209, 255, 0.18);
}

/* ===== Kartu kontak (form mini) ===== */
#ashan-contact-card {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 6;
  width: min(380px, calc(100vw - 36px));
  transform: translate(-50%, -46%) scale(0.96);
  opacity: 0;
  visibility: hidden;
  pointer-events: auto;
  padding: 24px 22px 20px;
  border-radius: 20px;
  background: rgba(15, 20, 42, 0.92);
  border: 1px solid rgba(139, 92, 246, 0.35);
  box-shadow:
    0 24px 70px rgba(3, 6, 16, 0.7),
    0 0 40px rgba(139, 92, 246, 0.16);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}

#ashan-contact-card.terbuka {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

#ashan-contact-card h3 {
  font-size: 17px;
  font-weight: 600;
  background: linear-gradient(90deg, var(--cyan), var(--violet));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

#ashan-contact-card > p {
  margin: 6px 0 16px;
  font-size: 13px;
  color: var(--teks-redup);
}

#ashan-contact-close {
  position: absolute;
  top: 10px;
  right: 14px;
  font-size: 22px;
  line-height: 1;
  color: rgba(233, 242, 255, 0.45);
  transition: color 0.2s ease;
}

#ashan-contact-close:hover {
  color: var(--cyan);
}

#ashan-contact-form input,
#ashan-contact-form textarea {
  width: 100%;
  margin-bottom: 10px;
  padding: 11px 15px;
  border-radius: 12px;
  background: rgba(13, 18, 38, 0.85);
  border: 1px solid rgba(139, 92, 246, 0.28);
  color: var(--teks);
  outline: none;
  resize: none;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
}

#ashan-contact-form input:focus,
#ashan-contact-form textarea:focus {
  border-color: rgba(79, 209, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(79, 209, 255, 0.13);
}

#ashan-contact-form input::placeholder,
#ashan-contact-form textarea::placeholder {
  color: rgba(207, 230, 255, 0.38);
}

#ashan-contact-submit {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(135deg, var(--violet), var(--cyan));
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.35);
  transition: filter 0.2s ease, transform 0.15s ease;
}

#ashan-contact-submit:hover { filter: brightness(1.12); }
#ashan-contact-submit:active { transform: scale(0.98); }
#ashan-contact-submit:disabled { opacity: 0.6; cursor: wait; }

#ashan-contact-status {
  margin-top: 10px;
  min-height: 1.2em;
  font-size: 13px;
  text-align: center;
}

#ashan-contact-status.ok { color: var(--teal); }
#ashan-contact-status.gagal { color: #ff9d9d; }

/* ===== Toast (pesan ramah) ===== */
#ashan-toast {
  position: fixed;
  top: 22px;
  left: 50%;
  z-index: 8;
  transform: translate(-50%, -12px);
  max-width: min(560px, calc(100vw - 32px));
  padding: 11px 20px;
  border-radius: 999px;
  background: rgba(13, 18, 38, 0.92);
  border: 1px solid rgba(79, 209, 255, 0.3);
  box-shadow: 0 10px 34px rgba(3, 6, 16, 0.6);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  font-size: 13.5px;
  text-align: center;
  color: var(--teks);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
}

#ashan-toast.tampil {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

/* ===== Keyframes ===== */
@keyframes muncul {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* muncul untuk elemen fixed dengan transform sendiri */
#ashan-subtitle.aktif { animation-name: munculHalus; }

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

@keyframes nafas {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.9; }
}

@keyframes denyutDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.8); }
}

@keyframes denyutCyan {
  0%, 100% {
    box-shadow: 0 0 0 6px rgba(79, 209, 255, 0.06), 0 0 30px rgba(79, 209, 255, 0.3), 0 0 70px rgba(79, 209, 255, 0.14), inset 0 0 18px rgba(79, 209, 255, 0.08);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(79, 209, 255, 0.1), 0 0 52px rgba(79, 209, 255, 0.5), 0 0 110px rgba(79, 209, 255, 0.26), inset 0 0 24px rgba(79, 209, 255, 0.14);
  }
}

@keyframes denyutViolet {
  0%, 100% {
    box-shadow: 0 0 0 6px rgba(139, 92, 246, 0.07), 0 0 30px rgba(139, 92, 246, 0.3), 0 0 70px rgba(139, 92, 246, 0.16), inset 0 0 18px rgba(139, 92, 246, 0.1);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(139, 92, 246, 0.12), 0 0 52px rgba(139, 92, 246, 0.5), 0 0 110px rgba(139, 92, 246, 0.28), inset 0 0 24px rgba(139, 92, 246, 0.16);
  }
}

@keyframes denyutTeal {
  0%, 100% {
    box-shadow: 0 0 0 6px rgba(45, 212, 191, 0.07), 0 0 30px rgba(45, 212, 191, 0.3), 0 0 70px rgba(45, 212, 191, 0.15), inset 0 0 18px rgba(45, 212, 191, 0.09);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(45, 212, 191, 0.12), 0 0 52px rgba(45, 212, 191, 0.48), 0 0 110px rgba(45, 212, 191, 0.25), inset 0 0 24px rgba(45, 212, 191, 0.15);
  }
}

/* ===== Responsif mobile ===== */
@media (max-width: 640px) {
  #ashan-wordmark {
    top: 14px;
    left: 16px;
    font-size: 11px;
    letter-spacing: 0.14em;
  }

  #ashan-dock {
    bottom: 16px;
    gap: 10px;
  }

  #ashan-mic {
    width: 74px;
    height: 74px;
  }

  #ashan-mic svg {
    width: 28px;
    height: 28px;
  }

  #ashan-line-ai { font-size: 14.5px; }
  #ashan-line-user { font-size: 12.5px; }
  #ashan-textsend { padding: 0 16px; }

  #ashan-contact-link,
  #ashan-admin-link {
    bottom: 14px;
    padding: 7px 12px;
    font-size: 11.5px;
  }

  #ashan-contact-link { left: 12px; }
  #ashan-admin-link { right: 12px; }
}

@media (max-width: 400px) {
  #ashan-mic {
    width: 66px;
    height: 66px;
  }

  #ashan-line-ai { font-size: 13.5px; }
}

/* Layar pendek (lanskap ponsel): rapatkan dock */
@media (max-height: 480px) {
  #ashan-dock { bottom: 12px; gap: 8px; }
  #ashan-mic { width: 62px; height: 62px; }
  #ashan-mic svg { width: 24px; height: 24px; }
  #ashan-subtitle.aktif { display: block; }
  #ashan-line-user { display: none; } /* prioritaskan balasan AI */
}

/* ===== Aksesibilitas: kurangi gerakan ===== */
@media (prefers-reduced-motion: reduce) {
  #ashan-mic,
  #ashan-chip-dot,
  #ashan-hint.tampil,
  #ashan-subtitle.aktif,
  #ashan-wordmark {
    animation: none !important;
  }

  #ashan-contact-card,
  #ashan-toast,
  #ashan-textform.tampil {
    transition: none !important;
  }
}
