/* English Kids - Eye-friendly Learning Platform */
:root {
    /* Light Mode - Soft eye-friendly colors */
    --bg-primary: #f7f5f0;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --bg-hover: #f0ebe3;
    --text-primary: #2c2c2c;
    --text-secondary: #5a5a5a;
    --text-muted: #8a8a8a;
    --accent: #4a90a4;
    --accent-hover: #3a7a8c;
    --accent-light: #e8f4f7;
    --success: #5a9a6e;
    --warning: #d4a84b;
    --danger: #c75c5c;
    --border: #e5e0d8;
    --shadow: 0 2px 12px rgba(0,0,0,0.06);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.08);
    --radius: 16px;
    --radius-sm: 10px;
    --header-h: 60px;
    --font-th: 'Sarabun', sans-serif;
    --font-en: 'Nunito', sans-serif;
}

body.dark-mode {
    --bg-primary: #1a1d23;
    --bg-secondary: #242830;
    --bg-card: #2a2e38;
    --bg-hover: #323842;
    --text-primary: #e8e6e3;
    --text-secondary: #b0ada8;
    --text-muted: #7a7875;
    --accent: #6bb3c7;
    --accent-hover: #5aa0b4;
    --accent-light: #2a3a42;
    --success: #6ab87e;
    --warning: #e0b85a;
    --danger: #d87070;
    --border: #3a3e48;
    --shadow: 0 2px 12px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
}

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

html {
    scroll-behavior: smooth;
    -webkit-tap-highlight-color: transparent;
}

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

/* Header */
.header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    z-index: 1000;
    box-shadow: var(--shadow);
}

.header-inner {
    max-width: 1200px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
}

.menu-toggle {
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    padding: 8px;
}

.menu-toggle span {
    display: block;
    width: 22px;
    height: 2.5px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: 0.3s;
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-en);
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--accent);
}

.logo-icon { font-size: 1.5rem; }

.header-actions {
    display: flex;
    gap: 8px;
}

.theme-btn, .profile-btn {
    background: var(--bg-hover);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-btn:hover, .profile-btn:hover {
    background: var(--accent-light);
}

/* Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100%;
    background: var(--bg-secondary);
    z-index: 1100;
    transition: left 0.3s ease;
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
}

.sidebar.open { left: 0; }

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 16px;
    border-bottom: 1px solid var(--border);
}

.sidebar-header h3 {
    font-size: 1.1rem;
    color: var(--accent);
}

.close-sidebar {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--text-secondary);
    cursor: pointer;
    width: 36px;
    height: 36px;
}

.nav-menu {
    list-style: none;
    padding: 12px 0;
}

.nav-menu > li > a,
.submenu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 1rem;
    transition: 0.2s;
    border-left: 3px solid transparent;
}

.nav-menu > li > a:hover,
.nav-menu > li > a.active,
.submenu a:hover {
    background: var(--accent-light);
    border-left-color: var(--accent);
    color: var(--accent);
}

.submenu {
    list-style: none;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s;
    background: var(--bg-primary);
}

.submenu.open { max-height: 400px; }

.submenu a {
    padding-left: 48px;
    font-size: 0.95rem;
}

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transition: 0.3s;
}

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

/* Main Content */
.main-content {
    max-width: 900px;
    margin: 0 auto;
    padding: calc(var(--header-h) + 20px) 16px 40px;
    min-height: 100vh;
}

/* Cards */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.card-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font-th);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-secondary:hover { background: var(--border); }

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--accent);
    color: var(--accent);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-block {
    width: 100%;
}

/* Home Page */
.hero {
    text-align: center;
    padding: 30px 20px;
}

.hero h1 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--accent);
}

.hero p {
    color: var(--text-secondary);
    font-size: 1.05rem;
    margin-bottom: 24px;
}

.grade-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
    margin-top: 20px;
}

.grade-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 12px;
    text-align: center;
    cursor: pointer;
    transition: 0.25s;
}

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

.grade-card .grade-num {
    font-family: var(--font-en);
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
}

.grade-card .grade-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.progress-bar-wrap {
    background: var(--bg-hover);
    border-radius: 20px;
    height: 10px;
    margin-top: 10px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--success));
    border-radius: 20px;
    transition: width 0.5s;
}

/* Lesson List */
.lesson-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.lesson-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: 0.2s;
}

.lesson-item:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

.lesson-item .lesson-icon {
    width: 48px;
    height: 48px;
    background: var(--accent-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.lesson-item .lesson-info {
    flex: 1;
}

.lesson-item .lesson-title {
    font-weight: 600;
    font-size: 1.05rem;
}

.lesson-item .lesson-desc {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.lesson-item .lesson-status {
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.lesson-item .lesson-status.done {
    background: var(--success);
    color: #fff;
}

/* Lesson Content */
.lesson-header {
    margin-bottom: 24px;
}

.lesson-header h1 {
    font-size: 1.6rem;
    color: var(--accent);
    margin-bottom: 8px;
}

.lesson-header .meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.section {
    margin-bottom: 28px;
}

.section-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--accent-light);
    display: flex;
    align-items: center;
    gap: 8px;
}

.vocab-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.vocab-card {
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: center;
    transition: 0.2s;
}

.vocab-card:hover {
    background: var(--accent-light);
}

.vocab-card .word {
    font-family: var(--font-en);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent);
}

.vocab-card .meaning {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.vocab-card .speak-btn {
    margin-top: 8px;
    background: var(--accent);
    color: #fff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    transition: 0.2s;
}

.vocab-card .speak-btn:hover {
    transform: scale(1.1);
}

.example-box {
    background: var(--bg-hover);
    border-left: 4px solid var(--accent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 16px;
    margin-bottom: 12px;
}

.example-box .en {
    font-family: var(--font-en);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.example-box .th {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.example-box .speak-inline {
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    font-size: 1.1rem;
    margin-left: 8px;
    vertical-align: middle;
}

.img-wrap {
    text-align: center;
    margin: 16px 0;
}

.img-wrap img {
    max-width: 100%;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.img-wrap .caption {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 8px;
}

.grammar-box {
    background: var(--accent-light);
    border-radius: var(--radius);
    padding: 20px;
    margin: 16px 0;
}

.grammar-box h4 {
    color: var(--accent);
    margin-bottom: 10px;
}

/* Quiz */
.quiz-container {
    margin-top: 20px;
}

.question-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.question-card .q-num {
    font-size: 0.85rem;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 8px;
}

.question-card .q-text {
    font-size: 1.05rem;
    font-weight: 500;
    margin-bottom: 14px;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: 0.2s;
    border: 2px solid transparent;
}

.option:hover {
    border-color: var(--accent);
}

.option.selected {
    border-color: var(--accent);
    background: var(--accent-light);
}

.option.correct {
    border-color: var(--success);
    background: rgba(90, 154, 110, 0.15);
}

.option.wrong {
    border-color: var(--danger);
    background: rgba(199, 92, 92, 0.15);
}

.option input {
    display: none;
}

.explanation {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    display: none;
}

.explanation.show {
    display: block;
}

.quiz-result {
    text-align: center;
    padding: 30px;
}

.quiz-result .score {
    font-size: 3rem;
    font-weight: 800;
    color: var(--accent);
    font-family: var(--font-en);
}

/* Games */
.game-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.game-card {
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: 0.25s;
}

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

.game-card .game-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.game-card h3 {
    font-size: 1.15rem;
    margin-bottom: 6px;
}

.game-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
}

/* Memory Game */
.memory-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    max-width: 400px;
    margin: 20px auto;
}

.memory-card {
    aspect-ratio: 1;
    background: var(--accent);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    cursor: pointer;
    transition: 0.3s;
    color: #fff;
    font-weight: 700;
}

.memory-card.flipped,
.memory-card.matched {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 2px solid var(--accent);
}

.memory-card.matched {
    opacity: 0.6;
    pointer-events: none;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    border: 1px solid var(--border);
}

.stat-card .stat-value {
    font-family: var(--font-en);
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
}

.stat-card .stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: 0.3s;
}

.modal.show {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.2rem;
    color: var(--accent);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.modal-body {
    padding: 20px;
}

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

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 0.95rem;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-th);
    font-size: 1rem;
    outline: none;
    transition: 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 14px 24px;
    border-radius: 30px;
    box-shadow: var(--shadow-lg);
    z-index: 3000;
    font-weight: 500;
    transition: 0.3s;
    border: 1px solid var(--border);
    opacity: 0;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Certificate Preview */
.cert-preview {
    background: linear-gradient(135deg, #f8f6f0, #e8f4f7);
    border: 3px solid var(--accent);
    border-radius: var(--radius);
    padding: 40px 30px;
    text-align: center;
    margin: 20px 0;
}

body.dark-mode .cert-preview {
    background: linear-gradient(135deg, #2a2e38, #1a2a30);
}

.cert-preview h2 {
    font-family: var(--font-en);
    color: var(--accent);
    font-size: 1.5rem;
    margin-bottom: 10px;
}

.cert-preview .cert-name {
    font-size: 1.8rem;
    font-weight: 700;
    margin: 16px 0;
    color: var(--text-primary);
}

/* Back button */
.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--accent);
    background: none;
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 16px;
    font-family: var(--font-th);
    padding: 0;
}

.back-btn:hover { text-decoration: underline; }

/* Responsive */
@media (max-width: 480px) {
    .hero h1 { font-size: 1.5rem; }
    .grade-grid { grid-template-columns: repeat(2, 1fr); }
    .memory-board { grid-template-columns: repeat(3, 1fr); }
    .vocab-grid { grid-template-columns: repeat(2, 1fr); }
    .card { padding: 16px; }
}

/* Utility */
.text-center { text-align: center; }
.mt-2 { margin-top: 16px; }
.mb-2 { margin-bottom: 16px; }
.hidden { display: none !important; }
.flex-center {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}
