/* ==========================================================
   TEMPLATE MENU IKON  (gelap = default, terang = opsional)
   Palet RAMAH LANSIA / MATA RABUN:
   - Kontras tinggi (teks >= 7:1, standar WCAG AAA)
   - Warna hangat (krem, amber, cokelat) - lebih nyaman karena
     lensa mata lansia menguning dan kurang peka warna biru
   - Hindari putih murni di atas hitam murni (silau/bayangan)
   - Ikon & huruf lebih besar, garis tepi tegas, fokus jelas
   Ubah warna cukup di blok VARIABEL di bawah.
   ========================================================== */

/* ---------- MODE GELAP (DEFAULT) ---------- */
:root {
  --bg:            #1a1612;
  --text:          #fff6e0;
  --group-bg:      #3b2d12;
  --group-border:  #ffc857;
  --group-text:    #ffe0a0;
  --icon-bg:       #2c261f;
  --icon-border:   #6b5f50;
  --icon-shadow:   rgba(0,0,0,.5);
  --glow:          rgba(255,200,87,.5);
  --focus:         #ffd166;
  --nav-bg:        #2e2314;
  --nav-text:      #fff6e0;
  --nav-active:    #ffd166;
  --fab-bg:        #0d1422;     /* biru malam: logo EduSphere (teks putih/perak) tampil jelas */
  --fab-text:      #3b2d12;
  --scroll-thumb:  #8a7c68;

  /* gelembung notifikasi (gaya komik) */
  --bubble-bg:     #fff6e0;
  --bubble-text:   #1b1b1b;
  --bubble-line:   #ffc857;     /* garis tepi gelembung */
  --bubble-shadow: #000000;     /* bayangan keras ala komik */
  --bubble-muted:  #5a4a2e;
  --badge-bg:      #b3261e;
  --badge-text:    #ffffff;

  --nav-height:    70px;
  --nav-max-width: 480px;       /* lebar isi menu utama di semua layar */
  --content-max:   1100px;      /* lebar maksimal area ikon */
  --fab-size:      96px;       /* diperbesar agar tulisan pada logo terbaca */
  --font:          "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

/* ---------- MODE TERANG ---------- */
:root[data-theme="light"] {
  --bg:            #fffaf0;
  --text:          #1b1b1b;
  --group-bg:      #ffefc2;
  --group-border:  #8a5a00;
  --group-text:    #5a3a00;
  --icon-bg:       #ffffff;
  --icon-border:   #a8977c;
  --icon-shadow:   rgba(60,40,0,.18);
  --glow:          rgba(214,140,0,.45);
  --focus:         #8a5a00;
  --nav-bg:        #4a3000;
  --nav-text:      #fffaf0;
  --nav-active:    #ffd166;
  --fab-bg:        #0d1422;
  --fab-text:      #4a3000;
  --scroll-thumb:  #a8977c;

  --bubble-bg:     #ffffff;
  --bubble-text:   #1b1b1b;
  --bubble-line:   #4a3000;
  --bubble-shadow: #4a3000;
  --bubble-muted:  #5a4a2e;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; }

/* ---------- KERANGKA: kolom penuh layar ---------- */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  position: relative;

  /* jarak tombol melayang (tema & lonceng) dari tepi layar */
  --edge: 12px;
}

/* Area gulir selebar layar (scrollbar di tepi layar);
   isinya dibatasi --content-max lewat padding. Karena flex:1 di
   atas nav, batas bawahnya = batas atas menu utama. */
.app-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 12px 80px;   /* bawah dilebihkan: ruang untuk tombol tema & tombol logo */
  padding-inline: max(12px, calc((100% - var(--content-max)) / 2));
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb) transparent;
}
.app-content::-webkit-scrollbar { width: 8px; }
.app-content::-webkit-scrollbar-thumb { background: var(--scroll-thumb); border-radius: 4px; }

/* ---------- TOMBOL GANTI TEMA (kiri bawah) ---------- */
.theme-toggle {
  position: absolute;
  left: var(--edge);
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom) + 14px);
  z-index: 15;
  width: 50px; height: 50px;
  border: 2px solid var(--icon-border);
  border-radius: 50%;
  background: var(--icon-bg);
  box-shadow: 0 3px 10px var(--icon-shadow);
  font-size: 24px;
  cursor: pointer;
  transition: box-shadow .25s ease, transform .25s ease;
}

/* ---------- GRUP MENU ---------- */
.menu-group { margin-bottom: 26px; }

.menu-group__title {
  display: block;
  width: max-content;
  max-width: calc(100% - 140px);   /* sisakan ruang untuk lonceng di kanan atas */
  margin: 0 auto 20px;
  padding: 10px 40px;
  background: var(--group-bg);
  color: var(--group-text);
  border: 3px solid var(--group-border);
  border-radius: 999px;
  font-size: 1.2rem;
  font-weight: 800;
  text-align: center;
}

/* ---------- GRID IKON: 3 kolom di HP ---------- */
.menu-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px 8px;
}
@media (min-width: 600px) { .menu-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 900px) { .menu-grid { grid-template-columns: repeat(6, 1fr); } }

.menu-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  padding: 4px;
  border-radius: 14px;
  outline: none;
}

.menu-item__icon {
  width: 96px; height: 96px;
  display: flex; align-items: center; justify-content: center;
  background: var(--icon-bg);
  border: 2px solid var(--icon-border);
  border-radius: 22px;
  box-shadow: 0 2px 8px var(--icon-shadow);
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.menu-item__icon img {
  width: 76px; height: 76px;
  object-fit: contain;
  transition: transform .25s ease;
}

.menu-item__label {
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.2;
  overflow-wrap: anywhere;
  transition: color .25s ease;
}

/* ---------- EFEK GLOW IKON (hover / fokus keyboard / sentuh) ---------- */
.menu-item:focus-visible .menu-item__icon {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}
.menu-item:focus-visible .menu-item__icon,
.menu-item:active .menu-item__icon {
  transform: translateY(-4px) scale(1.06);
  border-color: var(--group-border);
  box-shadow: 0 0 22px 4px var(--glow), 0 6px 14px var(--icon-shadow);
}
.menu-item:active .menu-item__icon { transform: scale(.96); }

@media (hover: hover) {
  .menu-item:hover .menu-item__icon {
    transform: translateY(-4px) scale(1.06);
    border-color: var(--group-border);
    box-shadow: 0 0 22px 4px var(--glow), 0 6px 14px var(--icon-shadow);
  }
  .menu-item:hover .menu-item__icon img { transform: scale(1.1); }
  .menu-item:hover .menu-item__label { color: var(--group-text); }
  .theme-toggle:hover {
    transform: rotate(20deg) scale(1.08);
    box-shadow: 0 0 16px 3px var(--glow);
  }
}
.theme-toggle:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }

/* ==========================================================
   NOTIFIKASI: LONCENG (kanan atas) + GELEMBUNG KOMIK
   ========================================================== */
.notif {
  position: absolute;
  top: 12px;
  right: var(--edge);
  z-index: 20;
}

.notif__bell {
  position: relative;
  width: 54px; height: 54px;
  display: flex; align-items: center; justify-content: center;
  background: var(--icon-bg);
  border: 2px solid var(--icon-border);
  border-radius: 50%;
  box-shadow: 0 3px 10px var(--icon-shadow);
  cursor: pointer;
  transition: box-shadow .25s ease, border-color .25s ease, transform .25s ease;
}
.notif__bell img { transform-origin: 50% 10%; }

.notif__badge {
  position: absolute;
  top: -5px; right: -5px;
  min-width: 24px; height: 24px;
  padding: 0 6px;
  display: flex; align-items: center; justify-content: center;
  background: var(--badge-bg);
  color: var(--badge-text);
  border: 2px solid var(--bg);
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 800;
  line-height: 1;
}
.notif__badge[hidden] { display: none; }

.notif__bell:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }
.notif.is-open .notif__bell { border-color: var(--group-border); box-shadow: 0 0 18px 3px var(--glow); }

@keyframes bell-ring {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(16deg); }
  40% { transform: rotate(-14deg); }
  60% { transform: rotate(9deg); }
  80% { transform: rotate(-6deg); }
}
@media (hover: hover) {
  .notif__bell:hover {
    border-color: var(--group-border);
    box-shadow: 0 0 18px 3px var(--glow);
    transform: scale(1.06);
  }
  .notif__bell:hover img { animation: bell-ring .7s ease-in-out; }
}

/* --- Gelembung komik: garis tebal, bayangan keras, ekor menunjuk ke lonceng --- */
.notif__bubble {
  position: absolute;
  top: calc(100% + 24px);
  right: 0;
  width: min(330px, calc(100vw - 24px));
  padding: 14px 14px 12px;
  background: var(--bubble-bg);
  color: var(--bubble-text);
  border: 3px solid var(--bubble-line);
  border-radius: 26px 8px 26px 26px;      /* sudut kanan atas lancip, dekat ekor */
  box-shadow: 6px 6px 0 var(--bubble-shadow);

  /* tertutup */
  visibility: hidden;
  opacity: 0;
  transform: scale(.55) rotate(-3deg);
  transform-origin: calc(100% - 27px) -24px;   /* tumbuh dari ujung ekor */
  transition: opacity .18s ease,
              transform .3s cubic-bezier(.34, 1.56, .64, 1),
              visibility 0s linear .3s;
}
.notif.is-open .notif__bubble {
  visibility: visible;
  opacity: 1;
  transform: none;
  transition: opacity .18s ease,
              transform .3s cubic-bezier(.34, 1.56, .64, 1),
              visibility 0s;
}

/* Ekor: segitiga luar (warna garis) + segitiga dalam (warna isi).
   Titik tengah ekor tepat di bawah titik tengah lonceng (27px dari kanan). */
.notif__bubble::before,
.notif__bubble::after {
  content: "";
  position: absolute;
  width: 0; height: 0;
  border-style: solid;
  border-color: transparent;
}
.notif__bubble::before {
  top: -26px;  right: 12px;                 /* basis tepat di tepi luar garis (-3px) */
  border-width: 0 15px 23px 15px;
  border-bottom-color: var(--bubble-line);
}
.notif__bubble::after {
  top: -19px;  right: 16px;                 /* menutup garis tepi di pangkal ekor */
  border-width: 0 11px 19px 11px;
  border-bottom-color: var(--bubble-bg);
}

.notif__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 3px dotted var(--bubble-line);
}
.notif__title { font-size: 1.25rem; font-weight: 900; letter-spacing: .02em; }

.notif__readall {
  min-height: 44px;
  padding: 6px 12px;
  background: transparent;
  color: var(--bubble-text);
  border: 2px solid var(--bubble-line);
  border-radius: 12px;
  font: inherit;
  font-size: .85rem;
  font-weight: 800;
  cursor: pointer;
}
.notif__readall:hover { background: var(--group-bg); color: var(--group-text); }
.notif__readall:focus-visible,
.notif__item:focus-visible { outline: 3px solid var(--bubble-line); outline-offset: 2px; }

.notif__list {
  max-height: min(55vh, 340px);
  overflow-y: auto;
  margin-top: 6px;
}
.notif__item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 8px 6px;
  border-radius: 12px;
  outline: none;
}
.notif__item:hover { background: rgba(138, 90, 0, .14); }
.notif__list li + li .notif__item { border-top: 2px solid rgba(138, 90, 0, .25); border-radius: 0 0 12px 12px; }

.notif__dot {
  flex: 0 0 14px;
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid var(--bubble-muted);
}
.notif__item.is-unread .notif__dot { background: var(--badge-bg); border-color: var(--badge-bg); }

.notif__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif__item-title { font-size: 1rem; font-weight: 700; line-height: 1.2; }
.notif__item.is-unread .notif__item-title { font-weight: 900; }
.notif__item-time { font-size: .85rem; color: var(--bubble-muted); }

/* ==========================================================
   MENU UTAMA (BAWAH)
   Latar FULL WIDTH layar; isi dikunci selebar --nav-max-width.
   ========================================================== */
.bottom-nav {
  flex: 0 0 auto;
  width: 100%;
  background: var(--nav-bg);
  color: var(--nav-text);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -4px 18px rgba(0,0,0,.3);
  z-index: 10;
}

.bottom-nav__inner {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-around;
  width: 100%;
  max-width: var(--nav-max-width);
  height: var(--nav-height);
  margin: 0 auto;
}

.bottom-nav__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
  opacity: .9;
  outline: none;
  transition: opacity .25s ease, color .25s ease;
}
.bottom-nav__icon {
  width: 34px; height: 34px;
  object-fit: contain;
  transition: transform .25s ease, filter .25s ease;
}
.bottom-nav__label { font-size: .85rem; font-weight: 700; }

.bottom-nav__item.is-active { opacity: 1; color: var(--nav-active); font-weight: 800; }
.bottom-nav__item.is-active .bottom-nav__icon { filter: drop-shadow(0 0 6px var(--glow)); }

.bottom-nav__item:focus-visible { outline: 3px solid var(--nav-active); outline-offset: -3px; border-radius: 12px; }
.bottom-nav__item:focus-visible,
.bottom-nav__item:active { opacity: 1; color: var(--nav-active); }
.bottom-nav__item:focus-visible .bottom-nav__icon,
.bottom-nav__item:active .bottom-nav__icon {
  transform: translateY(-3px) scale(1.15);
  filter: drop-shadow(0 0 8px var(--nav-active));
}

/* Tombol tengah (logo) menonjol ke atas */
.bottom-nav__center {
  flex: 0 0 var(--fab-size);
  width: var(--fab-size);
  height: var(--fab-size);
  margin-top: calc(var(--fab-size) * -0.5);
  display: flex; align-items: center; justify-content: center;
  background: var(--fab-bg);
  color: var(--fab-text);
  border: 3px solid var(--nav-active);
  border-radius: 50%;
  box-shadow: 0 4px 12px rgba(0,0,0,.45);
  overflow: hidden;
  outline: none;
  transition: transform .25s ease, box-shadow .25s ease;
}
.bottom-nav__center img {
  width: 100%; height: 100%;
  padding: 12px 14px;          /* sisakan ruang agar tulisan tidak terpotong lengkung lingkaran */
  object-fit: contain;         /* logo utuh, tidak terpotong lingkaran */
}
.bottom-nav__center:focus-visible,
.bottom-nav__center:active {
  transform: translateY(-3px) scale(1.06);
  box-shadow: 0 0 24px 6px var(--glow), 0 4px 12px rgba(0,0,0,.45);
}

@media (hover: hover) {
  .bottom-nav__item:hover { opacity: 1; color: var(--nav-active); }
  .bottom-nav__item:hover .bottom-nav__icon {
    transform: translateY(-3px) scale(1.15);
    filter: drop-shadow(0 0 8px var(--nav-active));
  }
  .bottom-nav__center:hover {
    transform: translateY(-3px) scale(1.06);
    box-shadow: 0 0 24px 6px var(--glow), 0 4px 12px rgba(0,0,0,.45);
  }
}

/* Hormati pengguna yang mematikan animasi di perangkatnya */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ==========================================================
   HALAMAN YANG DIMUAT LEWAT load_url (ke #appContent / frame)
   ========================================================== */
.page { padding-bottom: 8px; }
.page__text {
  max-width: 60ch;
  margin: 0 auto 22px;
  font-size: 1.1rem;
  line-height: 1.6;
  color: inherit;              /* ikut tema; di frame window ikut warna frame */
}
.page__text code {
  padding: 1px 6px;
  border-radius: 6px;
  background: rgba(127, 127, 127, .25);
  font-size: .95em;
}
.page__back {
  display: block;
  min-height: 52px;
  margin: 0 auto;
  padding: 12px 28px;
  background: var(--group-bg);
  color: var(--group-text);
  border: 3px solid var(--group-border);
  border-radius: 999px;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease;
}
.page__back:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }
.page__back:active { transform: scale(.96); }
@media (hover: hover) {
  .page__back:hover { transform: translateY(-2px); box-shadow: 0 0 20px 3px var(--glow); }
}

/* ==========================================================
   HALAMAN PROFIL (profil.php) + tombol umum
   ========================================================== */
:root {
  --ok:  #8fe388;      /* pesan berhasil (kontras tinggi di latar gelap) */
  --err: #ff9b8a;      /* pesan galat */
}
:root[data-theme="light"] {
  --ok:  #1b5e20;
  --err: #b3261e;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 12px 22px;
  background: var(--icon-bg);
  color: var(--text);
  border: 3px solid var(--icon-border);
  border-radius: 999px;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform .25s ease, box-shadow .25s ease, border-color .25s ease;
}
.btn--primary { background: var(--group-bg); color: var(--group-text); border-color: var(--group-border); }
.btn--ghost   { background: transparent; }
.btn--icon    { min-width: 52px; padding: 0; font-size: 1.8rem; line-height: 1; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; }
.btn:not(:disabled):active { transform: scale(.96); }
@media (hover: hover) {
  .btn:not(:disabled):hover { transform: translateY(-2px); border-color: var(--group-border); box-shadow: 0 0 20px 3px var(--glow); }
}

.profil { max-width: 520px; margin: 0 auto; padding-bottom: 8px; }
.profil [hidden] { display: none !important; }

.profil__head { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-bottom: 10px; text-align: center; }
.profil__avatar {
  width: 160px; height: 160px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--icon-bg);
  border: 4px solid var(--group-border);
  box-shadow: 0 0 22px -2px var(--glow);
}
.profil__name { font-size: 1.4rem; font-weight: 900; overflow-wrap: anywhere; }
.profil__code { font-size: 1.05rem; }
.profil__code strong {
  padding: 2px 12px;
  border-radius: 999px;
  background: var(--group-bg);
  color: var(--group-text);
  border: 2px solid var(--group-border);
  letter-spacing: .04em;
}

.profil__status { min-height: 1.7em; margin: 6px 0 14px; text-align: center; font-size: 1.05rem; font-weight: 700; }
.profil__status.is-ok  { color: var(--ok); }
.profil__status.is-err { color: var(--err); }

.profil__step { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-bottom: 24px; }
.profil__actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; }
.profil__hint { max-width: 360px; text-align: center; font-size: .98rem; line-height: 1.5; }

.profil__frame {
  width: 100%;
  max-width: 360px;
  aspect-ratio: 1;
  overflow: hidden;
  background: #000;
  border: 3px solid var(--group-border);
  border-radius: 24px;
  box-shadow: 0 0 18px -4px var(--glow);
}
.profil__video, .profil__canvas { display: block; width: 100%; height: 100%; object-fit: cover; }
.profil__video.is-mirrored { transform: scaleX(-1); }
.profil__canvas { touch-action: none; cursor: grab; }
.profil__canvas:active { cursor: grabbing; }
.profil__canvas:focus-visible { outline: 4px solid var(--focus); outline-offset: -4px; }

.profil__zoom { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 360px; }
.profil__zoom input[type="range"] { flex: 1; min-width: 0; height: 40px; accent-color: var(--group-border); }

.profil__form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 18px;
  border-top: 3px dotted var(--group-border);
}
.profil__label { margin-top: 6px; font-size: 1.05rem; font-weight: 800; }
.profil__input {
  min-height: 54px;
  padding: 10px 14px;
  background: var(--icon-bg);
  color: var(--text);
  border: 3px solid var(--icon-border);
  border-radius: 14px;
  font: inherit;
  font-size: 1.15rem;
}
.profil__input:focus-visible { outline: 4px solid var(--focus); outline-offset: 2px; border-color: var(--group-border); }
.profil__input[readonly] { opacity: .85; border-style: dashed; cursor: not-allowed; }
.profil__form .btn { align-self: center; margin-top: 10px; }

/* beri ruang di bawah saat langkah baru di-scroll ke tampilan (tombol tema & logo melayang di sana) */
.profil__step { scroll-margin: 8px 0 110px; }
