/* ============================================
   English Learning App - Main Stylesheet v2
   Light theme, modern, polished, mobile-first
   ============================================ */

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

:root {
    --blue: #4A90D9;
    --blue-dark: #2E6FB8;
    --blue-light: #EBF4FF;
    --blue-soft: #F0F7FF;
    --purple: #8B5CF6;
    --purple-light: #F3EEFF;
    --green: #10B981;
    --green-light: #D1FAE5;
    --red: #EF4444;
    --red-light: #FEE2E2;
    --orange: #F59E0B;
    --orange-light: #FEF3C7;
    --yellow: #B7791F;
    --yellow-light: #FEF9E7;
    --pink: #EC4899;
    --pink-light: #FCE7F3;
    --text: #1F2937;
    --text-muted: #6B7280;
    --text-light: #9CA3AF;
    --border: #E5E7EB;
    --border-light: #F3F4F6;
    --bg: #F9FAFB;
    --bg-blue: linear-gradient(135deg, #EBF4FF 0%, #F0F7FF 100%);
    --bg-hero: linear-gradient(135deg, #4A90D9 0%, #8B5CF6 100%);
    --white: #FFFFFF;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow: 0 4px 14px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 32px rgba(74,144,217,0.12), 0 4px 12px rgba(0,0,0,0.04);
    --shadow-hover: 0 12px 36px rgba(74,144,217,0.18);
    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Accessibility: keyboard focus */
.btn:focus-visible,
.option:focus-visible,
.filter-btn:focus-visible,
.nav-card:focus-visible,
.flashcard:focus-visible,
.nav-links a:focus-visible,
input:focus-visible,
button:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

/* ============================================
   NAVIGATION
   ============================================ */
nav {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(8px);
}

.nav-brand {
    font-size: 17px;
    font-weight: 800;
    background: var(--bg-hero);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.02em;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 2px;
    list-style: none;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-muted);
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-links a:hover { color: var(--blue); background: var(--blue-light); }

.nav-links a.active {
    background: var(--blue-light);
    color: var(--blue);
    font-weight: 600;
}

.nav-links a.admin-link {
    background: var(--purple-light);
    color: var(--purple);
    font-weight: 600;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text-muted);
}

.nav-user a {
    color: var(--red);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: 8px;
    transition: background 0.2s;
}

.nav-user a:hover { background: var(--red-light); }

/* ============================================
   LAYOUT
   ============================================ */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 36px 24px;
}

.container-wide { max-width: 1200px; }

.page-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 15px;
    margin-bottom: 32px;
}

/* Hero greeting for dashboard */
.hero-greeting {
    background: var(--bg-hero);
    color: white;
    border-radius: var(--radius-lg);
    padding: 32px 36px;
    margin-bottom: 32px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}

.hero-greeting::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255,255,255,0.15) 0%, transparent 70%);
    border-radius: 50%;
}

.hero-greeting h1 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 6px;
    letter-spacing: -0.02em;
    position: relative;
}

.hero-greeting p {
    font-size: 15px;
    opacity: 0.9;
    position: relative;
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 18px;
}

.nav-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 28px 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.25s;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.nav-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--card-accent, var(--blue));
    opacity: 0.85;
}

.nav-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-hover);
    border-color: var(--card-accent, var(--blue));
}

.nav-card .icon-wrap {
    width: 52px;
    height: 52px;
    background: var(--card-accent-light, var(--blue-light));
    color: var(--card-accent, var(--blue));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    line-height: 1;
}

.nav-card h3 {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.nav-card p {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
}

.nav-card .badge {
    align-self: flex-start;
    background: var(--card-accent-light, var(--blue-light));
    color: var(--card-accent, var(--blue));
    font-size: 12px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
}

/* Color variants for cards */
.nav-card.card-blue   { --card-accent: var(--blue);   --card-accent-light: var(--blue-light); }
.nav-card.card-purple { --card-accent: var(--purple); --card-accent-light: var(--purple-light); }
.nav-card.card-orange { --card-accent: var(--orange); --card-accent-light: var(--orange-light); }
.nav-card.card-green  { --card-accent: var(--green);  --card-accent-light: var(--green-light); }
.nav-card.card-pink   { --card-accent: var(--pink);   --card-accent-light: var(--pink-light); }

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 22px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
    font-family: inherit;
}

.btn-primary {
    background: var(--blue);
    color: white;
    box-shadow: 0 2px 8px rgba(74,144,217,0.3);
}

.btn-primary:hover {
    background: var(--blue-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(74,144,217,0.4);
}

.btn-success { background: var(--green); color: white; box-shadow: 0 2px 8px rgba(16,185,129,0.3); }
.btn-success:hover { background: #0EA572; transform: translateY(-1px); }

.btn-danger { background: var(--red); color: white; box-shadow: 0 2px 8px rgba(239,68,68,0.3); }
.btn-danger:hover { background: #DC2626; transform: translateY(-1px); }

.btn-outline {
    background: var(--white);
    color: var(--text);
    border: 1.5px solid var(--border);
}

.btn-outline:hover { background: var(--bg); border-color: var(--blue); color: var(--blue); }

.btn-lg { padding: 14px 32px; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; }

/* ============================================
   FORMS (Login/Register)
   ============================================ */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg-hero);
    position: relative;
    overflow: hidden;
}

.auth-wrapper::before,
.auth-wrapper::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
}

.auth-wrapper::before {
    width: 400px; height: 400px;
    top: -150px; right: -100px;
}

.auth-wrapper::after {
    width: 300px; height: 300px;
    bottom: -100px; left: -100px;
}

.auth-box {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 44px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    position: relative;
    z-index: 1;
}

.auth-logo { text-align: center; margin-bottom: 32px; }

.auth-logo h1 {
    font-size: 26px;
    font-weight: 800;
    background: var(--bg-hero);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.auth-logo p {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 6px;
}

.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    color: var(--text);
    transition: all 0.2s;
    outline: none;
    background: var(--white);
    font-family: inherit;
}

.form-group input:focus {
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(74,144,217,0.1);
}

.auth-footer {
    text-align: center;
    margin-top: 22px;
    font-size: 13px;
    color: var(--text-muted);
}

.auth-footer a {
    color: var(--blue);
    text-decoration: none;
    font-weight: 600;
}

.auth-footer a:hover { text-decoration: underline; }

.alert {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 18px;
    border: 1px solid;
}

.alert-error { background: var(--red-light); color: #B91C1C; border-color: #FECACA; }
.alert-success { background: var(--green-light); color: #047857; border-color: #A7F3D0; }

/* ============================================
   FLASHCARDS
   ============================================ */
.flashcard-area { max-width: 620px; margin: 0 auto; }

.flashcard {
    background: linear-gradient(135deg, #FFFFFF 0%, #F8FBFF 100%);
    border-radius: var(--radius-lg);
    padding: 52px 44px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s;
}

.flashcard:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }

.flashcard .word-en {
    font-size: 38px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
}

.flashcard .word-lt {
    font-size: 24px;
    font-weight: 700;
    color: var(--blue);
    display: none;
}

.flashcard .example {
    font-size: 14px;
    color: var(--text-muted);
    font-style: italic;
    display: none;
    max-width: 420px;
    line-height: 1.6;
}

.flashcard .hint {
    font-size: 12px;
    color: var(--text-light);
    position: absolute;
    bottom: 18px;
    font-weight: 500;
}

.flashcard.revealed .word-lt { display: block; animation: fadeIn 0.3s; }
.flashcard.revealed .example { display: block; animation: fadeIn 0.3s 0.1s both; }
.flashcard.revealed .hint { display: none; }

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

.flashcard-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 28px;
}

.card-counter {
    text-align: center;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 16px;
    font-weight: 500;
}

.progress-bar {
    background: var(--border);
    border-radius: 99px;
    height: 6px;
    margin-bottom: 32px;
    overflow: hidden;
}

.progress-bar-fill {
    background: linear-gradient(90deg, var(--blue) 0%, var(--purple) 100%);
    height: 100%;
    border-radius: 99px;
    transition: width 0.4s ease;
}

.filter-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.filter-btn {
    padding: 7px 16px;
    border-radius: 20px;
    border: 1.5px solid var(--border);
    background: var(--white);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-muted);
    font-family: inherit;
}

.filter-btn:hover { border-color: var(--blue); color: var(--blue); }

.filter-btn.active {
    background: var(--blue);
    color: white;
    border-color: var(--blue);
    box-shadow: 0 2px 8px rgba(74,144,217,0.3);
}

.session-complete {
    text-align: center;
    padding: 56px 24px;
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

.session-complete .big-emoji {
    font-size: 72px;
    margin-bottom: 16px;
    animation: bounce 0.6s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.session-complete h2 {
    font-size: 26px;
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.session-complete p {
    color: var(--text-muted);
    margin-bottom: 28px;
    font-size: 15px;
}

/* ============================================
   QUIZ (Grammar & Tenses)
   ============================================ */
.quiz-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 36px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-light);
    max-width: 720px;
    margin: 0 auto;
}

.quiz-question {
    font-size: 21px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 28px;
    line-height: 1.5;
    letter-spacing: -0.01em;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}

.option {
    padding: 14px 18px;
    border-radius: 12px;
    border: 2px solid var(--border);
    background: var(--white);
    cursor: pointer;
    font-size: 15px;
    color: var(--text);
    transition: all 0.2s;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 14px;
    font-family: inherit;
}

.option .opt-letter {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 800;
    flex-shrink: 0;
    color: var(--text-muted);
}

.option:hover:not(.disabled) {
    border-color: var(--blue);
    background: var(--blue-soft);
}

.option:hover:not(.disabled) .opt-letter {
    background: var(--blue);
    color: white;
}

.option.correct {
    border-color: var(--green);
    background: var(--green-light);
    color: #047857;
}

.option.correct .opt-letter { background: var(--green); color: white; }

.option.wrong {
    border-color: var(--red);
    background: var(--red-light);
    color: #B91C1C;
}

.option.wrong .opt-letter { background: var(--red); color: white; }

.option.disabled { cursor: default; }

.explanation-box {
    background: var(--blue-soft);
    border: 1px solid #BFDBFE;
    border-radius: 12px;
    padding: 16px 18px;
    font-size: 14px;
    color: var(--blue-dark);
    margin-bottom: 20px;
    display: none;
    line-height: 1.55;
}

.explanation-box.show { display: block; animation: fadeIn 0.3s; }

.quiz-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    gap: 12px;
}

.topic-badge {
    background: var(--orange-light);
    color: #92400E;
    font-size: 12px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid #FCD34D;
}

.level-badge-b2 {
    background: var(--blue-light);
    color: var(--blue);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
}

.level-badge-c1 {
    background: var(--purple-light);
    color: var(--purple);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 20px;
}

/* Score box */
.score-box { text-align: center; padding: 44px 24px; }

.score-circle {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 0 auto 28px;
    font-size: 36px;
    font-weight: 800;
    animation: scorePop 0.5s ease;
}

@keyframes scorePop {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.score-great { background: var(--green-light); color: #047857; border: 4px solid var(--green); }
.score-ok    { background: var(--orange-light); color: #92400E; border: 4px solid var(--orange); }
.score-bad   { background: var(--red-light);    color: #B91C1C; border: 4px solid var(--red); }

/* ============================================
   PROGRESS / STATS
   ============================================ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s;
}

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

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background: var(--stat-color, var(--blue));
}

.stat-card.stat-blue   { --stat-color: var(--blue); }
.stat-card.stat-purple { --stat-color: var(--purple); }
.stat-card.stat-orange { --stat-color: var(--orange); }
.stat-card.stat-green  { --stat-color: var(--green); }
.stat-card.stat-pink   { --stat-color: var(--pink); }

.stat-card .stat-icon {
    font-size: 22px;
    margin-bottom: 8px;
    line-height: 1;
}

.stat-card .stat-value {
    font-size: 30px;
    font-weight: 800;
    color: var(--stat-color, var(--blue));
    line-height: 1.1;
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.history-table th {
    text-align: left;
    padding: 12px 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}

.history-table td {
    padding: 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text);
}

.history-table tr:last-child td { border-bottom: none; }
.history-table tr:hover { background: var(--bg); }

.score-pill {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

/* Section heading */
.section-heading {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-heading .icon { font-size: 22px; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 640px) {
    .container { padding: 20px 16px; }
    nav {
        flex-wrap: wrap;
        height: auto;
        padding: 10px 14px;
        gap: 8px;
        justify-content: space-between;
    }
    .nav-brand { font-size: 15px; }
    .nav-user { font-size: 12px; gap: 6px; order: 2; }
    .nav-links {
        display: flex;
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
        -ms-overflow-style: none;
        gap: 2px;
        order: 3;
        width: 100%;
        padding: 4px 0 2px;
        margin: 0;
        border-top: 1px solid var(--border-light);
    }
    .nav-links::-webkit-scrollbar { display: none; }
    .nav-links a { padding: 6px 10px; font-size: 13px; white-space: nowrap; }

    .hero-greeting { padding: 24px 22px; border-radius: var(--radius); }
    .hero-greeting h1 { font-size: 22px; }
    .page-title { font-size: 22px; }

    .flashcard { padding: 38px 24px; }
    .flashcard .word-en { font-size: 30px; }
    .quiz-card { padding: 22px; }
    .quiz-question { font-size: 17px; }
    .auth-box { padding: 32px 22px; }
    .filter-bar { gap: 6px; }
    .score-box { padding: 28px 16px; }
    .stats-grid { gap: 10px; grid-template-columns: repeat(2, 1fr); }
    .stat-card { padding: 16px; }
    .stat-card .stat-value { font-size: 26px; }
}
