/* ============================================================
   منصة الاختبارات الإلكترونية — Design System
   ============================================================ */

:root {
    --primary: #1b2a4a;
    --primary-light: #24365f;
    --primary-dark: #101c33;
    --accent: #12b3a6;
    --accent-dark: #0d8f85;
    --gold: #e8a838;
    --danger: #e5484d;
    --danger-dark: #c73438;
    --success: #1fae6e;

    --bg: #f2f4f9;
    --surface: #ffffff;
    --surface-alt: #f8f9fc;
    --border: #e3e7f1;
    --text: #1c2333;
    --text-muted: #6b7385;
    --text-faint: #98a0b3;

    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 3px rgba(20, 30, 60, 0.06);
    --shadow: 0 6px 20px rgba(20, 30, 60, 0.08);
    --shadow-lg: 0 16px 40px rgba(20, 30, 60, 0.14);
    --transition: 180ms cubic-bezier(.4,0,.2,1);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #10141f;
        --surface: #171d2c;
        --surface-alt: #1d2436;
        --border: #2a3348;
        --text: #e7eaf2;
        --text-muted: #a3aac0;
        --text-faint: #6d7690;
        --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
        --shadow: 0 6px 20px rgba(0,0,0,0.35);
        --shadow-lg: 0 16px 40px rgba(0,0,0,0.45);
    }
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; }

::selection { background: var(--accent); color: #fff; }

/* ---------- Layout shells ---------- */

.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 24px;
}

.main-content {
    flex: 1;
    padding: 32px 0 64px;
}

/* ---------- Top navbar (public / user) ---------- */

.navbar {
    background: var(--primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 40;
}

.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 68px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.15rem;
    color: #fff;
}

.navbar-brand .logo-dot {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), var(--gold));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 800;
    color: var(--primary-dark);
}

.navbar-links {
    display: flex;
    align-items: center;
    gap: 6px;
}

.navbar-links a {
    color: rgba(255,255,255,.82);
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: .95rem;
    transition: background var(--transition), color var(--transition);
}

.navbar-links a:hover { background: rgba(255,255,255,.1); color: #fff; }
.navbar-links a.active { background: rgba(255,255,255,.14); color: #fff; }

.navbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-inline-start: 12px;
    margin-inline-start: 8px;
    border-inline-start: 1px solid rgba(255,255,255,.18);
}

.navbar-user .avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255,255,255,.14);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .85rem;
}

/* ---------- Admin shell (sidebar) ---------- */

.admin-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: var(--primary);
    color: rgba(255,255,255,.86);
    padding: 22px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 800;
    font-size: 1.05rem;
    padding: 6px 10px 22px;
}

.sidebar-brand .logo-dot {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--accent), var(--gold));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary-dark);
    font-weight: 800;
}

.sidebar-section-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: rgba(255,255,255,.4);
    padding: 14px 12px 6px;
    font-weight: 700;
}

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: .93rem;
    color: rgba(255,255,255,.78);
    margin-bottom: 2px;
    transition: background var(--transition), color var(--transition);
}

.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar nav a.active { background: var(--accent); color: #fff; }
.sidebar nav a .icon { font-size: 1.05rem; width: 20px; text-align: center; }

.admin-main {
    flex: 1;
    min-width: 0;
    padding: 28px 32px 64px;
}

.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 26px;
    flex-wrap: wrap;
    gap: 12px;
}

.admin-topbar h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 800;
}

/* ---------- Cards ---------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 24px;
}

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

.card-header h2, .card-header h3 {
    margin: 0;
    font-weight: 800;
}

/* stat cards */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 26px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    inset-inline-start: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--accent);
}

.stat-card.gold::before { background: var(--gold); }
.stat-card.danger::before { background: var(--danger); }
.stat-card.primary::before { background: var(--primary-light); }

.stat-card .value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary);
}

.stat-card .label {
    color: var(--text-muted);
    font-size: .88rem;
    font-weight: 600;
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    border-radius: var(--radius-sm);
    border: none;
    font-family: inherit;
    font-weight: 700;
    font-size: .93rem;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), background var(--transition), opacity var(--transition);
    text-align: center;
}

.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); }

.btn-dark { background: var(--primary); color: #fff; }
.btn-dark:hover { background: var(--primary-light); }

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

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

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-alt); color: var(--text); }

.btn-sm { padding: 7px 14px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Forms ---------- */

.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-weight: 700;
    font-size: .88rem;
    margin-bottom: 7px;
    color: var(--text);
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-family: inherit;
    font-size: .95rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(18, 179, 166, .15);
}

textarea.form-control { resize: vertical; min-height: 90px; }

.form-hint { color: var(--text-faint); font-size: .8rem; margin-top: 6px; }
.form-error { color: var(--danger); font-size: .82rem; margin-top: 6px; font-weight: 600; }

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

.option-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.option-letter {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--surface-alt);
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: var(--primary);
}

/* auth card */

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 30% 20%, var(--primary-light), var(--primary-dark) 70%);
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 38px 34px;
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
    margin-bottom: 22px;
}

.auth-logo .logo-dot {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), var(--gold));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: var(--primary-dark);
    font-size: 1.2rem;
}

.auth-card h1 {
    text-align: center;
    font-size: 1.3rem;
    margin: 0 0 4px;
}

.auth-card .subtitle {
    text-align: center;
    color: var(--text-muted);
    font-size: .9rem;
    margin-bottom: 26px;
}

.auth-footer-link {
    text-align: center;
    margin-top: 18px;
    font-size: .88rem;
    color: var(--text-muted);
}

.auth-footer-link a { color: var(--accent-dark); font-weight: 700; }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    font-size: .92rem;
}

table.data-table th {
    background: var(--surface-alt);
    text-align: start;
    padding: 13px 16px;
    font-weight: 700;
    color: var(--text-muted);
    font-size: .82rem;
    text-transform: uppercase;
    letter-spacing: .03em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

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

table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: var(--surface-alt); }

.table-actions { display: flex; gap: 8px; }

/* ---------- Badges ---------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 11px;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 700;
}

.badge-easy { background: #e4f7ee; color: var(--success); }
.badge-medium { background: #fdf1dd; color: #b3791a; }
.badge-hard { background: #fde5e6; color: var(--danger-dark); }
.badge-admin { background: #e9ecf7; color: var(--primary); }
.badge-user { background: #e4f7ee; color: var(--success); }
.badge-neutral { background: var(--surface-alt); color: var(--text-muted); }

@media (prefers-color-scheme: dark) {
    .badge-easy { background: rgba(31,174,110,.15); }
    .badge-medium { background: rgba(232,168,56,.15); color: var(--gold); }
    .badge-hard { background: rgba(229,72,77,.15); }
    .badge-admin { background: rgba(255,255,255,.08); }
    .badge-user { background: rgba(31,174,110,.15); }
}

/* ---------- Alerts ---------- */

.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-weight: 600;
    margin-bottom: 18px;
    border: 1px solid transparent;
}

.alert-success { background: #e4f7ee; color: #14805a; border-color: #bfe9d4; }
.alert-danger { background: #fde5e6; color: var(--danger-dark); border-color: #f7c3c5; }
.alert-info { background: #e9f2fb; color: #1a5c96; border-color: #c9e0f5; }

/* ---------- Landing / hero ---------- */

.hero {
    background: linear-gradient(155deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    padding: 90px 0 110px;
    position: relative;
    overflow: hidden;
}

.hero::after {
    content: '';
    position: absolute;
    width: 480px;
    height: 480px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(18,179,166,.25), transparent 70%);
    top: -180px;
    inset-inline-end: -140px;
}

.hero .container { position: relative; z-index: 1; }

.hero h1 {
    font-size: 2.5rem;
    font-weight: 800;
    max-width: 700px;
    margin: 0 0 18px;
    line-height: 1.4;
}

.hero p.lead {
    font-size: 1.1rem;
    color: rgba(255,255,255,.82);
    max-width: 600px;
    margin-bottom: 30px;
}

.hero-actions { display: flex; gap: 14px; flex-wrap: wrap; }

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 20px;
    margin-top: -60px;
    position: relative;
    z-index: 2;
}

.feature-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 26px 22px;
    border: 1px solid var(--border);
}

.feature-card .icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    background: rgba(18,179,166,.12);
    color: var(--accent-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 14px;
}

.feature-card h3 { margin: 0 0 8px; font-size: 1.05rem; }
.feature-card p { margin: 0; color: var(--text-muted); font-size: .9rem; }

/* ---------- Exam taking UI ---------- */

.exam-shell {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 24px;
    align-items: start;
}

@media (max-width: 900px) {
    .exam-shell { grid-template-columns: 1fr; }
}

.exam-header-bar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    flex-wrap: wrap;
    gap: 12px;
}

.timer-box {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--primary);
    background: var(--surface-alt);
    padding: 8px 18px;
    border-radius: 999px;
}

.timer-box.warning { color: var(--danger-dark); background: #fde5e6; }

.progress-track {
    height: 8px;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
    flex: 1;
    min-width: 160px;
    margin: 0 18px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--gold));
    border-radius: 999px;
    transition: width 220ms ease;
}

.question-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 30px;
    box-shadow: var(--shadow-sm);
}

.question-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.question-number {
    font-weight: 800;
    color: var(--text-faint);
    font-size: .9rem;
}

.question-text {
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 26px;
    line-height: 1.8;
}

.option-list { display: flex; flex-direction: column; gap: 12px; }

.option-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 15px 18px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--border);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}

.option-item:hover { border-color: var(--accent); background: var(--surface-alt); }

.option-item input[type="radio"] { accent-color: var(--accent); width: 18px; height: 18px; flex-shrink: 0; }

.option-item.selected { border-color: var(--accent); background: rgba(18,179,166,.07); }

.option-item .option-letter { flex-shrink: 0; }

.option-item .option-text { flex: 1; font-size: .96rem; }

.option-item.correct { border-color: var(--success); background: rgba(31,174,110,.08); }
.option-item.incorrect { border-color: var(--danger); background: rgba(229,72,77,.08); }

.question-nav-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 84px;
}

.question-nav-panel h4 { margin: 0 0 14px; font-size: .95rem; }

.nav-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 7px;
    max-height: 360px;
    overflow-y: auto;
    padding-inline-end: 2px;
}

.nav-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    background: var(--surface-alt);
    font-size: .78rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}

.nav-cell:hover { border-color: var(--accent); }
.nav-cell.answered { background: var(--accent); color: #fff; border-color: var(--accent); }
.nav-cell.current { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(232,168,56,.3); }

.nav-legend { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; font-size: .78rem; color: var(--text-muted); }
.nav-legend span { display: flex; align-items: center; gap: 8px; }
.legend-dot { width: 12px; height: 12px; border-radius: 4px; display: inline-block; }

.exam-footer-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 24px;
    gap: 12px;
    flex-wrap: wrap;
}

/* ---------- Result page ---------- */

.result-hero {
    text-align: center;
    padding: 40px 20px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    margin-bottom: 26px;
}

.score-ring {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: conic-gradient(var(--accent) calc(var(--pct) * 1%), var(--border) 0);
    position: relative;
}

.score-ring::before {
    content: '';
    position: absolute;
    inset: 10px;
    border-radius: 50%;
    background: var(--surface);
}

.score-ring .score-value {
    position: relative;
    z-index: 1;
    font-size: 2.1rem;
    font-weight: 800;
    color: var(--primary);
}

.result-hero h2 { margin: 4px 0 6px; }
.result-hero p { color: var(--text-muted); margin: 0; }

.review-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 26px;
    margin-bottom: 16px;
}

.review-item .explanation-box {
    background: var(--surface-alt);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    margin-top: 14px;
    font-size: .88rem;
    color: var(--text-muted);
    border-inline-start: 3px solid var(--accent);
}

/* ---------- Empty state ---------- */

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

.empty-state .icon { font-size: 2.6rem; margin-bottom: 12px; }

/* ---------- Footer ---------- */

.site-footer {
    text-align: center;
    padding: 24px;
    color: var(--text-faint);
    font-size: .85rem;
}

/* ---------- Misc utility ---------- */

.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mb-0 { margin-bottom: 0; }
.mt-16 { margin-top: 16px; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.w-full { width: 100%; }

@media (max-width: 640px) {
    .hero h1 { font-size: 1.9rem; }
    .admin-main { padding: 22px 16px 48px; }
    .sidebar { position: fixed; inset-inline-start: -280px; z-index: 50; transition: inset-inline-start var(--transition); }
    .sidebar.open { inset-inline-start: 0; }
}
