/* ============================================================
   نظام حصر الغياب - Behera STEM
   التصميم الداكن المطابق للـPDF المرجعي
   ============================================================ */

:root {
    --bg-body: #070b14;
    --bg-gradient-1: rgba(30, 58, 138, 0.18);
    --bg-gradient-2: rgba(88, 28, 135, 0.12);
    --bg-sidebar: #0d1222;
    --bg-sidebar-hover: #141b33;
    --bg-card: #121a30;
    --bg-card-alt: #0f1628;
    --bg-input: #0a0f1e;
    --border-soft: #1e2948;
    --border-card: #22304f;
    --text-main: #e6ebf7;
    --text-muted: #8892ab;
    --text-dim: #5a6480;
    --accent-blue: #3b82f6;
    --accent-violet: #8b5cf6;
    --gradient-btn: linear-gradient(90deg, #3b82f6, #8b5cf6);
    --gradient-btn-hover: linear-gradient(90deg, #2563eb, #7c3aed);
    --btn-secondary: #1b2744;
    --success: #10b981;
    --danger: #ef4444;
    --danger-dark: #7f1d1d;
    --warning: #f59e0b;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    font-family: 'Segoe UI', 'Tajawal', 'Noto Kufi Arabic', system-ui, -apple-system, sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    direction: rtl;
    min-height: 100vh;
}

body.dark-theme {
    background:
        radial-gradient(ellipse at 20% 10%, var(--bg-gradient-1) 0%, transparent 50%),
        radial-gradient(ellipse at 85% 90%, var(--bg-gradient-2) 0%, transparent 50%),
        var(--bg-body);
    background-attachment: fixed;
}

/* ============ Themes (data-theme على body) ============ */
/* Light: فاتح */
[data-theme="light"] {
    --bg-body: #f1f5f9;
    --bg-gradient-1: rgba(59, 130, 246, 0.10);
    --bg-gradient-2: rgba(139, 92, 246, 0.08);
    --bg-sidebar: #ffffff;
    --bg-sidebar-hover: #eef2f8;
    --bg-card: #ffffff;
    --bg-card-alt: #f8fafc;
    --bg-input: #ffffff;
    --border-soft: #e2e8f0;
    --border-card: #e2e8f0;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-dim: #94a3b8;
    --btn-secondary: #eef2f8;
    --shadow-card: 0 4px 18px rgba(15, 23, 42, 0.08);
    --login-card-bg: #ffffff;
    --login-card-border: #e2e8f0;
}
/* Blue: أزرق مؤسسي */
[data-theme="blue"] {
    --bg-body: #06101f;
    --bg-gradient-1: rgba(14, 165, 233, 0.16);
    --bg-gradient-2: rgba(2, 132, 199, 0.10);
    --bg-sidebar: #0a1628;
    --bg-sidebar-hover: #12233f;
    --bg-card: #0e1d34;
    --bg-card-alt: #0b172c;
    --bg-input: #081224;
    --border-soft: #18325a;
    --border-card: #1c3a66;
    --text-main: #e2f1ff;
    --text-muted: #89a8c8;
    --text-dim: #54728f;
    --accent-blue: #0ea5e9;
    --accent-violet: #22d3ee;
    --gradient-btn: linear-gradient(90deg, #0284c7, #0ea5e9);
    --gradient-btn-hover: linear-gradient(90deg, #0369a1, #0284c7);
    --btn-secondary: #132c4c;
}
/* Green: أخضر */
[data-theme="green"] {
    --bg-body: #070f0d;
    --bg-gradient-1: rgba(16, 185, 129, 0.14);
    --bg-gradient-2: rgba(4, 120, 87, 0.10);
    --bg-sidebar: #0b1512;
    --bg-sidebar-hover: #12211c;
    --bg-card: #0f1c17;
    --bg-card-alt: #0c1713;
    --bg-input: #091310;
    --border-soft: #1a362c;
    --border-card: #204338;
    --text-main: #e4f6ee;
    --text-muted: #7fa595;
    --text-dim: #537064;
    --accent-blue: #10b981;
    --accent-violet: #34d399;
    --gradient-btn: linear-gradient(90deg, #059669, #10b981);
    --gradient-btn-hover: linear-gradient(90deg, #047857, #059669);
    --btn-secondary: #16302a;
}
/* Red: أحمر */
[data-theme="red"] {
    --bg-body: #0f0a0c;
    --bg-gradient-1: rgba(239, 68, 68, 0.13);
    --bg-gradient-2: rgba(127, 29, 29, 0.10);
    --bg-sidebar: #160d10;
    --bg-sidebar-hover: #24131a;
    --bg-card: #1d1216;
    --bg-card-alt: #170e11;
    --bg-input: #130b0e;
    --border-soft: #3a1c26;
    --border-card: #45242f;
    --text-main: #f6e4e7;
    --text-muted: #b0848f;
    --text-dim: #765761;
    --accent-blue: #f43f5e;
    --accent-violet: #fb7185;
    --gradient-btn: linear-gradient(90deg, #e11d48, #f43f5e);
    --gradient-btn-hover: linear-gradient(90deg, #be123c, #e11d48);
    --btn-secondary: #33171f;
}

/* ثيمات فاتحة adjustments لعناصر ثنائية ثابتة */
[data-theme="light"] .stat-card::before { opacity: 0.85; }
[data-theme="light"] table.data-table tbody tr:hover { background: rgba(59, 130, 246, 0.06); }
[data-theme="light"] .topbar { background: rgba(255, 255, 255, 0.9); }

a { color: var(--accent-blue); text-decoration: none; }
a:hover { color: #60a5fa; }

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

/* ============ Sidebar ============ */
.sidebar {
    width: 250px;
    background: var(--bg-sidebar);
    border-left: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
    z-index: 50;
}

.sidebar-brand {
    padding: 22px 18px 16px;
    text-align: center;
    border-bottom: 1px solid var(--border-soft);
}

.brand-logo { margin-bottom: 10px; }

.logo-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e3a8a, #3b82f6);
    color: #fff;
    font-size: 26px;
    border: 2px solid rgba(59, 130, 246, 0.35);
    box-shadow: 0 0 18px rgba(59, 130, 246, 0.25);
}

.brand-text h2 {
    color: var(--accent-blue);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.sidebar-nav { flex: 1; padding: 14px 0; overflow-y: auto; }

.nav-list { list-style: none; }

.nav-item > a, .nav-item .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: var(--text-muted);
    font-size: 14.5px;
    transition: background 0.15s, color 0.15s;
    cursor: pointer;
}

.nav-item > a:hover, .nav-item .dropdown-toggle:hover {
    background: var(--bg-sidebar-hover);
    color: var(--text-main);
}

.nav-item.active > a {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.25), rgba(139, 92, 246, 0.15));
    color: var(--accent-blue);
    border-right: 3px solid var(--accent-blue);
}

.nav-item i.fa-bars, .nav-item .toggle-icon { margin-inline-start: auto; }

.toggle-icon { font-size: 11px; transition: transform 0.2s; }
.nav-dropdown.open .toggle-icon { transform: rotate(180deg); }

.nav-submenu { list-style: none; display: none; background: rgba(0, 0, 0, 0.18); }
.nav-dropdown.open .nav-submenu { display: block; }

.nav-submenu li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 38px 10px 20px;
    color: var(--text-muted);
    font-size: 13.5px;
    transition: color 0.15s;
}

.nav-submenu li a:hover, .nav-submenu li.active a { color: var(--accent-blue); }

.class-badge {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: var(--accent-blue);
    display: inline-block;
    flex-shrink: 0;
}

.sidebar-user {
    padding: 14px 16px;
    border-top: 1px solid var(--border-soft);
    background: rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #3b82f6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    flex-shrink: 0;
}

.user-name { font-size: 13.5px; font-weight: 600; color: var(--text-main); }
.user-role { font-size: 11.5px; color: var(--text-muted); margin-bottom: 6px; }

.dev-info { font-size: 10.5px; color: var(--text-dim); line-height: 1.5; }
.dev-info a { color: var(--accent-blue); font-size: 11px; }

.dev-info, .user-info, .user-details, .btn-logout-small { width: 100%; min-width: 0; }
.btn-logout-small { display: inline-flex; white-space: nowrap; width: auto; align-self: flex-start; }

.btn-logout-small {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--danger-dark);
    color: #fca5a5;
    border-radius: var(--radius-sm);
    font-size: 12px;
    transition: opacity 0.15s;
}
.btn-logout-small:hover { opacity: 0.85; color: #fecaca; }

/* ============ Main content ============ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 24px;
    background: rgba(13, 18, 34, 0.85);
    border-bottom: 1px solid var(--border-soft);
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: blur(8px);
    flex-wrap: wrap;
}

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

.page-title {
    font-size: 19px;
    font-weight: 700;
    color: var(--text-main);
}

.current-datetime {
    font-size: 12.5px;
    color: var(--text-muted);
}

.sidebar-toggle {
    display: none;
    background: var(--btn-secondary);
    border: 1px solid var(--border-soft);
    color: var(--text-main);
    border-radius: var(--radius-sm);
    width: 38px;
    height: 38px;
    cursor: pointer;
    font-size: 16px;
}

.page-content { padding: 22px 24px 40px; flex: 1; }

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s, box-shadow 0.15s;
    white-space: nowrap;
    font-family: inherit;
    text-decoration: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--gradient-btn);
    color: #fff;
    box-shadow: 0 4px 14px rgba(59, 130, 246, 0.3);
}
.btn-primary:hover { background: var(--gradient-btn-hover); color: #fff; }

.btn-secondary {
    background: var(--btn-secondary);
    color: var(--text-main);
    border: 1px solid var(--border-card);
}
.btn-secondary:hover { background: #22304f; color: var(--text-main); }

.btn-danger {
    background: var(--danger);
    color: #fff;
}
.btn-danger:hover { opacity: 0.88; color: #fff; }

.btn-logout {
    background: var(--danger-dark);
    color: #fca5a5;
    padding: 7px 14px;
    font-size: 12.5px;
}
.btn-logout:hover { color: #fecaca; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

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

.card-title {
    font-size: 15.5px;
    font-weight: 700;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title i { color: var(--accent-blue); font-size: 14px; }

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

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius);
    padding: 18px 16px;
    text-align: center;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 4px;
}
.stat-card.blue::before { background: var(--accent-blue); }
.stat-card.red::before { background: var(--danger); }
.stat-card.green::before { background: var(--success); }
.stat-card.orange::before { background: var(--warning); }

.stat-icon { font-size: 20px; margin-bottom: 6px; }
.stat-card.blue .stat-icon { color: var(--accent-blue); }
.stat-card.red .stat-icon { color: var(--danger); }
.stat-card.green .stat-icon { color: var(--success); }
.stat-card.orange .stat-icon { color: var(--warning); }

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

/* ============ Forms ============ */
.form-group { margin-bottom: 14px; }

.form-label {
    display: block;
    font-size: 12.5px;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 600;
}

.form-control {
    width: 100%;
    padding: 10px 13px;
    background: var(--bg-input);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 13.5px;
    font-family: inherit;
    transition: border-color 0.15s;
    direction: rtl;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%238892ab'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: left 12px center;
    padding-left: 32px;
}

.input-icon-wrap { position: relative; }

.input-icon-wrap .form-control { padding-inline-start: 38px; }

.input-icon-wrap i {
    position: absolute;
    inset-inline-start: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
    font-size: 13px;
    pointer-events: none;
}

.input-icon-wrap .icon-action {
    position: absolute;
    inset-inline-end: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 13px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
}

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

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

table.data-table th {
    background: #101730;
    color: var(--text-muted);
    font-weight: 600;
    text-align: right;
    padding: 11px 14px;
    border-bottom: 1px solid var(--border-card);
    white-space: nowrap;
}
table.data-table th.col-num { width: 48px; text-align: center; }
table.data-table th.col-actions { width: 110px; text-align: center; }
table.data-table td.actions { text-align: center; white-space: nowrap; }

table.data-table td {
    padding: 11px 14px;
    border-bottom: 1px solid rgba(34, 48, 79, 0.55);
    color: var(--text-main);
}

table.data-table tbody tr:hover { background: rgba(59, 130, 246, 0.05); }

table.data-table td.en, table.data-table th.en { direction: ltr; text-align: start; }

.time-start { color: var(--success); direction: ltr; display: inline-block; }
.time-end { color: var(--danger); direction: ltr; display: inline-block; }

/* ============ Badges ============ */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
}
.badge-active { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-inactive { background: rgba(90, 100, 128, 0.2); color: var(--text-dim); }
.badge-absent { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-present { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-late { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }

/* ============ Tabs (إدارة النظام) ============ */
.tabs-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 18px;
}

.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    font-family: inherit;
}

.tab-btn:hover { background: var(--bg-sidebar-hover); color: var(--text-main); }

.tab-btn.active {
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    color: #fff;
    border-color: transparent;
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ============ Modal ============ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 16px;
}
.modal-overlay.open { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.6);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-soft);
}

.modal-header h3 { font-size: 15.5px; }

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
}

.modal-body { padding: 20px; }

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border-soft);
    display: flex;
    gap: 10px;
    justify-content: flex-start;
}

/* ============ Empty state ============ */
.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 44px;
    color: var(--text-dim);
    margin-bottom: 14px;
    display: block;
}

.empty-state p { font-size: 14px; margin-bottom: 6px; }
.empty-state a { font-size: 13.5px; }

.choose-state {
    text-align: center;
    padding: 70px 20px;
    color: var(--text-muted);
}

.choose-state i { font-size: 34px; color: var(--warning); margin-bottom: 12px; display: block; }

/* ============ Summary chips ============ */
.summary-row {
    display: flex;
    gap: 14px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.summary-chip {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius);
    padding: 14px 24px;
    text-align: center;
    min-width: 160px;
    box-shadow: var(--shadow-card);
}

.summary-chip .chip-value {
    font-size: 20px;
    font-weight: 800;
    color: var(--accent-blue);
    direction: ltr;
}

.summary-chip .chip-label { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ============ Checkboxes / toggles ============ */
.check-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
}

.check-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
    padding: 9px 16px;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
    transition: all 0.15s;
}

.check-item input { accent-color: var(--accent-blue); width: 15px; height: 15px; cursor: pointer; }

.check-item:has(input:checked) {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.12);
}

/* ============ Alerts ============ */
.alert {
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    font-size: 13.5px;
    line-height: 1.7;
    margin-bottom: 16px;
}

.alert-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #fcd34d;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.alert b, .alert strong { font-weight: 700; }

/* ============ Flash messages ============ */
.flash {
    margin: 12px 24px 0;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: fadeSlide 0.3s ease;
}

.flash-success { background: rgba(16, 185, 129, 0.12); border: 1px solid rgba(16, 185, 129, 0.35); color: #6ee7b7; }
.flash-error { background: rgba(239, 68, 68, 0.12); border: 1px solid rgba(239, 68, 68, 0.35); color: #fca5a5; }

@keyframes fadeSlide { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* ============ Search bar (لوحة التحكم / الصف) ============ */
.search-box {
    margin-top: 22px;
}

.search-box .search-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-box .search-title i { color: var(--accent-blue); }

.search-box .form-control {
    padding: 12px 16px;
    font-size: 14px;
}

.search-results {
    margin-top: 10px;
    max-height: 220px;
    overflow-y: auto;
}

.search-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: var(--bg-card-alt);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 13px;
}

/* ============ Charts ============ */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
    margin-top: 20px;
}

.chart-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius);
    padding: 18px;
    box-shadow: var(--shadow-card);
    min-height: 280px;
}

.chart-card .card-title { margin-bottom: 12px; }

/* ============ Section heading ============ */
.section-label {
    font-size: 14.5px;
    font-weight: 700;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
}

.section-label i { color: var(--accent-blue); }

/* ============ Login page ============ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: #111833;
    border: 1px solid #25315a;
    border-radius: 16px;
    padding: 36px 32px 28px;
    box-shadow: 0 16px 60px rgba(0, 0, 0, 0.6);
    text-align: center;
}

.login-logo {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e3a8a, #3b82f6);
    color: #fff;
    font-size: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(59, 130, 246, 0.4);
    box-shadow: 0 0 24px rgba(59, 130, 246, 0.3);
    margin-bottom: 16px;
}

.login-school {
    color: var(--accent-blue);
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.login-system {
    color: var(--text-muted);
    font-size: 13px;
    margin-bottom: 26px;
}

.login-card .form-group { text-align: right; }

.login-card .form-control { text-align: start; }

.btn-login {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    font-weight: 700;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    margin-top: 6px;
    font-family: inherit;
    transition: opacity 0.15s;
}
.btn-login:hover { opacity: 0.9; }

.login-note {
    margin-top: 18px;
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.login-footer {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid #25315a;
    font-size: 10.5px;
    color: var(--text-dim);
    line-height: 1.7;
}

/* ============ Attendance marking (تسجيل الغياب) ============ */
.attendance-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 18px;
}

.attendance-toolbar .form-group { margin-bottom: 0; min-width: 170px; }

.att-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-bottom: 1px solid rgba(34, 48, 79, 0.55);
    flex-wrap: wrap;
}

.att-row .att-name { flex: 1; min-width: 150px; font-size: 14px; font-weight: 600; white-space: nowrap; }

.att-options { display: flex; gap: 5px; flex-shrink: 0; }

.att-row .form-control {
    max-width: 120px;
    min-width: 95px;
    flex-shrink: 0;
    padding: 7px 8px;
    font-size: 12px;
}

.att-row .att-opt label {
    padding: 6px 11px;
    font-size: 12px;
}

.att-opt {
    position: relative;
}

.att-opt input { position: absolute; opacity: 0; width: 0; height: 0; }

.att-opt label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: var(--btn-secondary);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    cursor: pointer;
    transition: all 0.15s;
}

.att-opt input:checked + label.opt-absent { background: rgba(239, 68, 68, 0.2); border-color: var(--danger); color: #f87171; }
.att-opt input:checked + label.opt-present { background: rgba(16, 185, 129, 0.2); border-color: var(--success); color: #34d399; }
.att-opt input:checked + label.opt-late { background: rgba(245, 158, 11, 0.2); border-color: var(--warning); color: #fbbf24; }

/* ============ List items (النسخ الاحتياطية) ============ */
.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card-alt);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.list-item .item-info { font-size: 13px; }
.list-item .item-info .item-name { font-weight: 600; color: var(--text-main); direction: ltr; display: inline-block; }
.list-item .item-info .item-date { color: var(--text-muted); font-size: 12px; margin-inline-start: 10px; }
.list-item .item-actions { display: flex; gap: 8px; }

/* ============ Footer area ============ */
.footer-note {
    text-align: center;
    color: var(--text-dim);
    font-size: 11.5px;
    margin-top: 36px;
    padding-top: 16px;
    border-top: 1px solid var(--border-soft);
}

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

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        top: 0;
        right: 0;
        height: 100vh;
        transform: translateX(100%);
        transition: transform 0.25s ease;
        box-shadow: -8px 0 30px rgba(0, 0, 0, 0.5);
    }
    .sidebar.open { transform: translateX(0); }

    .sidebar-toggle { display: inline-flex; }

    .page-content { padding: 16px; }

    .topbar { padding: 12px 16px; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }

    .tabs-bar { gap: 6px; }
    .tab-btn { padding: 8px 12px; font-size: 12px; }

    .form-row { grid-template-columns: 1fr; }

    .modal { max-width: 100%; }

    .attendance-toolbar .form-group { min-width: 100%; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .stat-value { font-size: 21px; }
    .login-card { padding: 28px 22px 22px; }
}

/* ============ School logo in sidebar ============ */
.brand-logo-img {
    width: 74px;
    height: 74px;
    border-radius: 50%;
    object-fit: contain;
    background: var(--bg-input);
    border: 2px solid var(--border-card);
    padding: 3px;
}

/* ============ App info block (أسفل الشريط الجانبي) ============ */
.app-info { font-size: 11px; color: var(--text-dim); line-height: 1.6; }
.app-info-title { font-weight: 600; color: var(--text-muted); }
.app-info-version { direction: ltr; display: inline-block; }
.dev-contact {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11.5px;
    color: #25d366;
    padding: 4px 0;
}
.dev-contact:hover { text-decoration: underline; }
[data-theme="light"] .dev-contact { color: #16a34a; }

/* ============ Logo upload preview ============ */
.logo-preview-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 8px;
}
.logo-preview {
    width: 78px;
    height: 78px;
    border-radius: 50%;
    object-fit: contain;
    background: var(--bg-input);
    border: 2px dashed var(--border-card);
    display: none;
}
.logo-preview.visible { display: block; }

/* ============ Theme selector ============ */
.theme-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 4px;
}
.theme-swatch {
    position: relative;
    width: 64px;
    height: 64px;
    border-radius: var(--radius);
    cursor: pointer;
    border: 2px solid var(--border-card);
    overflow: hidden;
    transition: border-color 0.15s, transform 0.1s;
}
.theme-swatch:hover { transform: scale(1.04); }
.theme-swatch input {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    cursor: pointer;
}
.theme-swatch .swatch-top { height: 52%; }
.theme-swatch .swatch-bottom { height: 48%; display: flex; align-items: center; justify-content: center; }
.theme-swatch .swatch-label {
    position: absolute;
    bottom: 2px;
    left: 0;
    right: 0;
    text-align: center;
    font-size: 10.5px;
    font-weight: 700;
    color: #fff;
}
.theme-swatch input:checked ~ .swatch-label { text-decoration: underline; }
.theme-swatch:has(input:checked) { border-color: #fff; box-shadow: 0 0 0 2px var(--accent-blue); }


/* ============ Print: تقرير PDF ============ */
@media print {
    body { background: #fff !important; color: #000 !important; }
    .sidebar, .topbar, .no-print, .flash { display: none !important; }
    .main-content { width: 100% !important; }
    .app-wrapper { display: block !important; }
    .page-content { padding: 0 !important; }
    .report-print-header { display: flex !important; }
    .print-hidden { display: none !important; }
}
.report-print-header { display: none; }

.login-logo-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: contain;
    border: 2px solid rgba(59, 130, 246, 0.4);
    box-shadow: 0 0 24px rgba(59, 130, 246, 0.3);
    margin-bottom: 16px;
    background: #fff;
}
.login-footer a { color: var(--accent-blue); direction: ltr; display: inline-block; }
[data-theme="light"] .login-card { background: var(--login-card-bg, #fff); border-color: var(--login-card-border, #e2e8f0); }
[data-theme="light"] .login-logo-img { background: #fff; }

/* تنبيهات نصية صغيرة تحت الحقول */
.form-hint {
    display: block;
    margin-top: 6px;
    font-size: 0.82rem;
    color: #9aa5b1;
    line-height: 1.6;
}
.light-theme .form-hint { color: #6b7280; }

/* زر نجاح (أخضر) */
.btn-success {
    background: #15803d;
    color: #fff;
}
.btn-success:hover { background: #166534; }

/* معاينة الاستيراد */
.import-preview {
    font-size: 0.9rem;
    line-height: 1.7;
}

/* ===== accordion: الفصول المنسدلة ===== */
.accordion-item { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; overflow: hidden; }
.accordion-btn {
    width: 100%; display: flex; align-items: center; justify-content: space-between;
    background: var(--bg-card); color: var(--text); border: none; padding: 14px 16px;
    font-size: 1rem; cursor: pointer; text-align: right; font-family: inherit;
    transition: background 0.15s;
}
.accordion-btn:hover { background: var(--bg-hover); }
.accordion-icon { transition: transform 0.2s; color: var(--text-muted); }
.accordion-item.active .accordion-icon { transform: rotate(180deg); }
.accordion-body { display: none; padding: 16px; background: var(--bg-subtle); border-top: 1px solid var(--border); }
.accordion-item.active .accordion-body { display: block; }
.periods-grid-title { font-weight: 600; margin-bottom: 12px; font-size: 0.95rem; }
.periods-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.period-box {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px;
    padding: 14px 12px; display: flex; flex-direction: column;
    align-items: stretch; gap: 8px; min-height: 130px;
}
.period-head { display: flex; align-items: flex-start; justify-content: space-between; }
.period-label { font-size: 0.95rem; font-weight: 700; }
.period-num { font-size: 1.3rem; font-weight: 800; color: var(--primary); line-height: 1.1; white-space: nowrap; font-family: inherit; }
.period-time { font-size: 0.82rem; color: var(--text-muted); direction: ltr; text-align: left; unicode-bidi: plaintext; }
.period-status { font-size: 0.82rem; color: var(--text-muted); }
.btn-whatsapp {
    background: #e9a518; color: #fff; border: none; border-radius: 8px;
    padding: 8px 10px; font-size: 0.85rem; cursor: pointer; width: 100%; margin-top: auto;
    font-family: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font-weight: 600;
}
.btn-whatsapp:hover { background: #d99a15; }
.btn-whatsapp:disabled { opacity: 0.6; cursor: default; }
@media (max-width: 900px) { .periods-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .periods-grid { grid-template-columns: repeat(2, 1fr); } }

/* حالة تسجيل الغياب للفصل (المسجل = أخضر فاتح، غير المسجل = أحمر باهت) */
.section-registered {
    background: rgba(34, 197, 94, 0.08);
    border-right: 3px solid #22c55e;
}
.section-registered .accordion-btn { color: #d1fae5; }
.section-not-registered {
    background: rgba(239, 68, 68, 0.06);
    border-right: 3px solid #f87171;
}
.sec-status-badge {
    font-size: 0.78em;
    padding: 2px 8px;
    border-radius: 10px;
    margin-right: 6px;
}
.sec-status-done { background: rgba(34, 197, 94, 0.15); color: #4ade80; }
.sec-status-pending { background: rgba(239, 68, 68, 0.12); color: #f87171; }
