/* ===========================
   CSS VARIABLES & RESET
   =========================== */

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

:root {
    --primary: #8b5cf6;
    --primary-dark: #7c3aed;
    --secondary: #10b981;
    --success: #10b981;
    --warning: #f59e0b;
    --error: #ef4444;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-card: #ffffff;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --border: #e5e7eb;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-lg: rgba(0, 0, 0, 0.15);
    --accent: #8b5cf6;
    --navbar-bg: #ffffff;
    --gradient: linear-gradient(135deg, #8b5cf6 0%, #10b981 100%);
    --code-bg: #1e1e1e;
    --code-text: #d4d4d4;
    --easy: #3fa34d;
    --medium: #f0a500;
    --hard: #d62828;
}

[data-theme="dark"] {
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-card: #1f2937;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --border: #374151;
    --shadow: rgba(0, 0, 0, 0.3);
    --shadow-lg: rgba(0, 0, 0, 0.5);
    --navbar-bg: #111827;
    --code-bg: #0f172a;
    --code-text: #cbd5e1;
    --easy: #34d399;
    --medium: #fbbf24;
    --hard: #f87171;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    min-height: 100vh;
}

/* ===========================
   HERO SECTION
   =========================== */

.hero {
    background: var(--gradient);
    padding: 4rem 2rem;
    text-align: center;
    color: white;
    position: relative;
    overflow: hidden;
    border-bottom: 2px solid var(--border);
}

.hero-content {
    position: relative;
    z-index: 1;
    max-width: 800px;
    margin: 0 auto;
}

.hero-h1 {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.hero-para {
    font-size: 1.25rem;
    margin-bottom: 2rem;
    opacity: 0.9;
}

.hero-stats {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.hero-stats span {
    background: rgba(255, 255, 255, 0.2);
    padding: 8px 20px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 8px;
    backdrop-filter: blur(10px);
}

[data-theme="dark"] .hero {
    background: linear-gradient(to right, #111827, #1f2937);
}

[data-theme="dark"] .hero-para {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

[data-theme="dark"] .hero-h1 {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

[data-theme="dark"] .hero-stats span {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    border: 1px solid #7c3aed;
}

/* ===========================
   MAIN CONTAINER
   =========================== */

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* ===========================
   STATS BAR
   =========================== */

.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: var(--bg-card);
    border-radius: 16px;
    border: 2px solid var(--border);
    box-shadow: 0 4px 20px var(--shadow);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 12px;
    transition: transform 0.3s ease;
}

.stat-item:hover {
    transform: translateY(-2px);
}

.stat-item i {
    font-size: 2rem;
    color: var(--primary);
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 800;
    display: block;
    color: var(--primary);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===========================
   PANELS
   =========================== */

.panel {
    background: var(--bg-card);
    border-radius: 16px;
    overflow: hidden;
    border: 2px solid var(--border);
    margin-bottom: 2rem;
    transition: transform 0.3s ease;
    box-shadow: 0 4px 20px var(--shadow);
}

.panel:hover {
    transform: translateY(-2px);
}

.panel-header {
    padding: 1.25rem 1.5rem;
    background: rgba(139, 92, 246, 0.1);
    border-bottom: 2px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.panel-header span {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
}

.difficulty-badge {
    padding: 0.375rem 1rem;
    border-radius: 50px;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.difficulty-badge.easy {
    background: var(--easy);
    color: white;
}

.difficulty-badge.medium {
    background: var(--medium);
    color: white;
}

.difficulty-badge.hard {
    background: var(--hard);
    color: white;
}

/* ===========================
   SQL BLOCK
   =========================== */

.sql-block {
    background: var(--code-bg);
    color: var(--code-text);
    padding: 1.5rem;
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre-wrap;
    margin: 1.5rem;
    border-radius: 12px;
    border: 1px solid var(--border);
}

/* ===========================
   TABLES
   =========================== */

.table-container {
    margin: 1.5rem;
    overflow-x: auto;
}

.sql-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-secondary);
    border-radius: 12px;
    overflow: hidden;
}

.sql-table th {
    background: rgba(139, 92, 246, 0.15);
    color: var(--text-primary);
    padding: 1rem;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid var(--border);
}

.sql-table td {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.sql-table tr:last-child td {
    border-bottom: none;
}

.sql-table tr:hover {
    background: rgba(139, 92, 246, 0.05);
}

/* ===========================
   OPTIONS GRID
   =========================== */

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem;
}

.option-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.option-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--shadow);
}

.option-card.selected {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.option-card.correct {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.15);
}

.option-card.wrong {
    border-color: var(--error);
    background: rgba(239, 68, 68, 0.15);
}

/* ===========================
   FEEDBACK PANEL
   =========================== */

.feedback-panel {
    animation: slideUp 0.5s ease;
}

.result-container {
    padding: 2rem;
    text-align: center;
    border-bottom: 2px solid var(--border);
}

.result-message {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    color: var(--success);
}

.result-message.error {
    color: var(--error);
}

.xp-earned {
    font-size: 1.25rem;
    color: var(--primary);
    font-weight: 600;
}

.explanation-section {
    padding: 2rem;
}

.explanation-section h4 {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.step {
    margin-bottom: 1rem;
    padding: 1rem 1.25rem;
    background: var(--bg-secondary);
    border-radius: 10px;
    border-left: 4px solid var(--primary);
    animation: fadeIn 0.5s ease;
}

.step:last-child {
    margin-bottom: 0;
}

/* ===========================
   ACTION BUTTONS
   =========================== */

.action-buttons {
    padding: 1.5rem;
    border-top: 2px solid var(--border);
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.action-buttons button {
    padding: 0.875rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
    overflow: hidden;
}

.btn-submit {
    background: var(--gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
}

.btn-next {
    background: var(--gradient);
    color: white;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

.btn-next:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.6);
}

/* ===========================
   NOTIFICATION
   =========================== */

.notification {
    position: fixed;
    top: 100px;
    right: 20px;
    padding: 16px 24px;
    background: var(--gradient);
    color: white;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
    transform: translateX(400px);
    transition: transform 0.4s ease;
    z-index: 1000;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
}

.notification.show {
    transform: translateX(0);
}

.notification.error {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.notification.success {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.notification.warning {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
}

/* ===========================
   ANIMATIONS
   =========================== */

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

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

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

/* ===========================
   RESPONSIVE DESIGN
   =========================== */

@media (max-width: 1024px) {
    .options-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-bar {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .hero-h1 {
        font-size: 2rem;
        flex-direction: column;
        gap: 0.5rem;
    }

    .hero-para {
        font-size: 1rem;
    }

    .hero-stats {
        gap: 1rem;
    }

    .hero-stats span {
        padding: 6px 15px;
        font-size: 0.9rem;
    }

    .container {
        padding: 1.5rem 1rem;
    }

    .stats-bar {
        grid-template-columns: 1fr;
        padding: 1rem;
        gap: 1rem;
    }

    .stat-item {
        padding: 0.75rem;
    }

    .panel-header {
        padding: 1rem;
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .sql-block {
        margin: 1rem;
        padding: 1rem;
        font-size: 0.875rem;
    }

    .table-container {
        margin: 1rem;
        overflow-x: auto;
    }

    .sql-table th,
    .sql-table td {
        padding: 0.75rem;
        font-size: 0.875rem;
    }

    .options-grid {
        padding: 1rem;
        gap: 1rem;
    }

    .option-card {
        padding: 1rem;
    }

    .result-container {
        padding: 1.5rem;
    }

    .result-message {
        font-size: 1.25rem;
    }

    .explanation-section {
        padding: 1.5rem;
    }

    .action-buttons {
        padding: 1rem;
        flex-direction: column;
    }

    .action-buttons button {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 2rem 1rem;
    }

    .hero-h1 {
        font-size: 1.75rem;
    }

    .container {
        padding: 1rem;
    }

    .sql-table {
        font-size: 0.8125rem;
    }

    .sql-table th,
    .sql-table td {
        padding: 0.5rem;
    }

    .option-card table {
        font-size: 0.8125rem;
    }

    .notification {
        left: 10px;
        right: 10px;
        width: calc(100% - 20px);
        transform: translateY(-100px);
        top: 80px;
    }

    .notification.show {
        transform: translateY(0);
    }
}