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

:root {
    --bg-primary: #0f0f23;
    --bg-secondary: #1a1a2e;
    --bg-gradient: linear-gradient(135deg, #0f0f23 0%, #1a1a2e 50%, #16213e 100%);
    --text-primary: #f0f0f0;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --surface-glass: rgba(20, 20, 35, 0.85);
    --surface-elevated: rgba(31, 41, 55, 0.9);
    --surface-hover: rgba(55, 65, 81, 0.6);
    --accent-primary: #60a5fa;
    --accent-hover: #3b82f6;
    --accent-glow: rgba(96, 165, 250, 0.4);
    --accent-subtle: rgba(96, 165, 250, 0.1);
    --success: #34d399;
    --success-glow: rgba(52, 211, 153, 0.3);
    --error: #f87171;
    --error-glow: rgba(248, 113, 113, 0.3);
    --warning: #fbbf24;
    --border-subtle: rgba(75, 85, 99, 0.2);
    --border-medium: rgba(96, 165, 250, 0.15);
    --border-strong: rgba(96, 165, 250, 0.3);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4), 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 16px rgba(0, 0, 0, 0.5), 0 4px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.6), 0 10px 20px rgba(0, 0, 0, 0.5);
    --header-height: 76px;
    --footer-height: 92px;
    --border-radius-sm: 8px;
    --border-radius-md: 12px;
    --border-radius-lg: 16px;
    --border-radius-xl: 20px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* HEADER */
.app-header {
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    border-bottom: 1px solid var(--border-medium);
    background: var(--surface-glass);
    backdrop-filter: blur(20px);
    box-shadow: var(--shadow-sm);
    z-index: 100;
}

.header-left,
.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
    flex: 1;
}

.header-right {
    justify-content: flex-end;
}

.header-title {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-size: 1.125rem;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-primary));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-img {
    height: 60px;
    width: auto;
    object-fit: contain;
    display: block;
}

.header-center {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 0;
    background: transparent;
    border-radius: 0;
    border: none;
    flex: 1;
}

.timer-display {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
}

.timer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 8px;
    padding-left: 8px;
    border-left: 1px solid var(--border-subtle);
}

/* Collapsed timer: hide clock and pause, keep the Show button visible */
.timer-display.collapsed .timer-row {
    display: none;
}

.timer-display.collapsed .timer-actions {
    margin-left: 0;
    padding-left: 0;
    border-left: none;
}

.timer-display.collapsed .pause-timer-btn {
    display: none;
}

.timer-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.timer-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.timer-value {
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--accent-primary);
    min-width: 60px;
    text-align: center;
    text-shadow: 0 0 10px var(--accent-glow);
}

/* Compact, simple clock styling */
.timer-display .timer-row:first-child .timer-value {
    font-size: 1.375rem;
    letter-spacing: 0.5px;
}

.timer-display .timer-row:nth-child(2) .timer-label {
    font-size: 0.65rem;
    opacity: 0.7;
}

.timer-display .timer-row:nth-child(2) .timer-value {
    font-size: 0.95rem;
    color: var(--text-secondary);
    text-shadow: none;
}

.hide-timer-btn {
    display: inline-flex;
    align-items: center;
    height: 32px;
    background: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    padding: 0 10px;
    border-radius: var(--border-radius-sm);
}

.hide-timer-btn::before {
    content: none;
}

.hide-timer-btn:hover {
    color: var(--accent-primary);
    background: var(--surface-hover);
    border-color: var(--border-strong);
}

/* Pause button for question timer */
.pause-timer-btn {
    display: inline-flex;
    align-items: center;
    height: 32px;
    background: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    padding: 0 10px;
    border-radius: var(--border-radius-sm);
}

.pause-timer-btn:hover {
    color: var(--accent-primary);
    border-color: var(--border-strong);
    background: var(--surface-hover);
}

/* Pause button states and icons */
.pause-timer-btn::before {
    content: '⏸';
    display: inline-block;
    margin-right: 6px;
    font-size: 0.9rem;
}

.pause-timer-btn.is-paused::before {
    content: '▶';
}

.pause-timer-btn.is-paused {
    background: var(--accent-subtle);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

/* Visual cue for paused timer */
.timer-display.paused .timer-value {
    opacity: 0.7;
    text-shadow: none;
}

.icon-btn {
    background: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-primary);
    cursor: pointer;
    padding: 10px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.icon-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.filters {
    display: flex;
    gap: 12px;
}

.filters select {
    background: var(--surface-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    padding: 10px 16px;
    border-radius: var(--border-radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
    outline: none;
}

.filters select:hover {
    border-color: var(--border-strong);
    background: var(--surface-hover);
}

.filters select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

/* MAIN */
.split-pane {
    display: flex;
    flex: 1;
    overflow: hidden;
    gap: 1px;
    background: var(--border-subtle);
}

.question-pane {
    flex: 1;
    padding: 48px;
    overflow-y: auto;
    background: linear-gradient(180deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
    max-width: 50%;
}

.answer-pane {
    flex: 1;
    padding: 48px;
    overflow-y: auto;
    background: var(--bg-secondary);
    max-width: 50%;
}

.question-text {
    font-size: 1.25rem;
    line-height: 1.8;
    margin-bottom: 32px;
}

.question-image-container {
    margin-top: 24px;
}

.question-image-container img {
    max-width: 100%;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--border-medium);
}

/* ANSWER PANE */
.question-header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.question-meta-left,
.question-meta-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.question-number-badge {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
    color: white;
    width: 44px;
    height: 44px;
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 10px;
    border-radius: var(--border-radius-md);
    display: flex;
    transition: var(--transition-smooth);
}

.info-btn:hover {
    background: var(--surface-hover);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.mark-review-btn {
    background: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--border-radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition-smooth);
}

.mark-review-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    color: var(--text-primary);
}

.mark-review-btn.marked {
    color: var(--warning);
    border-color: var(--warning);
    background: rgba(251, 191, 36, 0.1);
}

.prompt-text {
    font-size: 1.125rem;
    margin-bottom: 24px;
    font-weight: 600;
}

.choices-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.choice-btn {
    display: flex;
    align-items: flex-start;
    padding: 20px 24px;
    background: var(--surface-glass);
    border: 2px solid var(--border-subtle);
    border-radius: var(--border-radius-lg);
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    transition: var(--transition-smooth);
    backdrop-filter: blur(10px);
}

.choice-btn:hover {
    border-color: var(--border-strong);
    background: var(--surface-elevated);
    transform: translateY(-2px);
}

.choice-btn.selected {
    border-color: var(--accent-primary);
    background: var(--accent-subtle);
    box-shadow: 0 0 0 4px var(--accent-subtle);
}

.choice-label {
    width: 36px;
    height: 36px;
    border: 2px solid var(--border-medium);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
    font-weight: 700;
    font-size: 1rem;
    flex-shrink: 0;
    background: var(--surface-elevated);
    transition: var(--transition-smooth);
}

.choice-btn.selected .choice-label {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.choice-content {
    font-size: 1.0625rem;
    line-height: 1.6;
    padding-top: 6px;
}

.choice-btn.correct {
    border-color: var(--success);
    background: rgba(52, 211, 153, 0.1);
}

.choice-btn.correct .choice-label {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.choice-btn.incorrect {
    border-color: var(--error);
    background: rgba(248, 113, 113, 0.1);
}

.choice-btn.incorrect .choice-label {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

.feedback-area {
    margin-top: 32px;
    padding: 24px;
    background: var(--surface-glass);
    border-radius: var(--border-radius-lg);
    border-left: 4px solid var(--accent-primary);
    backdrop-filter: blur(10px);
}

.feedback-status {
    font-weight: 700;
    font-size: 1.25rem;
    display: block;
    margin-bottom: 12px;
}

.feedback-status.correct {
    color: var(--success);
}

.feedback-status.incorrect {
    color: var(--error);
}

.explanation-text {
    line-height: 1.7;
    color: var(--text-secondary);
}

/* FOOTER */
.app-footer {
    height: var(--footer-height);
    border-top: 1px solid var(--border-medium);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    background: var(--surface-glass);
    backdrop-filter: blur(20px);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.3);
    z-index: 100;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 24px;
    min-width: 280px;
}

.question-counter {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.question-counter span {
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1rem;
}

.progress-indicator {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.progress-indicator span {
    color: var(--success);
    font-weight: 700;
    font-size: 1rem;
}

.stats-btn {
    background: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: var(--border-radius-md);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.stats-btn:hover {
    background: var(--surface-hover);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.footer-center {
    flex: 1;
    display: flex;
    justify-content: center;
}

.footer-right {
    display: flex;
    gap: 12px;
}

/* BUTTONS */
.primary-btn {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-hover));
    color: white;
    border: none;
    padding: 14px 32px;
    border-radius: var(--border-radius-md);
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px var(--accent-glow);
}

.secondary-btn {
    background: transparent;
    color: var(--accent-primary);
    border: 2px solid var(--accent-primary);
    padding: 12px 28px;
    border-radius: var(--border-radius-md);
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.secondary-btn:hover {
    background: var(--accent-subtle);
}

.nav-btn {
    background: var(--surface-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-subtle);
    padding: 14px 28px;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9375rem;
    transition: var(--transition-smooth);
}

.nav-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border-strong);
    transform: translateY(-1px);
}

.nav-btn:disabled {
    border-radius: var(--border-radius-xl);
    padding: 40px;
    max-width: 540px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    backdrop-filter: blur(20px);
}

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-wide {
    max-width: 800px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
}

.modal-header h2 {
    font-size: 1.75rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-primary));
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.modal-header .icon-btn {
    font-size: 1.5rem;
    padding: 8px;
    width: 36px;
    height: 36px;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 32px;
}

.stat-item,
.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius-md);
    transition: var(--transition-smooth);
}

.stat-item:hover,
.info-item:hover {
    border-color: var(--border-strong);
    transform: translateX(4px);
}

.stat-label,
.info-label {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.stat-value {
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent-primary);
    text-shadow: 0 0 10px var(--accent-glow);
}

.info-value {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-footer {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* QUESTION NAVIGATOR */
.nav-legend {
    display: flex;
    gap: 24px;
    margin-bottom: 24px;
    flex-wrap: wrap;
    padding: 16px;
    background: var(--surface-elevated);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-subtle);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.legend-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
}

.correct-icon {
    background: var(--success);
    color: white;
}

.incorrect-icon {
    background: var(--error);
    color: white;
}

.attempted-icon {
    background: var(--warning);
    color: white;
}

.review-icon {
    background: var(--surface-elevated);
    border: 2px solid var(--warning);
    font-size: 0.875rem;
}

.question-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 12px;
    max-height: 500px;
    overflow-y: auto;
    padding: 4px;
}

.question-grid-item {
    position: relative;
    aspect-ratio: 1;
    background: var(--surface-elevated);
    border: 2px solid var(--border-subtle);
    border-radius: var(--border-radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.125rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    color: var(--text-primary);
}

.question-grid-item:hover {
    border-color: var(--accent-primary);
    background: var(--surface-hover);
    transform: scale(1.05);
}

.question-grid-item.current {
    border: 3px solid var(--text-primary);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}

.question-grid-item.correct {
    background: var(--success);
    color: white;
}

.question-grid-item.incorrect {
    background: var(--error);
    color: white;
}

.question-grid-item.attempted {
    background: var(--warning);
    color: white;
}

.question-grid-item .status-icon {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}

.question-grid-item.correct .status-icon {
    color: var(--success);
}

.question-grid-item.incorrect .status-icon {
    color: var(--error);
}

.question-grid-item.attempted .status-icon {
    color: var(--warning);
}

.question-grid-item .review-marker {
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 0.875rem;
}

.hidden {
    display: none !important;
}

::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--surface-elevated);
    border-radius: 5px;
    border: 2px solid var(--bg-primary);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

@media (max-width: 768px) {
    .logo-img {
        height: 24px;
    }

    .split-pane {
        flex-direction: column;
        overflow-y: auto;
    }

    .question-pane,
    .answer-pane {
        max-width: 100%;
        padding: 24px;
    }

    .app-header,
    .app-footer {
        padding: 0 20px;
    }

    .modal-content {
        padding: 28px;
        max-width: 95%;
    }

    .modal-wide {
        max-width: 95%;
    }

    .question-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 8px;
        max-height: 400px;
    }
}

/* Question Header Info Elements */
.question-header-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.question-meta-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.question-meta-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.question-number-badge {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: 6px 12px;
    background: var(--surface-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--border-radius-sm);
}

.level-badge,
.difficulty-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: var(--border-radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.level-badge {
    background: rgba(96, 165, 250, 0.15);
    color: var(--accent-primary);
    border: 1px solid var(--border-medium);
}

.difficulty-badge {
    border: 1px solid var(--border-subtle);
}

.difficulty-badge.easy {
    background: rgba(52, 211, 153, 0.15);
    color: var(--success);
    border-color: var(--success);
}

.difficulty-badge.medium {
    background: rgba(251, 191, 36, 0.15);
    color: var(--warning);
    border-color: var(--warning);
}

.difficulty-badge.hard {
    background: rgba(248, 113, 113, 0.15);
    color: var(--error);
    border-color: var(--error);
}

.info-btn {
    background: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius-md);
    transition: var(--transition-smooth);
}

.info-btn:hover {
    background: var(--surface-hover);
    border-color: var(--border-medium);
    color: var(--accent-primary);
}

.stats-btn {
    background: var(--surface-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: var(--border-radius-md);
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 8px;
}

.stats-btn:hover {
    background: var(--surface-hover);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.stats-btn svg {
    flex-shrink: 0;
}

/* MODAL */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background: var(--surface-glass);
    border: 1px solid var(--border-medium);
    border-radius: var(--border-radius-xl);
    padding: 40px;
    max-width: 540px;
    width: 90%;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    backdrop-filter: blur(20px);
}

.nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}