/* ===== CSS Variables ===== */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #ede9fe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 40px rgba(0,0,0,0.15);
    --radius: 12px;
    --radius-pill: 9999px;
}

/* ===== Reset & Base ===== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
}

/* ===== Utilities ===== */
.hidden {
    display: none !important;
}

/* ===== Offline Banner ===== */
.offline-banner {
    background: var(--warning-light);
    color: #92400e;
    padding: 0.625rem 1rem;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-bottom: 1px solid #fbbf24;
}

/* ===== Header ===== */
.app-header {
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    color: white;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1.25rem;
}

.logo-icon {
    font-size: 1.5rem;
}

.main-nav {
    display: none;
}

.nav-link {
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    opacity: 0.8;
    transition: all 0.2s;
}

.nav-link:hover,
.nav-link.active {
    opacity: 1;
    background: rgba(255,255,255,0.15);
}

.streak-badge {
    background: rgba(255,255,255,0.2);
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-pill);
    font-size: 0.875rem;
    font-weight: 600;
}

/* ===== Hero ===== */
.hero {
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    color: white;
    padding: 3rem 1.5rem;
    text-align: center;
}

.hero h1 {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    line-height: 1.2;
}

.hero p {
    opacity: 0.9;
    margin-bottom: 1.5rem;
    font-size: 1.05rem;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.875rem 2rem;
    border-radius: var(--radius-pill);
    font-weight: 600;
    border: none;
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 1rem;
}

.btn:active {
    transform: scale(0.98);
}

.btn-white {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow);
}

.btn-white:hover {
    box-shadow: var(--shadow-lg);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    color: white;
    width: 100%;
}

/* ===== Search Section ===== */
.search-section {
    padding: 1rem;
    background: white;
    border-bottom: 1px solid var(--border);
}

.search-bar {
    display: flex;
    align-items: center;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 0.75rem 1rem;
    gap: 0.5rem;
    transition: border-color 0.2s;
}

.search-bar:focus-within {
    border-color: var(--primary);
}

.search-icon {
    opacity: 0.5;
}

.search-bar input {
    border: none;
    background: none;
    flex: 1;
    font-size: 1rem;
    outline: none;
    color: var(--text);
}

.search-bar input::placeholder {
    color: var(--text-light);
}

/* ===== Section Titles ===== */
.section-title {
    font-size: 1.125rem;
    font-weight: 700;
    padding: 1.25rem 1rem 0.75rem;
    color: var(--text);
}

/* ===== History Section ===== */
.history-section {
    background: white;
    margin-bottom: 0.5rem;
    padding-bottom: 1rem;
}

.history-list {
    padding: 0 1rem;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.875rem 0;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: opacity 0.2s;
}

.history-item:last-child {
    border-bottom: none;
}

.history-item:hover {
    opacity: 0.7;
}

.history-info h4 {
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.history-info p {
    font-size: 0.8rem;
    color: var(--text-light);
}

.history-score {
    font-weight: 700;
    color: var(--success);
    font-size: 1rem;
}

/* ===== Categories ===== */
.categories-section {
    background: white;
    margin-bottom: 0.5rem;
    padding-bottom: 1rem;
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    padding: 0 1rem;
}

.category-pill {
    padding: 0.5rem;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: var(--radius-pill);
    font-size: 0.85rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}

.category-pill:hover {
    border-color: var(--primary);
}

.category-pill.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* ===== Quizzes Grid ===== */
.quizzes-section {
    background: white;
    padding-bottom: 1.5rem;
}

.quizzes-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 0 1rem;
}

/* ===== Quiz Cards ===== */
.quiz-card {
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.quiz-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.quiz-card-image {
    height: 120px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
}

.quiz-card-content {
    padding: 1rem;
}

.quiz-card h3 {
    font-size: 1rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.quiz-card-meta {
    display: flex;
    gap: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-light);
    flex-wrap: wrap;
}

.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-pill);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-easy { background: var(--success); color: white; }
.badge-medium { background: var(--warning); color: white; }
.badge-hard { background: var(--danger); color: white; }

/* ===== Daily Challenge ===== */
.daily-challenge {
    background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
    color: white;
    padding: 1.5rem;
    margin: 1rem;
    border-radius: var(--radius);
}

.daily-badge {
    display: inline-block;
    background: rgba(255,255,255,0.2);
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    margin-bottom: 0.75rem;
}

.daily-challenge h3 {
    font-size: 1.25rem;
    margin-bottom: 0.5rem;
}

.daily-challenge p {
    opacity: 0.9;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

/* ===== Footer ===== */
.app-footer {
    background: var(--text);
    color: var(--text-light);
    padding: 2rem 1rem;
    text-align: center;
    font-size: 0.875rem;
}

.footer-links {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1rem;
}

.footer-links a:hover {
    color: white;
}

/* ===== Tablet Styles ===== */
@media (min-width: 768px) {
    .main-nav {
        display: flex;
        gap: 0.5rem;
    }
    
    .hero {
        padding: 4rem 2rem;
    }
    
    .hero h1 {
        font-size: 2.5rem;
    }
    
    .categories-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .quizzes-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .daily-challenge {
        margin: 1.5rem;
        padding: 2rem;
    }
}

/* ===== Desktop Styles ===== */
@media (min-width: 1024px) {
    .quizzes-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .search-section,
    .categories-section,
    .quizzes-section,
    .history-section {
        max-width: 1200px;
        margin-left: auto;
        margin-right: auto;
    }
}

/* ===== Animation ===== */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.quiz-card {
    animation: fadeIn 0.3s ease-out;
}
