/* Dental Rakyat, halaman chat. Tanpa font eksternal: memakai font bawaan sistem.
 * Dua mode:
 *  - Desktop/tablet (>= 768px): halaman web biasa.
 *  - Mobile (< 768px): layar aplikasi chat penuh (app bar, percakapan, kolom pesan).
 * Batas 768px sama dengan batas widget Cekat beralih ke mode layar penuh.
 */

:root {
  /* Palet brand Dental Rakyat */
  --oranye: #E46036;
  --oranye-tua: #BD3500;
  --jingga: #F08519;
  --krem: #FFF7F0;
  --putih: #FFFFFF;

  /* Turunan untuk teks (cokelat hangat, kontras tinggi di atas krem) */
  --ink: #3A1A0E;
  --muted: #7A4A36;
  --line: #F2DCCB;

  --radius-panel: 28px;
  --radius-bubble: 22px;
  --radius-btn: 999px;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--krem);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
}

a { color: var(--oranye-tua); }

:focus-visible {
  outline: 3px solid var(--oranye-tua);
  outline-offset: 3px;
  border-radius: 6px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 16px;
  top: -100px;
  padding: 10px 16px;
  background: var(--putih);
  color: var(--ink);
  border-radius: 10px;
  z-index: 10;
}
.skip:focus { top: 12px; }

/* Header: pita oranye tua karena logo berwarna putih */
.site-header { background: var(--oranye-tua); }

.wordmark {
  display: block;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px 16px;
}

.wordmark img {
  display: block;
  height: 76px;
  width: auto;
}

.site-header :focus-visible { outline-color: var(--putih); }

/* =========================================================
   DESKTOP / TABLET
   ========================================================= */

.app { display: none; }

main.desk {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 16px;
}

.hero {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 56px;
  padding: 72px 0 80px;
  align-items: center;
}

.hero-copy { max-width: 34rem; }

.hero h1 {
  margin: 0 0 20px;
  font-size: clamp(2.5rem, 5vw, 3.5rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
  font-weight: 800;
  text-wrap: balance;
}

.lede {
  margin: 0 0 32px;
  color: var(--muted);
  font-size: 1.1875rem;
  max-width: 32rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 14px 28px 14px 22px;
  background: var(--oranye-tua);
  color: var(--putih);
  border-radius: var(--radius-btn);
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: none;
  transition: background-color 0.15s ease, transform 0.15s ease;
}
.btn svg { width: 22px; height: 22px; fill: currentColor; }
.btn:hover { background: var(--oranye); }
.btn:active { transform: translateY(1px); }

.note {
  margin: 20px 0 0;
  font-size: 0.9375rem;
  color: var(--muted);
  max-width: 30rem;
}

.preview { margin: 0; }

.preview-panel {
  padding: 40px 32px;
  background: var(--oranye);
  border-radius: var(--radius-panel);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bubble {
  max-width: 88%;
  padding: 16px 20px;
  border-radius: var(--radius-bubble);
  font-size: clamp(1.0625rem, 2vw, 1.3125rem);
  line-height: 1.45;
  font-weight: 500;
}

.bubble-patient {
  align-self: flex-end;
  background: var(--putih);
  color: var(--ink);
  border-bottom-right-radius: 6px;
}

.bubble-clinic {
  align-self: flex-start;
  background: var(--oranye-tua);
  color: var(--putih);
  border-bottom-left-radius: 6px;
}

.bubble-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 6px;
  padding: 16px 18px;
  background: var(--oranye-tua);
  border-bottom-left-radius: 6px;
}
.bubble-typing span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--krem);
  opacity: 0.35;
  animation: ketik 1.2s infinite ease-in-out;
}
.bubble-typing span:nth-child(2) { animation-delay: 0.15s; }
.bubble-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ketik {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 0.9; transform: translateY(-3px); }
}

.preview figcaption {
  margin-top: 10px;
  font-size: 0.8125rem;
  color: var(--muted);
  text-align: right;
}

.topics {
  border-top: 1px solid var(--line);
  padding: 32px 0 16px;
}

.topics h2 {
  margin: 0 0 16px;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}

.topics ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

.topics li {
  padding-left: 22px;
  position: relative;
}
.topics li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--jingga);
}

.site-footer {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 24px 16px 32px;
  color: var(--muted);
  font-size: 0.875rem;
}
.site-footer p { margin: 0; }

@media (min-width: 768px) and (max-width: 959px) {
  .hero { grid-template-columns: 1fr; gap: 40px; padding: 48px 0 56px; }
  .hero-copy { max-width: 40rem; }
  .preview { max-width: 560px; }
}

/* =========================================================
   MOBILE: layar beranda aplikasi
   ========================================================= */

@media (max-width: 767px) {
  html, body {
    height: 100%;
    overflow: hidden;            /* yang bergulir hanya isi layar, bukan dokumen */
    overscroll-behavior: none;
  }

  body {
    height: 100dvh;
    min-height: 0;
    font-size: 1rem;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
  }

  .skip,
  .desk { display: none; }

  /* App bar: menyatu dengan area sambutan di bawahnya */
  .site-header {
    flex: none;
    padding-top: env(safe-area-inset-top);
    position: relative;
    z-index: 2;
  }
  .wordmark {
    padding: 10px 20px;
    padding-left: max(20px, env(safe-area-inset-left));
  }
  .wordmark img { height: 44px; }

  .app {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .app-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 20px;
  }

  /* Area sambutan */
  .welcome {
    background: var(--oranye-tua);
    color: var(--putih);
    padding: 16px 20px 52px;
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
  }
  .welcome h1 {
    margin: 0 0 8px;
    font-size: 1.75rem;
    line-height: 1.15;
    letter-spacing: -0.02em;
    font-weight: 800;
    text-wrap: balance;
  }
  .welcome p {
    margin: 0;
    font-size: 1.0625rem;
    line-height: 1.45;
    max-width: 32ch;
  }

  /* Kartu daftar yang naik menimpa area sambutan */
  .group {
    position: relative;
    margin: -32px 16px 0;
    margin-left: max(16px, env(safe-area-inset-left));
    margin-right: max(16px, env(safe-area-inset-right));
    background: var(--putih);
    border-radius: 20px;
    box-shadow: 0 6px 20px rgba(189, 53, 0, 0.12);
    overflow: hidden;
  }

  .group-title {
    margin: 0;
    padding: 16px 16px 4px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--muted);
  }

  .group-list {
    margin: 0;
    padding: 0 0 6px;
    list-style: none;
  }

  .group-list li {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    position: relative;
  }
  .group-list li + li::before {
    content: "";
    position: absolute;
    top: 0;
    left: 70px;                 /* garis pemisah sejajar teks, seperti daftar di aplikasi */
    right: 0;
    border-top: 1px solid var(--line);
  }

  .row-icon {
    flex: none;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: var(--krem);
  }
  .row-icon svg { width: 22px; height: 22px; fill: var(--oranye); }

  .row-text {
    display: flex;
    flex-direction: column;
    min-width: 0;
    font-size: 0.875rem;
    line-height: 1.35;
    color: var(--muted);
  }
  .row-text strong {
    font-size: 1rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 2px;
  }

  .info {
    margin: 16px 24px 0;
    font-size: 0.8125rem;
    line-height: 1.5;
    color: var(--muted);
    text-align: center;
  }

  /* Tombol aksi utama di area jempol */
  .action-bar {
    flex: none;
    padding: 12px 16px;
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    background: var(--putih);
    border-top: 1px solid var(--line);
  }

  .action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    min-height: 54px;
    border-radius: 16px;
    background: var(--oranye-tua);
    color: var(--putih);
    font-size: 1.125rem;
    font-weight: 700;
    text-decoration: none;
    touch-action: manipulation;
    transition: transform 0.12s ease, background-color 0.12s ease;
  }
  .action-btn svg { width: 22px; height: 22px; fill: currentColor; }
  .action-btn:active { transform: scale(0.98); background: var(--oranye); }
  .action-btn:focus-visible { outline-offset: 3px; border-radius: 16px; }

  /* Satu momen gerak saat layar dibuka: kartu naik ke tempatnya */
  .group { animation: naik 0.42s cubic-bezier(0.2, 0.8, 0.3, 1) 0.05s both; }
  .info { animation: muncul 0.3s ease 0.3s both; }

  @keyframes naik {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: none; }
  }
  @keyframes muncul {
    from { opacity: 0; }
    to { opacity: 1; }
  }
}

/* Mobile mendatar dengan tinggi pendek */
@media (max-width: 767px) and (max-height: 480px) {
  .wordmark img { height: 34px; }
  .wordmark { padding: 6px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
