:root {
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --primary-color: #8b5cf6;
    --secondary-color: #ec4899;
    --accent-color: #06b6d4;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --gradient-main: linear-gradient(135deg, #8b5cf6 0%, #ec4899 100%);
    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --font-main: 'Outfit', sans-serif;
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 5%;
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(10px);
    position: fixed;
    width: 100%;
    top: 0;
    z-index: 1000;
    border-bottom: var(--glass-border);
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    cursor: pointer;
    letter-spacing: -0.5px;
}

.logo .dot {
    color: var(--secondary-color);
    font-size: 2rem;
    line-height: 0;
}

.nav-links {
    display: flex;
    list-style: none;
    gap: 2rem;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
}

.nav-links a {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    transition: color 0.3s ease;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--text-primary);
}

/* Shared navigation actions: give links to the course hub a clear button affordance. */
.nav-links a[href="/on-tap"] {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    color: var(--text-primary);
    font-weight: 700;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 9999px;
    box-shadow: var(--shadow-sm);
    transition: color 0.2s ease, background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.nav-links a[href="/on-tap"]:hover {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
    transform: translateY(-1px);
}

/* Buttons */
.btn-primary {
    background: var(--gradient-main);
    border: none;
    padding: 0.75rem 1.5rem;
    color: white;
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    font-family: var(--font-main);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3);
}

.btn-primary.large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--text-secondary);
    padding: 0.75rem 1.5rem;
    color: var(--text-primary);
    font-weight: 600;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: var(--font-main);
}

.btn-secondary:hover {
    border-color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.btn-secondary.large {
    padding: 1rem 2rem;
    font-size: 1.1rem;
}

/* Hero Section */
.hero-section {
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: 0 5%;
    position: relative;
    overflow: hidden;
    padding-top: 80px;
    /* Offset for fixed navbar */
}

/* Background Blurs */
.hero-section::before {
    content: '';
    position: absolute;
    top: -10%;
    right: -5%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.2) 0%, rgba(15, 23, 42, 0) 70%);
    border-radius: 50%;
    z-index: -1;
    filter: blur(80px);
}

.hero-section::after {
    content: '';
    position: absolute;
    bottom: 0%;
    left: -10%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.15) 0%, rgba(15, 23, 42, 0) 70%);
    border-radius: 50%;
    z-index: -1;
    filter: blur(80px);
}

.hero-content {
    flex: 1;
    padding-right: 2rem;
    z-index: 1;
}

.hero-title {
    font-size: 4rem;
    line-height: 1.1;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.gradient-text {
    background: var(--gradient-main);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
    max-width: 500px;
}

.cta-group {
    display: flex;
    gap: 1rem;
    margin-bottom: 3rem;
}

.stats-container {
    display: flex;
    gap: 3rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 1.5rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
}

.stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.hero-visual {
    flex: 1;
    position: relative;
    height: 500px;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Floating Cards Animation */
.floating-card {
    position: absolute;
    background: var(--glass-bg);
    border: var(--glass-border);
    backdrop-filter: blur(12px);
    padding: 1.5rem 2.5rem;
    border-radius: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: var(--shadow-lg);
    animation: float 6s ease-in-out infinite;
}

.korean-char {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.meaning {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.card-1 {
    top: 20%;
    left: 10%;
    animation-delay: 0s;
    transform: rotate(-10deg);
}

.card-2 {
    top: 40%;
    right: 15%;
    animation-delay: 2s;
    transform: rotate(5deg);
    background: rgba(139, 92, 246, 0.2);
    border-color: rgba(139, 92, 246, 0.3);
}

.card-3 {
    bottom: 20%;
    left: 20%;
    animation-delay: 4s;
    transform: rotate(-5deg);
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0) rotate(var(--rotation));
    }

    50% {
        transform: translateY(-20px) rotate(var(--rotation));
    }
}

.card-1 {
    --rotation: -10deg;
}

.card-2 {
    --rotation: 5deg;
}

.card-3 {
    --rotation: -5deg;
}

/* Feature Section */
.lessons-section {
    padding: 5rem 5%;
    background-color: #162036;
    /* Slightly lighter than body */
}

.section-header {
    text-align: center;
    margin-bottom: 4rem;
}

.section-tag {
    color: var(--secondary-color);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: inline-block;
}

.section-header h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.section-header p {
    color: var(--text-secondary);
    max-width: 600px;
    margin: 0 auto;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
}

.course-card {
    background: var(--surface-color);
    border: 1px solid rgba(255, 255, 255, 0.05);
    padding: 2rem;
    border-radius: 24px;
    transition: transform 0.3s ease, border-color 0.3s ease;
    display: flex;
    flex-direction: column;
}

.course-card:hover {
    transform: translateY(-10px);
    border-color: var(--primary-color);
}

.card-icon {
    width: 60px;
    height: 60px;
    background: rgba(139, 92, 246, 0.1);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

.course-card h3 {
    font-size: 1.5rem;
    margin-bottom: 0.75rem;
}

.course-card p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
    flex-grow: 1;
}

.card-link {
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: gap 0.2s ease;
}

.card-link:hover {
    gap: 0.75rem;
}

/* Footer */
.footer {
    background-color: #0b1120;
    padding: 4rem 5% 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer-content {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 3rem;
    margin-bottom: 3rem;
}

.footer-brand h3 {
    margin-bottom: 1rem;
}

.footer-brand p {
    color: var(--text-secondary);
}

.footer-links {
    display: flex;
    gap: 4rem;
}

.link-column h4 {
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

.link-column a {
    display: block;
    color: var(--text-secondary);
    text-decoration: none;
    margin-bottom: 0.75rem;
    transition: color 0.2s;
}

.link-column a:hover {
    color: var(--primary-color);
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.footer-bottom p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 768px) {
    .navbar {
        padding: 1rem 5%;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: var(--bg-color);
        flex-direction: column;
        padding: 2rem;
        gap: 1.5rem;
        text-align: center;
        border-bottom: var(--glass-border);
    }

    .nav-links.active {
        display: flex;
    }

    .menu-toggle {
        display: block;
    }

    .navbar .btn-primary {
        display: block !important;
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
        margin-left: auto;
    }

    .hero-section {
        flex-direction: column;
        text-align: center;
        padding-top: 120px;
    }

    .hero-content {
        padding-right: 0;
        margin-bottom: 3rem;
    }

    .cta-group {
        justify-content: center;
        flex-direction: column;
    }

    .stats-container {
        justify-content: center;
        gap: 1.5rem;
    }

    .hero-title {
        font-size: 2.5rem;
    }

    .hero-visual {
        width: 100%;
        height: 350px;
    }

    .flashcard {
        width: 90vw !important;
        height: 250px !important;
    }

    .kr-text {
        font-size: 2.2rem !important;
    }

    .vi-text {
        font-size: 1.8rem !important;
    }

    .quiz-input-group {
        flex-direction: column;
    }

    .tabs {
        gap: 0.5rem;
    }

    .tab-btn {
        font-size: 1rem;
        padding: 0.5rem;
    }

    /* Mobile User Menu Fix */
    .user-menu-container {
        margin-left: auto;
        margin-right: 15px;
        z-index: 1200;
        /* Higher than toggle */
    }

    .user-name {
        display: none;
        /* Hide name on mobile */
    }

    .user-trigger {
        padding: 4px;
        background: transparent;
        border: none;
    }

    .user-dropdown {
        width: 200px;
        right: -10px;
        top: 55px;
    }
}

/* User Profile Menu */
.user-menu-container {
    position: relative;
    cursor: pointer;
    font-family: var(--font-main);
    z-index: 1100;
}

/* Container for Trigger */
.user-trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    padding: 5px 14px 5px 6px;
    border-radius: 40px;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.20);
    box-shadow: var(--shadow-sm);
}

.user-trigger:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.32);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: white;
    font-size: 1.1rem;
    text-transform: uppercase;
}

.user-name {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.95rem;
    padding-right: 5px;
}

/* Dropdown */
.user-dropdown {
    position: absolute;
    top: calc(100% + 15px);
    right: 0;
    background: white;
    border-radius: 16px;
    width: 240px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);
    overflow: hidden;
    z-index: 2000;
}

.user-menu-container:hover .user-dropdown,
.user-menu-container.active .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    color: #334155 !important;
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background 0.2s;
    border-bottom: 1px solid #f1f5f9;
}

.user-dropdown a i {
    color: var(--text-secondary);
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.user-dropdown a:hover {
    background: #f8fafc;
    color: var(--primary-color) !important;
}

.user-dropdown a:hover i {
    color: var(--primary-color);
}

.user-dropdown a:last-child {
    border-bottom: none;
    color: #ef4444 !important;
}

.user-dropdown a:last-child:hover {
    background: #fef2f2;
}

/* Triangle Arrow */
.user-dropdown::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 24px;
    width: 12px;
    height: 12px;
    background: white;
    transform: rotate(45deg);
    border-top: 1px solid #f1f5f9;
    border-left: 1px solid #f1f5f9;
}

/* --- ADMIN DASHBOARD LAYOUT --- */

/* Wrapper cho Dashboard */
.dashboard-layout {
    display: flex;
    min-height: 100vh;
    padding-top: 80px;
    /* Offset cho Navbar */
}

/* Sidebar */
.admin-sidebar {
    width: 250px;
    background: var(--surface-color);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    padding: 2rem 1rem;
    position: fixed;
    top: 80px;
    bottom: 0;
    left: 0;
    overflow-y: auto;
    z-index: 900;
    display: none;
    /* Mặc định ẩn, hiện bằng JS nếu là admin */
}

.admin-sidebar.active {
    display: block;
}

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

.sidebar-item {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
}

.sidebar-item:hover,
.sidebar-item.active {
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary-color);
}

.sidebar-item i {
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

/* Main Content Area */
.dashboard-main {
    flex: 1;
    padding: 2rem;
    margin-left: 0;
    /* Mặc định user thường */
    transition: margin-left 0.3s ease;
}

.dashboard-main.admin-mode {
    margin-left: 250px;
}

/* KPI Cards Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.kpi-card {
    background: var(--surface-color);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.kpi-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.kpi-info h3 {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 0.25rem;
}

.kpi-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Data Tables */
.admin-table-container {
    background: var(--surface-color);
    border-radius: 20px;
    padding: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    overflow-x: auto;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
}

.admin-table th {
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    font-size: 0.8rem;
    letter-spacing: 1px;
}

.admin-table tr:hover td {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.02);
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
}

.status-active {
    background: rgba(34, 197, 94, 0.1);
    color: #4ade80;
}

.status-inactive {
    background: rgba(248, 113, 113, 0.1);
    color: #f87171;
}

.status-admin {
    background: rgba(139, 92, 246, 0.1);
    color: #a78bfa;
}

/* Responsive Sidebar */
@media (max-width: 768px) {
    .admin-sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .admin-sidebar.show {
        transform: translateX(0);
    }

    .dashboard-main.admin-mode {
        margin-left: 0;
    }
}

/* --- MODAL / POPUP STYLES --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: #1e293b;
    /* surface-color */
    padding: 2rem;
    border-radius: 24px;
    width: 90%;
    max-width: 450px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.9);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h3 {
    font-size: 1.5rem;
    color: white;
}

.modal-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.modal-close:hover {
    color: white;
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.modal-info-row {
    display: flex;
    justify-content: space-between;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1rem;
}
