/* ============================================================
   Driving Theory Platform — Stylesheet
   RTL Farsi by default; uses Vazirmatn (load via Google Fonts).
   ============================================================ */

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

:root {
    --bg:        #0f1419;
    --bg-2:      #1a1f2e;
    --bg-3:      #232a3d;
    --surface:   #1e2433;
    --border:    #2d3548;
    --text:      #e8eaf0;
    --text-mute: #9ba3b8;
    --primary:   #4f8cff;
    --primary-2: #3a73e6;
    --success:   #2ecc71;
    --danger:    #ff5c6c;
    --warn:      #ffb347;
    --gold:      #ffc857;
    --radius:    12px;
    --shadow:    0 4px 20px rgba(0,0,0,0.25);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, sans-serif;
    font-size: 15px;
    line-height: 1.7;
    min-height: 100vh;
}

body[dir="rtl"] { text-align: right; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-2); }

/* ----- Layout ----- */
.app-shell { display: flex; min-height: 100vh; }
.app-main  { flex: 1; padding: 24px 32px; max-width: 100%; overflow-x: hidden; }

.sidebar {
    width: 240px;
    background: var(--bg-2);
    border-inline-start: 1px solid var(--border);
    padding: 24px 0;
    flex-shrink: 0;
}
.sidebar .brand {
    padding: 0 24px 24px;
    font-size: 18px;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
    color: var(--gold);
}
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: var(--text-mute);
    border-inline-end: 3px solid transparent;
    transition: 0.15s;
}
.sidebar nav a:hover {
    background: var(--bg-3);
    color: var(--text);
}
.sidebar nav a.active {
    background: var(--bg-3);
    color: var(--primary);
    border-inline-end-color: var(--primary);
}
.sidebar nav a .icon { width: 20px; opacity: 0.8; }

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 22px; font-weight: 600; }
.topbar .user-chip {
    display: flex; align-items: center; gap: 10px;
    background: var(--surface); padding: 6px 14px; border-radius: 999px;
    border: 1px solid var(--border);
}

/* ----- Cards ----- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}
.card + .card { margin-top: 20px; }
.card h2, .card h3 { margin-top: 0; }

.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .sidebar { width: 70px; }
    .sidebar .brand { font-size: 0; padding: 0 0 12px; }
    .sidebar nav a span:not(.icon) { display: none; }
    .app-main { padding: 16px; }
}

/* ----- Stat tiles ----- */
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
}
.stat .label { color: var(--text-mute); font-size: 13px; }
.stat .value { font-size: 28px; font-weight: 700; margin-top: 4px; color: var(--gold); }

/* ----- Forms ----- */
label { display: block; margin: 12px 0 6px; color: var(--text-mute); font-size: 14px; }
input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=number], select, textarea {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 15px;
    transition: 0.15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.15);
}
textarea { min-height: 80px; resize: vertical; }
input[type=checkbox] { margin-inline-end: 6px; transform: scale(1.15); }

.btn {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    border: none;
    padding: 11px 20px;
    border-radius: 8px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.15s;
}
.btn:hover { background: var(--primary-2); color: #fff; }
.btn-block { display: block; width: 100%; text-align: center; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--bg-3); color: var(--text); }
.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #e04958; }
.btn-success { background: var(--success); }
.btn-warn { background: var(--warn); color: #000; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ----- Tables ----- */
table {
    width: 100%;
    border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius);
    overflow: hidden;
}
th, td { padding: 12px 14px; text-align: start; border-bottom: 1px solid var(--border); }
th { background: var(--bg-2); color: var(--text-mute); font-weight: 500; font-size: 13px; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg-3); }

/* ----- Badges ----- */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
}
.badge.ok    { background: rgba(46, 204, 113, 0.15); color: var(--success); }
.badge.warn  { background: rgba(255, 179, 71, 0.15); color: var(--warn); }
.badge.bad   { background: rgba(255, 92, 108, 0.15); color: var(--danger); }
.badge.muted { background: var(--bg-3); color: var(--text-mute); }

/* ----- Flash messages ----- */
.flash {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    border-inline-start: 4px solid var(--primary);
    background: var(--bg-2);
}
.flash.error   { border-color: var(--danger);  background: rgba(255, 92, 108, 0.08); }
.flash.success { border-color: var(--success); background: rgba(46, 204, 113, 0.08); }
.flash.info    { border-color: var(--primary); }

/* ----- Auth pages ----- */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(circle at 30% 20%, #1a2540 0%, var(--bg) 60%);
}
.auth-box {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    box-shadow: var(--shadow);
}
.auth-box h1 { margin: 0 0 24px; text-align: center; color: var(--gold); }
.auth-box .alt { text-align: center; margin-top: 16px; color: var(--text-mute); }

/* ----- Question card ----- */
.q-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
}
.q-card .q-text { font-size: 18px; font-weight: 500; margin-bottom: 18px; line-height: 1.8; }
.q-card .q-media { margin: 16px 0; text-align: center; }
.q-card .q-media img,
.q-card .q-media video { max-width: 100%; max-height: 400px; border-radius: 8px; }
.q-card .meta { color: var(--text-mute); font-size: 13px; margin-bottom: 12px; }

.answer-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: 0.15s;
}
.answer-row:hover { border-color: var(--primary); background: var(--bg-3); }
.answer-row.correct  { border-color: var(--success); background: rgba(46, 204, 113, 0.08); }
.answer-row.wrong    { border-color: var(--danger);  background: rgba(255, 92, 108, 0.08); }
.answer-row input    { margin-top: 4px; }
.answer-row .text    { flex: 1; }

/* ----- Progress bar ----- */
.progress {
    height: 8px;
    background: var(--bg);
    border-radius: 999px;
    overflow: hidden;
    margin: 8px 0;
}
.progress > span {
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--gold));
    border-radius: 999px;
}

/* ----- Exam timer ----- */
.exam-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--bg-2);
    border-bottom: 1px solid var(--border);
    padding: 14px 24px;
    display: flex; justify-content: space-between; align-items: center;
}
.exam-bar .timer {
    font-size: 22px; font-weight: 700;
    color: var(--gold); font-variant-numeric: tabular-nums;
}
.exam-bar .timer.danger { color: var(--danger); }

/* ----- Misc ----- */
.row { display: flex; gap: 12px; align-items: center; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.text-mute { color: var(--text-mute); }
.text-gold { color: var(--gold); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.empty {
    text-align: center; padding: 60px 20px; color: var(--text-mute);
}
