/* ============================================================
   EduConnect AI - main.css
   Global Variables, Layout, and Reusable Components
   ============================================================ */

/* @import PHẢI ở đầu file (CSS spec) - sửa lỗi Android Chrome */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&display=swap');

/* ─── CẤU TRÚC LAYOUT 3 CỘT (VIEWPORT FIT 100VH) ─── */
.main-layout-wrapper {
    display: flex;
    justify-content: center;
    gap: clamp(12px, 2vw, 24px);
    max-width: 100%;
    margin: 0;
    padding: clamp(10px, 2vh, 20px) clamp(16px, 3vw, 40px);
    align-items: stretch;
    height: calc(100vh - 70px);
    overflow: hidden;
}

/* Sidebar Nav Base */
.left-sidebar {
    height: 100%;
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: clamp(10px, 1.5vh, 20px) 15px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), padding 0.3s ease;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 100;
    flex-shrink: 0;
    min-height: 0;
    position: relative !important;
    top: 0 !important;
}

    /* Trạng thái MỞ RỘNG */
    .left-sidebar.expanded {
        width: clamp(230px, 19vw, 280px);
    }

    /* Trạng thái THU GỌN (Cực nhỏ) */
    .left-sidebar.collapsed {
        width: 74px;
        min-width: 74px;
        padding: 20px 10px;
        align-items: center;
    }

.center-content {
    flex: 1;
    min-width: 0;
    min-height: 0; /* Flex fix */
    height: 100%;
    overflow-y: auto;
    scrollbar-gutter: stable;
    transition: all 0.4s ease;
    padding-right: 4px;
}

.right-sidebar {
    position: relative;
    width: clamp(280px, 23vw, 340px);
    flex-shrink: 0;
    height: 100%;
    overflow-y: auto;
    background: transparent;
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease, margin 0.3s ease;
    min-height: 0;
}

    /* Collapsible Right Sidebar State */
    .right-sidebar.collapsed {
        width: 0;
        min-width: 0;
        margin-left: -24px;
        padding-left: 0;
        padding-right: 0;
        border: none;
        overflow: visible !important;
    }

    .right-sidebar.collapsed > *:not(.toggle-right-sidebar-btn) {
        display: none;
    }

/* NÚT BẤM TOGGLE SIDEBAR */
.toggle-sidebar-btn {
    position: absolute;
    top: 15px;
    right: -12px;
    width: 24px;
    height: 24px;
    background: #faad14;
    color: #000;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 110;
    transition: transform 0.4s, background 0.3s, left 0.4s;
}

    .toggle-sidebar-btn:hover {
        background: #fff;
        transform: scale(1.1);
    }

.left-sidebar.collapsed .toggle-sidebar-btn {
    transform: rotate(180deg); /* Quay mũi tên lại */
}

/* NÚT BẤM TOGGLE RIGHT SIDEBAR */
.toggle-right-sidebar-btn {
    position: absolute;
    top: 15px;
    left: -12px;
    width: 24px;
    height: 24px;
    background: #faad14;
    color: #000;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 110;
    transition: transform 0.4s, background 0.3s, left 0.4s;
}

.toggle-right-sidebar-btn:hover {
    background: #fff;
    transform: scale(1.1);
}

.right-sidebar.collapsed .toggle-right-sidebar-btn {
    transform: rotate(180deg);
    left: -24px;
}

/* SIDEBAR CONTENT VISIBILITY */
.sidebar-user-zone {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-width: 0;          /* FIX: cho phép flex co lại đúng */
    margin-bottom: 16px;
    /* Bỏ overflow:hidden ở đây để không clip nội dung con */
}

.user-avatar-mini {
    width: 44px;
    height: 44px;
    min-width: 44px;       /* FIX: giữ avatar không bị co */
    border-radius: 50%;
    background: var(--accent-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;        /* FIX: avatar không bao giờ bị ẩn */
    border: 2px solid var(--primary-color);
    object-fit: cover;
    box-shadow: 0 0 0 3px var(--accent-color);
}

.user-info-text {
    flex: 1;
    min-width: 0;          /* FIX: cho phép truncate text đúng cách */
    overflow: hidden;
    transition: opacity 0.3s ease, max-width 0.4s ease;
}

.user-name {
    font-weight: 700;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* FIX: cắt text thay vì bị ẩn */
    margin: 0 0 2px 0;
}

.user-currency {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 1px;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-divider {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 0 0 12px 0;
    width: 100%;
}

/* Khi thu gọn: ẩn text, chỉ hiện avatar */
.left-sidebar.collapsed .user-info-text,
.left-sidebar.collapsed .sidebar-divider,
.left-sidebar.collapsed .menu-text {
    display: none !important;
}

/* Khi thu gọn: căn giữa avatar */
.left-sidebar.collapsed .sidebar-user-zone {
    justify-content: center;
    margin-bottom: 12px;
}

/* MENU ITEMS */
.nav-menu-links {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    color: var(--text-color);
    border-radius: 12px;
    transition: var(--transition);
    white-space: nowrap;
    position: relative;
    font-weight: 500;
}

    .menu-item:hover {
        background: var(--accent-color);
        color: var(--primary-color);
    }

    .menu-item.active {
        background: var(--primary-gradient) !important;
        color: white !important;
        box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
    }

.menu-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

/* HOVER TOOLTIP KHI SIDEBAR THU GỌN */
.left-sidebar.collapsed .menu-item:hover::after {
    content: attr(data-title);
    position: absolute;
    left: 65px;
    top: 50%;
    transform: translateY(-50%);
    background: #1e293b;
    color: #fff;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
    z-index: 1000;
}

/* Fix mobile responsive stack */
@media (max-width: 1024px) {
    .main-layout-wrapper {
        flex-direction: column;
        height: auto;
        overflow: visible;
        padding: 0 12px 80px 12px;
    }

    .left-sidebar {
        width: 100% !important;
        height: auto !important;
        position: static !important;
        max-height: 60px !important;
        overflow: hidden !important;
        flex-direction: row !important;
        align-items: center;
        padding: 8px 12px !important;
        display: none !important; /* Ẩn sidebar trên mobile, dùng bottom nav thay */
    }

    .center-content {
        width: 100% !important;
        height: auto !important;
        overflow: visible !important;
    }

    .right-sidebar {
        width: 100% !important;
        height: auto !important;
        position: static !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .toggle-sidebar-btn, #btn-toggle-right-sidebar {
        display: none !important;
    }
}

:root {
    /* Modern Premium Color Palette */
    --primary-color: #4F46E5; /* Royal Indigo */
    --primary-dark: #312E81; /* Deep Indigo */
    --primary-light: #818CF8;
    --secondary-color: #C7D2FE;
    --accent-color: #EEF2FF; /* Soft lavender-blue accent */
    --text-color: #1E293B; /* Slate 800 */
    --text-muted: #64748B; /* Slate 500 */
    --bg-color: #F8FAFC; /* Slate 50 */
    --card-bg: #FFFFFF;
    --border-color: #E2E8F0; /* Slate 200 */
    /* Gradients */
    --primary-gradient: linear-gradient(135deg, #4F46E5 0%, #6366F1 50%, #818CF8 100%);
    --accent-gradient: linear-gradient(135deg, #EEF2FF 0%, #E0E7FF 100%);
    /* Functional Colors */
    --success: #10B981; /* Emerald 500 */
    --danger: #EF4444; /* Red 500 */
    --warning: #F59E0B; /* Amber 500 */
    --info: #06B6D4; /* Cyan 500 */
    /* Gamification Colors */
    --streak-fire: #FF5722;
    --hp-bar: #EF4444;
    --exp-bar: #F59E0B;
    --rank-gold: #F59E0B;
    --rank-silver: #94A3B8;
    --rank-bronze: #B45309;
    /* Spacing & Borders */
    --radius: 16px; /* Larger, smoother modern border-radius */
    --radius-sm: 10px;
    --radius-lg: 24px;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.02);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── DARK MODE ─── */
body.dark {
    --primary-color: #818CF8;
    --primary-dark: #C7D2FE;
    --primary-light: #6366F1;
    --secondary-color: #312E81;
    --accent-color: #1E1B4B;
    --text-color: #E2E8F0;
    --text-muted: #94A3B8;
    --bg-color: #0F172A;
    --card-bg: #1E293B;
    --border-color: #334155;
    --primary-gradient: linear-gradient(135deg, #6366F1 0%, #818CF8 50%, #A5B4FC 100%);
    --accent-gradient: linear-gradient(135deg, #1E1B4B 0%, #312E81 100%);
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -2px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

body.dark img {
    opacity: 0.92;
}

body.dark #preview-container,
body.dark #preview-text {
    background: #1a2236 !important;
    color: #E2E8F0 !important;
}

body.dark .docx-wrapper {
    background: #1a2236 !important;
}

body.dark .docx {
    background: #1E293B !important;
    color: #E2E8F0 !important;
}

body.dark input,
body.dark select,
body.dark textarea {
    background-color: #0F172A;
    color: #E2E8F0;
    border-color: #334155;
}

body.dark input::placeholder,
body.dark textarea::placeholder {
    color: #64748B;
}

body.dark .modal-content {
    background: #1E293B;
    border-color: #334155;
}

/* Prevent flash of unstyled content before JS injects the new theme switch */
#dark-mode-toggle {
    display: none;
}

body.dark #topbar {
    background: rgba(15, 23, 42, 0.9);
    border-bottom-color: #334155;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

body.dark #topbar #search-box {
    background: #1E293B;
    border-color: #334155;
    color: #E2E8F0;
}

body.dark #topbar #notif-bell {
    background: #1E293B;
    border-color: #334155;
}

body.dark #topbar #notif-bell:hover {
    background: #334155;
    border-color: #6366F1;
}

body.dark #user-dropdown {
    background: #1E293B !important;
    border: 1px solid #334155;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important;
}

body.dark #user-dropdown a {
    color: #E2E8F0 !important;
}

body.dark #user-dropdown a:hover {
    background: #334155;
    border-radius: 6px;
}

body.dark #username {
    color: #E2E8F0;
}

body.dark #user-avatar {
    border-color: #818CF8;
}

/* Global Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 99px;
}

    ::-webkit-scrollbar-thumb:hover {
        background: var(--text-muted);
    }

/* Base Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    min-height: 100vh;
    /* Không dùng overflow:hidden vì gây trắng màn hình trên mobile */
}

/* Chỉ dùng fixed layout trên desktop */
@media (min-width: 1025px) {
    html, body {
        height: 100vh;
        overflow: hidden;
    }
}

body {
    font-family: 'Plus Jakarta Sans', 'Outfit', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
    display: flex;
    flex-direction: column;
}

a {
    text-decoration: none;
    color: var(--primary-color);
    transition: var(--transition);
}

    a:hover {
        color: var(--primary-dark);
    }

ul {
    list-style: none;
}

button {
    cursor: pointer;
    border: none;
    outline: none;
    font-family: inherit;
    transition: var(--transition);
}

input, textarea, select {
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: inherit;
    background: var(--card-bg);
    color: var(--text-color);
    transition: var(--transition);
}

    input:focus, textarea:focus, select:focus {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
        outline: none;
    }

/* Layout Framework */
#topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    color: var(--text-color);
    padding: 0 40px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.03);
    transition: var(--transition);
    flex-shrink: 0; /* Important for 100vh layout */
}

    #topbar .left h1 {
        font-family: 'Outfit', sans-serif;
        font-weight: 800;
        font-size: 24px;
        background: var(--primary-gradient);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        letter-spacing: -0.5px;
    }

    #topbar .center {
        flex-grow: 1;
        max-width: 500px;
        margin: 0 40px;
    }

    #topbar #search-box {
        width: 100%;
        padding: 10px 20px;
        border-radius: 24px;
        border: 1px solid var(--border-color);
        background: var(--bg-color);
        color: var(--text-color);
    }

    #topbar .right {
        display: flex;
        align-items: center;
        gap: 16px;
    }

    #topbar #notif-bell {
        background: var(--bg-color);
        border: 1px solid var(--border-color);
        border-radius: 50%;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        position: relative;
        font-size: 16px;
    }

        #topbar #notif-bell:hover {
            background: var(--accent-color);
            border-color: var(--primary-light);
        }

#notif-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--card-bg);
}

#user-menu-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    transition: var(--transition);
}

    #user-menu-trigger:hover {
        background: var(--accent-color);
        border-color: var(--primary-light);
    }

#user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 1.5px solid var(--primary-color);
}

#username {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-color);
}

/* ===================================================
   DAY-NIGHT SWITCH ANIMATION
   =================================================== */
.theme-switch {
    --container-width: 6.5em;
    --container-height: 2.5em;
    --container-radius: 6.25em;
    --container-light-bg: #3D7EAE;
    --container-night-bg: #1D1F2C;
    
    --circle-container-diameter: 3.375em;
    --sun-moon-diameter: 2.125em;
    --sun-bg: #ECCA2F;
    --moon-bg: #C4C9D1;
    --spot-color: #959DB1;
    
    --stars-color: #fff;
    --clouds-color: #F3FDFF;
    --back-clouds-color: #AACADF;

    display: inline-block;
    position: relative;
    width: var(--container-width);
    height: var(--container-height);
    font-size: 13px; /* Đã điều chỉnh kích thước phù hợp với header */
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.theme-switch .slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: var(--container-light-bg);
    border-radius: var(--container-radius);
    overflow: hidden;
    transition: background-color 0.4s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2) inset;
}

.theme-switch .circle {
    position: absolute;
    height: var(--sun-moon-diameter);
    width: var(--sun-moon-diameter);
    left: 0.1875em;
    bottom: 0.1875em;
    background-color: var(--sun-bg);
    border-radius: 50%;
    transition: transform 0.45s cubic-bezier(0.54, 1.2, 0.4, 1.1), background-color 0.4s ease;
    z-index: 3;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.theme-switch .clouds-wrapper {
    position: absolute;
    width: 100%;
    height: 100%;
    bottom: -0.6em;
    right: -0.2em;
    transition: transform 0.4s ease, opacity 0.3s ease;
    z-index: 2;
}

.theme-switch .cloud {
    position: absolute;
    background: var(--clouds-color);
    border-radius: 50%;
}

.theme-switch .cloud-main {
    width: 2.2em;
    height: 1.2em;
    bottom: 0.4em;
    right: -0.2em;
}
.theme-switch .cloud-main::before {
    content: "";
    position: absolute;
    width: 1.2em;
    height: 1.2em;
    background: var(--clouds-color);
    border-radius: 50%;
    top: -0.5em;
    left: 0.4em;
}

.theme-switch .cloud-back {
    width: 2em;
    height: 1em;
    bottom: 0.6em;
    right: 0.8em;
    background: var(--back-clouds-color);
    z-index: -1;
}

.theme-switch .stars {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    opacity: 0;
    transition: opacity 0.4s ease;
    z-index: 1;
}
.theme-switch .star {
    position: absolute;
    background: var(--stars-color);
    border-radius: 50%;
    transition: transform 0.4s ease;
    transform: translateY(-20px);
}
.theme-switch .star:nth-child(1) { top: 0.5em; left: 1.2em; width: 3px; height: 3px; }
.theme-switch .star:nth-child(2) { top: 0.9em; left: 2.2em; width: 2px; height: 2px; }
.theme-switch .star:nth-child(3) { top: 0.4em; left: 3.2em; width: 3px; height: 3px; }

/* CHECKED STATE */
.theme-switch input:checked + .slider {
    background-color: var(--container-night-bg);
}

.theme-switch input:checked + .slider .circle {
    transform: translateX(calc(var(--container-width) - var(--sun-moon-diameter) - 0.375em));
    background-color: var(--moon-bg);
    box-shadow: inset -5px -4px 0px var(--spot-color), 0 2px 5px rgba(0,0,0,0.2);
}

.theme-switch input:checked + .slider .clouds-wrapper {
    transform: translateY(2em);
    opacity: 0;
}

.theme-switch input:checked + .slider .stars {
    opacity: 1;
}
.theme-switch input:checked + .slider .stars .star {
    transform: translateY(0);
}

/* Main Container */
main {
    max-width: 100%;
    margin: 0;
    padding: 0;
}

/* Sidebar Styles */
#col-left, #col-right {
    position: sticky;
    top: 90px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Sidebar Navigation */
#nav-links a {
    display: flex !important;
    align-items: center;
    gap: 12px;
    padding: 12px 16px !important;
    border-radius: var(--radius-sm) !important;
    color: var(--text-color) !important;
    font-weight: 500 !important;
    background: transparent !important;
    transition: var(--transition) !important;
}

    #nav-links a:hover {
        background: var(--accent-color) !important;
        color: var(--primary-color) !important;
        transform: translateX(4px);
    }

    #nav-links a[style*="background: var(--accent-color)"],
    #nav-links a[style*="background:var(--accent-color)"] {
        background: var(--primary-gradient) !important;
        color: white !important;
        box-shadow: 0 4px 15px rgba(79, 70, 229, 0.25) !important;
        font-weight: 600 !important;
    }

/* Cards & UI Components */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

    .card:hover {
        box-shadow: var(--shadow-md);
        transform: translateY(-2px);
    }

.btn {
    padding: 10px 20px;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 4px 14px rgba(79, 70, 229, 0.2);
}

    .btn-primary:hover {
        box-shadow: 0 6px 20px rgba(79, 70, 229, 0.3);
        opacity: 0.95;
        transform: translateY(-1px);
    }

    .btn-primary:active {
        transform: translateY(1px);
    }

/* Feed Tabs */
#feed-tabs {
    background: var(--card-bg);
    padding: 6px;
    border-radius: 30px;
    border: 1px solid var(--border-color);
    display: inline-flex !important;
    gap: 5px;
    margin-bottom: 20px;
}

    #feed-tabs .btn {
        border-radius: 24px;
        padding: 8px 20px;
        font-size: 14px;
        font-weight: 500;
        color: var(--text-muted);
        background: transparent;
        border: none;
    }

        #feed-tabs .btn:hover {
            color: var(--primary-color);
            background: var(--accent-color);
        }

        #feed-tabs .btn.active {
            background: var(--primary-gradient);
            color: white;
            box-shadow: 0 4px 10px rgba(79, 70, 229, 0.2);
            font-weight: 600;
        }

/* Create Post Box */
#create-post-box {
    padding: 16px 20px;
}

    #create-post-box button {
        border: 1px solid var(--border-color);
        border-radius: 24px !important;
        padding: 14px 20px !important;
        background: var(--bg-color) !important;
        color: var(--text-muted) !important;
        font-weight: 500 !important;
        font-size: 15px !important;
        box-shadow: none !important;
        transition: var(--transition) !important;
    }

        #create-post-box button:hover {
            background: var(--accent-color) !important;
            color: var(--primary-color) !important;
            border-color: var(--primary-light) !important;
        }

/* Modal styling */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(11, 15, 25, 0.5);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-content {
    background: var(--card-bg);
    padding: 30px;
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    position: relative;
}

/* Post Cards */
.post-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

    .post-card:hover {
        box-shadow: var(--shadow-md);
        transform: translateY(-2px);
        border-color: var(--primary-light);
    }

.post-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

    .post-header img {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        border: 2px solid var(--border-color);
        object-fit: cover;
    }

.tag-chip {
    display: inline-block;
    background: rgba(79, 70, 229, 0.08);
    color: var(--primary-color);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    margin: 4px 4px 4px 0;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
    user-select: none;
    font-weight: 600;
}

    .tag-chip:hover {
        background: rgba(79, 70, 229, 0.15);
        transform: translateY(-1px);
    }

    .tag-chip.active {
        background: var(--primary-gradient);
        color: white;
        box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25);
    }

.post-tags {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

    .post-tags .tag-chip {
        background: var(--bg-color);
        border: 1px solid var(--border-color);
        color: var(--text-muted);
        cursor: default;
        padding: 4px 12px;
    }

        .post-tags .tag-chip:hover {
            transform: none;
            background: var(--bg-color);
        }

.post-actions {
    margin-top: 15px;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    display: flex;
    gap: 12px;
}

    .post-actions .btn {
        background: transparent !important;
        border: none;
        color: var(--text-muted) !important;
        font-size: 14px;
        padding: 8px 16px;
        border-radius: var(--radius-sm);
        display: flex;
        align-items: center;
        gap: 6px;
        transition: var(--transition);
    }

        .post-actions .btn:hover {
            background: var(--accent-color) !important;
            color: var(--primary-color) !important;
        }

/* Gamification Widgets styling */
#streak-count, #streak-days {
    color: var(--streak-fire);
    font-weight: 700;
    text-shadow: 0 0 10px rgba(255, 87, 34, 0.15);
}

/* Responsive Rules */
@media (max-width: 1024px) {
    main {
        flex-direction: column !important;
        padding: 0 16px;
    }

    #col-left, #col-right {
        width: 100% !important;
        position: static !important;
        height: auto !important;
    }

    #col-center {
        width: 100% !important;
    }

    #topbar .center {
        display: none; /* Hide search bar on tablets */
    }
}

/* ============================================================
   EduConnect AI - Additional UI Polishments
   ============================================================ */

/* Document Card Styling */
.document-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

    .document-card:hover {
        transform: translateY(-4px);
        box-shadow: var(--shadow-md);
        border-color: var(--primary-light);
    }

    .document-card img {
        width: 100%;
        height: 160px;
        object-fit: cover;
        border-radius: var(--radius-sm);
        background: var(--bg-color);
        border: 1px solid var(--border-color);
    }

    .document-card h4 {
        font-size: 16px;
        font-weight: 700;
        color: var(--text-color);
        margin: 0;
        line-height: 1.4;
    }

    .document-card p {
        font-size: 13px;
        color: var(--text-muted);
        line-height: 1.5;
        margin: 0;
        flex-grow: 1;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .document-card .tags {
        font-size: 12px;
        color: var(--primary-color);
        font-weight: 600;
    }

    .document-card span {
        font-size: 13px;
        font-weight: 600;
        color: var(--text-muted);
        display: inline-flex;
        align-items: center;
        gap: 4px;
        margin-right: 12px;
    }

/* AI Tutor Chat Styling */
#conversation-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.conversation-item {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    transition: var(--transition);
    font-weight: 500;
}

    .conversation-item:hover,
    .conversation-item.active {
        background: var(--accent-color);
        border-color: var(--primary-color);
        color: var(--primary-color);
    }

.message {
    margin-bottom: 20px !important;
    max-width: 85% !important;
}

    .message.User {
        margin-left: auto !important;
        justify-content: flex-end !important;
        display: flex !important;
    }

        .message.User p {
            background: var(--primary-gradient) !important;
            color: white !important;
            padding: 14px 20px !important;
            border-radius: var(--radius) !important;
            border-bottom-right-radius: 4px !important;
            font-size: 15px !important;
            font-weight: 500 !important;
            line-height: 1.5 !important;
            box-shadow: 0 4px 15px rgba(79, 70, 229, 0.15) !important;
            margin: 0 !important;
        }

    .message.Assistant {
        margin-right: auto !important;
        justify-content: flex-start !important;
        display: flex !important;
        background: var(--card-bg) !important;
        border: 1px solid var(--border-color) !important;
        border-radius: var(--radius) !important;
        border-bottom-left-radius: 4px !important;
        padding: 20px !important;
        box-shadow: var(--shadow) !important;
        color: var(--text-color) !important;
    }

        .message.Assistant .ai-response-text {
            font-size: 15px !important;
            line-height: 1.6 !important;
            width: 100% !important;
        }

/* Leaderboard Page Styling */
#podium {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    padding: 40px 20px !important;
    margin-bottom: 24px;
    background: linear-gradient(180deg, var(--accent-color) 0%, var(--card-bg) 100%) !important;
    border-radius: var(--radius) !important;
    border: 1px solid var(--border-color) !important;
    box-shadow: var(--shadow) !important;
}

    #podium > div {
        flex: 1;
        max-width: 150px;
        padding: 20px 10px;
        border-radius: var(--radius-sm);
        background: var(--card-bg);
        border: 1px solid var(--border-color);
        box-shadow: var(--shadow);
        transition: var(--transition);
    }

        #podium > div:hover {
            transform: translateY(-4px);
            box-shadow: var(--shadow-md);
        }

    #podium #rank-1 {
        order: 2;
        border-top: 4px solid var(--rank-gold);
        transform: translateY(-16px);
        box-shadow: 0 10px 25px rgba(245, 158, 11, 0.2);
    }

    #podium #rank-2 {
        order: 1;
        border-top: 4px solid var(--rank-silver);
    }

    #podium #rank-3 {
        order: 3;
        border-top: 4px solid var(--rank-bronze);
    }

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th, td {
    padding: 14px 20px;
    font-size: 14px;
}

thead th {
    background: var(--accent-color);
    font-weight: 700;
    color: var(--primary-color);
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

tbody tr {
    transition: var(--transition);
    border-bottom: 1px solid var(--border-color);
}

    tbody tr:hover {
        background: var(--accent-color);
    }

tbody td {
    border-bottom: 1px solid var(--border-color);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* User Dropdown Animation */
#user-dropdown {
    animation: slideDownFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideDownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Search Page Main Input Styling */
#big-search-bar input {
    border-radius: 30px !important;
    padding: 16px 28px !important;
    font-size: 16px !important;
    border: 2px solid var(--border-color) !important;
    background: var(--card-bg) !important;
    color: var(--text-color) !important;
    box-shadow: var(--shadow) !important;
    transition: var(--transition) !important;
}

    #big-search-bar input:focus {
        border-color: var(--primary-color) !important;
        box-shadow: var(--shadow-md), 0 0 0 3px rgba(79, 70, 229, 0.1) !important;
    }

/* Trending Tag Chip on Explore page */
.trending-tag-chip {
    padding: 10px 18px;
    border-radius: 20px;
    border: none;
    color: white;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    transition: var(--transition);
}

    .trending-tag-chip:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 15px rgba(0,0,0,0.15);
    }

/* Featured User Item styling */
.featured-user-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

    .featured-user-item:hover {
        transform: translateY(-2px);
        border-color: var(--primary-light);
        box-shadow: var(--shadow);
    }

    .featured-user-item img {
        border: 2px solid var(--border-color);
    }

/* ─── CSS ĐỊNH HÌNH MODAL POPUP CHUẨN ─── */
.modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
    display: none;
    justify-content: center !important;
    align-items: center !important;
    z-index: 99999 !important;
}

.modal-content {
    background-color: var(--card-bg, #ffffff) !important;
    padding: 30px !important;
    border-radius: 12px !important;
    width: 90% !important;
    max-width: 500px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
    position: relative !important;
    animation: fadeInModal 0.3s ease-out;
}

@keyframes fadeInModal {
    from {
        transform: translateY(-20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* USER LEVEL WIDGET */
.user-level-widget {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
    margin: 8px 0;
}

.level-badge-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.level-badge {
    background: linear-gradient(135deg, #faad14, #ffec3d);
    color: #000;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 800;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.level-progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(0,0,0,0.1);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.level-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #52c41a, #b7eb8f);
    width: 0%;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Ensure level widget hides when sidebar is collapsed */
.left-sidebar.collapsed .user-level-widget {
    display: none !important;
}

/* LEVEL UP MODAL - CYBERPUNK GOLD EDITION */
#level-up-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.92);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

    #level-up-modal.show {
        opacity: 1;
        pointer-events: auto;
    }

.level-up-content.cyberpunk-gold {
    background: #0a0a0a;
    padding: 50px 40px;
    border-radius: 2px;
    text-align: center;
    max-width: 450px;
    width: 90%;
    transform: perspective(1000px) rotateX(20deg) scale(0.8);
    transition: all 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 0 50px rgba(250, 173, 20, 0.4), inset 0 0 20px rgba(250, 173, 20, 0.2);
    border: 2px solid #faad14;
    position: relative;
    overflow: hidden;
}

#level-up-modal.show .level-up-content.cyberpunk-gold {
    transform: perspective(1000px) rotateX(0) scale(1);
}

.cyber-lines::before, .cyber-lines::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg, transparent, #faad14, transparent);
}

.cyber-lines::before {
    top: 10px;
    left: 0;
}

.cyber-lines::after {
    bottom: 10px;
    left: 0;
}

.level-number-huge {
    font-size: 100px;
    font-weight: 950;
    color: #faad14;
    text-shadow: 0 0 15px rgba(250, 173, 20, 0.8), 0 0 30px rgba(250, 173, 20, 0.4);
    margin: 10px 0;
    display: block;
    font-family: 'Segoe UI Black', sans-serif;
    letter-spacing: -5px;
}

.glitch-text {
    position: relative;
    color: #fff;
    font-weight: 800;
    letter-spacing: 2px;
    text-transform: uppercase;
}

    .glitch-text::before, .glitch-text::after {
        content: attr(data-text);
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
    }

    .glitch-text::before {
        left: 2px;
        text-shadow: -2px 0 #ff00c1;
        clip: rect(44px, 450px, 56px, 0);
        animation: glitch-anim 5s infinite linear alternate-reverse;
    }

    .glitch-text::after {
        left: -2px;
        text-shadow: -2px 0 #00fff9, 2px 2px #ff00c1;
        animation: glitch-anim2 1s infinite linear alternate-reverse;
    }

@keyframes glitch-anim {
    0% {
        clip: rect(31px, 9999px, 94px, 0);
    }

    20% {
        clip: rect(62px, 9999px, 42px, 0);
    }

    40% {
        clip: rect(16px, 9999px, 78px, 0);
    }

    60% {
        clip: rect(81px, 9999px, 13px, 0);
    }

    80% {
        clip: rect(45px, 9999px, 67px, 0);
    }

    100% {
        clip: rect(92px, 9999px, 34px, 0);
    }
}

@keyframes glitch-anim2 {
    0% {
        clip: rect(10px, 9999px, 20px, 0);
    }

    100% {
        clip: rect(80px, 9999px, 90px, 0);
    }
}

/* REWARDS LIST */
.rewards-list-container {
    margin: 20px 0;
    background: rgba(250, 173, 20, 0.05);
    border-top: 1px solid rgba(250, 173, 20, 0.3);
    border-bottom: 1px solid rgba(250, 173, 20, 0.3);
    padding: 10px;
}

.rewards-scroll {
    max-height: 150px;
    overflow-y: auto;
    margin-top: 10px;
    padding: 5px;
}

    .rewards-scroll::-webkit-scrollbar {
        width: 4px;
    }

    .rewards-scroll::-webkit-scrollbar-thumb {
        background: #faad14;
    }

.reward-item-gold {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.05);
    margin-bottom: 8px;
    padding: 10px 15px;
    border-left: 3px solid #faad14;
    transition: transform 0.3s;
}

    .reward-item-gold:hover {
        transform: translateX(5px);
        background: rgba(250, 173, 20, 0.1);
    }

.reward-icon {
    margin-right: 15px;
    font-size: 1.2rem;
}

.reward-name {
    font-weight: 600;
    color: #fff;
    font-size: 14px;
}

.btn-gold-cyber {
    background: #faad14;
    color: #000;
    border: none;
    font-weight: 900;
    padding: 15px;
    text-transform: uppercase;
    letter-spacing: 2px;
    clip-path: polygon(10% 0, 100% 0, 90% 100%, 0% 100%);
    transition: all 0.3s;
    cursor: pointer;
}

    .btn-gold-cyber:hover {
        background: #fff;
        box-shadow: 0 0 20px #fff;
        transform: scale(1.05);
    }

/* SMART EDITOR INTERACTIVE PREVIEW */
.q-preview-card:hover {
    border-left-color: var(--primary-light) !important;
    transform: scale(1.01);
    box-shadow: var(--shadow-md);
}

.q-preview-card:active {
    transform: scale(0.99);
}

.opt-preview-item:hover {
    border-color: var(--primary-color) !important;
    background: rgba(79, 70, 229, 0.05) !important;
}

    .opt-preview-item:hover .mark-hint {
        opacity: 1 !important;
        transition: opacity 0.3s ease;
    }

.opt-preview-item b {
    display: inline-block;
    min-width: 25px;
}

#quiz-code-input {
    line-height: 20px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    white-space: pre;
    overflow-wrap: normal;
    tab-size: 4;
}

    /* Ensure the code input area feels like a real editor */
    #quiz-code-input::selection {
        background: rgba(79, 70, 229, 0.2);
    }

/* Auth Form & Settings Form Alignments */
.auth-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 600px;
}

.auth-form label {
    font-weight: 600;
    margin-top: 10px;
    margin-bottom: 2px;
    font-size: 14px;
    color: var(--text-color);
}

.auth-form input,
.auth-form textarea,
.auth-form select {
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
}

.auth-form textarea {
    resize: vertical;
    min-height: 80px;
    max-height: 400px;
}

/* ============================================================
   MOBILE NAVIGATION - Bottom Bar (thay thế left sidebar trên mobile)
   ============================================================ */
@media (max-width: 1024px) {
    /* Topbar mobile fix */
    #topbar {
        padding: 8px 12px;
        height: 56px;
    }

    #topbar .left h1,
    #topbar .left #logo {
        font-size: 16px !important;
    }

    #topbar .center {
        display: none; /* Ẩn search bar trên mobile, dùng trang search riêng */
    }

    #topbar .right {
        gap: 8px;
    }

    /* Main content area scroll bình thường */
    main {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 70px; /* Space cho bottom nav */
    }

    .main-layout-wrapper {
        height: auto;
        overflow: visible;
    }

    /* Bottom Navigation Bar */
    #mobile-bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: var(--card-bg);
        border-top: 1px solid var(--border-color);
        z-index: 999;
        align-items: center;
        justify-content: space-around;
        padding: 0 8px;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.08);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
    }

    #mobile-bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        color: var(--text-muted);
        text-decoration: none;
        font-size: 10px;
        padding: 6px 10px;
        border-radius: 10px;
        transition: all 0.2s ease;
        flex: 1;
        max-width: 70px;
    }

    #mobile-bottom-nav a .nav-icon {
        font-size: 20px;
        line-height: 1;
    }

    #mobile-bottom-nav a.active,
    #mobile-bottom-nav a:hover {
        color: var(--primary-color);
        background: var(--accent-color);
    }

    /* Ẩn right sidebar trên mobile nhỏ */
    @media (max-width: 768px) {
        .right-sidebar {
            display: none !important;
        }
    }
}

/* Trên desktop: ẩn bottom nav */
@media (min-width: 1025px) {
    #mobile-bottom-nav {
        display: none !important;
    }
}

