/* ============================================================
   E-Presensi Mobile — stylesheet aplikasi (mobile.app)
   Gaya mengikuti referensi: app-container 414px, aksen putih-abu (seragam
   SMA), appBg #EFEFEF, textDark #1A1A1A, font Inter.
   ============================================================ */

:root {
  --app-bg: #EFEFEF;
  --brand: #9AA0A6;
  --text-dark: #1A1A1A;
  --text-muted: #77777A;
  --surface: #FFFFFF;
  --border: #E5E5E0;
  --ok: #22B07D;
  --warn: #E89B2C;
  --info: #3A7DE8;
  --sick: #9A63D8;
  --bad: #E2544B;
  --radius: 22px;
  --shadow: 0 6px 24px rgba(26, 26, 26, 0.06);
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #dcdcd6;
  color: var(--text-dark);
  font-size: 15px;
  line-height: 1.45;
}

/* Bingkai aplikasi di desktop, full-screen di ponsel */
.app-frame {
  max-width: 414px;
  margin: 0 auto;
  height: 100dvh;
  max-height: 880px;
  background: var(--app-bg);
  position: relative;
  overflow: hidden;
  border-radius: 0;
}

/* Bezle gaya referensi saat dibuka di layar lebar */
@media (min-width: 500px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 28px 0;
  }
  .app-frame {
    height: min(720px, calc(100dvh - 56px));
    border-radius: 40px;
    border: 10px solid var(--text-dark);
    box-shadow: 0 24px 70px rgba(26, 26, 26, 0.28);
  }
}

.is-hidden { display: none !important; }

.screen {
  height: 100%;
  overflow-x: hidden;
}

/* ============================================================
   Layar Login
   ============================================================ */

#screen-login {
  background: var(--app-bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-wrap {
  width: 100%;
  padding: 32px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  overflow-y: auto;
  max-height: 100%;
}

.login-brand { text-align: center; }

.login-logo {
  width: 76px;
  height: 76px;
  margin: 0 auto 14px;
  border-radius: 26px;
  background: var(--brand);
  color: #FFFFFF;
  font-weight: 800;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.35);
  overflow: hidden;
}

.login-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 12px;
  background: #FFFFFF;
}

.login-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.login-sub {
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  margin-top: 2px;
}

.login-card {
  width: 100%;
  padding: 22px 18px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-hint {
  color: var(--text-muted);
  font-size: 12.5px;
  text-align: center;
  padding: 0 6px;
  margin-top: 16px;
}

.login-error {
  color: var(--bad);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  min-height: 18px;
  padding: 6px 8px 0;
}

/* Geser tombol Masuk ke bawah agar tidak menempel kotak NIS */
.login-card .btn-block { margin-top: 6px; }

/* Logo berbentuk gambar (dari API) */
.login-logo.is-img {
  background: #FFFFFF;
  box-shadow: inset 0 0 0 1px rgba(26, 26, 26, 0.08);
}
.login-logo.is-img img { width: 100%; height: 100%; object-fit: contain; padding: 10px; }
.login-logo.is-img span { display: none; }

.login-footer {
  margin-top: auto;
  padding: 22px 16px 18px;
  text-align: center;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.7;
}

.login-footer-sep { margin: 0 7px; }
.login-footer strong { color: #4C4C4C; font-weight: 700; }

/* ============================================================
   Komponen umum
   ============================================================ */

.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 6px;
  background: #ECECE7;
  padding: 5px;
  border-radius: 16px;
}

.seg-btn {
  border: none;
  background: transparent;
  padding: 10px 6px;
  border-radius: 12px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.18s;
  font-family: inherit;
}

.seg-btn.is-active {
  background: #1A1A1A;
  color: #FFFFFF;
  box-shadow: 0 3px 10px rgba(26, 26, 26, 0.25);
}

.field { display: flex; flex-direction: column; gap: 7px; }

.field-label { font-size: 12.5px; font-weight: 600; color: var(--text-muted); }

.input {
  width: 100%;
  border: 1.5px solid var(--border);
  background: #F6F6F3;
  border-radius: 14px;
  padding: 13px 15px;
  font-size: 15px;
  font-family: inherit;
  color: var(--text-dark);
  outline: none;
  transition: border-color 0.18s;
  resize: none;
}

.input:focus {
  border-color: #1A1A1A;
  background: #fff;
}

.input:disabled { opacity: 0.6; }

.select {
  border: 1.5px solid var(--border);
  background: #F6F6F3;
  border-radius: 12px;
  padding: 9px 11px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  color: var(--text-dark);
  outline: none;
  cursor: pointer;
}

.btn {
  border: none;
  cursor: pointer;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 14px;
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 700;
  transition: transform 0.12s, opacity 0.15s;
}

.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: default; }

.btn-primary {
  background: var(--brand);
  color: #FFFFFF;
  box-shadow: 0 8px 20px rgba(154, 160, 166, 0.35);
}

.btn-danger {
  background: #FDE9E7;
  color: var(--bad);
}

.btn-block { width: 100%; }

/* Tombol sekunder (garis netral) — dipakai tautan Login Panel Admin */
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.btn-ghost:hover { opacity: 0.92; }

.btn.is-loading span { opacity: 0.6; }
.btn.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid #1a1a1a;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn { position: relative; }

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   App shell
   ============================================================ */

#screen-app {
  display: flex;
  flex-direction: column;
  background: var(--app-bg);
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

#screen-app::-webkit-scrollbar { display: none; }

.app-header {
  padding: 26px 18px 16px;
  background: var(--app-bg);
  flex-shrink: 0;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.header-ident { display: flex; align-items: center; gap: 11px; min-width: 0; }

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--brand);
  color: #FFFFFF;
  font-weight: 800;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.header-name {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 160px;
}

.header-sub { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.dot-sep { margin: 0 4px; }

.school-name {
  background: #FFFFFF;
  border: 1px solid var(--border);
  color: #4C4C4C;
  font-size: 11.5px;
  font-weight: 700;
  padding: 6px 11px;
  border-radius: 999px;
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-greet { margin-top: 20px; }

.greet-title { font-size: 21px; font-weight: 800; letter-spacing: -0.4px; }
.greet-date { font-size: 13px; color: var(--text-muted); margin-top: 3px; font-weight: 500; }

/* Kartu status hari ini */
.today-card {
  margin-top: 18px;
  background: #1A1A1A;
  border-radius: var(--radius);
  padding: 20px 18px;
  color: #FFFFFF;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-shadow: 0 14px 30px rgba(26, 26, 26, 0.28);
}

.today-label { font-size: 12px; color: rgba(255, 255, 255, 0.6); font-weight: 600; }

.today-status { font-size: 19px; font-weight: 800; margin-top: 4px; }
.today-status.is-ok { color: #A7F3D0; }
.today-status.is-warn { color: #FFE1A6; }
.today-status.is-info { color: #BFDBFF; }
.today-status.is-sick, .today-status.is-bad { color: #FFD2CE; }

.today-sub { font-size: 12.5px; color: rgba(255, 255, 255, 0.7); margin-top: 8px; max-width: 250px; }

.today-chip {
  width: 52px;
  height: 52px;
  border-radius: 18px;
  background: #FFFFFF;
  color: #1A1A1A;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}

/* ============================================================
   Konten utama
   ============================================================ */

.app-main {
  flex: 0 0 auto;
  overflow: visible;
  padding: 4px 18px 118px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  margin-top: 20px;
}

.section-head:first-child { margin-top: 6px; }

.section-title { font-size: 17px; font-weight: 800; letter-spacing: -0.3px; }
.section-aux { font-size: 12.5px; font-weight: 650; color: var(--text-muted); }

.section-spaced { margin-top: 26px; }

.link-btn {
  border: none;
  background: none;
  font-family: inherit;
  color: #1A1A1A;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Statistik ringkasan */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.stat {
  background: var(--surface);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat i { font-size: 20px; margin-bottom: 6px; }
.stat b { font-size: 22px; font-weight: 800; letter-spacing: -0.5px; }
.stat span { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.stat-ok { color: var(--ok); }
.stat-warn { color: var(--warn); }
.stat-info { color: var(--info); }
.stat-sick { color: var(--sick); }

/* Baris item (presensi / izin) */
.recent-list, .history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.row {
  background: var(--surface);
  border-radius: 18px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}

.row-icon {
  width: 40px;
  height: 40px;
  border-radius: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.row-icon.is-ok { background: #E1F7ED; color: var(--ok); }
.row-icon.is-warn { background: #FDF0DC; color: var(--warn); }
.row-icon.is-info { background: #E4EDFC; color: var(--info); }
.row-icon.is-sick { background: #F0E6FA; color: var(--sick); }
.row-icon.is-bad { background: #FDE9E7; color: var(--bad); }

.row-body { flex: 1; min-width: 0; }
.row-title { font-size: 14px; font-weight: 700; }
.row-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge {
  font-size: 11.5px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  flex-shrink: 0;
}

.badge.is-ok { background: #E1F7ED; color: var(--ok); }
.badge.is-warn { background: #FDF0DC; color: var(--warn); }
.badge.is-info { background: #E4EDFC; color: var(--info); }
.badge.is-sick { background: #F0E6FA; color: var(--sick); }
.badge.is-bad { background: #FDE9E7; color: var(--bad); }

.recent-count {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  padding: 6px 0 2px;
}

.empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13.5px;
  padding: 26px 0;
  font-weight: 500;
}

.loading-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 13.5px;
  padding: 24px 0;
  font-weight: 500;
}

.is-spin { animation: spin 0.8s linear infinite; display: inline-block; }

/* Halaman riwayat */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 14px 0 16px;
}

/* Form izin */
.leave-form {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ============================================================
   Navigasi bawah
   ============================================================ */

.bottom-nav {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--brand);
  border-radius: 26px 26px 0 0;
  padding: 12px 10px calc(14px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  z-index: 20;
}

.nav-btn {
  border: none;
  background: transparent;
  color: #F2F3F4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  cursor: pointer;
  border-radius: 16px;
  font-family: inherit;
  font-size: 10.5px;
  font-weight: 600;
  transition: color 0.18s, background 0.18s;
}

.nav-btn i { font-size: 21px; }

.nav-btn.is-active {
  color: #1A1A1A;
  background: #FFFFFF;
}

/* Toast */
.toast {
  position: absolute;
  left: 50%;
  bottom: 92px;
  transform: translateX(-50%) translateY(16px);
  background: #1A1A1A;
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 600;
  padding: 12px 18px;
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 40;
  max-width: 82%;
  text-align: center;
}

.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.is-error { background: #B3261E; }

/* ------------------------------------------------------------
   Dialog konfirmasi in-app (pengganti window.confirm)
   ------------------------------------------------------------ */

.confirm-dialog {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 28px;
}

.confirm-dialog[hidden] { display: none; }

.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 26, 26, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.confirm-card {
  position: relative;
  width: min(320px, 100%);
  background: #FFFFFF;
  border-radius: var(--radius);
  padding: 22px 20px 20px;
  box-shadow: 0 18px 50px rgba(26, 26, 26, 0.3);
  animation: confirm-in 0.18s ease-out;
}

@keyframes confirm-in {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.confirm-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.2px;
  margin-bottom: 6px;
}

.confirm-msg {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: 18px;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* ------------------------------------------------------------
   Presensi kelas wali kelas (absen ulang)
   ------------------------------------------------------------ */

.btn--sm {
  font-size: 12.5px;
  padding: 8px 13px;
  border-radius: 13px;
}

.homeroom-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.homeroom-card__icon {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: #E3E6E8;
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.homeroom-card__body { flex: 1; min-width: 0; }

.homeroom-card__title { font-size: 14.5px; font-weight: 800; }
.homeroom-card__sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.homeroom-card .btn { margin-left: auto; flex-shrink: 0; }

.homeroom-banner {
  background: var(--brand);
  border-radius: var(--radius);
  padding: 16px 18px;
  color: #FFFFFF;
  box-shadow: 0 14px 30px rgba(154, 160, 166, 0.35);
}

.homeroom-banner__label {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: rgba(255, 255, 255, 0.7);
  font-weight: 700;
}

.homeroom-banner__name { font-size: 18px; font-weight: 800; margin-top: 3px; }

.homeroom-banner__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.homeroom-banner__row > div { min-width: 0; }
.homeroom-banner__name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.homeroom-banner__select {
  flex-shrink: 0;
  max-width: 52%;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--brand);
  background: #FFFFFF;
  border: none;
  border-radius: 12px;
  padding: 9px 30px 9px 12px;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%231A1A1A' d='M5 6 0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
}
.homeroom-banner__select option { color: #1A1A1A; background: #FFFFFF; }

.homeroom-hint {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 12px 2px 14px;
}

.homeroom-row {
  background: var(--surface);
  border-radius: 18px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow);
}

.homeroom-row .avatar {
  width: 42px;
  height: 42px;
  font-size: 15px;
}

.homeroom-row .stu-select {
  flex-shrink: 0;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 700;
  color: #FFFFFF;
  border: none;
  border-radius: 12px;
  padding: 9px 28px 9px 12px;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%23FFFFFF' d='M5 6 0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px;
}

.homeroom-row .stu-select option { color: #1A1A1A; background: #FFFFFF; }
.homeroom-row .stu-select:disabled { opacity: 0.6; }

.homeroom-row .stu-select.is-ok { background: var(--ok); }
.homeroom-row .stu-select.is-warn { background: var(--warn); }
.homeroom-row .stu-select.is-info { background: var(--info); }
.homeroom-row .stu-select.is-sick { background: var(--sick); }
.homeroom-row .stu-select.is-bad { background: var(--bad); }

/* ============================================================
   Splash Screen
   ============================================================ */

.splash {
  position: absolute;
  inset: 0;
  z-index: 60;
  background: var(--app-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 28px;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.splash-logo {
  width: 88px;
  height: 88px;
  border-radius: 28px;
  background: var(--brand);
  color: #FFFFFF;
  font-weight: 800;
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.35);
  overflow: hidden;
}

.splash-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 12px;
  background: #FFFFFF;
}

.splash-logo.is-image {
  background: #FFFFFF;
  box-shadow: inset 0 0 0 1px rgba(26, 26, 26, 0.08);
}
.splash-logo.is-image img {
  padding: 0;
  background: transparent;
}
.splash-logo.is-image span { display: none; }

.splash-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.4px;
}

.splash-sub {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  margin-top: -4px;
}

.splash-spinner {
  width: 22px;
  height: 22px;
  margin-top: 6px;
  border: 2.5px solid var(--border);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: splash-spin 0.8s linear infinite;
}

@keyframes splash-spin {
  to { transform: rotate(360deg); }
}

.splash.is-leaving {
  opacity: 0;
  visibility: hidden;
}