/* ============================================================================
   SISFO SD - Tema Prototype
   Sidebar layout, stat cards, gate mode, kartu ID, print styles
   ============================================================================ */

:root {
  --primary: #2563eb;
  --primary-dark: #1e3a8a;
  --primary-soft: #dbeafe;
  --accent: #059669;
  --accent-soft: #d1fae5;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #0891b2;
  --info-soft: #cffafe;
  --purple: #7c3aed;
  --purple-soft: #ede9fe;
  --slate: #475569;
  --slate-soft: #e2e8f0;
  --sidebar-bg: #0f172a;
  --sidebar-bg2: #16213b;
  --content-bg: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --card-radius: 14px;
}

* { box-sizing: border-box; }

body {
  font-family: "Segoe UI", "Poppins", Roboto, system-ui, -apple-system, sans-serif;
  background: var(--content-bg);
  color: var(--text);
  margin: 0;
}

/* ================= APP LAYOUT (Sidebar) ================= */
.app-layout { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 258px;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg2) 100%);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  z-index: 1050;
  transition: transform 0.25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 17px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.brand-name { color: #fff; font-weight: 700; font-size: 16px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: #94a3b8; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 0 16px; }

.nav-section {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: #64748b;
  padding: 16px 20px 6px;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 20px;
  color: #cbd5e1;
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

.sidebar-nav a i { font-size: 16px; width: 20px; text-align: center; }
.sidebar-nav a:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar-nav a.active {
  background: rgba(37, 99, 235, 0.18);
  color: #fff;
  border-left-color: var(--accent);
}

.sidebar-footer {
  padding: 12px 20px;
  font-size: 11px;
  color: #64748b;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.main-area { margin-left: 258px; min-height: 100vh; display: flex; flex-direction: column; }

/* ================= TOPBAR ================= */
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 14px;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.topbar-title { font-size: 18px; font-weight: 700; margin: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }

.live-clock { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--content-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 14px 5px 6px;
  font-size: 13px;
  font-weight: 600;
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}

.content { flex: 1; padding: 24px; }

/* ================= CARDS & TABLES ================= */
.card {
  border: none;
  border-radius: var(--card-radius);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 6px 20px rgba(15, 23, 42, 0.05);
}

.card-header { border-radius: var(--card-radius) var(--card-radius) 0 0 !important; font-weight: 600; }

.stat-card {
  border-radius: var(--card-radius);
  padding: 18px 20px;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.16);
}

.stat-card .stat-icon { position: absolute; right: 14px; top: 12px; font-size: 30px; opacity: 0.3; }
.stat-card h6 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.9; margin: 0 0 6px; }
.stat-card h2 { font-size: 30px; font-weight: 800; margin: 0; }

.stat-bg-primary { background: linear-gradient(135deg, #2563eb, #1d4ed8); }
.stat-bg-success { background: linear-gradient(135deg, #10b981, #059669); }
.stat-bg-warning { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-bg-danger  { background: linear-gradient(135deg, #ef4444, #dc2626); }
.stat-bg-info    { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.stat-bg-purple  { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.stat-bg-dark    { background: linear-gradient(135deg, #334155, #1e293b); }

/* Soft badges */
.badge-soft-success { background: var(--accent-soft); color: #047857; }
.badge-soft-warning { background: var(--warning-soft); color: #b45309; }
.badge-soft-danger  { background: var(--danger-soft); color: #b91c1c; }
.badge-soft-info    { background: var(--info-soft); color: #0e7490; }
.badge-soft-purple  { background: var(--purple-soft); color: #6d28d9; }
.badge-soft-slate   { background: var(--slate-soft); color: var(--slate); }
.badge-soft-primary { background: var(--primary-soft); color: var(--primary-dark); }

.table thead th {
  background: #f8fafc;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  padding: 12px 14px;
  white-space: nowrap;
}

.table td { padding: 12px 14px; vertical-align: middle; }
.table-hover tbody tr:hover { background: #f8fafc; }

/* Forms */
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem rgba(37, 99, 235, 0.15);
}

.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }

/* ================= GATE MODE (scan datang / penjemputan) ================= */
body.gate { background: #0b1220; color: #e2e8f0; }

.gate-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 24px;
  background: rgba(15, 23, 42, 0.8);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0;
  z-index: 1030;
}

.gate-header .gate-title { font-size: 17px; font-weight: 700; color: #fff; margin: 0; }
.gate-header .gate-sub { font-size: 12px; color: #94a3b8; }

.gate-main { padding: 24px; max-width: 1200px; margin: 0 auto; }

.gate-panel {
  background: #121a2e;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  padding: 22px;
}

.announce-box {
  background: linear-gradient(135deg, #1e293b, #0f172a);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 18px;
  padding: 30px;
  min-height: 230px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.announce-text {
  font-size: clamp(26px, 4vw, 46px);
  font-weight: 800;
  color: #fff;
  line-height: 1.25;
  margin: 0;
}

.on-air {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(220, 38, 38, 0.92);
  color: #fff;
  padding: 6px 16px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.on-air .dot {
  width: 10px;
  height: 10px;
  background: #fff;
  border-radius: 50%;
  animation: pulse-dot 1s infinite;
}

.gate-input {
  background: #0f172a;
  border: 2px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-align: center;
  border-radius: 12px;
}

.gate-input:focus {
  border-color: var(--accent);
  background: #0f172a;
  color: #fff;
  box-shadow: 0 0 0 0.25rem rgba(16, 185, 129, 0.2);
}

.gate-input::placeholder { color: #475569; font-weight: 400; letter-spacing: 0.05em; font-size: 15px; }

/* ================= FOTO / PLACEHOLDER ================= */
.photo-frame {
  background: #0f172a;
  border-radius: 14px;
  overflow: hidden;
  min-height: 260px;
  display: grid;
  place-items: center;
}

.photo-frame video { width: 100%; height: auto; min-height: 260px; object-fit: cover; }
.photo-frame img { width: 100%; height: 100%; object-fit: cover; }

.photo-placeholder { color: #475569; text-align: center; padding: 40px; }
.photo-placeholder i { font-size: 56px; display: block; margin-bottom: 10px; }

/* ================= KARTU ID ================= */
.id-card {
  width: 340px;
  min-height: 205px;
  border: 1.5px solid #334155;
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  color: #0f172a;
  display: inline-block;
  vertical-align: top;
  margin: 8px;
  break-inside: avoid;
}

.id-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: #fff;
}

.id-card-top.parent { background: linear-gradient(135deg, #b45309, #d97706); }

.id-logo {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 1.5px solid rgba(255, 255, 255, 0.7);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 13px;
}

.id-school { line-height: 1.15; }
.id-school div { font-size: 13px; font-weight: 700; }
.id-school small { font-size: 10px; opacity: 0.85; letter-spacing: 0.05em; }

.id-body { padding: 10px 14px 12px; text-align: center; }
.id-name { font-size: 15px; font-weight: 700; }
.id-meta { font-size: 11px; color: #475569; }
.id-barcode { margin: 6px 0 2px; }
.id-barcode svg { max-width: 100%; height: 42px; }

.id-qr { margin: 8px 0 4px; }
.id-qr .qr-el canvas { width: 96px; height: 96px; }
.id-code {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: #1e3a8a;
}

/* ================= QR OVERLAY (gate pages) ================= */
.qr-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 16px;
}

.qr-overlay-card {
  background: #121a2e;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 18px;
  width: 100%;
  max-width: 430px;
  color: #e2e8f0;
}

#qrReader {
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  background: #000;
  min-height: 230px;
}

#qrReader video { width: 100% !important; border-radius: 10px; }
#qrReader canvas { border-radius: 10px; }

/* ================= ANIMASI & UTIL ================= */
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.75); }
}

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

.fade-in { animation: fadeInUp 0.4s ease both; }

.realtime-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  animation: pulse-dot 1.2s infinite;
}

.clickable { cursor: pointer; }

/* ================= LOGIN ================= */
body.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 55%, #0891b2 100%);
  padding: 24px;
}

.login-panel {
  display: flex;
  width: 100%;
  max-width: 900px;
  min-height: 540px;
  background: #fff;
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 30px 70px rgba(2, 6, 23, 0.45);
  animation: fadeInUp 0.5s ease both;
}

.login-brand {
  flex: 1;
  background: linear-gradient(160deg, #0f172a, #1e3a8a);
  color: #fff;
  padding: 44px 38px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-brand h2 { font-weight: 800; margin: 18px 0 4px; }
.login-brand > p { color: #cbd5e1; margin-bottom: 22px; }

.login-features { list-style: none; padding: 0; margin: 0; }
.login-features li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  color: #e2e8f0;
  font-size: 14px;
}
.login-features i { color: #34d399; font-size: 18px; }

.login-form-side { flex: 1; padding: 44px 40px; display: flex; flex-direction: column; justify-content: center; }

.login-form-side h3 { font-weight: 800; margin-bottom: 4px; }
.login-form-side .sub { color: var(--muted); margin-bottom: 22px; font-size: 14px; }

.demo-box {
  margin-top: 24px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 14px;
  background: #f8fafc;
}

.demo-box .demo-title { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; }

.demo-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.demo-btns button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s;
}
.demo-btns button:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* ================= PRINT ================= */
@media print {
  .sidebar, .topbar, .no-print, .gate-header { display: none !important; }
  .main-area { margin-left: 0; }
  body { background: #fff; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 1px solid var(--border); }
}

/* ================= RESPONSIVE ================= */
@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .login-panel { flex-direction: column; }
  .login-brand { padding: 30px; }
}

@media (max-width: 575.98px) {
  .content { padding: 16px; }
  .topbar { padding: 10px 14px; }
  .live-clock { display: none; }
}
