/* ============================================================
   منصة المعاهد الشرعية — Modern UI v2 (مطابق project_v2)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&display=swap');

/* ─── CSS Variables ───────────────────────────────────────────*/
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #e0e7ff;
    --secondary: #8b5cf6;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #06b6d4;
    --info-light: #cffafe;

    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    --sidebar-bg: #0f172a;
    --sidebar-w: 270px;
    --navbar-h: 64px;

    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset & Base ────────────────────────────────────────────*/
*,
*::before,
*::after { box-sizing: border-box; }

body {
    font-family: 'Cairo', 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    padding-top: var(--navbar-h);
    min-height: 100vh;
    font-size: 14.5px;
    line-height: 1.6;
}

::-webkit-scrollbar       { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ─── Navbar ──────────────────────────────────────────────────*/
.app-navbar {
    height: var(--navbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0; right: 0; left: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    padding: 0 1.25rem;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
}

.navbar-toggler-custom {
    width: 40px; height: 40px;
    border: none;
    background: var(--bg);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.2rem;
    transition: all var(--transition);
    flex-shrink: 0;
}
.navbar-toggler-custom:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.navbar-brand-custom {
    flex: 1;
    text-align: center;
    font-weight: 800;
    font-size: 1.05rem;
    color: var(--text-primary);
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-shrink: 0;
}

.user-avatar {
    width: 36px; height: 36px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    display: none;
}
@media (min-width: 768px) {
    .user-name { display: block; }
}

.btn-logout {
    width: 36px; height: 36px;
    border: none;
    background: var(--danger-light);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--danger);
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    font-size: 1rem;
}
.btn-logout:hover {
    background: var(--danger);
    color: #fff;
    transform: scale(1.05);
}

/* ─── Sidebar ─────────────────────────────────────────────────*/
.app-sidebar {
    width: var(--sidebar-w) !important;
    background: var(--sidebar-bg) !important;
    border: none !important;
}

.sidebar-header {
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-logo {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.1rem;
    flex-shrink: 0;
}

.sidebar-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
}

.sidebar-subtitle {
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.3);
}

.sidebar-body {
    padding: 0.75rem 0;
    overflow-y: auto;
    overflow-x: hidden;
    height: calc(100% - 72px);
    /* Firefox */
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.08) transparent;
    /* fade على الحواف العلوية والسفلية */
    mask-image: linear-gradient(to bottom,
        transparent 0,
        #000 16px,
        #000 calc(100% - 16px),
        transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom,
        transparent 0,
        #000 16px,
        #000 calc(100% - 16px),
        transparent 100%);
}

/* WebKit (Chrome / Edge / Safari) */
.sidebar-body::-webkit-scrollbar {
    width: 6px;
}
.sidebar-body::-webkit-scrollbar-track {
    background: transparent;
    margin: 0.5rem 0;
}
.sidebar-body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(99,102,241,0.35), rgba(139,92,246,0.35));
    border-radius: 999px;
    border: 1.5px solid transparent;
    background-clip: padding-box;
    transition: all 0.2s ease;
}
.sidebar-body::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, var(--primary), var(--secondary));
    background-clip: padding-box;
    border-color: transparent;
}
.sidebar-body::-webkit-scrollbar-thumb:active {
    background: var(--primary);
    background-clip: padding-box;
}

/* السكرول يظهر فقط عند hover على الـ sidebar (خفّ المظهر) */
.app-sidebar .sidebar-body { scrollbar-color: transparent transparent; }
.app-sidebar:hover .sidebar-body { scrollbar-color: rgba(99,102,241,0.4) transparent; }
.app-sidebar .sidebar-body::-webkit-scrollbar-thumb { background: transparent; }
.app-sidebar:hover .sidebar-body::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(99,102,241,0.4), rgba(139,92,246,0.4));
    background-clip: padding-box;
}

.sidebar-section {
    padding: 0.9rem 1.25rem 0.3rem;
    font-size: 0.67rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.22);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.75rem;
    color: rgba(255, 255, 255, 0.55);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all var(--transition);
    margin: 1px 0.6rem;
    border-radius: var(--radius-sm);
    position: relative;
    border: none;
    background: transparent;
    width: calc(100% - 1.2rem);
    text-align: right;
    cursor: pointer;
}

.sidebar-link .link-icon {
    width: 30px; height: 30px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.06);
    transition: all var(--transition);
}

.sidebar-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.07);
}
.sidebar-link:hover .link-icon { background: rgba(255, 255, 255, 0.12); }

.sidebar-link.active {
    color: #fff;
    background: rgba(99, 102, 241, 0.18);
}
.sidebar-link.active .link-icon {
    background: var(--primary);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.45);
}
.sidebar-link.active::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 55%;
    background: var(--primary);
    border-radius: 999px 0 0 999px;
}

.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.05);
    margin: 0.4rem 1.2rem;
}

.sidebar-link.link-danger { color: rgba(248, 113, 113, 0.65); }
.sidebar-link.link-danger .link-icon { background: rgba(239, 68, 68, 0.1); color: #f87171; }
.sidebar-link.link-danger:hover { color: #fff; background: rgba(239, 68, 68, 0.15); }
.sidebar-link.link-danger:hover .link-icon { background: var(--danger); }

/* ─── Main / Page wrap ────────────────────────────────────────*/
main, .page-wrap {
    padding: 1.5rem 1.25rem !important;
    min-height: calc(100vh - var(--navbar-h));
    max-width: 1440px;
    margin: 0 auto;
}

/* ─── Page Header ─────────────────────────────────────────────*/
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding: 1rem 1.4rem;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.page-header h1, .page-header h2 {
    font-size: 1.15rem;
    font-weight: 800;
    margin: 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

/* alias لتركيبتي القديمة .page-title */
.page-title {
    font-size: 1.15rem;
    font-weight: 800;
    margin: 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.page-title .icon {
    width: auto !important; height: auto !important;
    background: transparent !important;
    color: var(--primary) !important;
    font-size: 1.1rem;
    border-radius: 0 !important;
    display: inline !important;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 0.3rem 0 0;
    width: 100%;
}

/* ─── Cards ───────────────────────────────────────────────────*/
.card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
    overflow: hidden;
    margin-bottom: 1.25rem;
}
.card:hover { box-shadow: var(--shadow); }

.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    padding: 0.85rem 1.25rem;
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card-body { padding: 1.25rem; }

/* .app-card — padding مباشر داخلها (بخلاف Bootstrap card) */
.app-card {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
    margin-bottom: 1.25rem;
    padding: 1.25rem;
}
.app-card:hover { box-shadow: var(--shadow); }

.app-card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-light);
    margin: -1.25rem -1.25rem 1rem;
    padding: 0.85rem 1.25rem;
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.app-card-title {
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}
.app-card-title .title-icon {
    width: 30px; height: 30px;
    border-radius: 8px;
    background: var(--primary-light);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
}

/* ─── Stat Cards ──────────────────────────────────────────────*/
.stat-card {
    border-radius: var(--radius-lg);
    padding: 1.2rem 1.4rem;
    position: relative;
    overflow: hidden;
    transition: transform var(--transition), box-shadow var(--transition);
    border: none;
    box-shadow: var(--shadow);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    text-decoration: none;
    background: linear-gradient(135deg, #6366f1, #818cf8);
}
.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    color: #fff;
}
.stat-card::after {
    content: '';
    position: absolute;
    bottom: -25px;
    left: -25px;
    width: 110px;
    height: 110px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.07);
    pointer-events: none;
}

.stat-card .stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-size: 1.3rem;
    flex-shrink: 0;
    z-index: 1;
}
.stat-card .stat-icon.success,
.stat-card .stat-icon.warning,
.stat-card .stat-icon.danger,
.stat-card .stat-icon.info { background: rgba(255,255,255,0.18); }

.stat-card .stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.35rem;
    color: rgba(255,255,255,0.85);
}

.stat-card .stat-value {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.2;
    color: #fff;
}

/* ألوان الـ stat icons القديمة → ترسم خلفية الـ stat-card */
.stat-card:has(.stat-icon.success), .stat-card.success { background: linear-gradient(135deg, #10b981, #34d399) !important; }
.stat-card:has(.stat-icon.warning), .stat-card.warning { background: linear-gradient(135deg, #f59e0b, #fbbf24) !important; }
.stat-card:has(.stat-icon.danger),  .stat-card.danger  { background: linear-gradient(135deg, #ef4444, #f87171) !important; }
.stat-card:has(.stat-icon.info),    .stat-card.info    { background: linear-gradient(135deg, #06b6d4, #22d3ee) !important; }
.stat-card:has(.stat-icon.secondary), .stat-card.secondary { background: linear-gradient(135deg, #475569, #64748b) !important; }

/* alias .stats-grid (القديم عندي) → نفس grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* .stat-icon المُستعمَلة خارج .stat-card (مثلاً في cards عادية) */
.card .stat-icon, .app-card .stat-icon, [class*="col-"] .card .stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 1.25rem;
    flex-shrink: 0;
}
.card .stat-icon.success, .app-card .stat-icon.success { background: var(--success-light); color: var(--success); }
.card .stat-icon.warning, .app-card .stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.card .stat-icon.danger,  .app-card .stat-icon.danger  { background: var(--danger-light);  color: var(--danger);  }
.card .stat-icon.info,    .app-card .stat-icon.info    { background: var(--info-light);    color: var(--info);    }

/* ─── Tables ──────────────────────────────────────────────────*/
.table, .app-table {
    font-size: 0.875rem;
    color: var(--text-primary);
    border-color: var(--border-light);
    width: 100%;
    border-collapse: collapse;
}

.table thead th, .app-table thead th {
    background: var(--surface-2);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    padding: 0.85rem 1rem;
    white-space: nowrap;
    border-top: none;
    text-align: center;
    vertical-align: middle;
    position: sticky;
    top: 0;
    z-index: 2;
}

.table tbody td, .app-table tbody td {
    padding: 0.6rem 1rem;
    border-color: var(--border-light);
    border-bottom: 1px solid var(--border-light);
    vertical-align: middle;
    text-align: center;
    height: 52px;
    box-sizing: border-box;
    white-space: nowrap;
}
.table thead th, .app-table thead th { white-space: nowrap; }

/* الجداول داخل scroll-containers تأخذ عرضها الطبيعي + تمرير أفقي */
.users-scroll, .years-scroll, .semesters-scroll, .subjects-scroll,
.table-responsive-card, .table-scroll-wrap {
    -webkit-overflow-scrolling: touch;
}
.users-scroll > .app-table,
.years-scroll > .app-table,
.semesters-scroll > .app-table,
.subjects-scroll > .app-table,
.table-responsive-card > .app-table,
.table-responsive-card > .table {
    width: max-content;
    min-width: 100%;
}

/* خلايا فيها d-flex (icon + نص) تبقى على سطر واحد */
.app-table tbody td .d-flex,
.table tbody td .d-flex {
    flex-wrap: nowrap;
}

.table tbody tr, .app-table tbody tr { transition: background var(--transition); }
.table tbody tr:hover, .app-table tbody tr:hover { background: #f8faff; }
.table tbody tr:last-child td, .app-table tbody tr:last-child td { border-bottom: none; }

/* خلية فارغة */
.table tbody td.dataTables_empty,
.table tbody tr:only-child td[colspan],
.app-table tbody tr:only-child td[colspan] {
    height: auto !important;
    padding: 1.5rem 1rem !important;
}

/* لفّ بتمرير */
.table-scroll-wrap, .table-responsive-card {
    overflow-x: auto;
    overflow-y: auto;
    max-height: 70vh;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    margin-bottom: 1.25rem;
}
.table-scroll-wrap .table,
.table-scroll-wrap .app-table,
.table-responsive-card .table,
.table-responsive-card .app-table { margin-bottom: 0; }

/* ─── Badges & Chips ──────────────────────────────────────────*/
.badge, .badge-soft {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.28em 0.65em;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.badge-soft { background: var(--primary-light); color: var(--primary-dark); }
.badge-soft-success { background: var(--success-light); color: #065f46; }
.badge-soft-warning { background: var(--warning-light); color: #92400e; }
.badge-soft-danger  { background: var(--danger-light);  color: #991b1b; }
.badge-soft-info    { background: var(--info-light);    color: #0e7490; }

/* score chips للعلامات */
.score-chip {
    display: inline-block;
    padding: 0.32rem 0.8rem;
    border-radius: var(--radius-sm);
    font-weight: 800;
    font-size: 0.88rem;
    font-family: 'Cairo', sans-serif;
}
.score-chip.passed { background: var(--success-light); color: #047857; }
.score-chip.failed { background: var(--danger-light);  color: #b91c1c; }
.score-chip.empty  { background: var(--border-light);  color: var(--text-muted); }

/* ─── Buttons ─────────────────────────────────────────────────*/
.btn {
    font-family: 'Cairo', sans-serif;
    font-weight: 600;
    font-size: 0.875rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    border: none;
    cursor: pointer;
    padding: 0.5rem 1rem;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-dark), #4338ca);
    box-shadow: 0 6px 18px rgba(99, 102, 241, 0.42);
    transform: translateY(-1px);
    color: #fff;
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #059669);
    color: #fff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}
.btn-success:hover {
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.42);
    transform: translateY(-1px);
    color: #fff;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: #fff;
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}
.btn-danger:hover { transform: translateY(-1px); color: #fff; }

.btn-warning {
    background: linear-gradient(135deg, var(--warning), #d97706);
    color: #fff;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}
.btn-warning:hover { transform: translateY(-1px); color: #fff; }

.btn-info {
    background: linear-gradient(135deg, var(--info), #0891b2);
    color: #fff;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}
.btn-info:hover { transform: translateY(-1px); color: #fff; }

.btn-outline-primary {
    border: 1.5px solid var(--primary);
    color: var(--primary);
    background: transparent;
}
.btn-outline-primary:hover { background: var(--primary-light); color: var(--primary-dark); }

.btn-outline-secondary {
    border: 1.5px solid var(--border);
    color: var(--text-secondary);
    background: transparent;
}
.btn-outline-secondary:hover { background: var(--bg); color: var(--text-primary); }

.btn-outline-danger {
    border: 1.5px solid var(--danger);
    color: var(--danger);
    background: transparent;
}
.btn-outline-danger:hover { background: var(--danger-light); }

/* alias btn-soft-* (القديمة عندي) → نفس outline */
.btn-soft-primary { background: var(--primary-light); color: var(--primary-dark); border: 1.5px solid transparent; }
.btn-soft-primary:hover { background: var(--primary); color: #fff; }
.btn-soft-success { background: var(--success-light); color: #047857; border: 1.5px solid transparent; }
.btn-soft-success:hover { background: var(--success); color: #fff; }
.btn-soft-warning { background: var(--warning-light); color: #92400e; border: 1.5px solid transparent; }
.btn-soft-warning:hover { background: var(--warning); color: #fff; }
.btn-soft-danger  { background: var(--danger-light);  color: #b91c1c; border: 1.5px solid transparent; }
.btn-soft-danger:hover { background: var(--danger); color: #fff; }
.btn-soft-info    { background: var(--info-light);    color: #0e7490; border: 1.5px solid transparent; }
.btn-soft-info:hover { background: var(--info); color: #fff; }

.btn-icon {
    width: 34px; height: 34px;
    padding: 0 !important;
    border-radius: var(--radius-sm);
    justify-content: center;
}

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.82rem; }
.btn-lg { padding: 0.7rem 1.4rem; font-size: 0.95rem; }

/* ─── Forms ───────────────────────────────────────────────────*/
.form-label {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.form-control,
.form-select {
    font-family: 'Cairo', sans-serif;
    font-size: 0.875rem;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    background: var(--surface);
    transition: all var(--transition);
    padding: 0.52rem 0.85rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    outline: none;
}

.form-control::placeholder { color: var(--text-muted); }

.form-control-sm,
.form-select-sm {
    padding: 0.32rem 0.7rem;
    font-size: 0.82rem;
}

.input-group-text {
    background: var(--surface-2);
    border: 1.5px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.form-text {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.form-check-input { cursor: pointer; }
.form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }
.form-check-input:focus { box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1); }

/* ─── Section divider ─────────────────────────────────────────*/
.section-divider {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin: 1.25rem 0 0.75rem;
}
.section-divider::after { content: ''; flex: 1; height: 1px; background: var(--border-light); }
.section-divider .label { font-size: 0.75rem; color: var(--text-secondary); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }

/* ─── Alerts ──────────────────────────────────────────────────*/
.alert {
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.85rem 1.1rem;
}
.alert-success { background: var(--success-light); color: #065f46; }
.alert-danger  { background: var(--danger-light);  color: #991b1b; }
.alert-warning { background: var(--warning-light); color: #92400e; }
.alert-info    { background: var(--info-light);    color: #0e7490; }
.alert-light   { background: var(--surface-2);     color: var(--text-primary); border: 1px solid var(--border); }

/* ─── Login ───────────────────────────────────────────────────*/
body.login-body {
    padding-top: 0;
    background: #0f172a;
}

.login-bg {
    position: fixed;
    inset: 0;
    overflow: hidden;
    z-index: 0;
}
.login-bg::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.3) 0%, transparent 70%);
    top: -200px; right: -200px;
    border-radius: 50%;
    animation: float1 8s ease-in-out infinite;
}
.login-bg::after {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.2) 0%, transparent 70%);
    bottom: -150px; left: -150px;
    border-radius: 50%;
    animation: float2 10s ease-in-out infinite;
}
@keyframes float1 {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(-30px, 25px); }
}
@keyframes float2 {
    0%, 100% { transform: translate(0, 0); }
    50%      { transform: translate(25px, -20px); }
}

.login-wrapper {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.45s ease;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(28px); }
    to   { opacity: 1; transform: translateY(0); }
}

.login-logo-wrap {
    width: 70px; height: 70px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #fff;
    margin: 0 auto 1.25rem;
    box-shadow: 0 8px 28px rgba(99, 102, 241, 0.5);
    animation: glow 2.5s ease infinite;
}
@keyframes glow {
    0%, 100% { box-shadow: 0 8px 28px rgba(99, 102, 241, 0.5); }
    50%      { box-shadow: 0 8px 40px rgba(139, 92, 246, 0.7); }
}

.login-title {
    font-size: 1.4rem;
    font-weight: 800;
    color: #fff;
    text-align: center;
    margin-bottom: 0.25rem;
}
.login-subtitle {
    font-size: 0.83rem;
    color: rgba(255, 255, 255, 0.4);
    text-align: center;
    margin-bottom: 2rem;
}

.login-card .form-label { color: rgba(255, 255, 255, 0.65); font-size: 0.82rem; }
.login-card .form-control { background: rgba(255, 255, 255, 0.07); border: 1.5px solid rgba(255, 255, 255, 0.1); color: #fff; }
.login-card .form-control::placeholder { color: rgba(255, 255, 255, 0.22); }
.login-card .form-control:focus {
    background: rgba(255, 255, 255, 0.11);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
    color: #fff;
}
.login-card .input-group-text {
    background: rgba(255, 255, 255, 0.06);
    border: 1.5px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.35);
}
.login-card .form-check-label { color: rgba(255, 255, 255, 0.5); font-size: 0.82rem; }
.login-card .form-check-input { background-color: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.18); }
.login-card .form-check-input:checked { background-color: var(--primary); border-color: var(--primary); }

.btn-login {
    width: 100%;
    padding: 0.72rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 700;
    font-family: 'Cairo', sans-serif;
    cursor: pointer;
    transition: all var(--transition);
    box-shadow: 0 8px 22px rgba(99, 102, 241, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(99, 102, 241, 0.55);
}

/* ─── Empty State ─────────────────────────────────────────────*/
.empty-state {
    text-align: center;
    padding: 3.5rem 2rem;
    color: var(--text-muted);
}
.empty-state .icon, .empty-state .empty-icon {
    width: 70px; height: 70px;
    background: var(--bg);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 1rem;
    color: var(--text-muted);
}
.empty-state h5 { color: var(--text-primary); font-weight: 700; margin-bottom: 0.4rem; }

/* ─── Modal ───────────────────────────────────────────────────*/
.modal-content {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}
.modal-header { border-bottom: 1px solid var(--border-light); padding: 1.1rem 1.4rem; }
.modal-title { font-weight: 700; font-size: 1rem; }
.modal-footer { border-top: 1px solid var(--border-light); }

/* ─── DataTables ──────────────────────────────────────────────*/
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.32rem 0.7rem;
    font-size: 0.85rem;
    font-family: 'Cairo', sans-serif;
    color: var(--text-primary);
    background: var(--surface);
}
.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    outline: none;
}
.dataTables_wrapper .dataTables_info { font-size: 0.82rem; color: var(--text-muted); padding: 0.75rem 1rem; }
.dataTables_wrapper .dataTables_paginate { padding: 0.5rem 1rem; }
.paginate_button.current {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark)) !important;
    color: #fff !important;
    border: none !important;
    border-radius: var(--radius-sm) !important;
}

/* ─── Select2 ─────────────────────────────────────────────────*/
.select2-container--bootstrap-5 .select2-selection {
    border: 1.5px solid var(--border) !important;
    border-radius: var(--radius-sm) !important;
    font-family: 'Cairo', sans-serif !important;
    min-height: 38px !important;
}
.select2-container--bootstrap-5.select2-container--focus .select2-selection {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12) !important;
}

/* ─── Tooltips ────────────────────────────────────────────────*/
.tooltip-inner {
    background: var(--text-primary);
    color: #fff;
    font-family: 'Cairo', sans-serif;
    font-size: 0.78rem;
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}
.tooltip .tooltip-arrow::before { border-color: var(--text-primary) !important; }

/* ─── Animations ──────────────────────────────────────────────*/
.fade-in { animation: fadeIn 0.3s ease; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }

.btn-loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}
.btn-loading::after {
    content: '';
    position: absolute;
    width: 16px; height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
}

/* ─── Utilities ───────────────────────────────────────────────*/
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }

.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger  { color: var(--danger) !important; }
.text-info    { color: var(--info) !important; }
.text-muted   { color: var(--text-muted) !important; }

.num { font-variant-numeric: tabular-nums; }

/* ─── Print ───────────────────────────────────────────────────*/
@media print {
    .app-navbar, .app-sidebar, .no-print { display: none !important; }
    body { padding-top: 0; background: #fff; }
    .card, .app-card, .table-responsive-card { box-shadow: none; border: 1px solid #ddd; }
}

/* ─── Responsive — Tablet (≤768px) ─────────────────────────── */
@media (max-width: 768px) {
    main, .page-wrap { padding: 1rem 0.85rem !important; }

    .page-header {
        flex-direction: column;
        align-items: stretch;
        gap: 0.6rem;
        padding: 0.85rem 1rem;
    }
    .page-header h1, .page-header h2, .page-title {
        font-size: 1.05rem;
        justify-content: center;
    }
    .page-header .btn,
    .page-header a.btn {
        width: 100%;
        justify-content: center;
    }

    .card-header, .app-card-header { padding: 0.75rem 1rem; font-size: 0.84rem; flex-wrap: wrap; gap: 0.4rem; }
    .card-body, .app-card > * { padding: 1rem !important; }

    .modal-dialog { margin: 0.5rem; }

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

    .row.g-3 > [class*="col-md-"],
    .row.g-4 > [class*="col-md-"] { flex: 0 0 100%; max-width: 100%; }

    .d-flex.gap-2, .d-flex.gap-3 { flex-wrap: wrap; }
    .btn-group { flex-wrap: wrap; }
    .btn-group .btn { font-size: 0.78rem; padding: 0.3rem 0.6rem; }
}

/* ─── Mobile (≤576px) ─────────────────────────────────────── */
@media (max-width: 576px) {
    main, .page-wrap { padding: 0.6rem 0.4rem !important; }

    .page-header { padding: 0.7rem 0.75rem; margin-bottom: 0.6rem; border-radius: var(--radius); }
    .page-header h1, .page-header h2, .page-title { font-size: 0.95rem; gap: 0.4rem; }

    .card, .app-card { border-radius: var(--radius); }
    .card-body { padding: 0.75rem; }
    .card-header, .app-card-header { padding: 0.65rem 0.75rem; font-size: 0.82rem; }

    .stat-card { padding: 0.9rem 1rem; border-radius: var(--radius); }
    .stat-card .stat-value { font-size: 1.15rem; }
    .stat-card .stat-label { font-size: 0.68rem; }
    .stat-card .stat-icon { width: 38px; height: 38px; font-size: 1.05rem; }
    .stat-card::after { width: 70px; height: 70px; bottom: -15px; left: -15px; }

    .stats-grid { grid-template-columns: 1fr; }

    .table-responsive-card, .table-scroll-wrap { max-height: 60vh; border-radius: var(--radius-sm); }
    .table, .app-table { font-size: 0.78rem; }
    .table thead th, .app-table thead th { padding: 0.55rem 0.5rem; font-size: 0.65rem; letter-spacing: 0.03em; }
    .table tbody td, .app-table tbody td { padding: 0.45rem 0.5rem; height: 42px; font-size: 0.78rem; }

    .btn { font-size: 0.8rem; padding: 0.35rem 0.7rem; }
    .btn-icon { width: 30px; height: 30px; }
    .btn-icon i { font-size: 0.8rem; }
    .btn-sm { padding: 0.25rem 0.5rem; font-size: 0.75rem; }

    .form-control, .form-select { font-size: 0.82rem; padding: 0.42rem 0.7rem; }
    .form-label { font-size: 0.78rem; margin-bottom: 0.25rem; }

    .badge, .badge-soft { font-size: 0.65rem; padding: 0.2em 0.5em; }

    .app-navbar { padding: 0 0.75rem; gap: 0.5rem; }
    .navbar-brand-custom { font-size: 0.88rem; }
    .navbar-toggler-custom { width: 36px; height: 36px; font-size: 1.05rem; }
    .user-avatar { width: 32px; height: 32px; font-size: 0.75rem; }
    .btn-logout { width: 32px; height: 32px; font-size: 0.9rem; }

    .login-card { padding: 1.5rem 1rem; border-radius: var(--radius-lg); }
    .login-logo-wrap { width: 58px; height: 58px; font-size: 1.6rem; margin-bottom: 1rem; }
    .login-title { font-size: 1.15rem; }
    .login-subtitle { font-size: 0.78rem; margin-bottom: 1.5rem; }
    .btn-login { padding: 0.6rem; font-size: 0.88rem; }

    .alert { font-size: 0.82rem; padding: 0.7rem 0.9rem; }

    .modal-dialog { margin: 0.35rem; }
    .modal-header { padding: 0.85rem 1rem; }
    .modal-title { font-size: 0.92rem; }
    .modal-body { padding: 0.85rem 1rem; }
    .modal-footer { padding: 0.6rem 1rem; }

    .swal2-popup { font-size: 0.85rem !important; padding: 1rem !important; width: 90vw !important; max-width: 340px !important; }

    .row > [class*="col-md-3"],
    .row > [class*="col-lg-3"] { flex: 0 0 50%; max-width: 50%; }
    .row > [class*="col-md-4"],
    .row > [class*="col-lg-4"],
    .row > [class*="col-md-6"],
    .row > [class*="col-lg-6"] { flex: 0 0 100%; max-width: 100%; }

    .empty-state { padding: 2rem 1rem; }
    .empty-state .icon, .empty-state .empty-icon { width: 55px; height: 55px; font-size: 1.5rem; }
}

/* ─── Very small (≤400px) ─────────────────────────────────── */
@media (max-width: 400px) {
    main, .page-wrap { padding: 0.4rem 0.25rem !important; }
    .page-header { padding: 0.55rem 0.65rem; }
    .page-header h1, .page-header h2, .page-title { font-size: 0.85rem; }
    .stat-card { padding: 0.65rem 0.75rem; }
    .stat-card .stat-value { font-size: 0.95rem; }
    .stat-card .stat-label { font-size: 0.6rem; }
    .table tbody td, .app-table tbody td { padding: 0.4rem 0.4rem; height: 38px; }
    .btn { font-size: 0.73rem; padding: 0.28rem 0.5rem; }
    .btn-icon { width: 26px; height: 26px; }
}
