/* =========================================================
   Student Attendance Management System - Stylesheet
   ========================================================= */

:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --bg: #f4f6fb;
    --card-bg: #ffffff;
    --text: #1f2937;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --sidebar-bg: #111827;
    --sidebar-text: #d1d5db;
    --sidebar-active: #4f46e5;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
}

[data-theme="dark"] {
    --bg: #0f1420;
    --card-bg: #171e2e;
    --text: #e5e7eb;
    --text-muted: #9ca3af;
    --border: #2a3347;
    --sidebar-bg: #0a0e18;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    transition: background .2s, color .2s;
}

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

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

.sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    flex-shrink: 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform .25s ease;
}

.sidebar-brand {
    padding: 22px 20px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }

.sidebar-nav { padding: 14px 0; list-style: none; margin: 0; }

.sidebar-nav .section-label {
    padding: 14px 20px 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #6b7280;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    font-size: 14.5px;
    color: var(--sidebar-text);
    border-left: 3px solid transparent;
}

.sidebar-nav li a:hover { background: rgba(255,255,255,0.06); color: #fff; }

.sidebar-nav li a.active {
    background: rgba(79,70,229,0.15);
    border-left-color: var(--primary);
    color: #fff;
    font-weight: 600;
}

.sidebar-nav li a .icon { width: 18px; text-align: center; }

.main {
    margin-left: 250px;
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar .page-title { font-size: 19px; font-weight: 700; }

.topbar-right { display: flex; align-items: center; gap: 14px; }

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--text);
}

.theme-toggle, .icon-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 36px; height: 36px;
    cursor: pointer;
    color: var(--text);
    font-size: 15px;
}

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

/* ---------- Cards ---------- */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.card-header h3 { margin: 0; font-size: 16px; font-weight: 700; }

/* ---------- Stat cards ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 16px;
    margin-bottom: 22px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.stat-card .stat-icon {
    width: 38px; height: 38px;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
    color: #fff;
    margin-bottom: 4px;
}

.stat-card .stat-value { font-size: 26px; font-weight: 800; }
.stat-card .stat-label { font-size: 12.5px; color: var(--text-muted); }

.bg-indigo { background: #4f46e5; }
.bg-blue { background: #0284c7; }
.bg-green { background: #16a34a; }
.bg-red { background: #dc2626; }
.bg-amber { background: #d97706; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: .15s;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13.5px; font-weight: 600; }

.form-control {
    width: 100%;
    padding: 9px 12px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
}

.form-control:focus { outline: none; border-color: var(--primary); }

.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 180px; }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.8px;
}

table.data-table th {
    text-align: left;
    padding: 11px 12px;
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .03em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

table.data-table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table.data-table tr:hover td { background: rgba(79,70,229,0.03); }

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 700;
}

.badge-present { background: #dcfce7; color: #166534; }
.badge-absent { background: #fee2e2; color: #991b1b; }
[data-theme="dark"] .badge-present { background: #14532d; color: #bbf7d0; }
[data-theme="dark"] .badge-absent { background: #7f1d1d; color: #fecaca; }

/* ---------- Login page ---------- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #4f46e5, #0ea5e9);
    padding: 20px;
}

.login-card {
    background: #fff;
    border-radius: 14px;
    padding: 36px 32px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}

.login-card h1 { font-size: 20px; margin: 0 0 4px; text-align: center; }
.login-card p.sub { text-align: center; color: var(--text-muted); font-size: 13.5px; margin-bottom: 24px; }

/* ---------- Alerts ---------- */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13.8px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.alert-success { background: #dcfce7; color: #166534; }
.alert-danger { background: #fee2e2; color: #991b1b; }
.alert-info { background: #dbeafe; color: #1e40af; }

/* ---------- Toast notifications ---------- */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    min-width: 260px;
    padding: 13px 16px;
    border-radius: 9px;
    color: #fff;
    font-size: 13.8px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
    animation: slideIn .25s ease;
}

.toast.success { background: #16a34a; }
.toast.error { background: #dc2626; }
.toast.info { background: #4f46e5; }

@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ---------- Misc ---------- */
.text-muted { color: var(--text-muted); }
.reason-input { display: none; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filters .form-group { margin-bottom: 0; min-width: 160px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.progress-bar { background: var(--border); border-radius: 20px; height: 8px; overflow: hidden; width: 100%; }
.progress-bar-fill { height: 100%; background: var(--success); }
.chip { display:inline-flex; align-items:center; gap:6px; padding:3px 10px; border-radius:16px; background:var(--bg); border:1px solid var(--border); font-size:12px; }

/* ---------- Modal ---------- */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show { display: flex; }

.modal-box {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}

.modal-box h3 { margin-top: 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- Responsive ---------- */
@media (max-width: 992px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main { margin-left: 0; }
    .menu-toggle { display: block; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-row { flex-direction: column; }
}

@media print {
    .sidebar, .topbar, .no-print, .filters, .btn { display: none !important; }
    .main { margin-left: 0 !important; }
    body { background: #fff; }
    .card { box-shadow: none; border: none; }
    .print-header { display: flex !important; }
}

.print-header {
    display: none;
    align-items: center;
    gap: 14px;
    padding-bottom: 14px;
    margin-bottom: 18px;
    border-bottom: 2px solid #111827;
}

.print-header img { height: 50px; max-width: 200px; object-fit: contain; }
.print-header .print-brand-name { font-size: 19px; font-weight: 800; color: #111827; }
.print-header .print-meta { margin-left: auto; text-align: right; font-size: 12px; color: #4b5563; }
.print-header .print-report-title { font-size: 13.5px; font-weight: 700; color: #111827; }
