/**
 * ========================================
 * E-LEARNING PLATFORM - CUSTOM STYLES
 * ========================================
 * Giao diện hiện đại, responsive, hỗ trợ Dark/Light Mode
 */

/* ========================================
   IMPORT FONTS
   ======================================== */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

/* ========================================
   ROOT VARIABLES - LIGHT MODE
   ======================================== */
:root {
    /* Colors */
    --primary-color: #4A90E2;
    --secondary-color: #50C878;
    --accent-color: #FFD700;
    --danger-color: #E74C3C;
    --warning-color: #F39C12;
    --success-color: #27AE60;
    
    /* Background */
    --bg-primary: #FFFFFF;
    --bg-secondary: #F8F9FA;
    --bg-tertiary: #E9ECEF;
    
    /* Text */
    --text-primary: #2C3E50;
    --text-secondary: #7F8C8D;
    --text-light: #BDC3C7;
    
    /* Border */
    --border-color: #DEE2E6;
    --border-radius: 12px;
    
    /* Shadow */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.15);
    
    /* Spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    
    /* Font */
    --font-family: 'Poppins', sans-serif;
    --font-size-base: 16px;
    
    /* Floating controls */
    --floating-size: 48px;
    --floating-gap: 10px;
    --floating-right: 22px;
    --floating-bottom: 20px;
}

/* ========================================
   DARK MODE VARIABLES
   ======================================== */
[data-theme="dark"] {
    --bg-primary: #1A1A2E;
    --bg-secondary: #16213E;
    --bg-tertiary: #0F3460;
    
    --text-primary: #EAEAEA;
    --text-secondary: #B0B0B0;
    --text-light: #808080;
    
    --border-color: #2C3E50;
    
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
}

/* ========================================
   GLOBAL STYLES
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--secondary-color);
}

/* ========================================
   NAVBAR
   ======================================== */
.navbar {
    background-color: var(--bg-primary);
    box-shadow: var(--shadow-md);
    padding: 0.7rem 0;
    position: relative;
    z-index: 1000;
    transition: background-color 0.3s ease;
}

.navbar .container {
    flex-wrap: nowrap;
}

.navbar-nav {
    flex-wrap: nowrap;
    gap: 0.35rem;
}

.mobile-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.mobile-action-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    position: relative;
}

.mobile-action-btn i {
    font-size: 0.9rem;
}

.mobile-action-btn .notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
}

.mobile-controls {
    margin-left: auto;
    position: relative;
    z-index: 1101;
    pointer-events: none;
}

.mobile-controls > * {
    pointer-events: auto;
}

@media (max-width: 576px) {
    .mobile-controls {
        z-index: 1200;
    }

    .mobile-controls .mobile-actions {
        position: fixed;
        top: 12px;
        right: 70px;
        z-index: 1199;
        background: var(--bg-primary);
        border-radius: 999px;
        padding: 0.15rem 0.35rem;
        box-shadow: var(--shadow-md);
    }

    .mobile-controls .mobile-action-btn {
        box-shadow: var(--shadow-sm);
    }

    .mobile-controls .navbar-toggler {
        position: relative;
        z-index: 1201;
    }

    .navbar .navbar-collapse {
        position: fixed;
        top: 62px;
        right: 12px;
        left: auto;
        width: min(230px, calc(100vw - 24px));
        background: var(--bg-primary);
        border-radius: 14px;
        box-shadow: 0 18px 40px rgba(15, 23, 42, 0.3);
        border: 1px solid rgba(15, 23, 42, 0.08);
        padding: 0.6rem;
        max-height: calc(100vh - 85px);
        overflow-y: auto;
        z-index: 1201;
    }

    .navbar .navbar-collapse:not(.show) {
        display: none !important;
    }

    .navbar .navbar-collapse.show {
        display: block !important;
    }

    .navbar .navbar-nav {
        flex-direction: column;
        align-items: stretch;
        gap: 0.25rem;
    }

    .navbar .navbar-nav .nav-link {
        padding: 0.4rem 0.55rem;
        border-radius: 12px;
        font-weight: 500;
        font-size: 0.95rem;
    }

    .navbar .dropdown-menu {
        position: static;
        width: 100%;
        margin-top: 0.4rem;
        border-radius: 12px;
        border: 1px solid rgba(15, 23, 42, 0.08);
        box-shadow: none;
    }

    .navbar .user-dropdown {
        display: none;
    }

    .mobile-user-card {
        background: var(--bg-secondary);
        border: 1px solid rgba(15, 23, 42, 0.08);
        border-radius: 12px;
        padding: 0.75rem;
        margin-top: 0.5rem;
        box-shadow: var(--shadow-sm);
    }

    .mobile-user-card .mobile-user-header {
        display: flex;
        align-items: center;
        gap: 0.6rem;
        margin-bottom: 0.6rem;
    }

    .mobile-user-card .mobile-user-header img {
        width: 42px;
        height: 42px;
        border-radius: 50%;
        object-fit: cover;
    }

    .mobile-user-card .mobile-user-links a {
        display: flex;
        align-items: center;
        gap: 0.45rem;
        padding: 0.35rem 0;
        border-radius: 8px;
        color: var(--text-primary);
        font-size: 0.95rem;
    }

    .mobile-user-card .mobile-user-links a i {
        width: 18px;
        color: var(--primary-color);
    }

    .mobile-user-card .mobile-user-links a.logout {
        color: var(--danger-color, #dc3545);
    }

    .mobile-manage-links {
        margin-top: 0.8rem;
        background: var(--bg-secondary);
        border: 1px solid rgba(15,23,42,0.08);
        border-radius: 12px;
        padding: 0.6rem 0.75rem;
        box-shadow: var(--shadow-sm);
    }

    .mobile-manage-links .section-title {
        font-weight: 600;
        font-size: 0.9rem;
        color: var(--text-secondary);
        display: block;
        margin-bottom: 0.4rem;
    }

    .mobile-manage-links a {
        display: flex;
        align-items: center;
        gap: 0.45rem;
        padding: 0.35rem 0;
        border-radius: 8px;
        color: var(--text-primary);
        font-size: 0.92rem;
    }

    .mobile-manage-links a i {
        width: 18px;
        color: var(--primary-color);
    }
}

.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.45);
    z-index: 900;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.menu-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

body.menu-open {
    overflow: hidden;
}

body.dashboard-page .menu-overlay {
    display: none !important;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--primary-color) !important;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.navbar-brand i {
    font-size: 1.4rem;
}

.navbar-nav .nav-link {
    color: var(--text-primary) !important;
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.35rem 0.8rem !important;
    border-radius: var(--border-radius);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    white-space: nowrap;
}

.navbar-nav .nav-link:hover {
    background-color: var(--bg-secondary);
    color: var(--primary-color) !important;
}

.navbar-nav .nav-link.active {
    background-color: var(--primary-color);
    color: white !important;
}

.navbar-nav .nav-cta {
    border: none;
    border-radius: var(--border-radius);
    padding: 0.3rem 0.75rem !important;
    margin-left: 0.2rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    background: transparent;
}

.navbar-nav .nav-cta:hover {
    background-color: var(--bg-secondary);
    color: var(--primary-color) !important;
}

.navbar-nav .nav-cta-admin {
    color: var(--danger-color) !important;
    background: transparent;
}

.navbar-nav .nav-cta-admin:hover {
    background-color: rgba(231, 76, 60, 0.1);
}

.navbar .dropdown-menu {
    border-radius: var(--border-radius);
    border: none;
    box-shadow: var(--shadow-lg);
    padding: 0.75rem;
    max-height: 420px;
    overflow-y: auto;
}

.navbar-toggler {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.35rem 0.5rem;
    transition: all 0.2s ease;
    position: relative;
    z-index: 1102;
}

.navbar-toggler:focus {
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.3);
}

.navbar-toggler-icon {
    background-image: none;
    width: 1.4rem;
    height: 2px;
    background-color: var(--text-primary);
    position: relative;
    display: block;
}

.navbar-toggler-icon::before,
.navbar-toggler-icon::after {
    content: '';
    position: absolute;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: inherit;
    transition: transform 0.2s ease;
}

.navbar-toggler-icon::before {
    transform: translateY(-6px);
}

.navbar-toggler-icon::after {
    transform: translateY(6px);
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    border-radius: var(--border-radius);
    padding: 0.6rem 1.5rem;
    font-weight: 500;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), #357ABD);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-success {
    background: linear-gradient(135deg, var(--success-color), #229954);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger-color), #C0392B);
}

.btn-warning {
    background: linear-gradient(135deg, var(--warning-color), #D68910);
}

/* ========================================
   CARDS
   ======================================== */
.card {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    transition: all 0.3s ease;
    overflow: hidden;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    background-color: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    background-color: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
}

/* ========================================
   COURSE CARD
   ======================================== */
.course-card {
    position: relative;
    height: 100%;
}

.course-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
}

.course-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: var(--accent-color);
    color: var(--text-primary);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.course-progress {
    margin-top: 1rem;
}

.progress {
    height: 8px;
    border-radius: 10px;
    background-color: var(--bg-tertiary);
}

.progress-bar {
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
    border-radius: 10px;
}

/* ========================================
   DASHBOARD STATS
   ======================================== */
.stat-card {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    text-align: center;
}

.stat-card i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.8;
}

.stat-card h3 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stat-card p {
    font-size: 1rem;
    opacity: 0.9;
}

/* ========================================
   FLOATING CONTROLS (STACKED BUTTONS)
   ======================================== */
.floating-btn {
    width: var(--floating-size);
    height: var(--floating-size);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0;
    box-shadow: var(--shadow-lg);
    border: none;
}

.floating-btn i {
    font-size: 1rem;
}

.scroll-top-btn {
    position: fixed;
    right: var(--floating-right);
    bottom: calc(var(--floating-bottom) + var(--floating-size) + var(--floating-gap));
    z-index: 997;
}

/* ========================================
   DARK MODE TOGGLE
   ======================================== */
.theme-toggle {
    position: fixed;
    bottom: var(--floating-bottom);
    right: var(--floating-right);
    width: var(--floating-size);
    height: var(--floating-size);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    transition: all 0.3s ease;
    z-index: 999;
}

.theme-toggle:hover {
    transform: scale(1.1) rotate(15deg);
}

.theme-toggle i {
    color: white;
    font-size: 1.5rem;
}

/* ========================================
   CHATBOT PREVIEW WIDGET
   ======================================== */
.chatbot-fab {
    position: fixed;
    bottom: calc(var(--floating-bottom) + 2 * (var(--floating-size) + var(--floating-gap)));
    right: var(--floating-right);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    border: none;
    border-radius: 999px;
    width: var(--floating-size);
    height: var(--floating-size);
    justify-content: center;
    padding: 0;
    background: var(--primary-color);
    color: #fff;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 997;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chatbot-fab span {
    display: none;
}

.chatbot-fab:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.2);
}

.chatbot-fab:hover span {
    display: inline-block;
    position: absolute;
    right: 60px;
    background: var(--bg-primary);
    color: var(--text-primary);
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    font-size: 0.85rem;
    box-shadow: var(--shadow-md);
    white-space: nowrap;
}

.chatbot-panel {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 250px;
    height: 400px;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: 0 20px 45px rgba(0,0,0,0.2);
    border: 1px solid var(--border-color);
    z-index: 996;
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.chatbot-panel.active {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.chatbot-header {
    padding: 0.45rem 0.75rem;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: #fff;
    border-radius: 16px 16px 0 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    cursor: move;
    user-select: none;
}

.chatbot-panel.dragging {
    opacity: 0.95;
    cursor: grabbing;
}

.chatbot-header .chatbot-label {
    font-weight: 600;
}

.chatbot-status {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: rgba(255,255,255,0.85);
}

.chatbot-status .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
}

.chatbot-body {
    padding: 0.5rem 0.65rem 0.65rem;
    font-size: 0.82rem;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.chatbot-suggestions {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.65rem;
}

.chatbot-suggestion {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.35rem 0.55rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chatbot-suggestion:hover {
    background: var(--bg-primary);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.chatbot-input textarea {
    resize: none;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.8rem;
    padding: 0.3rem 0.45rem;
}

.chatbot-input .btn {
    font-size: 0.85rem;
    padding: 0.4rem 0.65rem;
}

.chatbot-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-right: 0.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chatbot-message {
    border-radius: 10px;
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
    line-height: 1.4;
    box-shadow: var(--shadow-sm);
}

.chatbot-message.user {
    background: var(--primary-color);
    color: #fff;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chatbot-message.assistant {
    background: var(--bg-secondary);
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chatbot-message small {
    display: block;
    margin-top: 0.25rem;
    opacity: 0.65;
    font-size: 0.7rem;
}

.chatbot-status-banner {
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    background: var(--bg-secondary);
}

.chatbot-status-banner i {
    color: var(--primary-color);
}

.chatbot-loading {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

body.no-chatbot .chatbot-fab,
body.no-chatbot .chatbot-panel {
    display: none !important;
}

[data-theme="dark"] .chatbot-panel {
    box-shadow: 0 20px 45px rgba(0,0,0,0.45);
}

@media (max-width: 576px) {
    .chatbot-fab {
        right: 15px;
        bottom: 140px;
    }

    .chatbot-panel {
        right: 15px;
        left: 15px;
        width: min(90vw, 280px);
        height: 360px;
        bottom: 150px;
    }
}

/* ========================================
   NOTIFICATION BADGE
   ======================================== */
.notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--danger-color);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ========================================
   FORUM STYLES
   ======================================== */
.forum-topic {
    background-color: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    transition: all 0.3s ease;
}

.forum-topic:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.forum-topic.pinned {
    border-left: 4px solid var(--accent-color);
}

.forum-reply {
    background-color: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1rem;
}

.forum-reply.solution {
    border-left: 4px solid var(--success-color);
}

/* ========================================
   CHAT STYLES
   ======================================== */
.chat-container {
    height: 600px;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background-color: var(--bg-secondary);
}

.chat-message {
    margin-bottom: 1rem;
    display: flex;
    align-items: flex-start;
}

.chat-message.sent {
    flex-direction: row-reverse;
}

.chat-message .avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    margin: 0 0.5rem;
}

.chat-bubble {
    background-color: var(--bg-primary);
    padding: 0.8rem 1.2rem;
    border-radius: 18px;
    max-width: 70%;
    box-shadow: var(--shadow-sm);
}

.chat-message.sent .chat-bubble {
    background: linear-gradient(135deg, var(--primary-color), #357ABD);
    color: white;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 992px) {
    body {
        font-size: 15px;
    }

    .navbar {
        padding: 0.85rem 0;
    }

    .navbar-nav .nav-link {
        padding: 0.6rem 0.75rem !important;
    }

    .navbar .dropdown-menu {
        width: 100%;
        margin-top: 0.75rem;
    }

    .hero-section {
        text-align: center;
        padding: 3rem 0;
    }

    .hero-section .row {
        flex-direction: column-reverse;
    }

    .hero-section img {
        max-width: 420px;
        width: 100%;
        margin: 2rem auto 0;
        display: block;
    }

    .hero-section .d-flex {
        flex-direction: column;
        gap: 0.75rem !important;
    }

    .hero-section .btn {
        width: 100%;
    }

    .stat-card {
        padding: 1.5rem;
        margin-bottom: 1rem;
    }

    .stat-card h3 {
        font-size: 2rem;
    }

    .stat-card i {
        font-size: 2.5rem;
    }

    .card-header {
        padding: 1rem 1.25rem;
    }

    .card-body {
        padding: 1.25rem;
    }

    .table-responsive {
        border-radius: var(--border-radius);
        margin-bottom: 1.5rem;
        box-shadow: var(--shadow-sm);
    }

    .table-responsive table {
        min-width: 640px;
    }

    .course-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .course-stats {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
    }

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

    .floating-controls {
        bottom: 70px;
        right: 15px;
    }

    .chat-container {
        height: 520px;
    }
}

// ...existing code...
@media (max-width: 576px) {
    body {
        font-size: 14px;
    }

    .navbar {
        padding: 0.5rem 0;
    }

    .navbar-brand {
        font-size: 0.95rem;
    }

    .navbar .container {
        padding: 0 0.75rem;
    }

    .navbar-nav {
        flex-direction: column;
        align-items: stretch;
        gap: 0.1rem;
    }

    /* overlay */
    .menu-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.35);
        z-index: 1000;
        pointer-events: auto;
    }

    body.menu-open .menu-overlay {
        display: block;
    }

    body.menu-open {
        overflow: hidden;
    }

    /* menu: nhỏ gọn, không quá to */
    .navbar-collapse,
    .navbar-collapse.show,
    .navbar-collapse.collapsing {
        position: absolute;
        top: 50px;
        right: 0.5rem;
        width: min(85%, 200px);
        background: var(--bg-primary);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        padding: 0.25rem 0;
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
        z-index: 1200;
        max-height: calc(100vh - 70px);
        overflow-y: auto;
        display: block !important;
    }

    /* ẩn các nút nổi khi menu mở */
    body.menu-open .theme-toggle,
    body.menu-open .chatbot-fab,
    body.menu-open .scroll-top-btn,
    body.menu-open .floating-btn {
        display: none !important;
        pointer-events: none !important;
    }

    .navbar .dropdown-menu {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        margin-top: 2px;
        padding: 0.2rem 0;
        box-shadow: 0 6px 12px rgba(0,0,0,0.1);
        border: 1px solid var(--border-color);
        background: var(--bg-primary);
        border-radius: 6px;
        z-index: 2000;
        display: none;
    }

    .navbar .dropdown.show > .dropdown-menu {
        display: block !important;
    }

    .navbar .dropdown-item {
        border-radius: 4px;
        padding: 6px 10px;
        display: flex;
        align-items: center;
        gap: 0.25rem;
        font-size: 0.8rem;
        width: 100%;
    }

    .navbar .dropdown-item:hover {
        background: var(--bg-secondary);
    }

    .navbar-nav .nav-link {
        width: 100%;
        display: flex;
        align-items: center;
        gap: 0.25rem;
        padding: 7px 10px !important;
        font-size: 0.85rem;
    }

    .navbar-nav .nav-cta,
    .navbar-nav .nav-cta-admin {
        width: 100%;
        justify-content: center;
        margin-left: 0;
        font-size: 0.8rem;
        padding: 6px 8px !important;
    }

    .navbar-collapse .dropdown-header {
        font-size: 0.75rem;
        padding: 4px 8px;
        text-align: left;
        font-weight: 600;
    }

    .hero-section .display-4 {
        font-size: 1.8rem;
        line-height: 1.2;
    }

    .hero-section .lead {
        font-size: 0.9rem;
    }

    .stat-card {
        text-align: left;
    }

    .stat-card h3 {
        font-size: 1.4rem;
    }

    .stat-card p {
        font-size: 0.85rem;
    }

    .course-card,
    .card {
        margin-bottom: 1.25rem;
    }

    .course-card-body {
        padding: 0.9rem;
    }

    .course-title {
        font-size: 0.95rem;
        min-height: auto;
    }

    .course-description {
        -webkit-line-clamp: 3;
    }

    .course-author span {
        max-width: 100%;
    }

    .course-stats {
        gap: 0.5rem;
    }

    .table-responsive table {
        min-width: 480px;
        font-size: 0.8rem;
    }

    .table-responsive::-webkit-scrollbar {
        height: 5px;
    }

    .table-responsive::-webkit-scrollbar-thumb {
        background-color: rgba(0, 0, 0, 0.15);
        border-radius: 3px;
    }

    .chat-message {
        flex-direction: column;
        align-items: flex-start;
        font-size: 0.85rem;
    }

    .chat-message.sent {
        flex-direction: column;
        align-items: flex-end;
    }

    .chat-message .avatar {
        width: 28px;
        height: 28px;
        margin-bottom: 0.25rem;
    }

    .chat-bubble {
        max-width: 95%;
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    #scrollTopBtn {
        bottom: 70px;
        right: 15px;
        width: 40px;
        height: 40px;
    }
}
// ...existing code...

@media (max-width: 400px) {
    .navbar-brand {
        font-size: 1rem;
    }

    .hero-section .display-4 {
        font-size: 1.8rem;
    }

    .hero-section img {
        max-width: 280px;
    }

    .stat-card {
        padding: 1.25rem;
    }

    .theme-toggle {
        width: 48px;
        height: 48px;
        bottom: 15px;
        right: 15px;
    }
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.text-muted {
    color: var(--text-secondary) !important;
}

.bg-light {
    background-color: var(--bg-secondary) !important;
}

.border-radius {
    border-radius: var(--border-radius);
}

.shadow-sm {
    box-shadow: var(--shadow-sm);
}

.shadow-md {
    box-shadow: var(--shadow-md);
}

.shadow-lg {
    box-shadow: var(--shadow-lg);
}

/* ========================================
   COURSE CARD STYLES
   ======================================== */

.course-card {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
}

.course-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
}

.course-card img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    display: block;
}

.course-card-body {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.course-meta {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.course-meta .badge {
    font-size: 0.75rem;
    padding: 0.35rem 0.75rem;
    font-weight: 500;
}

.course-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
    line-height: 1.4;
    min-height: 60px;
}

.course-title a {
    color: var(--text-primary);
    text-decoration: none;
    transition: color 0.3s ease;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.course-title a:hover {
    color: var(--primary-color);
}

.course-description {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1rem;
    flex: 1;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.course-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
    gap: 1rem;
}

.course-author {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
}

.course-author img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.course-author span {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.course-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.course-stats span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    white-space: nowrap;
}

.course-stats i {
    color: var(--primary-color);
}

@media (max-width: 576px) {
    .course-card {
        padding: 1.1rem;
    }

    .course-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.6rem;
    }

    .course-author img {
        width: 26px;
        height: 26px;
    }

    .course-author span {
        font-size: 0.8rem;
    }
}

/* ========================================
   PERSONAL LEARNING ROADMAP
   ======================================== */
.roadmap-card {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    height: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.roadmap-course {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.roadmap-progress .progress {
    height: 8px;
    margin-bottom: 0.35rem;
}

.roadmap-step {
    border: 1px dashed var(--border-color);
    border-radius: 10px;
    padding: 0.65rem;
    display: flex;
    justify-content: space-between;
    gap: 0.5rem;
    align-items: center;
}

.roadmap-step strong {
    font-size: 0.9rem;
}

.roadmap-step .btn {
    flex-shrink: 0;
}

.roadmap-card small {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

@media (max-width: 768px) {
    .roadmap-card {
        padding: 0.85rem;
    }

    .roadmap-step {
        flex-direction: column;
        align-items: flex-start;
    }

    .roadmap-step .btn {
        width: 100%;
    }
}

/* Responsive adjustments for course cards */
@media (max-width: 768px) {
    .course-card img {
        height: 180px;
    }

    .course-card-body {
        padding: 1rem;
    }

    .course-title {
        font-size: 1.1rem;
        min-height: auto;
    }

    .course-footer {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .course-author {
        width: 100%;
    }

    .course-stats {
        width: 100%;
        justify-content: space-between;
    }

    .admin-layout .col-md-3.col-lg-2 {
        width: 100%;
        order: -1;
        margin-bottom: 1rem;
        position: static !important;
        top: auto !important;
        z-index: auto !important;
    }

    .admin-layout .col-md-3.col-lg-2 .card {
        position: static !important;
    }

    .admin-layout .col-md-9.col-lg-10 {
        width: 100%;
    }
}

/* ========================================
   COURSE BADGE (for index.php)
   ======================================== */

.card.course-card {
    position: relative;
    border: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

.card.course-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
}

.card.course-card .card-img-top {
    height: 200px;
    object-fit: cover;
}

.course-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--primary-color);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

[data-theme="dark"] .course-badge {
    background: rgba(26, 26, 46, 0.95);
    color: var(--primary-color);
}

.card.course-card .card-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.75rem;
    min-height: 60px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.card.course-card .card-text {
    color: var(--text-secondary);
    line-height: 1.6;
}

.card.course-card .btn-primary {
    background: var(--primary-color);
    border: none;
    padding: 0.5rem 1.5rem;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.card.course-card .btn-primary:hover {
    background: var(--secondary-color);
    transform: scale(1.05);
}

/* ========================================
   ADMIN SIDEBAR MENU - FIX ICON ALIGNMENT
   ======================================== */

/* Sidebar default (no sticky) */
.col-md-3.col-lg-2.mb-4 {
    position: static;
    top: auto;
    align-self: stretch;
    z-index: auto;
}

@media (max-width: 768px) {
    .col-md-3.col-lg-2.mb-4 {
        width: 100% !important;
        order: -1;
        margin-bottom: 1rem;
    }

    .col-md-9.col-lg-10 {
        width: 100% !important;
    }
}

/* Icon alignment */
.list-group-item i {
    display: inline-block;
    width: 20px;
    text-align: center;
    margin-right: 10px;
}

.list-group-item {
    transition: all 0.3s ease;
}

.list-group-item:hover {
    background-color: var(--bg-secondary);
    padding-left: 1.5rem;
}

.list-group-item.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.list-group-item.active:hover {
    background-color: var(--primary-color);
}
/* ========================================
   FIX DROPDOWN AVATAR TRONG MENU MOBILE
   ======================================== */
@media (max-width: 576px) {
    /* Dropdown phải có position: relative để dropdown-menu absolute hiển thị đúng */
    .navbar-collapse .nav-item.dropdown {
        position: relative;
    }

    .navbar-collapse .dropdown-menu {
        position: absolute !important;
        top: 100% !important;
        left: 0 !important;
        right: auto !important;
        width: 100% !important;
        margin-top: 4px !important;
        padding: 0.3rem 0 !important;
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15) !important;
        border: 1px solid var(--border-color) !important;
        background: var(--bg-primary) !important;
        border-radius: 6px !important;
        z-index: 2100 !important;
        display: none !important;
        min-width: unset !important;
    }

    /* Hiển thị dropdown khi có class show */
    .navbar-collapse .dropdown.show > .dropdown-menu,
    .navbar-collapse .nav-item.dropdown.show > .dropdown-menu {
        display: block !important;
    }

    .navbar-collapse .dropdown-item {
        padding: 8px 12px !important;
        border-radius: 4px !important;
        font-size: 0.85rem !important;
    }

    .navbar-collapse .dropdown-item:hover {
        background: rgba(74, 144, 226, 0.1) !important;
    }

    .navbar-collapse .dropdown-divider {
        margin: 0.3rem 0 !important;
    }
}

/* === Responsive Navbar overrides === */
.navbar .dropdown-menu{max-height:70vh;overflow-y:auto;overflow-x:hidden;}
@media (max-width:576px){
  .navbar .navbar-collapse{position:fixed;top:0;right:0;left:auto;width:min(260px,calc(100vw-30px));height:100vh;background:var(--bg-primary);border-radius:0 0 0 20px;box-shadow:0 25px 45px rgba(15,23,42,0.35);border-left:1px solid rgba(15,23,42,0.08);border-bottom:1px solid rgba(15,23,42,0.08);padding:1rem 0.8rem 1.2rem;overflow-y:auto;z-index:1201;transform:translateX(100%);transition:transform .25s ease;}
  .navbar .navbar-collapse.show{transform:translateX(0);}
  .navbar .navbar-nav{flex-direction:column;align-items:stretch;gap:0.2rem;}
  .navbar .navbar-nav .nav-link{padding:0.5rem 0.65rem;border-radius:12px;font-weight:500;font-size:0.92rem;width:100%;}
  .navbar .dropdown-menu{position:static;width:100%;margin-top:0.4rem;border-radius:12px;border:1px solid rgba(15,23,42,0.08);max-height:55vh;overflow-y:auto;box-shadow:none;display:none;padding:0.35rem;}
  .navbar .dropdown.mobile-expanded>.dropdown-menu,.navbar .dropdown-menu.show{display:block!important;}
  .navbar .dropdown-item{border-radius:6px;padding:0.35rem 0.55rem;font-size:0.83rem;gap:0.35rem;}
  .navbar-collapse .nav-item.dropdown.notifications,.navbar-collapse .nav-item.dropdown.messages{display:block!important;}
  .teacher-manage-dropdown .dropdown-menu{display:none;background:var(--bg-secondary);}
  .teacher-manage-dropdown.mobile-expanded .dropdown-menu{display:block!important;}
  .teacher-manage-dropdown .dropdown-item{font-size:0.83rem;}
  .navbar .user-dropdown{display:none;}
  .mobile-user-card{background:var(--bg-secondary);border:1px solid rgba(15,23,42,0.08);border-radius:12px;padding:0.75rem;margin-top:0.5rem;box-shadow:var(--shadow-sm);}
  .mobile-user-card .mobile-user-header{display:flex;align-items:center;gap:0.6rem;margin-bottom:0.6rem;}
  .mobile-user-card .mobile-user-header img{width:42px;height:42px;border-radius:50%;object-fit:cover;}
  .mobile-user-card .mobile-user-links a{display:flex;align-items:center;gap:0.45rem;padding:0.35rem 0;border-radius:8px;color:var(--text-primary);font-size:0.95rem;}
  .mobile-user-card .mobile-user-links a i{width:18px;color:var(--primary-color);} 
  .mobile-user-card .mobile-user-links a.logout{color:var(--danger-color,#dc3545);}
}

