/* =============================================
   MARKHOR JUNIOR CONTEST - Main Stylesheet
   ============================================= */

:root {
    --primary: #1a3a6b;
    --primary-light: #2456a4;
    --accent: #e8a020;
    --accent-dark: #c47d0a;
    --success: #22a06b;
    --danger: #e5343a;
    --warning: #f59e0b;
    --bg: #f0f4f8;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius: 12px;
    --shadow: 0 2px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.6;
}

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}
.btn-primary   { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-accent    { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); }
.btn-success   { background: var(--success); color: #fff; }
.btn-danger    { background: var(--danger); color: #fff; }
.btn-outline   { background: transparent; border: 2px solid var(--primary); color: var(--primary); }
.btn-sm        { padding: 6px 14px; font-size: 13px; }
.btn-lg        { padding: 14px 28px; font-size: 16px; }
.btn-block     { width: 100%; justify-content: center; }

/* ---- CARDS ---- */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
}
.card-header {
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.card-title { font-size: 18px; font-weight: 700; color: var(--primary); }

/* ---- FORMS ---- */
.form-group { margin-bottom: 18px; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-control {
    width: 100%;
    padding: 11px 14px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    color: var(--text);
    background: #fff;
    transition: border-color 0.2s;
    outline: none;
}
.form-control:focus { border-color: var(--primary-light); }
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ---- ALERTS ---- */
.alert {
    padding: 12px 18px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}
.alert-success { background: #d1fae5; color: #065f46; border-left: 4px solid var(--success); }
.alert-danger  { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--danger); }
.alert-warning { background: #fef3c7; color: #92400e; border-left: 4px solid var(--warning); }
.alert-info    { background: #dbeafe; color: #1e40af; border-left: 4px solid #3b82f6; }

/* ---- TABLES ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
table th {
    background: #f8fafc;
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border);
}
table td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table tr:hover td { background: #f8fafc; }

/* ---- BADGES ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-primary { background: #dbeafe; color: #1e40af; }
.badge-gray    { background: #f1f5f9; color: #475569; }

/* ---- ADMIN SIDEBAR ---- */
.admin-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: var(--primary);
    color: #fff;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
}
.sidebar-brand {
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
}
.sidebar-brand-name { font-size: 15px; font-weight: 700; line-height: 1.3; }
.sidebar-brand-sub  { font-size: 11px; opacity: 0.7; }
.sidebar-logo {
    width: 38px; height: 38px;
    background: var(--accent);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 20px;
}
.sidebar-nav { padding: 12px 0; flex: 1; }
.nav-section {
    padding: 14px 20px 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    opacity: 0.5;
}
.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 20px;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}
.nav-link:hover, .nav-link.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
    padding-left: 26px;
}
.nav-link .icon { font-size: 18px; width: 22px; text-align: center; }

.admin-main {
    margin-left: 260px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.admin-topbar {
    background: #fff;
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    position: sticky;
    top: 0;
    z-index: 99;
}
.admin-content { padding: 28px; flex: 1; }

.topbar-title { font-size: 20px; font-weight: 700; color: var(--primary); }
.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
}
.topbar-avatar {
    width: 36px; height: 36px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; font-weight: 700;
}

/* ---- DASHBOARD STATS ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-icon {
    width: 52px; height: 52px;
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}
.stat-info p { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.stat-info h3 { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1; margin-top: 2px; }

/* ---- STUDENT LOGIN PAGE ---- */
.student-login {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, #0f2548 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-box {
    background: #fff;
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo {
    text-align: center;
    margin-bottom: 30px;
}
.login-logo img { max-height: 70px; }
.login-logo h1 { font-size: 22px; color: var(--primary); font-weight: 800; margin-top: 10px; }
.login-logo p  { font-size: 13px; color: var(--text-muted); margin-top: 3px; }

/* ---- EXAM INTERFACE ---- */
.exam-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: #f0f4f8;
}
.exam-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.exam-topbar {
    background: var(--primary);
    color: #fff;
    padding: 0 20px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    gap: 16px;
}
.exam-title { font-size: 15px; font-weight: 700; }

.timer-box {
    background: rgba(255,255,255,0.15);
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 8px;
    padding: 6px 16px;
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 1px;
    font-family: monospace;
    min-width: 90px;
    text-align: center;
}
.timer-box.warning { background: rgba(245,158,11,0.3); border-color: var(--warning); color: #fef3c7; }
.timer-box.danger  { background: rgba(229,52,58,0.3);  border-color: var(--danger);  color: #fee2e2; animation: pulse 1s infinite; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.7} }

.exam-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}
.question-card {
    background: #fff;
    border-radius: 14px;
    padding: 28px;
    box-shadow: var(--shadow);
    max-width: 760px;
    margin: 0 auto;
}
.question-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
}
.question-number { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.question-marks {
    background: #dbeafe;
    color: #1e40af;
    padding: 3px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
}
.question-text {
    font-size: 17px;
    line-height: 1.7;
    color: var(--text);
    margin-bottom: 22px;
    font-weight: 500;
}
.question-image {
    max-width: 100%;
    max-height: 260px;
    border-radius: 8px;
    margin-bottom: 18px;
    display: block;
}

.options-list { list-style: none; display: flex; flex-direction: column; gap: 10px; }
.option-item label {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border: 2px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 15px;
}
.option-item label:hover { border-color: var(--primary-light); background: #f0f4fb; }
.option-item input[type=radio] { width: 18px; height: 18px; accent-color: var(--primary); flex-shrink: 0; }
.option-item.selected label { border-color: var(--primary); background: #e8eefb; font-weight: 600; }
.option-item.locked label  { cursor: not-allowed; opacity: 0.7; background: #f8fafc; }

.option-letter {
    width: 30px; height: 30px;
    background: var(--bg);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    flex-shrink: 0;
}
.selected .option-letter { background: var(--primary); color: #fff; }

.exam-actions {
    display: flex;
    gap: 10px;
    margin-top: 24px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}

/* ---- QUESTION NAVIGATION SIDEBAR ---- */
.question-nav {
    width: 230px;
    background: #fff;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}
.nav-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
}
.nav-grid { padding: 14px; display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.nav-btn {
    width: 34px; height: 34px;
    border: 2px solid var(--border);
    border-radius: 6px;
    background: #fff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.15s;
    color: var(--text-muted);
}
.nav-btn:hover      { border-color: var(--primary); color: var(--primary); }
.nav-btn.answered   { background: var(--success); border-color: var(--success); color: #fff; }
.nav-btn.locked     { background: #94a3b8; border-color: #94a3b8; color: #fff; }
.nav-btn.current    { border-color: var(--primary); color: var(--primary); font-weight: 800; box-shadow: 0 0 0 3px rgba(26,58,107,0.15); }
.nav-btn.skipped    { background: #fef3c7; border-color: var(--warning); color: #92400e; }

.nav-legend { padding: 14px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; }

.nav-stats { padding: 12px 14px; border-top: 1px solid var(--border); }
.nav-stat  { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; }
.nav-stat strong { font-weight: 700; }

/* ---- RESULT PAGE ---- */
.result-page {
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, #0f2548 100%);
    padding: 40px 20px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}
.result-card {
    background: #fff;
    border-radius: 20px;
    padding: 36px;
    max-width: 640px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.result-score {
    text-align: center;
    margin-bottom: 28px;
}
.score-circle {
    width: 140px; height: 140px;
    border-radius: 50%;
    margin: 0 auto 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 6px solid;
}
.score-circle.passed { border-color: var(--success); background: #d1fae5; color: #065f46; }
.score-circle.failed { border-color: var(--danger);  background: #fee2e2; color: #991b1b; }
.score-percent { font-size: 34px; font-weight: 800; line-height: 1; }
.score-label   { font-size: 12px; font-weight: 600; margin-top: 4px; }

.result-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}
.result-stat {
    background: var(--bg);
    border-radius: 10px;
    padding: 14px;
    text-align: center;
}
.result-stat .val { font-size: 24px; font-weight: 800; color: var(--text); }
.result-stat .lbl { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .sidebar.open { transform: translateX(0); }
    .admin-main { margin-left: 0; }
    .question-nav { display: none; }
    .question-nav.open { display: flex; position: fixed; top: 60px; right: 0; bottom: 0; z-index: 200; box-shadow: -4px 0 20px rgba(0,0,0,0.15); }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .admin-content { padding: 16px; }
    .exam-body { padding: 14px; }
    .question-card { padding: 18px; }
}
@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .result-stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ---- UTILITIES ---- */
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 12px; }
.justify-between { justify-content: space-between; }
.fw-bold { font-weight: 700; }
.text-danger  { color: var(--danger); }
.text-success { color: var(--success); }
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}
.page-header h2 { font-size: 22px; font-weight: 800; color: var(--primary); }
