/* ==========================================================================
   Palet: navy tinta resmi + emas stempel + kertas dingin
   Tipografi: Fraunces (display, dipakai hemat) + Inter (isi) + IBM Plex Mono (data/nomor)
   Elemen tanda tangan: "meterai" lingkar berputar pelan di kartu login & header dashboard
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500..700&family=Inter:wght@400;500;600;700&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
  --ink: #16233f;
  --ink-2: #223257;
  --gold: #b8862f;
  --gold-soft: #e7cd93;
  --paper: #eef1f6;
  --paper-card: #ffffff;
  --line: #d7dce6;
  --text: #202838;
  --muted: #62697b;
  --ok: #2e7d5b;
  --ok-bg: #e4f3ec;
  --warn: #c77d22;
  --warn-bg: #fbeedd;
  --bad: #b23a3a;
  --bad-bg: #fbe7e7;
  --plum: #6a4c93;
  --plum-bg: #eee7f7;
  --radius: 10px;
  --shadow: 0 8px 28px rgba(22, 35, 63, 0.10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--paper);
  background-image:
    radial-gradient(circle at 12% 8%, rgba(184,134,47,0.06), transparent 40%),
    radial-gradient(circle at 90% 90%, rgba(22,35,63,0.05), transparent 45%);
  color: var(--text);
  font-family: "Inter", system-ui, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: "Fraunces", serif;
  color: var(--ink);
  letter-spacing: 0.2px;
  margin: 0;
}

.mono { font-family: "IBM Plex Mono", monospace; letter-spacing: 0.2px; }

a { color: var(--ink-2); }

.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* ---------- Seal / meterai — elemen tanda khas aplikasi ---------- */
.seal {
  width: 56px; height: 56px; border-radius: 50%;
  border: 2px dashed var(--gold);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  animation: spin 22s linear infinite;
  position: relative;
}
.seal::before {
  content: "";
  position: absolute; inset: 6px;
  border: 1px solid var(--gold-soft);
  border-radius: 50%;
}
.seal span {
  font-family: "Fraunces", serif; font-weight: 700; color: var(--gold);
  font-size: 18px; animation: spin-rev 22s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spin-rev { to { transform: rotate(-360deg); } }
@media (prefers-reduced-motion: reduce) {
  .seal, .seal span { animation: none; }
}

/* ---------- Topbar ---------- */
.topbar {
  background: var(--ink);
  color: #fff;
  padding: 14px 0;
  box-shadow: var(--shadow);
}
.topbar .container { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.topbar-brand { display: flex; align-items: center; gap: 12px; }
.topbar-brand .seal { width: 38px; height: 38px; border-color: var(--gold-soft); }
.topbar-brand .seal span { font-size: 13px; }
.topbar-title { line-height: 1.15; }
.topbar-title strong { display: block; font-size: 15px; }
.topbar-title small { color: #b9c2d6; font-size: 12px; }
.topbar-user { display: flex; align-items: center; gap: 12px; font-size: 14px; color: #dfe4ee; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 32px 16px;
}
.login-card {
  background: var(--paper-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%; max-width: 440px;
  padding: 32px 30px 28px;
  border: 1px solid var(--line);
}
.login-head { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.login-head h1 { font-size: 21px; }
.login-head small { color: var(--muted); display: block; margin-top: 2px; font-size: 12.5px; }

.tabs { display: flex; background: var(--paper); border-radius: 999px; padding: 4px; margin-bottom: 22px; }
.tab-btn {
  flex: 1; border: none; background: transparent; padding: 9px 0;
  font-weight: 600; font-size: 13.5px; color: var(--muted); border-radius: 999px; cursor: pointer;
  transition: background .15s, color .15s;
}
.tab-btn.active { background: var(--ink); color: #fff; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--ink-2); }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 14.5px; font-family: inherit; background: #fbfcfe; color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--gold-soft); border-color: var(--gold); background: #fff;
}
.field small.hint { color: var(--muted); font-size: 12px; display: block; margin-top: 5px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border-radius: 8px; border: none; font-weight: 600; font-size: 14px;
  cursor: pointer; transition: transform .08s ease, box-shadow .15s ease; font-family: inherit;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { box-shadow: 0 4px 14px rgba(22,35,63,.28); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { box-shadow: 0 4px 14px rgba(184,134,47,.35); }
.btn-outline { background: transparent; border: 1px solid var(--line); color: var(--ink-2); }
.btn-outline:hover { border-color: var(--ink-2); }
.btn-danger { background: var(--bad); color: #fff; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-sm { padding: 7px 12px; font-size: 12.5px; }

.error-msg {
  background: var(--bad-bg); color: var(--bad); border-radius: 8px; padding: 10px 12px;
  font-size: 13.5px; margin-bottom: 14px; display: none;
}
.error-msg.show { display: block; }

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

/* ---------- Dashboard layout ---------- */
.page { padding: 28px 0 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h2 { font-size: 24px; }
.page-head p { color: var(--muted); margin: 4px 0 0; font-size: 13.5px; }

.tabs-nav { display: flex; gap: 6px; margin-bottom: 22px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tabs-nav button {
  background: none; border: none; padding: 10px 16px; font-weight: 600; font-size: 13.5px;
  color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; font-family: inherit;
}
.tabs-nav button.active { color: var(--ink); border-color: var(--gold); }

.panel { display: none; }
.panel.active { display: block; }

.card {
  background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 22px 22px 24px; box-shadow: var(--shadow); margin-bottom: 22px;
}
.card h3 { font-size: 16.5px; margin-bottom: 4px; }
.card .card-sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }

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

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
.stat-card {
  background: var(--paper-card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat-card .num { font-family: "Fraunces", serif; font-size: 28px; color: var(--ink); font-weight: 600; }
.stat-card .lbl { font-size: 12.5px; color: var(--muted); margin-top: 2px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; background: var(--paper); color: var(--ink-2); font-size: 12px;
  text-transform: uppercase; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #f7f9fc; }
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700;
  letter-spacing: .02em; background: #eee; color: #555;
}
.badge-istimewa { background: var(--plum-bg); color: var(--plum); }
.badge-baik { background: var(--ok-bg); color: var(--ok); }
.badge-memadai { background: var(--warn-bg); color: var(--warn); }
.badge-kurang { background: var(--bad-bg); color: var(--bad); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; justify-content: space-between; }
.toolbar .left { display: flex; gap: 10px; flex-wrap: wrap; }
.search-input { min-width: 240px; }

.dropzone {
  border: 2px dashed var(--line); border-radius: var(--radius); padding: 26px;
  text-align: center; color: var(--muted); font-size: 13.5px; background: #fbfcfe; cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dropzone.drag { border-color: var(--gold); background: #fdf8ee; }
.dropzone strong { color: var(--ink-2); }

.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 10px; display:none; }
.progress.show { display: block; }
.progress > div { height: 100%; background: var(--gold); width: 0%; transition: width .2s; }

.log-box {
  background: #0f1a30; color: #cfe0ff; font-family: "IBM Plex Mono", monospace; font-size: 12px;
  border-radius: 8px; padding: 12px 14px; max-height: 220px; overflow-y: auto; margin-top: 14px; display: none;
  line-height: 1.6;
}
.log-box.show { display: block; }
.log-box .ok { color: #8fe3b0; }
.log-box .err { color: #ff9f9f; }

/* ---------- Toast & loading ---------- */
#toast-host { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 9999; }
.toast {
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 8px; font-size: 13.5px;
  box-shadow: var(--shadow); opacity: 0; transform: translateY(8px); transition: all .25s ease; max-width: 340px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-error { background: var(--bad); }
.toast-success { background: var(--ok); }

#loading-overlay {
  position: fixed; inset: 0; background: rgba(22,35,63,.55); display: none;
  align-items: center; justify-content: center; z-index: 9998;
}
#loading-overlay.show { display: flex; }
.loading-box { background: #fff; border-radius: var(--radius); padding: 22px 28px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); font-size: 14px; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--gold); animation: spin 0.8s linear infinite; }

/* ---------- Certificate/biodata (siswa) ---------- */
.biodata-head { display: flex; align-items: center; gap: 18px; margin-bottom: 6px; }
.biodata-head h2 { font-size: 22px; }
.biodata-head .seal { width: 48px; height: 48px; }
.biodata-sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }

.bio-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px 24px; margin: 18px 0 6px; }
@media (max-width: 640px) { .bio-grid { grid-template-columns: 1fr; } }
.bio-item .lbl { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.bio-item .val { font-size: 15px; font-weight: 600; color: var(--ink-2); margin-top: 2px; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .display { color: var(--ink-2); font-size: 18px; margin-bottom: 6px; }

.pill-note { background: var(--warn-bg); color: var(--warn); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; margin-top: 6px; }

.hidden { display: none !important; }

/* ---------- Modal (form tambah/edit siswa) ---------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(22,35,63,.6);
  display: none; align-items: flex-start; justify-content: center;
  padding: 40px 16px; overflow-y: auto; z-index: 9990;
}
.modal-overlay.show { display: flex; }
.modal-box {
  background: #fff; border-radius: var(--radius); max-width: 640px; width: 100%;
  padding: 24px 26px 26px; box-shadow: var(--shadow);
}
.modal-box h3 { margin-bottom: 4px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal-close { background: none; border: none; float: right; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1; }
