/* ============================================================
   Presensi Siswa - Stylesheet Utama
   ============================================================ */
:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --warning: #d97706;
    --danger: #dc2626;
    --bg: #f1f5f9;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
}

* { box-sizing: border-box; }

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

a { text-decoration: none; color: inherit; }

/* ---------- Layout Umum ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    background: #0f172a;
    color: #e2e8f0;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
}
.sidebar .brand { padding: 0 20px 20px; font-size: 18px; font-weight: 700; border-bottom: 1px solid #1e293b; margin-bottom: 12px; }
.sidebar .brand small { display:block; font-weight: 400; font-size: 12px; color: #94a3b8; margin-top: 4px;}
.sidebar nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 20px; font-size: 14px; color: #cbd5e1;
    border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: #1e293b; }
.sidebar nav a.active { background: #1e293b; color: #fff; border-left-color: var(--primary); }
.sidebar .logout-link { margin-top: auto; padding: 12px 20px; color: #f87171; font-size: 14px; }

.main-content { flex: 1; padding: 28px 32px; max-width: 100%; overflow-x: auto; }

.topbar { display:flex; justify-content: space-between; align-items:center; margin-bottom: 24px; }
.topbar h1 { font-size: 22px; margin: 0; }
.topbar .user-chip { display:flex; align-items:center; gap:8px; background:#fff; padding:8px 14px; border-radius: 30px; box-shadow: var(--shadow); font-size: 14px; }

/* ---------- Cards / Stats ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--card-bg); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); border-left: 4px solid var(--primary); }
.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger { border-left-color: var(--danger); }
.stat-card .label { font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.stat-card .value { font-size: 28px; font-weight: 700; }

.card { background: var(--card-bg); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card h2, .card h3 { margin-top: 0; }

/* ---------- Table ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th { text-align: left; background: #f8fafc; padding: 10px 12px; border-bottom: 2px solid var(--border); white-space: nowrap; }
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
tbody tr:hover { background: #f8fafc; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-hadir { background: #dcfce7; color: #166534; }
.badge-terlambat { background: #fef3c7; color: #92400e; }
.badge-izin { background: #dbeafe; color: #1e40af; }
.badge-sakit { background: #ede9fe; color: #5b21b6; }
.badge-alfa { background: #fee2e2; color: #991b1b; }
.badge-belum { background: #f1f5f9; color: #64748b; }

/* ---------- Forms & Buttons ---------- */
.form-row { margin-bottom: 14px; }
.form-row label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--text-muted); }
.form-row input, .form-row select, .form-row textarea {
    width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px;
}
.form-row input:focus, .form-row select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

.btn {
    display: inline-flex; align-items: center; gap: 6px; justify-content:center;
    padding: 10px 18px; border-radius: 8px; border: none; cursor: pointer;
    font-size: 14px; font-weight: 600; transition: all .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: #f8fafc; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items:center; margin-bottom: 16px; justify-content: space-between; }
.toolbar-left, .toolbar-right { display: flex; gap: 10px; flex-wrap: wrap; align-items:center; }

/* ---------- Modal ---------- */
.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(15,23,42,0.5);
    align-items: center; justify-content: center; z-index: 1000; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal-box { background: #fff; border-radius: var(--radius); padding: 24px; width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto; }
.modal-box h3 { margin-top: 0; }
.modal-close { float: right; cursor: pointer; font-size: 20px; color: var(--text-muted); background:none; border:none;}

/* ---------- Toast ---------- */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 14px 18px; border-radius: 8px; color: #fff; font-size: 14px; box-shadow: var(--shadow); min-width: 240px; animation: slideIn .2s ease; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--primary); }
@keyframes slideIn { from { transform: translateX(30px); opacity:0;} to { transform: translateX(0); opacity:1;} }

/* ---------- Login Page ---------- */
.login-wrapper { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg,#1e3a8a,#2563eb); }
.login-box { background: #fff; padding: 40px; border-radius: 16px; width: 100%; max-width: 380px; box-shadow: 0 20px 40px rgba(0,0,0,0.2); }
.login-box .logo-area { text-align:center; margin-bottom: 24px; }
.login-box .logo-area .icon { font-size: 40px; }
.login-box h1 { font-size: 20px; text-align:center; margin: 8px 0 4px; }
.login-box p.subtitle { text-align:center; color: var(--text-muted); font-size: 13px; margin-bottom: 24px;}
.login-error { background:#fee2e2; color:#991b1b; padding:10px 14px; border-radius:8px; font-size:13px; margin-bottom:16px; display:none;}

/* ---------- Halaman Scan (Kiosk) ---------- */
.scan-wrapper {
    min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center;
    background: linear-gradient(160deg,#0f172a,#1e3a8a); color: #fff; padding: 20px; text-align:center;
}
.scan-clock { font-size: 52px; font-weight: 700; letter-spacing: 2px; }
.scan-date { font-size: 16px; color: #cbd5e1; margin-bottom: 24px; }
.scan-mode-toggle { display:flex; gap: 10px; margin-bottom: 24px; background: rgba(255,255,255,0.08); padding: 6px; border-radius: 30px; }
.scan-mode-toggle button {
    padding: 10px 24px; border-radius: 24px; border:none; background:transparent; color:#cbd5e1; cursor:pointer; font-weight:600; font-size:14px;
}
.scan-mode-toggle button.active { background: #fff; color:#1e3a8a; }
.scan-box { background: rgba(255,255,255,0.06); border: 2px dashed rgba(255,255,255,0.25); border-radius: 20px; padding: 20px; width: 100%; max-width: 420px; }
#scanner-video-wrap { border-radius: 14px; overflow: hidden; }
.scan-input-hidden { position: absolute; opacity: 0; pointer-events: none; }
.scan-tab-switch { display:flex; gap:8px; margin-bottom: 16px; justify-content:center; }
.scan-tab-switch button { background: rgba(255,255,255,0.1); border:1px solid rgba(255,255,255,0.2); color:#fff; padding:8px 16px; border-radius:8px; cursor:pointer; font-size:13px;}
.scan-tab-switch button.active { background:#fff; color:#1e3a8a; font-weight:600; }

.scan-result-card { margin-top: 24px; width: 100%; max-width: 420px; background: #fff; color: var(--text); border-radius: 16px; padding: 20px; display:none; text-align:left; align-items:center; gap: 16px; }
.scan-result-card.show { display: flex; }
.scan-result-card.result-error { background: #fee2e2; }
.scan-result-card .foto { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; background: #e2e8f0; flex-shrink:0; }
.scan-result-card .info h3 { margin: 0 0 4px; font-size: 17px; }
.scan-result-card .info p { margin: 2px 0; font-size: 13px; color: var(--text-muted); }

.scan-footer-link { margin-top: 30px; font-size: 12px; color: rgba(255,255,255,0.5); }

/* ---------- Kartu Barcode Cetak ---------- */
.print-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.kartu-siswa {
    border: 1px solid #cbd5e1; border-radius: 10px; padding: 12px; display:flex; flex-direction:column; align-items:center;
    text-align:center; page-break-inside: avoid;
}
.kartu-siswa .sekolah { font-size: 11px; font-weight:700; text-transform:uppercase; }
.kartu-siswa .nama { font-size: 14px; font-weight:700; margin: 4px 0 0; }
.kartu-siswa .kelas { font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.kartu-siswa svg { max-width: 100%; }

@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
}

@media (max-width: 900px) {
    .sidebar { display: none; }
    .form-grid { grid-template-columns: 1fr; }
}
