:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #64748b;
    --secondary-hover: #475569;
    --bg-body: #f1f5f9;
    --bg-card: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;

    --sidebar-width: 280px;
    --header-height: 64px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Header */
.top-bar {
    height: var(--header-height);
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    z-index: 10;
}

.logo {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.badge {
    background: var(--primary);
    color: white;
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.exam-stats {
    display: flex;
    gap: 2rem;
    align-items: center;
    font-weight: 500;
}

.timer-box {
    font-variant-numeric: tabular-nums;
    background: #f8fafc;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.timer-box.warning {
    color: var(--danger);
    border-color: var(--danger);
    background-color: #fef2f2;
}

/* Main Layout */
.main-layout {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h3 {
    font-size: 0.875rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
}

.legend {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e2e8f0;
}

.dot.current {
    background: var(--primary);
}

.dot.answered {
    background: var(--success);
}

.dot.flagged {
    background: var(--warning);
}

.question-grid {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    align-content: start;
}

.grid-item {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    background: #f8fafc;
    color: var(--text-muted);
}

.grid-item:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.grid-item.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.grid-item.answered:not(.active) {
    background: #ecfdf5;
    border-color: var(--success);
    color: var(--success);
}

.grid-item.flagged {
    position: relative;
}

.grid-item.flagged::after {
    content: '';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--warning);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.875rem;
    color: var(--text-muted);
    text-align: center;
}

/* Question Area */
.question-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.question-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    margin-bottom: 2rem;
}

.question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.q-number {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    color: #cbd5e1;
    transition: color 0.2s;
}

.btn-icon:hover,
.btn-icon.active {
    color: var(--warning);
}

.q-text {
    font-size: 1.25rem;
    line-height: 1.6;
    margin-bottom: 2rem;
    font-weight: 500;
}

.q-image img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 2rem;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.option-item {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.option-item:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
}

.option-item.selected {
    background-color: #eff6ff;
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.option-radio {
    margin-right: 1rem;
    width: 20px;
    height: 20px;
}

.option-text {
    font-size: 1rem;
    line-height: 1.5;
}

/* Footer Controls */
.navigation-controls {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.btn {
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
}

.btn-secondary {
    background: white;
    border: 1px solid var(--border);
    color: var(--text-main);
}

.btn-secondary:hover:not(:disabled) {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-danger-outline {
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
}

.btn-danger-outline:hover {
    background: #fef2f2;
}

.hidden {
    display: none !important;
}

/* Results Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: white;
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
}

.score-circle {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 2rem;
}

.circular-chart {
    display: block;
    margin: 0 auto;
    max-width: 150px;
    max-height: 150px;
}

.circle-bg {
    fill: none;
    stroke: #eee;
    stroke-width: 3.8;
}

.circle {
    fill: none;
    stroke-width: 2.8;
    stroke-linecap: round;
    stroke: var(--primary);
    animation: progress 1s ease-out forwards;
}

@keyframes progress {
    0% {
        stroke-dasharray: 0 100;
    }
}

.percentage {
    fill: var(--text-main);
    font-family: sans-serif;
    font-weight: bold;
    font-size: 0.5em;
    text-anchor: middle;
}

.score-text {
    margin-top: 1rem;
    font-weight: 600;
    font-size: 1.25rem;
}

.results-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.result-item {
    padding: 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f8fafc;
}

.result-item.correct {
    border-left: 4px solid var(--success);
}

.result-item.incorrect {
    border-left: 4px solid var(--danger);
}

.res-q-text {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.res-explanation {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 4px;
}

.res-status {
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
}

.status-correct {
    color: var(--success);
    background: #ecfdf5;
}

.status-incorrect {
    color: var(--danger);
    background: #fef2f2;
}

.modal-footer {
    padding: 1rem;
    border-top: 1px solid var(--border);
    text-align: right;
}

/* Helper for result item options display */
.res-options {
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

.res-opt {
    padding: 2px 0;
}

.res-opt.is-correct {
    color: var(--success);
    font-weight: 600;
}

.res-opt.is-wrong {
    color: var(--danger);
    text-decoration: line-through;
}

/* Filters */
.filters {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.filter-btn {
    padding: 0.25rem 0.75rem;
    border-radius: 100px;
    border: 1px solid var(--border);
    background: white;
    font-size: 0.75rem;
    cursor: pointer;
}

.filter-btn.active {
    background: var(--text-main);
    color: white;
    border-color: var(--text-main);
}