/* =====================================================================
   SISTEM DESAIN — Absensi AMCIS
   Palet: tinta teal tua, pasir hangat, kuningan pudar, sage & clove
   Tipografi: Fraunces (judul) + Public Sans (isi/UI)
   Motif tanda tangan: bujur sangkar diputar 45° (referensi ubin geometris)
   ===================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Public+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --ink: #12302B;
  --ink-soft: #2B4A44;
  --teal: #0F4C43;
  --teal-deep: #0A332C;
  --sand: #F3EEDD;
  --sand-2: #EAE2C8;
  --paper: #FBF9F2;
  --brass: #B98A2E;
  --brass-soft: #E4C77E;
  --sage: #5C7F63;
  --sage-bg: #E4EBE1;
  --clove: #8A3B32;
  --clove-bg: #F3E1DC;
  --amber: #A8721E;
  --amber-bg: #F4E6C9;
  --line: #DCD3B6;
  --ink-muted: #6B7A73;
  --white: #FFFFFF;
  --shadow-card: 0 1px 2px rgba(18, 48, 43, 0.06), 0 6px 20px -8px rgba(18, 48, 43, 0.18);
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--sand);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .font-display {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  color: var(--teal-deep);
  line-height: 1.2;
  margin: 0 0 0.4em;
}

a { color: var(--teal); text-decoration: none; }
a:hover { text-decoration: underline; }

p { max-width: 68ch; }

/* --- Motif tanda tangan: bujur sangkar diputar --- */
.motif {
  position: relative;
  width: 14px;
  height: 14px;
  display: inline-block;
  transform: rotate(45deg);
  background: var(--brass);
  flex: none;
}
.motif--outline {
  background: transparent;
  border: 2px solid var(--brass);
}

/* =========================== LAYOUT SHELL =========================== */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 248px;
  flex: none;
  background: var(--teal-deep);
  color: var(--sand);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 20px;
  border-bottom: 1px solid rgba(243, 238, 221, 0.14);
  margin-bottom: 18px;
}

.sidebar-brand .motif { background: var(--brass-soft); }

.sidebar-brand-text { line-height: 1.25; }
.sidebar-brand-text strong {
  display: block;
  font-family: 'Fraunces', serif;
  font-size: 15.5px;
  color: var(--white);
}
.sidebar-brand-text span {
  display: block;
  font-size: 11.5px;
  color: var(--brass-soft);
  letter-spacing: 0.02em;
}

.nav-group { margin-bottom: 18px; }
.nav-group-label {
  font-size: 11px;
  color: rgba(243, 238, 221, 0.45);
  padding: 0 10px;
  margin-bottom: 6px;
  letter-spacing: 0.03em;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: 8px;
  color: rgba(243, 238, 221, 0.85);
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 2px;
}
.nav-link:hover { background: rgba(243, 238, 221, 0.08); text-decoration: none; }
.nav-link.active { background: var(--teal); color: var(--white); }
.nav-link .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; opacity: 0.55; flex: none;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid rgba(243, 238, 221, 0.14);
  font-size: 13px;
}
.sidebar-user { color: var(--white); font-weight: 600; margin-bottom: 2px; }
.sidebar-role { color: rgba(243, 238, 221, 0.55); font-size: 12px; margin-bottom: 10px; }
.btn-logout {
  display: block;
  text-align: center;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(243, 238, 221, 0.25);
  color: var(--sand);
  font-size: 13px;
}
.btn-logout:hover { background: rgba(243, 238, 221, 0.08); text-decoration: none; }

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 21px; margin: 0; }
.topbar .subtitle { color: var(--ink-muted); font-size: 13.5px; margin-top: 2px; }
.topbar-date {
  font-size: 13px;
  color: var(--ink-muted);
  text-align: right;
}
.topbar-date strong { display: block; color: var(--ink); font-size: 14px; }

.content { padding: 26px 28px 60px; }

/* =========================== COMPONENTS =========================== */

.card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.card-pad { padding: 20px 22px; }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
}
.card-head h3 { margin: 0; font-size: 16.5px; }

.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.stat-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.stat-card .motif { position: absolute; top: 18px; right: 20px; }
.stat-card .stat-label { font-size: 12.5px; color: var(--ink-muted); margin-bottom: 8px; }
.stat-card .stat-value { font-family: 'Fraunces', serif; font-size: 32px; color: var(--teal-deep); font-weight: 600; }
.stat-card .stat-foot { font-size: 12.5px; color: var(--ink-muted); margin-top: 4px; }
.stat-card.accent-teal { border-top: 3px solid var(--teal); }
.stat-card.accent-brass { border-top: 3px solid var(--brass); }
.stat-card.accent-clove { border-top: 3px solid var(--clove); }
.stat-card.accent-sage { border-top: 3px solid var(--sage); }

/* Tables */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
table.table th, table.table td {
  padding: 11px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.table th {
  background: var(--sand);
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 12.5px;
}
table.table tbody tr:hover { background: #FCFBF6; }
table.table td.wrap { white-space: normal; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
}
.badge-hadir { background: var(--sage-bg); color: var(--sage); }
.badge-terlambat { background: var(--amber-bg); color: var(--amber); }
.badge-izin { background: #E3E7F1; color: #45558C; }
.badge-sakit { background: #EFE3F1; color: #7A4A8C; }
.badge-alpa { background: var(--clove-bg); color: var(--clove); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  line-height: 1.2;
}
.btn-primary { background: var(--teal); color: var(--white); }
.btn-primary:hover { background: var(--teal-deep); text-decoration: none; }
.btn-brass { background: var(--brass); color: var(--white); }
.btn-brass:hover { background: #9C7526; text-decoration: none; }
.btn-outline { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-outline:hover { background: var(--sand); text-decoration: none; }
.btn-danger { background: var(--clove-bg); color: var(--clove); }
.btn-danger:hover { background: #E9CCC5; text-decoration: none; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* Forms */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.field .hint { font-size: 12px; color: var(--ink-muted); margin-top: 5px; }
input[type=text], input[type=password], input[type=date], input[type=time],
input[type=number], input[type=search], input[type=tel], input[type=file],
select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: var(--white);
  color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brass-soft);
  outline-offset: 1px;
  border-color: var(--brass);
}
.form-row { display: flex; gap: 16px; }
.form-row > .field { flex: 1; }

/* Alerts / flash */
.alert {
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  margin-bottom: 18px;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 10px;
}
.alert-success { background: var(--sage-bg); color: #3E5B44; border-color: #C6D8C8; }
.alert-error { background: var(--clove-bg); color: var(--clove); border-color: #E4C4BC; }
.alert-info { background: #E3E7F1; color: #384675; border-color: #CBD3E8; }

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.toolbar-filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.toolbar-filters select, .toolbar-filters input { width: auto; }

.pill-tabs { display: flex; gap: 6px; background: var(--sand); padding: 4px; border-radius: 999px; width: max-content; }
.pill-tabs a {
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; color: var(--ink-soft);
}
.pill-tabs a.active { background: var(--white); color: var(--teal-deep); box-shadow: var(--shadow-card); text-decoration: none; }
.pill-tabs a:hover { text-decoration: none; }

.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--sand-2); color: var(--teal-deep);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; overflow: hidden; flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }

.person-cell { display: flex; align-items: center; gap: 10px; }
.person-cell .name { font-weight: 600; color: var(--ink); }
.person-cell .meta { font-size: 12.5px; color: var(--ink-muted); }

.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--ink-muted);
}
.empty-state .motif { margin: 0 auto 14px; }

/* =========================== LOGIN =========================== */
.auth-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--teal-deep) 0%, var(--teal) 100%);
  padding: 24px;
}
.auth-card {
  background: var(--paper);
  border-radius: 14px;
  width: 100%;
  max-width: 380px;
  padding: 34px 32px 30px;
  box-shadow: 0 20px 60px -20px rgba(0,0,0,0.5);
}
.auth-motif-row { display: flex; gap: 6px; margin-bottom: 20px; }
.auth-motif-row .motif:nth-child(1) { background: var(--brass); }
.auth-motif-row .motif:nth-child(2) { background: var(--sage); }
.auth-motif-row .motif:nth-child(3) { background: var(--clove); }
.auth-card h1 { font-size: 22px; margin-bottom: 2px; }
.auth-card .subtitle { color: var(--ink-muted); font-size: 13.5px; margin-bottom: 26px; }
.auth-card .btn-primary { width: 100%; justify-content: center; padding: 11px; margin-top: 4px; }
.auth-foot { text-align: center; margin-top: 20px; font-size: 12.5px; color: var(--ink-muted); }

/* =========================== SCAN / GERBANG KIOSK =========================== */
.kiosk {
  min-height: 100vh;
  background: var(--teal-deep);
  color: var(--sand);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 22px 16px 40px;
}
.kiosk-head {
  width: 100%;
  max-width: 480px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.kiosk-head .motif { background: var(--brass-soft); }
.kiosk-head-text strong { display: block; font-family: 'Fraunces', serif; font-size: 16px; color: var(--white); }
.kiosk-head-text span { font-size: 12px; color: rgba(243,238,221,0.6); }
.kiosk-clock { margin-left: auto; text-align: right; }
.kiosk-clock .time { font-family: 'Fraunces', serif; font-size: 20px; color: var(--brass-soft); }
.kiosk-clock .date { font-size: 11.5px; color: rgba(243,238,221,0.55); }

.kiosk-scanner {
  width: 100%;
  max-width: 480px;
  background: rgba(243, 238, 221, 0.06);
  border: 1px solid rgba(243, 238, 221, 0.16);
  border-radius: 16px;
  padding: 14px;
}
#qr-reader { width: 100%; border-radius: 10px; overflow: hidden; }
#qr-reader video { border-radius: 10px; }

.kiosk-status {
  width: 100%;
  max-width: 480px;
  margin-top: 18px;
  min-height: 190px;
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  justify-content: center;
  transition: background 0.2s ease;
  background: rgba(243, 238, 221, 0.06);
  border: 1px solid rgba(243, 238, 221, 0.16);
}
.kiosk-status.status-ok { background: var(--sage); border-color: var(--sage); color: var(--white); }
.kiosk-status.status-late { background: var(--amber); border-color: var(--amber); color: var(--white); }
.kiosk-status.status-err { background: var(--clove); border-color: var(--clove); color: var(--white); }
.kiosk-status .avatar { width: 56px; height: 56px; font-size: 20px; margin-bottom: 10px; }
.kiosk-status .kiosk-name { font-family: 'Fraunces', serif; font-size: 24px; margin-bottom: 2px; }
.kiosk-status .kiosk-meta { font-size: 13.5px; opacity: 0.9; margin-bottom: 8px; }
.kiosk-status .kiosk-msg { font-size: 15px; font-weight: 700; letter-spacing: 0.01em; }
.kiosk-status .kiosk-idle { font-size: 14px; color: rgba(243,238,221,0.6); }

.kiosk-foot { margin-top: 22px; font-size: 12px; color: rgba(243,238,221,0.45); text-align: center; }
.kiosk-foot a { color: rgba(243,238,221,0.6); }

/* =========================== KARTU QR CETAK =========================== */
.qr-card {
  width: 320px;
  border: 1.5px solid var(--teal);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  break-inside: avoid;
  background: var(--white);
}
.qr-card .school-name { font-size: 11px; font-weight: 700; color: var(--teal); text-transform: uppercase; letter-spacing: 0.04em; }
.qr-card .student-name { font-family: 'Fraunces', serif; font-size: 17px; margin: 6px 0 2px; }
.qr-card .student-meta { font-size: 12px; color: var(--ink-muted); margin-bottom: 10px; }
.qr-card .qr-img { width: 170px; height: 170px; }
.qr-card .qr-token { font-size: 10px; color: var(--ink-muted); margin-top: 8px; letter-spacing: 0.03em; }
.qr-grid { display: flex; flex-wrap: wrap; gap: 18px; }

@media print {
  .no-print { display: none !important; }
  body { background: var(--white); }
  .qr-card { box-shadow: none; }
}

/* =====================================================================
   KOMPONEN RESPONSIVE & SIDEBAR OFF-CANVAS (HAMBURGER MENU)
   ===================================================================== */

/* Elemen Navigasi Hambuger & Overlay (Hidden by Default di Desktop) */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 30px;
  height: 22px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  flex: none;
}

.hamburger-btn span {
  width: 100%;
  height: 3px;
  background: var(--teal-deep);
  border-radius: 2px;
}

.btn-sidebar-close {
  display: none;
  background: transparent;
  border: none;
  color: var(--sand);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  margin-left: auto;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 51, 44, 0.5);
  backdrop-filter: blur(2px);
  z-index: 998;
}

/* ---------------------------------------------------------------------
   MEDIA QUERY: TABLET & MOBILE (<= 860px)
   --------------------------------------------------------------------- */
@media (max-width: 860px) {
  .hamburger-btn {
    display: flex;
  }

  .btn-sidebar-close {
    display: block;
  }

  /* Ubah Sidebar Menjadi Off-Canvas Slide Out */
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    bottom: 0;
    width: 260px;
    z-index: 999;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.25);
    overflow-y: auto;
  }

  /* Class saat Sidebar Aktif Terbuka */
  .sidebar.show {
    left: 0;
  }

  .sidebar-overlay.show {
    display: block;
  }

  /* Layout Main & Topbar */
  .main {
    width: 100%;
  }

  .topbar {
    padding: 12px 18px;
  }

  .topbar-date {
    font-size: 12px;
  }

  .content {
    padding: 16px;
  }

  .form-row {
    flex-direction: column;
  }

  /* Paksa Grid Menjadi 1 Kolom Vertikal di Layar Sempit */
  .grid-4, .grid-3, .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* =====================================================================
   FIX TOMBOL HAMBURGER & SIDEBAR MOBILE
   ===================================================================== */

.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 38px;
  height: 34px;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  flex: none;
  z-index: 99;
  -webkit-tap-highlight-color: transparent;
}

.hamburger-btn span {
  width: 100%;
  height: 3px;
  background: var(--teal-deep);
  border-radius: 2px;
  pointer-events: none; /* Mencegah sentuhan terhalang garis span */
}

.btn-sidebar-close {
  display: none;
  background: transparent;
  border: none;
  color: var(--sand);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  margin-left: auto;
  padding: 4px 8px;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(10, 51, 44, 0.5);
  backdrop-filter: blur(2px);
  z-index: 998;
}

@media (max-width: 860px) {
  .hamburger-btn {
    display: flex !important;
  }

  .btn-sidebar-close {
    display: block !important;
  }

  .sidebar {
    position: fixed !important;
    top: 0;
    left: -280px !important;
    bottom: 0;
    width: 260px !important;
    z-index: 9999 !important;
    transition: left 0.3s ease !important;
    box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
  }

  .sidebar.show {
    left: 0 !important;
  }

  .sidebar-overlay.show {
    display: block !important;
  }
}