/*
 * Nền tảng Dịch & Học tiếng Anh AI - CSS Styling System (Vanilla CSS)
 * Phong cách: Modern SaaS Glassmorphism (Kính mờ)
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    /* Dark Theme Colors (Default) */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121e;
    --bg-glass: rgba(18, 18, 30, 0.55);
    --bg-glass-hover: rgba(25, 25, 45, 0.7);
    --border-glass: rgba(255, 255, 255, 0.06);
    --border-glass-active: rgba(255, 255, 255, 0.15);

    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    --accent-primary: #6366f1;
    /* Indigo */
    --accent-secondary: #a855f7;
    /* Purple */
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --accent-glow: rgba(99, 102, 241, 0.3);

    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;

    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;

    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow-premium: 0 10px 30px -5px rgba(0, 0, 0, 0.3);
}

body.light-theme {
    /* Light Theme Colors */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-glass: rgba(255, 255, 255, 0.65);
    --bg-glass-hover: rgba(255, 255, 255, 0.85);
    --border-glass: rgba(99, 102, 241, 0.08);
    --border-glass-active: rgba(99, 102, 241, 0.2);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    --accent-primary: #4f46e5;
    --accent-secondary: #9333ea;
    --accent-gradient: linear-gradient(135deg, #4f46e5 0%, #9333ea 100%);
    --accent-glow: rgba(79, 70, 229, 0.15);

    --shadow-premium: 0 10px 30px -5px rgba(99, 102, 241, 0.05);
}

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

html {
    background-color: var(--bg-primary);
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-body);
    height: 100vh;
    max-height: 100vh;
    display: flex;
    overflow: hidden;
    transition: background-color 0.4s ease, color 0.4s ease;
}

/* Background blur decorations */
.bg-glow-1,
.bg-glow-2 {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    z-index: -1;
    opacity: 0.35;
    pointer-events: none;
}

.bg-glow-1 {
    width: 450px;
    height: 450px;
    background: var(--accent-primary);
    top: -100px;
    left: -100px;
}

.bg-glow-2 {
    width: 400px;
    height: 400px;
    background: var(--accent-secondary);
    bottom: -100px;
    right: -100px;
}

/* Navigation Sidebar */
.sidebar {
    width: 280px;
    min-width: 280px;
    max-width: 280px;
    flex-shrink: 0;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: var(--transition-smooth);
}

.brand {
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand i {
    font-size: 28px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-text {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--text-primary);
}

.nav-links {
    list-style: none;
    padding: 0 16px;
    flex-grow: 1;
    overflow-y: auto;
}

.nav-item {
    margin-bottom: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition-smooth);
    cursor: pointer;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--text-primary);
}

.nav-item.active .nav-link {
    background: var(--accent-gradient);
    color: #ffffff;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.sidebar-footer {
    padding: 20px 16px;
    border-top: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Main Content Area */
.main-wrapper {
    flex-grow: 1;
    min-width: 0;
    height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;

    @media (max-width: 1024px) {
        max-width: 100vw;
        overflow-x: hidden;
    }
}

header {
    height: 70px;
    flex-shrink: 0;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    background-color: rgba(var(--bg-secondary), 0.3);
    backdrop-filter: blur(10px);
}



.header-title {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.theme-toggle {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.theme-toggle:hover {
    background: var(--bg-glass-hover);
    transform: rotate(15deg);
}

.content-container {
    padding: 30px 40px;
    flex-grow: 1;
    overflow-y: auto;
}

/* Glassmorphism Cards */
.glass-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 24px;
    backdrop-filter: blur(16px);
    box-shadow: var(--shadow-premium);
    transition: var(--transition-smooth);
    margin-bottom: 24px;
}

.glass-card:hover {
    border-color: var(--border-glass-active);
}

/* Grid Layouts */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.card-stat {
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    background: var(--accent-gradient);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.stat-info h3 {
    font-size: 26px;
    font-family: var(--font-heading);
    font-weight: 800;
    margin-bottom: 2px;
}

.stat-info p {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
}

.row-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    /* overflow: hidden; */
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: none;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-secondary {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-glass-active);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    opacity: 0.9;
}

/* Translator UI styles */
.translator-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.text-area-wrapper {
    position: relative;
    border-radius: 16px;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-glass);
    overflow: hidden;
}

.text-area-wrapper textarea {
    width: 100%;
    height: 200px;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    padding: 20px;
    font-size: 16px;
    resize: none;
    font-family: var(--font-body);
}

.text-area-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    background: rgba(0, 0, 0, 0.1);
    border-top: 1px solid var(--border-glass);
}

.control-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
    transition: var(--transition-smooth);
}

.control-btn:hover {
    color: var(--text-primary);
    transform: scale(1.1);
}

.swap-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    margin: 0 auto 15px auto;
    transition: var(--transition-smooth);
}

.swap-btn:hover {
    transform: rotate(180deg) scale(1.1);
    border-color: var(--accent-primary);
}

/* Checkboxes */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.check-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 10px 14px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 10px;
    font-size: 13px;
    transition: var(--transition-smooth);
}

.check-label:hover {
    background: var(--bg-glass-hover);
}

.check-label input[type="checkbox"] {
    accent-color: var(--accent-primary);
    width: 16px;
    height: 16px;
}

.context-box {
    margin-top: 16px;
    transition: var(--transition-smooth);
}

.input-text {
    width: 100%;
    padding: 12px 16px;
    background: rgba(0, 0, 0, 0.15);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    color: var(--text-primary);
    outline: none;
    font-size: 14px;
    font-family: var(--font-body);
}

.input-text:focus {
    border-color: var(--accent-primary);
}

/* Chat Coach Styles */
.chat-container {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 20px;
    height: calc(100vh - 165px);
    max-height: calc(100vh - 165px);
}

.chat-session-item {
    position: relative;
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: scale(0.3);
        opacity: 0.4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.chat-sessions-list {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.session-list-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-glass);
    font-weight: 600;
}

.sessions-scroll {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
}

.chat-session-item {
    padding: 12px 14px;
    border-radius: 10px;
    cursor: pointer;
    margin-bottom: 8px;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
}

.chat-session-item:hover {
    background: rgba(255, 255, 255, 0.03);
}

.chat-session-item.active {
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.3);
}

.chat-session-item h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.chat-session-item p {
    font-size: 11px;
    color: var(--text-secondary);
}

.chat-area {
    display: flex;
    flex-direction: column;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    overflow: hidden;
}

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

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message-bubble {
    max-width: 75%;
    padding: 14px 18px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.message-bubble.bot {
    background: rgba(255, 255, 255, 0.05);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-glass);
}

.message-bubble.user {
    background: var(--accent-gradient);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message-eval {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 12px;
}

.correction-alert {
    background: rgba(245, 158, 11, 0.15);
    border-left: 3px solid var(--warning);
    padding: 8px 10px;
    margin-top: 6px;
    border-radius: 4px;
    color: #ffd8a8;
}

.chat-input-area {
    padding: 16px;
    border-top: 1px solid var(--border-glass);
    background: rgba(0, 0, 0, 0.1);
}

.chat-input-wrapper {
    width: 100%;
    display: flex;
    gap: 12px;
}

/* Flashcards UI styles */
.flashcards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}

.flashcard-wrapper {
    height: 180px;
    perspective: 1000px;
    cursor: pointer;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.flashcard-wrapper.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front,
.flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-premium);
}

.flashcard-back {
    transform: rotateY(180deg);
    background: rgba(99, 102, 241, 0.1);
    border-color: rgba(99, 102, 241, 0.2);
}

.flashcard-difficulty {
    font-size: 10px;
    padding: 4px 8px;
    border-radius: 6px;
    text-transform: uppercase;
    font-weight: 700;
    align-self: flex-start;
}

.difficulty-easy {
    background: rgba(16, 185, 129, 0.15);
    color: #a7f3d0;
}

.difficulty-medium {
    background: rgba(245, 158, 11, 0.15);
    color: #fde68a;
}

.difficulty-hard {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

.flashcard-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.flashcard-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
    transition: var(--transition-smooth);
}

.flashcard-btn:hover {
    color: var(--text-primary);
}

/* GitHub Heatmap Grid Styling */
.heatmap-container {
    display: flex;
    flex-direction: column;
    overflow-x: auto;
    padding-bottom: 8px;
}

.heatmap-scroll-wrapper {
    min-width: 720px;
}

.heatmap-grid {
    display: grid;
    grid-template-flow: column;
    grid-template-columns: repeat(53, 1fr);
    grid-template-rows: repeat(7, 1fr);
    gap: 3px;
    width: max-content;
}

.heatmap-cell {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.05);
    transition: var(--transition-smooth);
    position: relative;
}

.heatmap-cell:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.95);
    color: white;
    font-size: 10px;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.level-0 {
    background: rgba(255, 255, 255, 0.05);
}

.level-1 {
    background: rgba(99, 102, 241, 0.25);
}

.level-2 {
    background: rgba(99, 102, 241, 0.5);
}

.level-3 {
    background: rgba(99, 102, 241, 0.75);
}

.level-4 {
    background: #6366f1;
}

/* Game board styling */
.game-selection-panel {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.game-item-card {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 24px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 180px;
}

.game-item-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-primary);
    box-shadow: 0 8px 25px rgba(99, 102, 241, 0.15);
}

.game-item-card h3 {
    font-family: var(--font-heading);
    font-size: 18px;
    margin-bottom: 8px;
}

.game-item-card p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.game-stage {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    padding: 30px;
    min-height: 450px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.unscramble-pool {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px 0;
    min-height: 60px;
    padding: 10px;
    border: 1px dashed var(--border-glass);
    border-radius: 12px;
}

.unscramble-word {
    padding: 8px 16px;
    background: var(--bg-glass-hover);
    border: 1px solid var(--border-glass-active);
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    transition: var(--transition-smooth);
}

.unscramble-word:hover {
    background: var(--accent-primary);
    color: white;
}

.unscramble-workspace {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 20px 0;
    min-height: 60px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    border: 1px solid var(--border-glass);
}

.mcq-choices-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 20px;
}

.mcq-choice-btn {
    padding: 16px 20px;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    transition: var(--transition-smooth);
}

.mcq-choice-btn:hover {
    background: var(--bg-glass-hover);
    border-color: var(--border-glass-active);
}

.mcq-choice-btn.correct {
    background: rgba(16, 185, 129, 0.2);
    border-color: var(--success);
    color: #10b981;
}

.mcq-choice-btn.wrong {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--danger);
    color: #ef4444;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tab-content {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.tab-content.active {
    display: block;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Mobile sidebar toggle button */
.sidebar-toggle {
    display: none;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-primary);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    transition: var(--transition-smooth);
    flex-shrink: 0;
}

.sidebar-toggle:hover {
    background: var(--bg-glass-hover);
}

/* Mobile sidebar overlay backdrop */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 199;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Live correction - redesigned as floating notification */
.live-correction-panel {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(239, 68, 68, 0.08));
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 12px;
    padding: 12px 16px;
    margin: 0 16px 8px 16px;
    font-size: 12px;
    display: none;
    animation: fadeIn 0.3s ease;
}

/* Session delete button */
.session-delete-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: var(--danger);
    width: 26px;
    height: 26px;
    border-radius: 6px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 11px;
    transition: var(--transition-smooth);
    z-index: 2;
}

.session-delete-btn:hover {
    background: rgba(239, 68, 68, 0.3);
}

.chat-session-item:hover .session-delete-btn {
    display: flex !important;
}

/* Typing indicator for chat */
.typing-bubble {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    max-width: 200px;
    animation: fadeIn 0.3s ease;
}

.typing-bubble .dot {
    width: 8px;
    height: 8px;
    background: var(--text-secondary);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-bubble .dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-bubble .dot:nth-child(2) {
    animation-delay: -0.16s;
}

.typing-bubble .typing-text {
    font-size: 12px;
    color: var(--text-secondary);
    margin-left: 4px;
}

/* Backup tab specific styles for consistency */
.backup-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* ===== RESPONSIVE: Tablet (max 1024px) ===== */
@media (max-width: 1024px) {

    html,
    body {
        max-width: 100vw;
        overflow-x: hidden !important;
    }

    body {
        flex-direction: column;
        height: auto;
        max-height: none;
        overflow-y: auto;
    }

    .sidebar {
        width: 100%;
        height: auto;
        min-height: auto;
        max-height: none;
        min-width: unset;
        max-width: unset;
        border-right: none;
        border-bottom: 1px solid var(--border-glass);
        position: relative;
    }

    .main-wrapper {
        height: auto;
        max-height: none;
        overflow: visible;
        max-width: 100vw;
        overflow-x: hidden;
    }

    .nav-links {
        display: flex;
        overflow-x: auto;
        padding: 10px;
        gap: 8px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

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

    .nav-item {
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .nav-link {
        padding: 10px 14px;
        font-size: 13px;
        white-space: nowrap;
    }

    .sidebar-footer {
        display: none;
    }

    header {
        padding: 0 20px;
        height: 60px;
    }

    .header-title {
        font-size: 18px;
    }

    .content-container {
        padding: 20px;
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .row-grid {
        grid-template-columns: 1fr;
    }

    .translator-panel {
        grid-template-columns: 1fr;
    }

    .chat-container {
        grid-template-columns: 1fr;
        height: auto;
        max-height: none;
    }

    .chat-sessions-list {
        height: 200px;
    }

    .chat-area {
        height: 500px;
    }

    .mcq-choices-grid {
        grid-template-columns: 1fr;
    }

    .backup-grid {
        grid-template-columns: 1fr;
    }

    .game-selection-panel {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }

    /* Auth modal */
    #auth-modal>.glass-card,
    #translation-detail-modal>.glass-card {
        width: 90% !important;
        max-width: 400px;
    }
}

/* ===== RESPONSIVE: Mobile (max 768px) ===== */
@media (max-width: 768px) {
    body {
        flex-direction: column;
        height: auto;
        max-height: none;
        overflow-x: hidden;
        overflow-y: auto;
    }

    .bg-glow-1,
    .bg-glow-2 {
        display: none;
    }

    .dashboard-mb-hidden {
        display: none;
    }

    /* Sidebar becomes slide-in overlay */
    .sidebar {
        position: fixed;
        top: 0;
        left: -300px;
        width: 280px;
        min-width: 280px;
        max-width: 280px;
        height: 100vh;
        z-index: 200;
        border-right: 1px solid var(--border-glass);
        border-bottom: none;
        background-color: var(--bg-secondary);
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        overflow-y: auto;
    }

    .sidebar.mobile-open {
        left: 0;
    }

    /* Reset nav-links to vertical on mobile sidebar */
    .nav-links {
        display: flex;
        flex-direction: column;
        overflow-x: visible;
        overflow-y: auto;
        padding: 8px 12px;
        gap: 4px;
    }

    .nav-item {
        margin-bottom: 0;
        flex-shrink: 0;
    }

    .nav-link {
        padding: 11px 14px;
        font-size: 13px;
        white-space: nowrap;
        gap: 12px;
        border-radius: 10px;
    }

    .nav-link i {
        font-size: 15px;
        width: 20px;
        text-align: center;
    }

    .brand {
        padding: 18px 16px;
    }

    .brand-text {
        font-size: 18px;
    }

    .brand i {
        font-size: 24px;
    }

    .sidebar-footer {
        display: flex;
        padding: 14px 12px;
    }

    /* Main wrapper no longer needs margin-top */
    .main-wrapper {
        margin-top: 0;
        height: auto;
        max-height: none;
        overflow: visible;
    }

    .sidebar-toggle {
        display: flex;
    }

    header {
        padding: 0 16px;
        height: 56px;
        gap: 8px;
        position: sticky;
        top: 0;
        z-index: 100;
        background-color: var(--bg-secondary);
    }

    .header-title {
        font-size: 14px;
        display: block;
        white-space: nowrap;
        display: none;
    }

    #header-active-mode-badge {
        display: none;
    }

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

    /* Compact auth profile on mobile */
    #auth-user-profile {
        flex-wrap: nowrap !important;
    }

    #auth-user-name {
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    #btn-logout,
    #btn-show-login {
        padding: 5px 10px !important;
        font-size: 11px !important;
    }

    .content-container {
        padding: 16px;
    }

    /* Dashboard */
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .card-stat {
        gap: 10px;
        padding: 16px !important;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        border-radius: 10px;
        font-size: 15px;
        flex-shrink: 0;
    }

    .stat-info h3 {
        font-size: 18px;
    }

    .stat-info p {
        font-size: 10px;
    }

    .row-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    /* Glass cards */
    .glass-card {
        padding: 16px;
        border-radius: 14px;
        margin-bottom: 14px;
    }

    /* Translator */
    .translator-panel {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .text-area-wrapper textarea {
        height: 130px;
        font-size: 14px;
        padding: 14px;
    }

    .text-area-controls {
        padding: 10px 14px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .checkbox-grid {
        grid-template-columns: 1fr 1fr;
        gap: 6px;
    }

    .check-label {
        font-size: 11px;
        padding: 8px 10px;
        gap: 6px;
    }

    /* Chat - improved mobile layout */
    .chat-container {
        grid-template-columns: 1fr;
        height: auto;
        max-height: none;
        gap: 12px;
    }

    .chat-sessions-list {
        height: auto;
        max-height: 600px;
        border-radius: 14px;
    }

    .sessions-scroll {
        max-height: 600px;
    }

    .chat-area {
        height: calc(100dvh - 15px);
        min-height: 500px;
        border-radius: 14px;
    }

    .chat-header {
        padding: 10px 14px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .chat-header h3 {
        font-size: 14px !important;
    }

    .message-bubble {
        max-width: 88%;
        padding: 10px 14px;
        font-size: 13px;
        border-radius: 14px;
    }

    .message-bubble.user {
        border-bottom-right-radius: 4px;
    }

    .message-bubble.bot {
        border-bottom-left-radius: 4px;
    }

    .message-eval {
        font-size: 11px;
    }

    .chat-input-wrapper {
        gap: 8px;
    }

    .chat-input-area {
        padding: 10px 12px;
    }

    .live-correction-panel {
        margin: 0 10px 6px 10px;
        padding: 10px 12px;
        font-size: 11px;
    }

    /* Flashcards tab - force single column */
    #flashcards-tab .row-grid {
        grid-template-columns: 1fr !important;
    }

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

    .flashcard-wrapper {
        height: 150px;
    }

    /* Games */
    .game-selection-panel {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .game-item-card {
        height: auto;
        padding: 16px;
        min-height: 100px;
    }

    .game-item-card h3 {
        font-size: 15px;
    }

    .game-item-card p {
        font-size: 12px;
    }

    .game-stage {
        padding: 16px;
        min-height: auto;
        border-radius: 14px;
    }

    /* Game config bar */
    .game-selection-panel>.glass-card {
        flex-direction: column;
        align-items: stretch !important;
    }

    .game-selection-panel>.glass-card>div:last-child {
        flex-wrap: wrap;
    }

    .game-selection-panel>.glass-card select,
    .game-selection-panel>.glass-card input[type="text"] {
        width: 100% !important;
    }

    .unscramble-word {
        padding: 6px 12px;
        font-size: 13px;
    }

    /* Settings tab */
    #settings-tab .row-grid {
        grid-template-columns: 1fr !important;
    }

    /* Backup */
    .backup-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    #backup-tab textarea {
        font-size: 11px;
    }

    /* Auth modal */
    #auth-modal>.glass-card {
        width: 92% !important;
        max-width: 380px;
        padding: 22px !important;
    }

    #translation-detail-modal>.glass-card {
        width: 95% !important;
        max-width: 500px;
        padding: 20px !important;
    }

    /* Heatmap */
    .heatmap-cell {
        width: 8px;
        height: 8px;
    }

    .heatmap-scroll-wrapper {
        min-width: 550px;
    }

    /* Review overlay scores grid */
    #chat-review-overlay [style*="grid-template-columns: repeat(4"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Table responsive */
    table {
        font-size: 12px !important;
    }

    table th,
    table td {
        padding: 6px 8px !important;
    }

    /* Generator tab */
    #generator-tab .glass-card [style*="grid-template-columns: 2fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    #generator-tab .glass-card [style*="grid-template-columns: 2fr 2fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* History filter grid */
    #translator-tab [style*="grid-template-columns: repeat(auto-fit"] {
        grid-template-columns: 1fr 1fr !important;
    }
}

/* ===== RESPONSIVE: Small phone (max 480px) ===== */
@media (max-width: 480px) {
    header {
        height: 52px;
        padding: 0 12px;
    }

    .sidebar-toggle {
        width: 36px;
        height: 36px;
        font-size: 16px;
        border-radius: 8px;
    }

    .header-title {
        font-size: 13px;
    }

    #header-active-mode-badge {
        display: none;
    }

    #header-active-mode-badge,
    #header-ai-provider-badge {
        display: none;
        font-size: 1px !important;
        padding: 3px 6px !important;
    }

    .theme-toggle {
        width: 34px;
        height: 34px;
    }

    .content-container {
        padding: 12px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .card-stat {
        gap: 8px;
        padding: 12px !important;
    }

    .stat-icon {
        width: 34px;
        height: 34px;
        font-size: 13px;
        border-radius: 8px;
    }

    .stat-info h3 {
        font-size: 16px;
    }

    .stat-info p {
        font-size: 9px;
    }

    .glass-card {
        padding: 14px;
        border-radius: 12px;
        margin-bottom: 10px;
    }

    .text-area-wrapper textarea {
        height: 110px;
        font-size: 13px;
        padding: 12px;
    }

    .text-area-controls {
        padding: 8px 10px;
    }

    .btn {
        padding: 10px 14px;
        font-size: 12px;
    }

    /* Chat on small phones */
    .chat-area {
        /* height: calc(100vh - 280px);
        min-height: 350px; */
    }

    .chat-messages {
        padding: 10px;
        gap: 8px;
    }

    .message-bubble {
        max-width: 92%;
        padding: 8px 12px;
        font-size: 12px;
        border-radius: 12px;
    }

    .chat-input-area {
        padding: 8px 10px;
    }

    .chat-input-wrapper input,
    .chat-input-wrapper textarea {
        font-size: 13px !important;
        padding: 10px 12px !important;
    }

    /* Flashcards */
    .flashcards-grid {
        grid-template-columns: 1fr;
    }

    .flashcard-wrapper {
        height: 140px;
    }

    .flashcard-front,
    .flashcard-back {
        padding: 14px;
    }

    /* Games */
    .game-stage {
        padding: 14px;
    }

    .game-item-card {
        padding: 12px;
        min-height: 90px;
    }

    .game-item-card h3 {
        font-size: 14px;
    }

    .game-item-card p {
        font-size: 11px;
    }

    .unscramble-word {
        padding: 5px 10px;
        font-size: 12px;
    }

    .checkbox-grid {
        grid-template-columns: 1fr;
    }

    /* Auth Modal */
    #auth-modal>.glass-card {
        width: 95% !important;
        padding: 18px !important;
    }

    /* Heatmap */
    .heatmap-cell {
        width: 6px;
        height: 6px;
    }

    .heatmap-grid {
        gap: 2px;
    }

    /* Game score results on finish */
    #game-board [style*="display:flex"][style*="justify-content:center"] {
        flex-direction: column;
        gap: 12px !important;
    }

    /* Swap button */
    .swap-btn {
        width: 36px;
        height: 36px;
    }

    /* Toast */
    .toast-notification {
        right: 10px !important;
        left: 10px !important;
        bottom: 10px !important;
    }

    /* Game footer actions */
    #game-footer-actions {
        flex-direction: column;
        gap: 10px !important;
    }

    #game-footer-actions>div:last-child {
        width: 100%;
        justify-content: space-between;
    }
}

/* Custom Redesigned Dropdowns Select */
select.input-text {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 16px;
    padding-right: 40px !important;
    cursor: pointer;
    transition: var(--transition-smooth);
}

select.input-text option {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    padding: 10px;
}

body.light-theme select.input-text {
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* Badge Status styling */
.badge-status {
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    display: inline-block;
    text-transform: uppercase;
}

.badge-status.mastered {
    background: rgba(16, 185, 129, 0.15);
    color: #a7f3d0;
}

.badge-status.learning {
    background: rgba(245, 158, 11, 0.15);
    color: #fde68a;
}

/* Contrast enhancement for Light Theme badges */
body.light-theme .badge-status.mastered,
body.light-theme .difficulty-easy {
    background: rgba(16, 185, 129, 0.2) !important;
    color: #065f46 !important;
    font-weight: 700;
}

body.light-theme .badge-status.learning,
body.light-theme .difficulty-medium {
    background: rgba(245, 158, 11, 0.2) !important;
    color: #92400e !important;
    font-weight: 700;
}

body.light-theme .difficulty-hard {
    background: rgba(239, 68, 68, 0.2) !important;
    color: #991b1b !important;
    font-weight: 700;
}

/* AI Configuration Active Border Highlight */
#ai-translation-options.ai-options-active {
    border: 2px solid var(--accent-primary) !important;
    padding: 15px 20px !important;
    box-shadow: 0 0 15px var(--accent-glow) !important;
    background: rgba(99, 102, 241, 0.04) !important;
}