/* ============================================================
   School Management System - Main Stylesheet
   ============================================================ */

/* CSS Variables - Light Theme */
:root {
    --sidebar-width: 260px;
    --sidebar-bg: #1a1f36;
    --sidebar-hover: rgba(255,255,255,0.08);
    --sidebar-active: rgba(99,102,241,0.3);
    --topbar-height: 64px;
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
}

/* Dark Theme */
[data-theme="dark"] {
    --bg: #0f172a;
    --card-bg: #1e293b;
    --border: #334155;
    --text: #f1f5f9;
    --text-muted: #94a3b8;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    transition: background 0.3s, color 0.3s;
}

/* ─── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.school-logo {
    width: 58px;
    height: 58px;
    background: #ffffff;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 2px;
}

.school-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sidebar-nav { padding: 12px 0; }

.nav-section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.3);
    padding: 16px 16px 6px;
    text-transform: uppercase;
}

.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: 8px;
    margin: 2px 8px;
    transition: all 0.15s;
}
.sidebar-nav .nav-link:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--sidebar-active); color: #fff; }
.sidebar-nav .nav-link i { width: 18px; text-align: center; font-size: 15px; }

/* ─── MAIN CONTENT ──────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

/* ─── TOP BAR ────────────────────────────────────────────── */
.topbar {
    height: var(--topbar-height);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: var(--shadow);
}

/* ─── PAGE CONTENT ──────────────────────────────────────── */
.page-content { padding: 28px 28px; flex: 1; }

/* ─── STAT CARDS ─────────────────────────────────────────── */
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-card .stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}
.stat-card .stat-value { font-size: 28px; font-weight: 700; line-height: 1.2; }
.stat-card .stat-label { font-size: 13px; color: var(--text-muted); font-weight: 500; }

/* ─── CARDS ──────────────────────────────────────────────── */
.card {
    background: var(--card-bg) !important;
    border: 1px solid var(--border) !important;
    border-radius: 16px !important;
    box-shadow: var(--shadow) !important;
}
.card-header {
    background: transparent !important;
    border-bottom: 1px solid var(--border) !important;
    padding: 16px 20px !important;
    font-weight: 600;
}

/* ─── TABLES ─────────────────────────────────────────────── */
.table { color: var(--text) !important; }
.table thead th { background: var(--bg) !important; color: var(--text-muted) !important; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; border-bottom: 2px solid var(--border) !important; }
.table tbody tr:hover { background: var(--bg) !important; }
.table td, .table th { border-color: var(--border) !important; vertical-align: middle; }

/* ─── BUTTONS ────────────────────────────────────────────── */
.btn-primary { background: var(--primary) !important; border-color: var(--primary) !important; }
.btn-primary:hover { background: var(--primary-dark) !important; border-color: var(--primary-dark) !important; }
.btn { border-radius: 10px !important; font-weight: 500; font-size: 14px; }

/* ─── FORMS ──────────────────────────────────────────────── */
.form-control, .form-select {
    border: 1px solid var(--border) !important;
    background: var(--card-bg) !important;
    color: var(--text) !important;
    border-radius: 10px !important;
    font-size: 14px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(99,102,241,0.15) !important;
}
.form-label { font-weight: 600; font-size: 13px; color: var(--text-muted); }

/* ─── BADGES ─────────────────────────────────────────────── */
.badge-present { background: #d1fae5; color: #065f46; }
.badge-absent  { background: #fee2e2; color: #991b1b; }
.badge-late    { background: #fef3c7; color: #92400e; }
.status-paid   { background: #d1fae5; color: #065f46; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.status-pending{ background: #fef3c7; color: #92400e; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.status-overdue{ background: #fee2e2; color: #991b1b; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.status-partial{ background: #dbeafe; color: #1e40af; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }

/* ─── AVATAR ─────────────────────────────────────────────── */
.avatar-circle {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

/* ─── ATTENDANCE GRID ────────────────────────────────────── */
.attendance-row { transition: background 0.1s; }
.attendance-row:hover { background: rgba(99,102,241,0.04); }
.att-btn { width: 36px; height: 36px; border-radius: 8px; border: 2px solid var(--border); background: none; cursor: pointer; font-size: 12px; font-weight: 700; transition: all 0.15s; }
.att-btn.selected-P { background: #10b981; border-color: #10b981; color: white; }
.att-btn.selected-A { background: #ef4444; border-color: #ef4444; color: white; }
.att-btn.selected-L { background: #f59e0b; border-color: #f59e0b; color: white; }

/* ─── PAGE TITLE ──────────────────────────────────────────── */
.page-title { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.page-subtitle { color: var(--text-muted); font-size: 14px; margin: 0; }

/* ─── DARK MODE: DataTables ──────────────────────────────── */
[data-theme="dark"] .dataTables_wrapper { color: var(--text); }
[data-theme="dark"] .dataTables_filter input { background: var(--card-bg); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .select2-container--bootstrap-5 .select2-selection { background: var(--card-bg); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown { background: var(--card-bg); border-color: var(--border); }
[data-theme="dark"] .select2-container--bootstrap-5 .select2-results__option { color: var(--text); }
[data-theme="dark"] .modal-content { background: var(--card-bg); color: var(--text); border-color: var(--border); }

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .page-content { padding: 16px; }
    .stat-value { font-size: 22px !important; }
}
