/**
 * Exam Platform - Complete Design System
 * Mobile-first, modern, accessible
 * Version: 1.0
 */

/* ============================================
   CSS RESET & BASE
   ============================================ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

/* ============================================
   CSS VARIABLES - DESIGN TOKENS
   ============================================ */
:root {
    /* Colors - Light Mode */
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --bg-code: #1e293b;
    --bg-hero: linear-gradient(135deg, #667eea 0%, #764ba2 100%);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --text-inverse: #ffffff;

    --accent-primary: #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: #e0e7ff;

    --success: #10b981;
    --success-light: #d1fae5;
    --success-dark: #059669;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --error: #ef4444;
    --error-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #dbeafe;

    --border: #e2e8f0;
    --border-light: #f1f5f9;
    --border-focus: #6366f1;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', 'SF Mono', Consolas, monospace;

    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;

    --leading-tight: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.75;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* Layout */
    --header-height: 60px;
    --container-max: 1200px;
    --sidebar-width: 280px;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.2s ease;
    --transition-slow: 0.3s ease;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-code: #0d1117;
    --bg-hero: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);

    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent-primary: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-light: #312e81;

    --border: #334155;
    --border-light: #1e293b;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.5);
}

/* ============================================
   BASE STYLES
   ============================================ */
body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-relaxed);
    color: var(--text-primary);
    background: var(--bg-secondary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-hover);
}

img {
    max-width: 100%;
    height: auto;
}

/* ============================================
   LAYOUT - CONTAINERS
   ============================================ */
.exam-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.container {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-4);
}

@media (min-width: 768px) {
    .container {
        padding: 0 var(--space-6);
    }
}

.main-content {
    flex: 1;
    padding-top: var(--header-height);
}

/* ============================================
   HEADER
   ============================================ */
.exam-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    z-index: 100;
}

.exam-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Logo */
.logo {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-weight: 700;
    font-size: var(--text-lg);
    color: var(--text-primary);
    text-decoration: none;
}

.logo:hover {
    color: var(--text-primary);
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: var(--bg-hero);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: var(--text-sm);
}

.logo-img {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: white;
    padding: 2px;
}

.logo-text {
    display: none;
}

@media (min-width: 480px) {
    .logo-text {
        display: inline;
    }
}

/* Mobile Menu Button */
.menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.menu-btn:hover {
    background: var(--bg-tertiary);
}

@media (min-width: 768px) {
    .menu-btn {
        display: none;
    }
}

/* Header Navigation */
.header-nav {
    display: none;
    align-items: center;
    gap: var(--space-6);
}

@media (min-width: 768px) {
    .header-nav {
        display: flex;
    }
}

.header-nav a {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    transition: color var(--transition-fast);
}

.header-nav a:hover {
    color: var(--text-primary);
}

/* Theme Toggle */
.theme-toggle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    z-index: 100;
}

.theme-toggle:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Theme icons - stack on top of each other */
.theme-toggle svg {
    position: absolute;
    transition: opacity var(--transition-fast);
}

/* Theme icon visibility - Light mode: show sun, hide moon */
.theme-icon-sun {
    opacity: 1;
}

.theme-icon-moon {
    opacity: 0;
}

/* Dark mode: show moon, hide sun */
[data-theme="dark"] .theme-icon-sun {
    opacity: 0;
}

[data-theme="dark"] .theme-icon-moon {
    opacity: 1;
}

/* Dark mode: fix SVG diagrams visibility */
[data-theme="dark"] .question-diagram svg {
    filter: invert(1) hue-rotate(180deg);
}

/* ============================================
   HERO SECTION
   ============================================ */
.hero {
    background: var(--bg-hero);
    padding: var(--space-12) 0;
    text-align: center;
    color: white;
}

.hero-title {
    font-size: var(--text-3xl);
    font-weight: 700;
    margin-bottom: var(--space-4);
    line-height: var(--leading-tight);
}

@media (min-width: 768px) {
    .hero-title {
        font-size: var(--text-4xl);
    }
}

.hero-subtitle {
    font-size: var(--text-lg);
    opacity: 0.9;
    max-width: 600px;
    margin: 0 auto;
}

/* ============================================
   BREADCRUMB
   ============================================ */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-muted);
    padding: var(--space-4) 0;
    flex-wrap: wrap;
}

.breadcrumb a {
    color: var(--text-muted);
}

.breadcrumb a:hover {
    color: var(--accent-primary);
}

.breadcrumb-separator {
    color: var(--border);
}

.breadcrumb-current {
    color: var(--text-secondary);
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    transition: all var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-clickable {
    cursor: pointer;
    text-decoration: none;
    display: block;
    color: inherit;
}

.card-clickable:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* Board Card */
.board-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: var(--space-8);
}

.board-card-icon {
    width: 64px;
    height: 64px;
    background: var(--accent-light);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: var(--space-4);
}

.board-card-icon svg {
    width: 32px;
    height: 32px;
    color: var(--accent-primary);
}

.board-card-title {
    font-size: var(--text-xl);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.board-card-subtitle {
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-4);
}

.board-card-meta {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.board-card-badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-3);
    background: var(--success-light);
    color: var(--success-dark);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 500;
}

.board-card-badge.coming-soon {
    background: var(--bg-tertiary);
    color: var(--text-muted);
}

/* Practice Set Card */
.set-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.set-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.set-card-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
}

.set-card-badge {
    font-size: var(--text-xs);
    font-weight: 500;
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    background: var(--accent-light);
    color: var(--accent-primary);
}

.set-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.set-card-meta-item {
    display: flex;
    align-items: center;
    gap: var(--space-1);
}

.set-card-meta-item svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

/* Difficulty Indicator */
.difficulty-bar {
    display: flex;
    gap: 2px;
    align-items: center;
}

.difficulty-bar span {
    width: 20px;
    height: 6px;
    background: var(--border);
    border-radius: 2px;
}

.difficulty-bar.easy span:nth-child(-n+2) {
    background: var(--success);
}

.difficulty-bar.medium span:nth-child(-n+3) {
    background: var(--warning);
}

.difficulty-bar.hard span:nth-child(-n+4) {
    background: var(--error);
}

.difficulty-bar.hard span:nth-child(5) {
    background: var(--error);
}

/* ============================================
   GRID LAYOUTS
   ============================================ */
.grid {
    display: grid;
    gap: var(--space-6);
}

.grid-2 {
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

.grid-3 {
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 992px) {
    .grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-xs);
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--text-base);
}

.btn-primary {
    background: var(--accent-primary);
    color: var(--text-inverse);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--bg-tertiary);
    border-color: var(--border-focus);
}

.btn-success {
    background: var(--success);
    color: var(--text-inverse);
}

.btn-success:hover:not(:disabled) {
    background: var(--success-dark);
}

.btn-warning {
    background: var(--warning);
    color: var(--text-inverse);
}

.btn-warning:hover:not(:disabled) {
    background: #d97706;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-block {
    width: 100%;
}

/* ============================================
   AD SLOTS
   ============================================ */
.ad-slot {
    margin: var(--space-6) 0;
    text-align: center;
    min-height: 50px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ad-slot-header {
    margin-top: var(--space-4);
}

.ad-slot-footer {
    margin-bottom: var(--space-4);
}

.ad-slot-sidebar {
    display: none;
    min-height: 250px;
}

@media (min-width: 992px) {
    .ad-slot-sidebar {
        display: flex;
    }
}

.ad-slot-sticky {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 90;
    margin: 0;
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    padding: var(--space-2);
    min-height: auto;
}

@media (min-width: 992px) {
    .ad-slot-sticky {
        display: none;
    }
}

/* ============================================
   FOOTER
   ============================================ */
.exam-footer {
    background: var(--bg-primary);
    border-top: 1px solid var(--border);
    padding: var(--space-8) 0;
    margin-top: auto;
}

.footer-content {
    text-align: center;
    color: var(--text-muted);
    font-size: var(--text-sm);
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: var(--space-6);
    margin-top: var(--space-4);
    flex-wrap: wrap;
}

.footer-links a {
    color: var(--text-muted);
}

.footer-links a:hover {
    color: var(--accent-primary);
}

/* ============================================
   SECTION TITLES
   ============================================ */
.section-title {
    font-size: var(--text-2xl);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-6);
}

.section-subtitle {
    font-size: var(--text-base);
    color: var(--text-secondary);
    margin-top: calc(var(--space-2) * -1);
    margin-bottom: var(--space-6);
}

/* ============================================
   PAGE SECTIONS
   ============================================ */
.page-section {
    padding: var(--space-8) 0;
}

@media (min-width: 768px) {
    .page-section {
        padding: var(--space-12) 0;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-error { color: var(--error); }

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }

.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }

.hidden { display: none !important; }

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Hide on mobile */
.hide-mobile {
    display: none;
}

@media (min-width: 768px) {
    .hide-mobile {
        display: block;
    }
}

/* Hide on desktop */
.hide-desktop {
    display: block;
}

@media (min-width: 768px) {
    .hide-desktop {
        display: none;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.animate-fade-in {
    animation: fadeIn 0.3s ease;
}

.animate-slide-up {
    animation: slideUp 0.3s ease;
}

.animate-pulse {
    animation: pulse 2s infinite;
}

/* ============================================
   MOBILE OVERLAY
   ============================================ */
.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
    z-index: 90;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   MOBILE MENU
   ============================================ */
.mobile-menu {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: var(--bg-primary);
    transform: translateX(100%);
    transition: transform var(--transition-normal);
    z-index: 100;
    padding: var(--space-6);
    overflow-y: auto;
}

.mobile-menu.open {
    transform: translateX(0);
}

.mobile-menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border);
}

.mobile-menu-nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.mobile-menu-nav a {
    padding: var(--space-3) var(--space-4);
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.mobile-menu-nav a:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ============================================
   BACK LINK
   ============================================ */
.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-muted);
    margin-bottom: var(--space-4);
}

.back-link:hover {
    color: var(--accent-primary);
}

.back-link svg {
    width: 16px;
    height: 16px;
}
