/* =========================================================
   Presensi Kelas - styles
   ========================================================= */

:root {
  --bg: #f4f6fb;
  --bg-grad-1: #eef2ff;
  --bg-grad-2: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e6e9f0;
  --border-strong: #d3d8e3;
  --text: #1a2233;
  --text-soft: #5b6478;
  --muted: #8a93a6;
  --primary: #4f46e5;
  --primary-600: #4338ca;
  --primary-soft: #eef0ff;
  --danger: #e11d48;
  --danger-soft: #fff1f3;
  --ok: #16a34a;
  --ok-soft: #ecfdf5;
  --warn: #d97706;
  --warn-soft: #fff7ed;
  --info: #2563eb;
  --info-soft: #eff6ff;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 30, 60, .06), 0 1px 3px rgba(20, 30, 60, .04);
  --shadow-md: 0 6px 18px rgba(20, 30, 60, .08), 0 2px 6px rgba(20, 30, 60, .05);
  --shadow-lg: 0 24px 60px rgba(20, 30, 60, .14), 0 8px 24px rgba(20, 30, 60, .08);
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, var(--bg-grad-1), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, #f0fdf4, transparent 55%),
    var(--bg-grad-2);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app { min-height: 100%; }

/* ---------- Screens ---------- */
.screen { display: none; min-height: 100%; }
.screen.is-active { display: flex; }

/* ---------- Login ---------- */
#screen-login {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  padding: 32px;
  animation: rise .5s cubic-bezier(.2,.7,.2,1);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}

.brand { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.brand h1 { font-size: 22px; margin: 0; letter-spacing: -.02em; }
.brand-sub { margin: 2px 0 0; color: var(--muted); font-size: 13px; }

.brand-mark {
  width: 48px; height: 48px; flex: none;
  display: grid; place-items: center;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(145deg, #6366f1, #4f46e5);
  box-shadow: 0 8px 20px rgba(79, 70, 229, .35);
}
.brand-mark.sm { width: 34px; height: 34px; border-radius: 10px; box-shadow: var(--shadow-sm); }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 7px; }
.field-label { font-size: 13px; font-weight: 600; color: var(--text-soft); }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  width: 100%;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, .15);
}
input::placeholder { color: var(--muted); }

.select-wrap { position: relative; }
.select-wrap select { appearance: none; padding-right: 38px; cursor: pointer; }
.select-wrap .chev {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 11px 16px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .08s, background .15s, border-color .15s, box-shadow .15s, opacity .15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(79,70,229,.28); }
.btn-primary:hover:not(:disabled) { background: var(--primary-600); }

.btn-ghost { background: transparent; color: var(--text-soft); border-color: var(--border-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }

.btn-soft { background: var(--primary-soft); color: var(--primary-600); }
.btn-soft:hover:not(:disabled) { background: #e4e6ff; }

.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-block { width: 100%; }

.error-text { color: var(--danger); font-size: 13px; margin: 0; }
.login-foot { text-align: center; color: var(--muted); font-size: 12px; margin: 18px 0 0; }

/* ---------- Topbar ---------- */
#screen-main { flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-brand {
  display: flex; align-items: center; gap: 10px;
  color: inherit; text-decoration: none;
  border-radius: 10px;
  padding: 3px 6px 3px 3px;
  transition: background .15s;
  margin-right: 4px;
}
.topbar-brand:hover { background: var(--surface-2); }
.topbar-title { font-weight: 700; letter-spacing: -.01em; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* Topbar navigation links */
.topbar-nav {
  display: flex;
  gap: 2px;
  margin-left: 8px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}
.nav-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
}
.nav-link svg { opacity: .6; transition: opacity .15s; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link:hover svg { opacity: 1; }
.nav-link.is-active {
  background: var(--primary-soft);
  color: var(--primary-600);
}
.nav-link.is-active svg { opacity: 1; }

@media (max-width: 640px) {
  .topbar-title { display: none; }
  .topbar-nav { margin-left: 0; padding-left: 0; border-left: none; }
  .nav-link { padding: 7px 10px; font-size: 12px; }
  .nav-link span { display: none; }
  .nav-link svg { opacity: 1; }
}
.teacher-chip {
  font-size: 13px; font-weight: 600; color: var(--text-soft);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 6px 12px; border-radius: 999px;
}

/* ---------- Content ---------- */
.content {
  width: 100%; max-width: 920px; margin: 0 auto; padding: 24px 20px 64px;
  display: flex; flex-direction: column; gap: 20px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}
.card-head h2 { margin: 0 0 4px; font-size: 18px; letter-spacing: -.01em; }
.card-head p { margin: 0; color: var(--muted); font-size: 13px; }

.grid-3 {
  display: grid; gap: 16px;
  grid-template-columns: repeat(3, 1fr);
  margin: 18px 0;
}
@media (max-width: 720px) { .grid-3 { grid-template-columns: 1fr; } }

.session-card .btn-primary { margin-top: 4px; }

/* ---------- Roster ---------- */
.roster-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.roster-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.summary-pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  font-size: 12px; font-weight: 600;
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-soft);
  display: inline-flex; align-items: center; gap: 6px;
}
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.hadir { color: var(--ok); background: var(--ok-soft); border-color: #c3ecd8; }
.pill.sakit { color: var(--warn); background: var(--warn-soft); border-color: #fde9c6; }
.pill.izin  { color: var(--info); background: var(--info-soft); border-color: #cdddff; }
.pill.alpha { color: var(--danger); background: var(--danger-soft); border-color: #fbd5dd; }

.search-wrap {
  position: relative; margin: 16px 0 10px;
}
.search-wrap svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search-wrap input { padding-left: 38px; }

.roster-list { display: flex; flex-direction: column; gap: 8px; }

.student-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color .15s, background .15s;
}
.student-row:hover { border-color: var(--border-strong); }
.student-row.marked { background: #fff; border-color: var(--border-strong); }

.student-info { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 38px; height: 38px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 14px; color: #fff;
  background: linear-gradient(145deg, #818cf8, #6366f1);
}
.student-meta { min-width: 0; }
.student-name { font-weight: 600; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.student-id { font-size: 12px; color: var(--muted); }

.status-group { display: flex; gap: 6px; flex-wrap: wrap; }
.status-btn {
  font: inherit; font-size: 12px; font-weight: 700;
  padding: 7px 11px; border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-soft);
  cursor: pointer; transition: all .12s;
  min-width: 54px;
}
.status-btn:hover { border-color: var(--text-soft); }
.status-btn.active { color: #fff; border-color: transparent; }
.status-btn.active.hadir { background: var(--ok); }
.status-btn.active.sakit  { background: var(--warn); }
.status-btn.active.izin   { background: var(--info); }
.status-btn.active.alpha  { background: var(--danger); }

@media (max-width: 560px) {
  .student-row { flex-wrap: wrap; }
  .status-group { width: 100%; }
  .status-btn { flex: 1; }
}

.roster-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.muted { color: var(--muted); font-size: 13px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: #11161f; color: #fff;
  padding: 12px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0; transition: opacity .25s, transform .25s;
  z-index: 50; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.ok { background: #14532d; }
.toast.err { background: #7f1d1d; }

/* ---------- Spinner ---------- */
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Empty state ---------- */
.empty {
  text-align: center; color: var(--muted); padding: 28px 12px;
  font-size: 14px;
}

/* ---------- Admin ---------- */
.admin-content { max-width: 760px; }

/* Admin gate (PIN login) */
.admin-gate-card {
  text-align: center;
  padding: 40px 32px;
  animation: rise .4s cubic-bezier(.2,.7,.2,1);
}
.admin-gate-icon {
  width: 64px; height: 64px; margin: 0 auto 20px;
  display: grid; place-items: center;
  border-radius: 18px;
  color: var(--primary);
  background: var(--primary-soft);
  border: 1px solid #e0e3ff;
}
.admin-gate-head { text-align: center; }
.admin-gate-head h2 { font-size: 20px; }
.admin-pin-row {
  display: flex; gap: 10px; margin-top: 24px;
  max-width: 360px; margin-left: auto; margin-right: auto;
}
.admin-pin-row input {
  flex: 1; text-align: center; font-size: 18px; letter-spacing: .3em; font-weight: 600;
}

/* Admin cards */
.admin-card {
  padding: 0;
  overflow: hidden;
  animation: rise .35s cubic-bezier(.2,.7,.2,1);
}
.admin-card + .admin-card { margin-top: 0; }

/* Admin tab navigation */
.admin-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 5px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 60px;
  z-index: 15;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.admin-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--text-soft);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  min-width: max-content;
}
.admin-tab svg { flex: none; opacity: .6; transition: opacity .15s; }
.admin-tab:hover { background: var(--surface-2); color: var(--text); }
.admin-tab:hover svg { opacity: .9; }
.admin-tab.is-active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, .28);
}
.admin-tab.is-active svg { opacity: 1; }
.admin-tab-count {
  font-size: 11px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--text-soft);
  padding: 1px 7px;
  border-radius: 999px;
  min-width: 20px;
  text-align: center;
}
.admin-tab.is-active .admin-tab-count {
  background: rgba(255,255,255,.25);
  color: #fff;
}

/* Admin panels — only active one is visible */
.admin-panel { display: none; animation: rise .25s cubic-bezier(.2,.7,.2,1); }
.admin-panel.is-active { display: block; }

@media (max-width: 600px) {
  .admin-tabs { top: 52px; padding: 4px; }
  .admin-tab { padding: 9px 10px; font-size: 13px; gap: 6px; }
  .admin-tab span:nth-child(2) { display: inline; }
}

/* Admin add row */
.admin-add-row {
  display: flex; gap: 8px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-wrap: wrap;
}
.admin-add-row input, .admin-add-row .select-wrap {
  flex: 1; min-width: 130px;
}
.admin-add-row .select-wrap select {
  appearance: none; padding-right: 36px; cursor: pointer;
}
.admin-add-btn { flex: none; }
.admin-add-btn svg { margin-right: 2px; }

/* Admin list */
.admin-list {
  display: flex; flex-direction: column;
  padding: 8px;
  gap: 4px;
}
.admin-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.admin-item:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.admin-item-info { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; min-width: 0; }
.admin-item-name { font-weight: 600; }
.admin-item-meta {
  color: var(--muted); font-size: 12px;
  background: var(--surface-2);
  padding: 2px 8px; border-radius: 6px;
  border: 1px solid var(--border);
}
.admin-remove {
  font-size: 12px; font-weight: 600; color: var(--danger);
  background: var(--danger-soft); border: 1px solid #fbd5dd;
  border-radius: 8px; padding: 6px 12px; cursor: pointer;
  transition: all .15s;
  display: inline-flex; align-items: center; gap: 5px;
  flex: none;
}
.admin-remove:hover { background: #fbd5dd; color: #b91c3c; }
.admin-remove svg { width: 14px; height: 14px; }

/* Admin empty state inside lists */
.admin-list .empty {
  padding: 20px 12px;
  font-size: 13px;
}

/* Student add row needs more space */
.admin-add-row-student input { min-width: 110px; }
@media (max-width: 600px) {
  .admin-add-row { flex-direction: column; }
  .admin-add-row input, .admin-add-row .select-wrap { min-width: 0; }
  .admin-add-btn { width: 100%; }
  .admin-add-row { padding: 14px 16px; }
}

