:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --accent: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f4f6fb;
    --card-bg: #ffffff;
    --text: #1f2937;
    --text-soft: #6b7280;
    --border: #e5e7eb;
}

[data-theme="dark"] {
    --bg: #0f172a;
    --card-bg: #1e293b;
    --text: #f1f5f9;
    --text-soft: #94a3b8;
    --border: #334155;
}

* { box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Poppins', 'Segoe UI', sans-serif;
    transition: background .3s ease, color .3s ease;
    min-height: 100vh;
    overflow-x: hidden;
}

.animated-bg {
    position: fixed;
    inset: 0;
    z-index: -1;
    background: linear-gradient(-45deg, #4f46e5, #06b6d4, #4338ca, #7c3aed);
    background-size: 400% 400%;
    animation: gradientShift 18s ease infinite;
    opacity: .12;
}

@keyframes gradientShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.glass-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0,0,0,.06);
}

.navbar-brand-logo {
    height: 42px;
    width: 42px;
    object-fit: cover;
    border-radius: 10px;
}

.clock-display {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: 2px;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.date-display {
    font-size: 1.1rem;
    color: var(--text-soft);
}

.badge-wib {
    background: linear-gradient(90deg, var(--primary), var(--accent));
    color: #fff;
    font-size: .8rem;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 4px 12px;
    border-radius: 20px;
    align-self: center;
    transform: translateY(-4px);
}

.running-text-wrap {
    background: var(--primary);
    color: #fff;
    padding: 10px 0;
    overflow: hidden;
    white-space: nowrap;
}
.running-text {
    display: inline-block;
    padding-left: 100%;
    animation: marquee 22s linear infinite;
}
@keyframes marquee {
    0%   { transform: translateX(0); }
    100% { transform: translateX(-100%); }
}

.stat-card {
    border-radius: 18px;
    padding: 22px;
    color: #fff;
    position: relative;
    overflow: hidden;
    transition: transform .25s ease;
}
.stat-card:hover { transform: translateY(-6px); }
.stat-card .stat-icon {
    font-size: 2.2rem;
    opacity: .85;
}
.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
}
.bg-grad-1 { background: linear-gradient(135deg, #4f46e5, #7c3aed); }
.bg-grad-2 { background: linear-gradient(135deg, #10b981, #06b6d4); }
.bg-grad-3 { background: linear-gradient(135deg, #f59e0b, #f97316); }
.bg-grad-4 { background: linear-gradient(135deg, #ef4444, #db2777); }
.bg-grad-5 { background: linear-gradient(135deg, #64748b, #334155); }

.btn-scan {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border: none;
    color: #fff;
    font-weight: 600;
    font-size: 1.2rem;
    padding: 18px 46px;
    border-radius: 50px;
    box-shadow: 0 8px 25px rgba(79,70,229,.4);
    transition: transform .25s ease, box-shadow .25s ease;
}
.btn-scan:hover {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 12px 30px rgba(79,70,229,.55);
    color: #fff;
}

.theme-toggle {
    cursor: pointer;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border: 1px solid var(--border);
}

#scanner-modal .modal-content {
    border-radius: 22px;
    overflow: hidden;
}

#qr-reader { border-radius: 16px; overflow: hidden; }

.result-card {
    text-align: center;
    padding: 20px;
}
.result-photo {
    width: 130px;
    height: 130px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--primary);
    margin: 0 auto 15px;
}

.pulse-ring {
    animation: pulse 1.5s ease-out infinite;
}
@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(79,70,229,.5); }
    70%  { box-shadow: 0 0 0 20px rgba(79,70,229,0); }
    100% { box-shadow: 0 0 0 0 rgba(79,70,229,0); }
}

footer.app-footer {
    color: var(--text-soft);
    padding: 24px 0;
    text-align: center;
    font-size: .9rem;
}

/* ===== Scanner status indicator ===== */
.scanner-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .85rem;
    font-weight: 600;
    color: var(--success);
    background: rgba(16,185,129,.1);
    padding: 6px 14px;
    border-radius: 20px;
}
.dot-live {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--success);
    display: inline-block;
    animation: pulse-dot 1.4s ease-in-out infinite;
}
@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,.5); }
    50% { box-shadow: 0 0 0 6px rgba(16,185,129,0); }
}
.scanner-status.paused { color: var(--warning); background: rgba(245,158,11,.12); }
.scanner-status.paused .dot-live { background: var(--warning); animation: none; }

/* ===== Overlay hasil scan otomatis (auto-dismiss, tanpa perlu klik) ===== */
.result-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15,23,42,.55);
    backdrop-filter: blur(3px);
}
.result-overlay.show {
    display: flex;
}
.result-overlay-card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 32px 36px;
    max-width: 380px;
    width: 92%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.result-icon {
    font-size: 3.2rem;
    margin-bottom: 6px;
}
.result-icon.success { color: var(--success); }
.result-icon.error { color: var(--danger); }
.result-photo-big {
    width: 110px;
    height: 110px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid var(--primary);
    margin: 0 auto;
    display: block;
}
.result-progress {
    margin-top: 18px;
    height: 4px;
    border-radius: 4px;
    background: var(--border);
    overflow: hidden;
}
.result-progress-bar {
    height: 100%;
    width: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transform-origin: left;
}
.result-progress-bar.animate {
    animation: shrink-progress linear forwards;
}
@keyframes shrink-progress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

.badge-status-hadir,
.badge-status-Hadir { background: #10b981; color: #fff; }
.badge-status-terlambat,
.badge-status-Terlambat { background: #f59e0b; color: #fff; }
.badge-status-izin,
.badge-status-Izin { background: #6366f1; color: #fff; }
.badge-status-sakit,
.badge-status-Sakit { background: #f97316; color: #fff; }
.badge-status-alfa,
.badge-status-Alfa { background: #ef4444; color: #fff; }
.badge-status-pulang,
.badge-status-Pulang { background: #64748b; color: #fff; }
.badge-status-default { background: #94a3b8; color: #fff; }

/* ===== Panel daftar siswa yang sudah absen (landing page) ===== */
.recent-list {
    max-height: 420px;
    overflow-y: auto;
    padding-right: 4px;
}
.recent-list::-webkit-scrollbar { width: 6px; }
.recent-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
.recent-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 8px;
    border-radius: 12px;
    transition: background .2s ease;
}
.recent-item:hover { background: var(--bg); }
.recent-item + .recent-item { border-top: 1px solid var(--border); }
.recent-item .avatar {
    width: 40px; height: 40px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
    border: 2px solid var(--border);
}
.recent-item .info { flex: 1; min-width: 0; }
.recent-item .info .nm { font-weight: 600; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-item .info .kl { font-size: .75rem; color: var(--text-soft); }
.recent-item .meta { text-align: right; flex-shrink: 0; }
.recent-item .meta .jm { font-size: .78rem; color: var(--text-soft); margin-top: 3px; display:block; }
.recent-item.animate__animated { animation-duration: .5s; }

/* ==========================================================================
   Footer aplikasi (termasuk kredit EDU APP ID)
   ========================================================================== */
.app-footer {
    margin-top: 40px;
    padding: 22px 16px 26px;
    border-top: 1px solid var(--border);
    background: var(--card-bg);
    text-align: center;
}
.app-footer__inner { max-width: 780px; margin: 0 auto; }
.app-footer p { margin: 0; line-height: 1.6; }
.app-footer__school { font-size: .82rem; font-weight: 600; color: var(--text); }
.app-footer__credit { font-size: .8rem; color: var(--text-soft); margin-top: 2px !important; }
.app-footer__credit a { color: var(--primary); text-decoration: none; font-weight: 700; }
.app-footer__credit a:hover { text-decoration: underline; }
.app-footer__credit span, .app-footer__credit b { color: var(--text); font-weight: 700; }
.app-footer__meta { font-size: .72rem; color: var(--text-soft); opacity: .85; margin-top: 2px !important; }

.app-footer--admin {
    margin-top: 0;
    border-top: 1px solid var(--border);
    background: transparent;
    padding: 18px 16px 24px;
}
.app-footer-print {
    margin-top: 8mm;
    padding-top: 3mm;
    border-top: .3mm solid #94a3b8;
    text-align: center;
    font-size: 8pt;
    color: #64748b;
}

/* ==========================================================================
   Utilitas tambahan
   ========================================================================== */
.page-header { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.page-header h1, .page-header h2 { font-size: 1.15rem; font-weight: 800; margin: 0; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filter-bar .form-control, .filter-bar .form-select { min-width: 150px; }
.empty-state { text-align: center; padding: 46px 20px; color: var(--text-soft); }
.empty-state i { font-size: 3rem; opacity: .35; display: block; margin-bottom: 10px; }
.text-tiny { font-size: .74rem; }
.table-card .table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-soft); }
.help-text { font-size: .78rem; color: var(--text-soft); }
.info-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 4px 12px; border-radius: 999px;
    font-size: .76rem; font-weight: 600;
    background: rgba(79,70,229,.08); color: var(--primary);
}
