/*
 * Dark theme. The site is light by default; <html data-theme="dark"> is set by the
 * moon switch (see templates/_theme_head.html.twig) and remembered in localStorage.
 * Everything below is scoped under html[data-theme="dark"], so the light look is untouched.
 * Dark accent is a greenish turquoise (#4CC9A9), asked by Tony; the light theme keeps its sage green.
 */

/* ── 1. The switch (both looks) ───────────────────────────────────────── */

.theme-toggle {
    position: fixed;
    top: 10px;
    right: 12px;
    z-index: 10001;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--card-bg);
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

/* Keep the fixed switch from covering the links on the right of the top bars. */
/* "html" in front outranks the later media-query rules that set `padding` on these bars. */
html .dashboard-navbar,
html .student-navbar,
html .lp-nav,
html .map-bar {
    padding-right: 64px;
}

/* ── 2. Dark tokens ───────────────────────────────────────────────────── */

html[data-theme="dark"] {
    color-scheme: dark;
    --background: #111814;
    --card-bg: #1B241F;
    --hover-bg: #24302A;
    --border: #2E3A34;
    --text-primary: #E6EEE9;
    --text-secondary: #D9B07E;
    --accent: #4CC9A9;
    --hover-shadow: rgba(76, 201, 169, 0.2);
    --gradient-start: #2A9D86;
    --gradient-end: #0B4A43;
    /* Tokens some dashboard pages read with a light fallback. */
    --border-color: #2E3A34;
    --bg-secondary: #1B241F;
}

html[data-theme="dark"] .lp,
html[data-theme="dark"] .lp-courses {
    --lp-bg: #111814;
    --lp-tint: #1B241F;
    --lp-muted: #A9B8B1;
    --lp-border: #2E3A34;
    --lp-green: #E6EEE9;
    --lp-sage-text: #4CC9A9;
    --lp-sage: #4CC9A9;
}

/* ── 3. Brand fills: these tokens flip to light, but sit behind white text ─ */

html[data-theme="dark"] .phone-mockup,
html[data-theme="dark"] .phone-mockup::before,
html[data-theme="dark"] .map-tip,
html[data-theme="dark"] .map-see,
html[data-theme="dark"] .lp-btn-dark,
html[data-theme="dark"] .lp-btn-ghost:hover,
html[data-theme="dark"] .lp-blob-2 {
    background: #0B4A43;
}

html[data-theme="dark"] .detail-chip:hover,
html[data-theme="dark"] .detail-chip.is-active {
    background: var(--cat, #0B4A43);
    border-color: var(--cat, #0B4A43);
}

html[data-theme="dark"] .lp-nav::before {
    background: linear-gradient(90deg, #2A9D86, #0B4A43);
}

html[data-theme="dark"] .lp-course-media {
    background: linear-gradient(135deg, #2A9D86, #0B4A43);
}

html[data-theme="dark"] .lp-plan-featured {
    background: linear-gradient(160deg, #2A9D86 -20%, #0B4A43 70%);
}

html[data-theme="dark"] .lp-final {
    background:
        radial-gradient(circle at 85% 20%, rgba(255, 186, 0, 0.16), transparent 35%),
        linear-gradient(135deg, #2A9D86, #0B4A43);
}

/* The lp "dark" button reads its text colour from the page, keep it white. */
html[data-theme="dark"] .lp-btn-dark,
html[data-theme="dark"] .lp-btn-ghost:hover {
    color: #fff;
}

/* Map "see more" button: the dark panel keeps its hover colour. */
html[data-theme="dark"] .map-see:hover {
    background: #0F5E55;
}

/* ── 4. Hard-coded light surfaces and dark text ───────────────────────── */

/* Landing page */
html[data-theme="dark"] .lp-nav { background: rgba(17, 24, 20, 0.85); }
html[data-theme="dark"] .lp-hero-visual { background: linear-gradient(160deg, #1B241F 0%, #24302A 100%); }
html[data-theme="dark"] .lp-visual-play { background: rgba(27, 36, 31, 0.9); }
html[data-theme="dark"] .lp-chip,
html[data-theme="dark"] .lp-course,
html[data-theme="dark"] .lp-plan,
html[data-theme="dark"] .lp-social,
html[data-theme="dark"] .lp-reviews-arrow,
html[data-theme="dark"] .lp-review-close {
    background: #1B241F;
    color: var(--lp-green, #E6EEE9);
}

/* The featured plan keeps its green fill with white text. */
html[data-theme="dark"] .lp-plan-featured { color: #fff; }

/* Private messages */
html[data-theme="dark"] .pm-loading,
html[data-theme="dark"] .pm-empty-state,
html[data-theme="dark"] .pm-preview,
html[data-theme="dark"] .pm-chat-title small,
html[data-theme="dark"] .pm-list-meta,
html[data-theme="dark"] .pm-composer-foot { color: #A9B8B1; }
html[data-theme="dark"] .pm-empty-state p { color: #E6EEE9; }
html[data-theme="dark"] .pm-list-item,
html[data-theme="dark"] .pm-chat,
html[data-theme="dark"] .pm-bubble,
html[data-theme="dark"] .pm-composer {
    background: #1B241F;
    border-color: #2E3A34;
    color: #E6EEE9;
}
html[data-theme="dark"] .pm-list-item:hover { border-color: #4CC9A9; }
html[data-theme="dark"] .pm-chat-header,
html[data-theme="dark"] .pm-composer { border-color: #2E3A34; }
html[data-theme="dark"] .pm-chat-header { background: #161E1A; }
html[data-theme="dark"] .pm-thread { background: #111814; }
html[data-theme="dark"] .pm-back { background: #24302A; color: #E6EEE9; }
html[data-theme="dark"] .pm-notice { background: #2A2314; color: #E8C98C; border-bottom-color: #4A3C1C; }
html[data-theme="dark"] .pm-day span { background: #24302A; color: #A9B8B1; }
html[data-theme="dark"] .pm-bubble.teacher:not(:is(.pm-row.mine *)) { background: #1F2E25; border-color: #3A5043; }
html[data-theme="dark"] .pm-bubble.kept:not(:is(.pm-row.mine *)) { border-color: #B07A45; }
html[data-theme="dark"] .pm-origin,
html[data-theme="dark"] .pm-quote { color: #D9A86C; }
html[data-theme="dark"] .pm-answer,
html[data-theme="dark"] .pm-replying { background: #2A2016; color: #D9A86C; border-color: #B07A45; }
html[data-theme="dark"] .question-block { background: #2A2016; border-color: #B07A45; }
html[data-theme="dark"] .question-label { color: #D9A86C; }
html[data-theme="dark"] .pm-row.mine .pm-bubble { background: #0B4A43; border-color: #0B4A43; color: #fff; }
html[data-theme="dark"] .pm-badge { background: #24302A; color: #E6EEE9; }
html[data-theme="dark"] .pm-row.mine .pm-badge { background: rgba(255, 255, 255, 0.2); color: #fff; }
html[data-theme="dark"] .pm-composer textarea { background: #111814; color: #E6EEE9; border-color: #2E3A34; }
html[data-theme="dark"] .pm-composer button { background: #0B4A43; color: #fff; }
html[data-theme="dark"] .pm-composer button:disabled { background: #3A4A41; }

/* Level test */
html[data-theme="dark"] .level-test-card,
html[data-theme="dark"] .sheet,
html[data-theme="dark"] .sheet-option,
html[data-theme="dark"] .history-item,
html[data-theme="dark"] .cloze-progress {
    background: #1B241F;
    border-color: #2E3A34;
    color: #E6EEE9;
}
html[data-theme="dark"] .level-test-info small,
html[data-theme="dark"] .level-test-note,
html[data-theme="dark"] .cloze-number,
html[data-theme="dark"] .level-lock-note { color: #A9B8B1; }
html[data-theme="dark"] .cloze-intro,
html[data-theme="dark"] .sheet-sentence,
html[data-theme="dark"] .review-explanation { color: #E6EEE9; }
html[data-theme="dark"] .btn-level-test { background: #0B4A43; color: #fff; }
html[data-theme="dark"] .btn-level-test.secondary { background: #24302A; color: #E6EEE9; }
html[data-theme="dark"] .cloze-blank { background: #3A1A2B; color: #F9A8D4; }
html[data-theme="dark"] .cloze-blank.filled { background: #14261A; color: #86EFAC; border-bottom-color: #4CC9A9; }
html[data-theme="dark"] .cloze-warning { background: #2A2314; color: #FCD34D; border-color: #6B5311; }
html[data-theme="dark"] .cloze-error { color: #FCA5A5; }
html[data-theme="dark"] .sheet-option.selected { background: #14261A; border-color: #4CC9A9; }
html[data-theme="dark"] .sheet-nav button { background: #24302A; color: #E6EEE9; }
html[data-theme="dark"] .result-card { background: #1B241F; border-color: #2E3A34; }
html[data-theme="dark"] .result-card.passed { background: #14261A; border-color: #2F6B45; }
html[data-theme="dark"] .result-card.failed { background: #2B1616; border-color: #7F2D2D; }
html[data-theme="dark"] .review-item { border-color: #2E3A34; }
html[data-theme="dark"] .review-item.wrong { background: #2B1616; }
html[data-theme="dark"] .review-item.right { background: #14261A; }
html[data-theme="dark"] .tag-wrong { background: #3A1A1A; color: #FCA5A5; }
html[data-theme="dark"] .tag-right,
html[data-theme="dark"] .level-test-chip-passed { background: #14261A; color: #86EFAC; }
html[data-theme="dark"] .level-test-chip-locked,
html[data-theme="dark"] .level-test-chip-premium_only,
html[data-theme="dark"] .level-test-chip-cooling_down { background: #24302A; color: #A9B8B1; }
html[data-theme="dark"] .level-test-chip { background: #0B4A43; color: #fff; }

/* Map page (the page around the map only: region colours are left alone) */
html[data-theme="dark"] .map-search-panel,
html[data-theme="dark"] .embassy-card,
html[data-theme="dark"] .detail-item {
    background: #1B241F;
    color: #E6EEE9;
}
html[data-theme="dark"] .map-search-result.is-highlighted { background: #24302A; }
html[data-theme="dark"] .detail-notice { background: #2A2314; color: #E8C98C; border-color: #6B5311; }
html[data-theme="dark"] .badge-example { background: #3A3015; color: #E8C98C; }

/* Lesson page */
html[data-theme="dark"] .exercise-block,
html[data-theme="dark"] .exercise-block-card { background: #2A2314; }
html[data-theme="dark"] .exercise-label { color: #F2B45A; }
html[data-theme="dark"] .exercise-block-card { border-color: #f59e0b; }
html[data-theme="dark"] .interaction-section { border-top-color: #2E3A34; }
html[data-theme="dark"] .interaction-title,
html[data-theme="dark"] .answer-meta { color: #A9B8B1; }
html[data-theme="dark"] .interaction-note,
html[data-theme="dark"] .comment-meta { color: #8A9A92; }
html[data-theme="dark"] .comment-item,
html[data-theme="dark"] .student-answer-card { background: #1B241F; border-color: #2E3A34; }
html[data-theme="dark"] .comment-text,
html[data-theme="dark"] .student-answer-card strong { color: #E6EEE9; }
html[data-theme="dark"] .teacher-reply { background: #1E2140; }
html[data-theme="dark"] .answer-box { background: #14261A; border-color: #2F6B45; }
html[data-theme="dark"] .interaction-textarea { background: #111814; color: #E6EEE9; border-color: #2E3A34; }
html[data-theme="dark"] .interaction-textarea:focus { box-shadow: 0 0 0 2px #2A2F6B; }
html[data-theme="dark"] .all-answers-toggle { color: #A5B4FC; }
html[data-theme="dark"] .completion-overlay { background: rgba(17, 24, 20, 0.92); }

/* Teacher: answers page, inbox, requests, level test editor, lesson blocks */
html[data-theme="dark"] .exercise-block-label { color: #F2B45A; }
html[data-theme="dark"] .exercise-content { color: #E6EEE9; border-bottom-color: #5A4A1E; }
html[data-theme="dark"] .student-name { color: #E6EEE9; }
html[data-theme="dark"] .answer-date,
html[data-theme="dark"] .teacher-reply-date,
html[data-theme="dark"] .no-answers { color: #8A9A92; }
html[data-theme="dark"] .answer-text { background: #161E1A; color: #E6EEE9; }
html[data-theme="dark"] .teacher-reply-item { background: #1E2140; color: #E6EEE9; }
html[data-theme="dark"] .reply-textarea { background: #111814; color: #E6EEE9; border-color: #2E3A34; }
html[data-theme="dark"] .reply-textarea:focus { box-shadow: 0 0 0 2px #2A2F6B; }

html[data-theme="dark"] .inbox-tabs,
html[data-theme="dark"] .inbox-table th { border-bottom-color: #2E3A34; }
html[data-theme="dark"] .inbox-table td { border-bottom-color: #24302A; }
html[data-theme="dark"] .inbox-table tr:hover td { background: #1B241F; }
html[data-theme="dark"] .inbox-table .student-name { color: #E6EEE9; }
html[data-theme="dark"] .inbox-table .meta,
html[data-theme="dark"] .inbox-table th,
html[data-theme="dark"] .inbox-tab { color: #A9B8B1; }
html[data-theme="dark"] .drawer-textarea,
html[data-theme="dark"] .cl-modal select { background: #111814; color: #E6EEE9; }
html[data-theme="dark"] .drawer-close:hover { color: #E6EEE9; }
html[data-theme="dark"] .drawer-exercise {
    background: color-mix(in srgb, var(--accent) 12%, #111814);
    border-bottom-color: color-mix(in srgb, var(--accent) 30%, #111814);
}
html[data-theme="dark"] .thread-msg-wrap.teacher .thread-msg {
    background: color-mix(in srgb, var(--accent) 30%, #111814);
}
html[data-theme="dark"] .drawer-send:disabled {
    background: color-mix(in srgb, var(--accent) 40%, #111814);
}

html[data-theme="dark"] .your-turn { background: #3A3015; color: #E8C98C; }
html[data-theme="dark"] .thread-message { background: #24302A; }
html[data-theme="dark"] .thread-message.teacher { background: #14293A; }
html[data-theme="dark"] .thread-message.system { background: #3A1A1A; }
html[data-theme="dark"] .action-box { border-color: #4CC9A9; }
html[data-theme="dark"] .field-error,
html[data-theme="dark"] .form-error,
html[data-theme="dark"] .score-line.warn,
html[data-theme="dark"] .level-name-error { color: #FCA5A5; }
html[data-theme="dark"] .badge-published { background: #14261A; color: #86EFAC; }
html[data-theme="dark"] .badge-draft { background: #3A3015; color: #E8C98C; }
html[data-theme="dark"] .type-option.selected { background: #1E2140; }
html[data-theme="dark"] .alert-success { background: #14261A; color: #86EFAC; border-color: #2F6B45; }
html[data-theme="dark"] .alert-error { background: #2B1616; color: #FCA5A5; border-color: #7F2D2D; }

/* 404 and sign-in pages (own <style> blocks with hard-coded colours) */
html[data-theme="dark"] body { background: #111814; color: #E6EEE9; }
html[data-theme="dark"] .auth-container { background: #111814; }
html[data-theme="dark"] .auth-box { background: #1B241F; }
html[data-theme="dark"] .user-info { background: #111814; }
html[data-theme="dark"] .user-avatar { border-color: #1B241F; }
html[data-theme="dark"] .error-title,
html[data-theme="dark"] .auth-title,
html[data-theme="dark"] .user-name { color: #E6EEE9; }
html[data-theme="dark"] .error-description,
html[data-theme="dark"] .auth-description,
html[data-theme="dark"] .user-email { color: #A9B8B1; }
html[data-theme="dark"] .btn-secondary { background: #1B241F; color: #E6EEE9; border-color: #2E3A34; }
html[data-theme="dark"] .error-message { background: #2B1616; }

/* Inline style="" attributes beat any stylesheet, hence !important (demo-login page). */
html[data-theme="dark"] [style*="background: white"] { background: #1B241F !important; }
html[data-theme="dark"] [style*="background: #F8F9FB"] { background: #111814 !important; }
html[data-theme="dark"] [style*="color: #6b7280"] { color: #A9B8B1 !important; }

/* ── 5. Form fields and the Summernote editor ─────────────────────────── */

html[data-theme="dark"] .form-input,
html[data-theme="dark"] .form-textarea,
html[data-theme="dark"] .edit-input,
html[data-theme="dark"] .note-input {
    background: #111814;
    color: #E6EEE9;
    border-color: #2E3A34;
}
html[data-theme="dark"] .form-input::placeholder,
html[data-theme="dark"] .form-textarea::placeholder,
html[data-theme="dark"] .edit-input::placeholder { color: #6F7F77; }

html[data-theme="dark"] .note-editor.note-frame { border-color: #2E3A34; color: #E6EEE9; }
html[data-theme="dark"] .note-editor .note-editing-area .note-editable { background: #111814; color: #E6EEE9; }
html[data-theme="dark"] .note-toolbar { background: #1B241F; border-color: #2E3A34; color: #E6EEE9; }
html[data-theme="dark"] .note-btn { background: #24302A; border-color: #2E3A34; color: #E6EEE9; }
html[data-theme="dark"] .note-btn:hover,
html[data-theme="dark"] .note-btn:focus,
html[data-theme="dark"] .note-btn.active { background: #2E3A34; border-color: #3A4A41; color: #E6EEE9; }
html[data-theme="dark"] .note-dropdown-menu,
html[data-theme="dark"] .note-popover,
html[data-theme="dark"] .note-popover-content,
html[data-theme="dark"] .note-modal-content { background: #1B241F; border-color: #2E3A34; color: #E6EEE9; }
html[data-theme="dark"] a.note-dropdown-item,
html[data-theme="dark"] .note-modal-title,
html[data-theme="dark"] .note-form-label,
html[data-theme="dark"] .note-modal .close { color: #E6EEE9; }
html[data-theme="dark"] .note-dropdown-item:hover { background: #24302A; }
html[data-theme="dark"] .note-modal-header,
html[data-theme="dark"] .note-editor .note-status-output { border-color: #2E3A34; }
html[data-theme="dark"] .note-editor .note-statusbar { background: #1B241F; border-top-color: #2E3A34; }
html[data-theme="dark"] .note-popover .note-popover-arrow::after { border-top-color: #1B241F; border-bottom-color: #1B241F; }
