:root {
    --sidebar-width: 270px;
    --sidebar-bg: #1a2341;
    --sidebar-hover: #243060;
    --sidebar-active: #3d5af1;
    --accent: #3d5af1;
    --topbar-height: 60px;
}

* { box-sizing: border-box; }

body {
    font-family: 'Cairo', sans-serif;
    background: #f0f2f8;
    margin: 0;
    overflow-x: hidden;
}

/* ===== WRAPPER ===== */
.wrapper {
    display: flex;
    min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 1000;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.sidebar-header {
    padding: 24px 20px 16px;
    background: rgba(0,0,0,0.2);
    text-align: center;
}

.sidebar-user {
    padding: 12px 16px;
    background: rgba(0,0,0,0.15);
    margin: 0;
}

.avatar-circle {
    width: 36px;
    height: 36px;
    background: var(--accent);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.badge-role {
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
}
.badge-admin { background: #e74c3c; }
.badge-teacher { background: #27ae60; }
.badge-student { background: #3498db; }

.nav-section {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.4);
    padding: 16px 20px 4px;
    font-weight: 700;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.2s;
    border-right: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: var(--sidebar-hover);
    color: #fff;
    border-right-color: rgba(255,255,255,0.3);
}

.sidebar-nav a.active {
    background: var(--accent);
    color: #fff;
    border-right-color: #fff;
    font-weight: 600;
}

.sidebar-nav a i {
    width: 18px;
    text-align: center;
    font-size: 15px;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 14px;
    padding: 8px 12px;
    border-radius: 8px;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: rgba(231,76,60,0.2);
    color: #e74c3c;
}

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

/* ===== TOPBAR ===== */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.topbar-breadcrumb { flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.toggle-sidebar {
    color: #555;
    border: none;
    background: none;
    padding: 4px 8px;
    border-radius: 6px;
}
.toggle-sidebar:hover { background: #f3f4f6; }

/* ===== CONTENT AREA ===== */
.content-area {
    padding: 24px;
    flex: 1;
}

/* ===== CARDS ===== */
.stat-card {
    background: #fff;
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 1px solid #f0f2f8;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.1); }

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.blue   { background: #eff6ff; color: #3d5af1; }
.stat-icon.green  { background: #f0fdf4; color: #22c55e; }
.stat-icon.orange { background: #fff7ed; color: #f97316; }
.stat-icon.purple { background: #faf5ff; color: #a855f7; }
.stat-icon.red    { background: #fef2f2; color: #ef4444; }
.stat-icon.teal   { background: #f0fdfa; color: #14b8a6; }

.stat-number { font-size: 28px; font-weight: 700; line-height: 1; }
.stat-label  { font-size: 13px; color: #6b7280; margin-top: 2px; }

/* ===== PAGE CARD ===== */
.page-card {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.06);
    border: 1px solid #f0f2f8;
    overflow: hidden;
}

.page-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.page-card-title {
    font-size: 15px;
    font-weight: 700;
    color: #1f2937;
    margin: 0;
}

.page-card-body { padding: 20px; }

/* ===== TABLES ===== */
.table-modern {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.table-modern th {
    background: #f8fafc;
    font-weight: 600;
    color: #374151;
    padding: 12px 14px;
    border-bottom: 2px solid #e5e7eb;
    white-space: nowrap;
}

.table-modern td {
    padding: 11px 14px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
    color: #374151;
}

.table-modern tbody tr:hover { background: #f9fafb; }
.table-modern tbody tr:last-child td { border-bottom: none; }

/* ===== BADGES ===== */
.grade-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

/* ===== FORMS ===== */
.form-label { font-weight: 600; font-size: 13px; color: #374151; }

.form-control, .form-select {
    border-radius: 8px;
    border: 1.5px solid #e5e7eb;
    font-family: 'Cairo', sans-serif;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(61,90,241,0.1);
}

/* ===== BUTTONS ===== */
.btn { font-family: 'Cairo', sans-serif; border-radius: 8px; font-weight: 600; font-size: 13px; }
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: #2d4ae0; border-color: #2d4ae0; }

/* ===== RECITATION PANEL ===== */
.recite-panel {
    background: linear-gradient(135deg, #1a2341 0%, #243060 100%);
    border-radius: 16px;
    color: #fff;
    padding: 24px;
    margin-bottom: 24px;
}

.juz-display {
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.2);
}

.juz-number {
    font-size: 48px;
    font-weight: 700;
    color: #fbbf24;
    line-height: 1;
}

.page-range {
    font-size: 18px;
    color: rgba(255,255,255,0.8);
    margin-top: 8px;
}

/* ===== SEARCH/FILTER BAR ===== */
.filter-bar {
    background: #f8fafc;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid #e5e7eb;
}

/* ===== EXPORT BUTTONS ===== */
.export-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    border: 1.5px solid;
    transition: all 0.2s;
}

.export-pdf  { color: #dc2626; border-color: #dc2626; }
.export-pdf:hover  { background: #dc2626; color: #fff; }
.export-excel { color: #16a34a; border-color: #16a34a; }
.export-excel:hover { background: #16a34a; color: #fff; }
.export-word  { color: #2563eb; border-color: #2563eb; }
.export-word:hover  { background: #2563eb; color: #fff; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-right: 0;
    }
    .content-area { padding: 16px; }
    .stat-card { flex-direction: column; text-align: center; }
}

/* ===== SELECT2 FIX ===== */
.select2-container--bootstrap-5 .select2-selection {
    font-family: 'Cairo', sans-serif;
}

/* ===== MODAL ===== */
.modal-header { background: var(--accent); color: #fff; }
.modal-header .btn-close { filter: invert(1); }

/* ===== LOGIN PAGE ===== */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a2341 0%, #3d5af1 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: #fff;
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo i { font-size: 48px; color: var(--accent); }
.login-logo h4 { font-weight: 700; color: #1a2341; margin-top: 8px; }

/* ===== PAGINATION ===== */
.page-link { font-family: 'Cairo', sans-serif; }

/* ===== PRINT ===== */
@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .main-content { margin-right: 0 !important; }
    .content-area { padding: 0 !important; }
}
