/**
 * Design System & Theme Styling - kiemtratocdodanhmay.com
 */

@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,600&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
    /* Base Color Palette (Dark Theme - Default) */
    --bg-main: #0f172a;
    --bg-surface: #1e293b;
    --bg-surface-hover: #334155;
    --bg-input: #0b1120;
    --border-color: #334155;
    --border-subtle: #1e293b;

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-subtle: #64748b;

    --primary: #0ea5e9;
    --primary-hover: #0284c7;
    --primary-light: rgba(14, 165, 233, 0.15);

    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.15);
    --warning: #f59e0b;
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.2);

    /* Typing Engine Specific Colors */
    --word-default: #64748b;
    --word-active: #f8fafc;
    --char-correct: #10b981;
    --char-wrong: #ef4444;
    --caret-color: #0ea5e9;

    --font-sans: 'Be Vietnam Pro', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.35);

    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

/* Light Theme */
[data-theme="light"] {
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --bg-surface-hover: #f1f5f9;
    --bg-input: #f8fafc;
    --border-color: #e2e8f0;
    --border-subtle: #cbd5e1;

    --text-main: #0f172a;
    --text-muted: #475569;
    --text-subtle: #94a3b8;

    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-light: rgba(2, 132, 199, 0.1);

    --word-default: #94a3b8;
    --word-active: #0f172a;
    --char-correct: #059669;
    --char-wrong: #dc2626;
    --caret-color: #0284c7;
}

/* Cyberpunk Neon Theme */
[data-theme="cyberpunk"] {
    --bg-main: #080710;
    --bg-surface: #121024;
    --bg-surface-hover: #1e1940;
    --bg-input: #05040a;
    --border-color: #3b2d71;

    --text-main: #00ffcc;
    --text-muted: #ff007f;
    --text-subtle: #795290;

    --primary: #00ffcc;
    --primary-hover: #00d6aa;
    --primary-light: rgba(0, 255, 204, 0.15);

    --success: #00ff66;
    --danger: #ff0055;

    --word-default: #554477;
    --word-active: #ffffff;
    --char-correct: #00ffcc;
    --char-wrong: #ff0055;
    --caret-color: #ff007f;
}

/* Sepia Retro Theme */
[data-theme="sepia"] {
    --bg-main: #fbf0d9;
    --bg-surface: #f3e5c8;
    --bg-surface-hover: #e8d5b0;
    --bg-input: #fdf7ec;
    --border-color: #d9c49d;

    --text-main: #433422;
    --text-muted: #755f43;
    --text-subtle: #a18a6c;

    --primary: #8c531b;
    --primary-hover: #6b3e10;
    --primary-light: rgba(140, 83, 27, 0.12);

    --word-default: #b0997c;
    --word-active: #2b1f11;
    --char-correct: #2e7d32;
    --char-wrong: #c62828;
    --caret-color: #8c531b;
}

/* Forest Green Theme */
[data-theme="forest"] {
    --bg-main: #0c1a14;
    --bg-surface: #142a20;
    --bg-surface-hover: #1e3d30;
    --bg-input: #07120e;
    --border-color: #234b39;

    --text-main: #e2f9ed;
    --text-muted: #7bc4a1;
    --text-subtle: #4b856b;

    --primary: #10b981;
    --primary-hover: #059669;
    --primary-light: rgba(16, 185, 129, 0.15);

    --word-default: #47705b;
    --word-active: #ffffff;
    --char-correct: #34d399;
    --char-wrong: #f87171;
    --caret-color: #10b981;
}

/* Monokai Theme */
[data-theme="monokai"] {
    --bg-main: #272822;
    --bg-surface: #383a30;
    --bg-surface-hover: #49483e;
    --bg-input: #1e1f1c;
    --border-color: #555746;

    --text-main: #f8f8f2;
    --text-muted: #a6e22e;
    --text-subtle: #75715e;

    --primary: #66d9ef;
    --primary-hover: #a6e22e;
    --primary-light: rgba(102, 217, 239, 0.15);

    --word-default: #75715e;
    --word-active: #f8f8f2;
    --char-correct: #a6e22e;
    --char-wrong: #f92672;
    --caret-color: #fd971f;
}

/* Universal Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.6;
    transition: background-color var(--transition-normal), color var(--transition-normal);
}

a {
    color: inherit;
    text-decoration: none;
    transition: color var(--transition-fast);
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    outline: none;
}

input, select, textarea {
    font-family: inherit;
    outline: none;
}

/* Header */
.site-header {
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.header-inner,
.topbar-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0.6rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 800;
    font-size: 1.15rem;
    color: var(--text-main);
    white-space: nowrap;
    flex-shrink: 0;
}

.brand-logo svg {
    color: var(--primary);
    flex-shrink: 0;
}

.brand-highlight {
    color: var(--primary);
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 0.15rem 0;
}

.header-nav::-webkit-scrollbar {
    display: none;
}

.nav-link {
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    white-space: nowrap;
    flex-shrink: 0;
    line-height: 1.2;
}

.nav-link:hover, .nav-link.active {
    color: var(--primary);
    background-color: var(--primary-light);
}

.header-actions,
.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.action-btn {
    padding: 0.45rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    background-color: var(--bg-main);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.action-btn:hover {
    color: var(--text-main);
    border-color: var(--primary);
}

.theme-select {
    padding: 0.35rem 0.65rem;
    background-color: var(--bg-main);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    cursor: pointer;
    white-space: nowrap;
    max-width: 140px;
}

/* App Main Container */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    gap: 1.5rem;
    flex: 1;
    width: 100%;
}

/* Sidebar Menu */
.sidebar {
    width: 300px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

.sidebar-title {
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-subtle);
    margin-bottom: 0.75rem;
    padding-left: 0.5rem;
}

.sidebar-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.sidebar-menu-item a {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.65rem 0.85rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.925rem;
    transition: all var(--transition-fast);
}

.sidebar-menu-item a:hover {
    background-color: var(--bg-surface-hover);
    color: var(--text-main);
}

.sidebar-menu-item.active a {
    background-color: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.menu-icon {
    font-size: 1.15rem;
    width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.lesson-num-badge {
    width: 22px;
    height: 22px;
    border-radius: var(--radius-sm);
    background-color: var(--bg-subtle);
    color: var(--primary);
    font-weight: 700;
    font-size: 0.78rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
}

.sidebar-menu-item.active .lesson-num-badge {
    background-color: var(--primary);
    color: #ffffff;
}

/* Main Content Area */
.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Footer */
.site-footer {
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    padding: 2.5rem 1.5rem;
    margin-top: auto;
}

.footer-inner {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 2rem;
}

.footer-brand p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 0.75rem;
    max-width: 380px;
}

.footer-col h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1rem;
}

.footer-col ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.footer-col a {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.footer-col a:hover {
    color: var(--primary);
}

.footer-bottom {
    max-width: 1400px;
    margin: 2rem auto 0;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-subtle);
    font-size: 0.85rem;
}

/* Mobile Sidebar Overlay */
#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

#overlay.show,
#overlay.active {
    opacity: 1;
    visibility: visible;
}

.sidebar-open, .sidebar-close {
    display: none;
}

/* Responsive */
@media (max-width: 1280px) {
    .header-nav {
        gap: 0.25rem;
    }
    .nav-link {
        font-size: 0.8rem;
        padding: 0.35rem 0.45rem;
    }
    .theme-select {
        max-width: 115px;
        font-size: 0.78rem;
        padding: 0.3rem 0.45rem;
    }
}

@media (max-width: 1100px) {
    .header-inner,
    .topbar-inner {
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
    }
    .brand-logo {
        font-size: 1.05rem;
    }
    .nav-link {
        font-size: 0.76rem;
        padding: 0.3rem 0.4rem;
        gap: 0.2rem;
    }
}

@media (max-width: 992px) {
    .app-container {
        flex-direction: column;
        padding: 1rem;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -300px;
        width: 280px;
        height: 100vh;
        background-color: var(--bg-surface);
        z-index: 1001;
        padding: 1.5rem;
        overflow-y: auto;
        transition: left var(--transition-normal);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.show,
    .sidebar.open {
        left: 0;
    }

    .sidebar-open {
        display: flex;
        padding: 0.5rem;
        color: var(--text-main);
        font-size: 1.25rem;
    }

    .sidebar-close {
        display: block;
        align-self: flex-end;
        color: var(--text-muted);
        font-size: 1.25rem;
        margin-bottom: 1rem;
    }

    .header-nav {
        display: none;
    }

    .footer-inner {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 600px) {
    .footer-inner {
        grid-template-columns: 1fr;
    }
}

/* Category Tabs */
.category-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    margin-bottom: 0.75rem;
}

.category-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    font-weight: 600;
    background-color: var(--bg-subtle);
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    white-space: nowrap;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.category-tab:hover {
    color: var(--text-main);
    border-color: var(--primary);
    background-color: var(--bg-subtle);
}

.category-tab.active {
    background-color: var(--primary);
    color: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 2px 8px var(--primary-glow);
}

.topic-meta-badge {
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
    border-radius: var(--radius-sm);
    background-color: var(--bg-subtle);
    color: var(--text-subtle);
    margin-left: auto;
}

/* Site Footer */
.site-footer {
    background-color: var(--bg-surface);
    border-top: 1px solid var(--border-color);
    padding: 3rem 1.5rem 1.5rem;
    margin-top: 3rem;
    width: 100%;
}

.footer-container,
.site-foot-wrap {
    max-width: 1400px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr;
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-brand-title,
.site-brand-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.footer-desc {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.6;
    margin-bottom: 1rem;
}

.footer-column h4,
.footer-column h3,
.site-foot-col h3,
.site-foot-col h4,
.col-heading,
.footer-col-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.footer-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.footer-links a {
    color: var(--text-muted);
    font-size: 0.88rem;
    transition: color var(--transition-fast);
}

.footer-links a:hover {
    color: var(--primary);
    text-decoration: underline;
}

/* Accessibility & SEO utility */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.footer-bottom,
.legal-notice-row {
    max-width: 1400px;
    margin: 0 auto;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    color: var(--text-subtle);
    font-size: 0.85rem;
}

@media (max-width: 900px) {
    .footer-container,
    .site-foot-wrap {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 600px) {
    .footer-container,
    .site-foot-wrap {
        grid-template-columns: 1fr;
    }
}

