/* ═══════════════════════════════════════════════════════════════
   AdaptiveQuiz — Glassmorphic Design System
   ═══════════════════════════════════════════════════════════════ */

:root {
    --primary: #6c5ce7;
    --primary-light: #a29bfe;
    --secondary: #00cec9;
    --accent: #fd79a8;
    --success: #00b894;
    --warning: #fdcb6e;
    --danger: #d63031;
    --dark: #0a0a1a;
    --darker: #06060f;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.7);
    --text-muted: rgba(255, 255, 255, 0.4);
    --radius: 16px;
    --radius-sm: 10px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--dark);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Animated gradient background */
body::before {
    content: '';
    position: fixed;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: radial-gradient(circle at 20% 50%, rgba(108, 92, 231, 0.15) 0%, transparent 50%),
                radial-gradient(circle at 80% 20%, rgba(0, 206, 201, 0.1) 0%, transparent 50%),
                radial-gradient(circle at 40% 80%, rgba(253, 121, 168, 0.08) 0%, transparent 50%);
    animation: bgShift 20s ease-in-out infinite;
    z-index: -1;
}

@keyframes bgShift {
    0%, 100% { transform: translate(0, 0); }
    50% { transform: translate(-2%, 2%); }
}

/* ── Typography ───────────────────────────────────────────── */
h1 { font-size: 2.5rem; font-weight: 800; letter-spacing: -0.02em; }
h2 { font-size: 1.75rem; font-weight: 700; }
h3 { font-size: 1.25rem; font-weight: 600; }
a { color: var(--primary-light); text-decoration: none; transition: 0.2s; }
a:hover { color: var(--secondary); }

/* ── Loading Overlay ──────────────────────────────────────── */
.loading-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(6, 6, 15, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-content {
    text-align: center;
    padding: 3rem 4rem;
    max-width: 420px;
}

.loading-spinner {
    width: 56px; height: 56px;
    margin: 0 auto;
    border: 4px solid rgba(108, 92, 231, 0.2);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.loading-dots span {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--primary-light);
    animation: dotPulse 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes dotPulse {
    0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1.2); }
}

/* ── Glass Card ───────────────────────────────────────────── */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.glass-sm {
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    padding: 1.25rem;
}

/* ── Navbar ───────────────────────────────────────────────── */
.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 2rem;
    background: rgba(10, 10, 26, 0.8);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-brand {
    font-size: 1.4rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-links { display: flex; gap: 0.5rem; align-items: center; }

.nav-link {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: 0.3s;
}

.nav-link:hover, .nav-link.active {
    background: rgba(108, 92, 231, 0.2);
    color: var(--text-primary);
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: white;
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.4);
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.6);
    color: white;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.btn-success {
    background: linear-gradient(135deg, var(--success), #00b09b);
    color: white;
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #e17055);
    color: white;
}

.btn-outline {
    background: transparent;
    color: var(--primary-light);
    border: 1px solid var(--primary-light);
}
.btn-outline:hover {
    background: var(--primary);
    color: white;
}

.btn-lg { padding: 1rem 2rem; font-size: 1.1rem; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

/* ── Form Controls ────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }

.form-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-control {
    width: 100%;
    padding: 0.8rem 1rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: 0.3s;
    outline: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.2);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

select.form-control option { background: #1a1a2e; color: white; }

textarea.form-control { resize: vertical; min-height: 120px; }

/* ── Alerts / Flash ───────────────────────────────────────── */
.alert {
    padding: 0.8rem 1.2rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.alert-success { background: rgba(0, 184, 148, 0.15); border: 1px solid rgba(0, 184, 148, 0.3); color: #55efc4; }
.alert-danger { background: rgba(214, 48, 49, 0.15); border: 1px solid rgba(214, 48, 49, 0.3); color: #ff7675; }
.alert-warning { background: rgba(253, 203, 110, 0.15); border: 1px solid rgba(253, 203, 110, 0.3); color: #ffeaa7; }
.alert-info { background: rgba(0, 206, 201, 0.15); border: 1px solid rgba(0, 206, 201, 0.3); color: #81ecec; }

/* ── Layout ───────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 2rem; }
.container-sm { max-width: 500px; margin: 0 auto; padding: 2rem; }
.container-md { max-width: 800px; margin: 0 auto; padding: 2rem; }

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1.5rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.5rem; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col { display: flex; flex-direction: column; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.gap-3 { gap: 1.5rem; }

.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-gradient {
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

/* ── Stat Cards ───────────────────────────────────────────── */
.stat-card {
    text-align: center;
    padding: 1.5rem;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Badge ────────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-primary { background: rgba(108, 92, 231, 0.2); color: var(--primary-light); }
.badge-success { background: rgba(0, 184, 148, 0.2); color: #55efc4; }
.badge-danger { background: rgba(214, 48, 49, 0.2); color: #ff7675; }
.badge-warning { background: rgba(253, 203, 110, 0.2); color: #ffeaa7; }

/* ── Progress Bar ─────────────────────────────────────────── */
.progress {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.5s ease;
}

/* ── Quiz Options ─────────────────────────────────────────── */
.option-card {
    padding: 1rem 1.25rem;
    border: 2px solid var(--glass-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.option-card:hover {
    border-color: var(--primary);
    background: rgba(108, 92, 231, 0.1);
}

.option-card.selected {
    border-color: var(--primary);
    background: rgba(108, 92, 231, 0.15);
}

.option-card.correct {
    border-color: var(--success);
    background: rgba(0, 184, 148, 0.15);
}

.option-card.wrong {
    border-color: var(--danger);
    background: rgba(214, 48, 49, 0.15);
}

.option-key {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}

/* ── Flashcards ───────────────────────────────────────────── */
.flip-card {
    perspective: 1000px;
    cursor: pointer;
    height: 180px;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flip-card.flipped .flip-card-inner { transform: rotateY(180deg); }

.flip-card-front, .flip-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    text-align: center;
}

.flip-card-front {
    background: linear-gradient(135deg, rgba(108, 92, 231, 0.2), rgba(0, 206, 201, 0.1));
    border: 1px solid var(--glass-border);
}

.flip-card-back {
    background: linear-gradient(135deg, rgba(0, 206, 201, 0.2), rgba(253, 121, 168, 0.1));
    border: 1px solid var(--glass-border);
    transform: rotateY(180deg);
}

/* ── Source type selector ─────────────────────────────────── */
.source-tabs { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 1.5rem; }

.source-tab {
    padding: 0.6rem 1.2rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--glass-border);
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: 0.3s;
}

.source-tab.active, .source-tab:hover {
    background: rgba(108, 92, 231, 0.2);
    border-color: var(--primary);
    color: var(--text-primary);
}

.source-panel { display: none; }
.source-panel.active { display: block; }

/* ── Mastery bar ──────────────────────────────────────────── */
.mastery-item { margin-bottom: 1rem; }
.mastery-label { display: flex; justify-content: space-between; margin-bottom: 0.4rem; font-size: 0.85rem; }

/* ── Answer review card ───────────────────────────────────── */
.answer-card {
    padding: 1.25rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    border-left: 4px solid;
}

.answer-card.correct { border-color: var(--success); background: rgba(0, 184, 148, 0.05); }
.answer-card.wrong { border-color: var(--danger); background: rgba(214, 48, 49, 0.05); }

/* ── Landing Hero ─────────────────────────────────────────── */
.hero {
    text-align: center;
    padding: 6rem 2rem 4rem;
    position: relative;
}

.hero h1 { font-size: 3.5rem; line-height: 1.1; margin-bottom: 1.5rem; }
.hero p { font-size: 1.2rem; color: var(--text-secondary); max-width: 600px; margin: 0 auto 2rem; }

.hero-badge {
    display: inline-block;
    padding: 0.4rem 1rem;
    background: rgba(108, 92, 231, 0.15);
    border: 1px solid rgba(108, 92, 231, 0.3);
    border-radius: 999px;
    font-size: 0.85rem;
    color: var(--primary-light);
    margin-bottom: 1.5rem;
}

/* ── Feature Grid ─────────────────────────────────────────── */
.feature-card {
    padding: 2rem;
    text-align: center;
    transition: transform 0.3s, box-shadow 0.3s;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.feature-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.feature-card h3 { margin-bottom: 0.5rem; }
.feature-card p { color: var(--text-secondary); font-size: 0.9rem; }

/* ── Tech Stack ───────────────────────────────────────────── */
.tech-stack {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    padding: 2rem 0;
}

.tech-item {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.tech-item span { display: block; font-size: 1.8rem; margin-bottom: 0.25rem; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .hero h1 { font-size: 2.2rem; }
    .navbar { flex-direction: column; gap: 0.5rem; }
    .nav-links { flex-wrap: wrap; justify-content: center; }
    .container { padding: 1rem; }
}

/* ── Animations ───────────────────────────────────────────── */
.fade-in {
    animation: fadeIn 0.5s ease;
}

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

.pulse { animation: pulse 2s infinite; }
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--darker); }
::-webkit-scrollbar-thumb {
    background: rgba(108, 92, 231, 0.4);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--primary); }
