
/* =====================================================
   HEADER DARKMODE SYNC WITH TTS INTERFACE - FIXED
   Chỉnh Header để đồng bộ với TTS (#0a0a0a + accent trắng)
   Fixed: Ẩn search box, căn 4 buttons sang phải
   ===================================================== */

/* =====================================================
   COLOR VARIABLES - TTS PALETTE
   ===================================================== */
:root {
    /* Light Mode (Default) */
    --page-bg: #ffffff;
    --sidebar-bg: #f8f9fa;
    --content-bg: #ffffff;
    --text-color: #1a1a1a;
    --text-secondary: #666;
    --input-bg: #f1f3f5;
    --input-border: #dee2e6;
    --input-focus: #000000;
    --primary-color: #000000;
    --primary-hover: #333;
    --shadow: rgba(0, 0, 0, 0.1);
    --hover-bg: #f1f3f5;
    --border-color: #dee2e6;
}

html.dark {
    /* Dark Mode - TTS Style */
    --page-bg: #0a0a0a;           /* Đen thuần như TTS */
    --sidebar-bg: #0f0f0f;        /* Đen nhạt hơn */
    --content-bg: #0f0f0f;        /* Content matching */
    --text-color: #e5e5e5;        /* Text trắng nhạt */
    --text-secondary: #888;       /* Xám như TTS */
    --input-bg: #1a1a1a;          /* Input background */
    --input-border: #2a2a2a;      /* Border mỏng */
    --input-focus: #ffffff;       /* Focus trắng */
    --primary-color: #ffffff;     /* Accent trắng */
    --primary-hover: #e5e5e5;     /* Hover nhạt hơn */
    --shadow: rgba(0, 0, 0, 0.5); /* Shadow đậm */
    --hover-bg: #1a1a1a;          /* Hover state */
    --border-color: #2a2a2a;      /* Border color */
}

/* =====================================================
   TOP HEADER - MAIN CONTAINER
   ===================================================== */
.top-header {
    /* ✅ BACKGROUND MỜ MỜ */
    background-color: rgba(15, 15, 15, 0.3) !important; /* Dark mode - 70% opacity */
    
    /* ✅ BLUR EFFECT - HIỆU ỨNG KÍNH MỜ */
    backdrop-filter: blur(12px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(12px) saturate(180%) !important;
    
    border-bottom: 1px solid var(--border-color) !important;
    padding: 10px 20px !important;
    display: flex !important;
    justify-content: flex-start !important;
    align-items: center !important;
    gap: 10px;
    
    /* ✅ STICKY */
    position: sticky !important;
    top: 0 !important;
    z-index: 100 !important;
    
    /* ✅ SMOOTH TRANSITION */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
}

/* ✅ LIGHT MODE - Background trắng mờ */
html:not(.dark) .top-header {
    background-color: rgba(255, 255, 255, 0.3) !important;
    backdrop-filter: blur(12px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(12px) saturate(180%) !important;
}

/* =====================================================
   SCROLLED STATE - THÊM SHADOW + ĐẬM HƠN
   ===================================================== */
.top-header.scrolled {
    /* ✅ Đậm hơn khi scroll */
    background-color: rgba(15, 15, 15, 0.85) !important;
    backdrop-filter: blur(16px) saturate(200%) !important;
    -webkit-backdrop-filter: blur(16px) saturate(200%) !important;
    
    /* ✅ Shadow đẹp */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
}

html:not(.dark) .top-header.scrolled {
    background-color: rgba(255, 255, 255, 0.85) !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08) !important;
}

html.dark .top-header.scrolled {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
}

/* =====================================================
   SIDEBAR TOGGLE BUTTON - MỚI THÊM
   ===================================================== */
.sidebar-toggle-btn {
    width: 36px !important;
    height: 36px !important;
    background-color: var(--input-bg) !important;
    border: 1px solid var(--input-border) !important;
    border-radius: 8px !important;
    display: flex !important; /* ✅ LUÔN HIỆN - CẢ DESKTOP */
    align-items: center;
    justify-content: center;
    color: var(--text-color) !important;
    cursor: pointer;
    font-size: 18px !important;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    background-color: var(--hover-bg) !important;
    border-color: var(--primary-color) !important;
    color: var(--primary-color) !important;
    transform: scale(1.05);
}

.sidebar-toggle-btn:active {
    transform: scale(0.95);
}

/* Icon trong toggle button */
.sidebar-toggle-icon {
    transition: transform 0.3s ease;
}

/* ✅ Khi sidebar đóng, icon xoay 180 độ */
.sidebar:not(.active) ~ .main-content .sidebar-toggle-icon {
    transform: rotate(0deg);
}

.sidebar.active ~ .main-content .sidebar-toggle-icon {
    transform: rotate(180deg);
}
/* =====================================================
   SIDEBAR - ĐÓNG/MỞ CẢ DESKTOP
   ===================================================== */
.sidebar {
    width: 280px; /* Width khi mở */
    background-color: var(--sidebar-bg) !important;
    border-right: 1px solid var(--border-color) !important;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ✅ KHI ĐÓNG - MINI SIDEBAR (CHỈ ICON) */
.sidebar:not(.active) {
    width: 70px !important; /* Sidebar nhỏ, chỉ đủ chứa icon */
}

/* Main content điều chỉnh khi sidebar đóng/mở */
.main-content {
    margin-left: 280px;
    min-height: 100vh;
    background-color: var(--page-bg);
    display: flex;
    flex-direction: column;
    
    /* ✅ Không cần padding-top vì header sticky */
    padding-top: 0 !important;
}


/* =====================================================
   HEADER LEFT - MENU TOGGLE + 3 BUTTONS
   ===================================================== */
.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
    /* ✅ KHÔNG CẦN margin-left, tự động bên trái */
}

/* Menu Toggle Button */
.menu-toggle {
    background: transparent !important;
    border: none !important;
    color: var(--text-color) !important;
    font-size: 22px;
    padding: 8px;
    cursor: pointer;
    transition: color 0.2s ease, transform 0.2s ease;
    display: none;
}

.menu-toggle:hover {
    color: var(--primary-color) !important;
    transform: scale(1.1);
}

/* =====================================================
   HEADER RIGHT - NOTIFICATION/LOGIN
   ===================================================== */
.header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto !important; /* ✅ ĐẨY SANG PHẢI */
    flex-shrink: 0;
}

/* =====================================================
   HEADER BUTTONS - SMOOTH TRANSITION
   ===================================================== */
   /* =====================================================
   EXTRA: GRADIENT OVERLAY (OPTIONAL)
   ===================================================== */
.top-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0) 0%,
        rgba(0, 0, 0, 0.02) 100%
    );
    pointer-events: none;
    z-index: -1;
}

html:not(.dark) .top-header::before {
    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0.3) 0%,
        rgba(255, 255, 255, 0) 100%
    );
}
.header-btn,
.header-dropdown-container {
    flex-shrink: 0;
}

.header-btn {
    width: 36px !important; /* ✅ GIẢM TỪ 40px → 36px */
    height: 36px !important;
    background-color: var(--input-bg) !important;
    border: 1px solid var(--input-border) !important;
    border-radius: 8px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color) !important;
    cursor: pointer;
    font-size: 15px !important; /* ✅ GIẢM TỪ 16px → 15px */
    text-decoration: none;
    flex-shrink: 0;
    transition: background-color 0.3s ease, 
                border-color 0.3s ease, 
                color 0.3s ease, 
                transform 0.2s ease !important;
}

.header-btn:hover {
    background-color: var(--hover-bg) !important;
    border-color: var(--primary-color) !important;
    color: var(--primary-color) !important;
    transform: scale(1.05);
}

/* Theme Toggle - Special Animation */
.theme-toggle {
    position: relative;
    overflow: hidden;
}

.theme-toggle:hover {
    transform: rotate(180deg) scale(1.1) !important;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.theme-icon-light,
.theme-icon-dark {
    transition: all 0.3s ease;
}

/* Notification Button */
.notification-btn {
    position: relative;
}

/* =====================================================
   NOTIFICATION BADGE - SMOOTH TRANSITION
   ===================================================== */
.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 16px !important;
    height: 16px !important;
    background: var(--primary-color) !important;
    color: var(--page-bg) !important;
    border-radius: 50%;
    font-size: 9px !important;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid var(--content-bg);
    animation: pulse-badge 2s infinite;
    
    /* ✅ SMOOTH TRANSITION */
    transition: background-color 0.3s ease, 
                color 0.3s ease, 
                border-color 0.3s ease !important;
}

html.dark .notification-badge {
    background: #ffffff !important;
    color: #000000 !important;
}

html:not(.dark) .notification-badge {
    background: #000000 !important;
    color: #ffffff !important;
}

@keyframes pulse-badge {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.9;
    }
}

/* =====================================================
   USER MENU - SMOOTH TRANSITION
   ===================================================== */
.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 6px !important;
    background-color: var(--input-bg) !important;
    border: 1px solid var(--input-border) !important;
    border-radius: 8px !important;
    cursor: pointer;
    margin-left: 6px;
    flex-shrink: 0;
    
    /* ✅ SMOOTH TRANSITION */
    transition: background-color 0.3s ease, 
                border-color 0.3s ease, 
                transform 0.2s ease !important;
}

.user-menu:hover {
    background-color: var(--hover-bg) !important;
    border-color: var(--primary-color) !important;
    transform: translateY(-1px);
}


/* User Avatar */
.user-avatar {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color) !important;
    transition: border-color 0.2s ease;
}

.user-menu:hover .user-avatar {
    border-color: var(--primary-color) !important;
}

/* User Avatar Placeholder */
.user-avatar-placeholder {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50%;
    background: var(--primary-color) !important;
    color: var(--page-bg) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px !important;
    font-weight: 700;
    text-transform: uppercase;
}

/* User Info */
.user-info-header {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-name {
    font-size: 13px !important;
    font-weight: 600 !important;
    color: var(--text-color) !important;
    line-height: 1.2;
    transition: color 0.2s ease;
}

.user-role-badge {
    font-size: 10px !important;
    color: var(--text-secondary) !important;
    line-height: 1;
    font-weight: 500;
    transition: color 0.2s ease;
}

.dropdown-icon {
    color: var(--text-secondary) !important;
    font-size: 12px !important;
    transition: all 0.2s ease;
}

.user-menu:hover .dropdown-icon {
    color: var(--primary-color) !important;
    transform: translateY(2px);
}

/* =====================================================
   LOGIN BUTTON - SMOOTH TRANSITION
   ===================================================== */
.login-btn {
    padding: 8px 16px !important; /* ✅ GIẢM TỪ 9px 18px */
    background: var(--primary-color) !important;
    color: var(--page-bg) !important;
    border-radius: 8px !important;
    text-decoration: none;
    font-weight: 600 !important;
    font-size: 12px !important; /* ✅ GIẢM TỪ 13px → 12px */
    display: flex;
    align-items: center;
    gap: 6px;
    border: none;
    flex-shrink: 0;
    transition: background-color 0.3s ease, 
                color 0.3s ease, 
                transform 0.2s ease, 
                box-shadow 0.3s ease !important;
}
.login-btn:hover {
    background: var(--primary-hover) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}


html:not(.dark) .login-btn:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.login-btn:active {
    transform: translateY(0);
}

/* =====================================================
   NOTIFICATION DROPDOWN - GIỮ NGUYÊN BÊN PHẢI
   ===================================================== */
.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0 !important; /* Notification vẫn bên phải */
    left: auto !important;
    margin-top: 8px;
    width: 360px;
    background: var(--content-bg) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 10px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2) !important;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 2000;
    overflow: hidden;
}

html.dark .dropdown-menu {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5) !important;
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Dropdown Header */
.dropdown-header {
    padding: 14px 18px !important;
    border-bottom: 1px solid var(--border-color) !important;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--sidebar-bg);
}

.dropdown-header h5 {
    font-size: 14px !important;
    font-weight: 700 !important;
    margin: 0;
    color: var(--text-color) !important;
}

.mark-all-read {
    font-size: 11px !important;
    color: var(--primary-color) !important;
    text-decoration: none;
    font-weight: 600;
    transition: opacity 0.2s ease;
}

.mark-all-read:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* Dropdown List */
.dropdown-list {
    max-height: 320px;
    overflow-y: auto;
    background: var(--content-bg);
}

/* Custom Scrollbar */
.dropdown-list::-webkit-scrollbar {
    width: 5px;
}

.dropdown-list::-webkit-scrollbar-track {
    background: var(--content-bg);
}

.dropdown-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.dropdown-list::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Notification Item */
.notification-item {
    display: flex;
    gap: 12px;
    padding: 12px 18px !important;
    border-bottom: 1px solid var(--border-color) !important;
    transition: background 0.15s ease;
    text-decoration: none;
    cursor: pointer;
}

.notification-item:last-child {
    border-bottom: none !important;
}

.notification-item:hover {
    background: var(--hover-bg) !important;
}

.notification-item.unread {
    background: rgba(255, 255, 255, 0.03) !important;
    border-left: 3px solid var(--primary-color);
    padding-left: 15px !important;
}

html:not(.dark) .notification-item.unread {
    background: rgba(0, 0, 0, 0.02) !important;
}

/* Notification Icon */
.notification-icon {
    width: 34px !important;
    height: 34px !important;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px !important;
    flex-shrink: 0;
    border: 1px solid var(--border-color);
}

/* Icon Types - Subtle Colors */
.notification-icon.type-success {
    background: rgba(255, 255, 255, 0.05) !important;
    color: #4ade80 !important;
}

.notification-icon.type-warning {
    background: rgba(255, 255, 255, 0.05) !important;
    color: #fbbf24 !important;
}

.notification-icon.type-danger {
    background: rgba(255, 255, 255, 0.05) !important;
    color: #ef4444 !important;
}

.notification-icon.type-info {
    background: rgba(255, 255, 255, 0.05) !important;
    color: #60a5fa !important;
}

html:not(.dark) .notification-icon {
    background: rgba(0, 0, 0, 0.03) !important;
}

/* Notification Content */
.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-content p {
    font-size: 13px !important;
    font-weight: 500 !important;
    color: var(--text-color) !important;
    margin: 0 0 4px 0 !important;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notification-content .time-ago {
    font-size: 11px !important;
    color: var(--text-secondary) !important;
    font-weight: 500;
}

/* Empty State */
.notification-empty {
    padding: 40px 20px !important;
    text-align: center;
    color: var(--text-secondary) !important;
}

.notification-empty i {
    font-size: 36px !important;
    margin-bottom: 12px;
    opacity: 0.5;
}

.notification-empty p {
    font-size: 13px;
    margin: 0;
}

/* Dropdown Footer */
.dropdown-footer {
    padding: 10px !important;
    text-align: center;
    border-top: 1px solid var(--border-color) !important;
    background: var(--sidebar-bg);
}

.dropdown-footer a {
    font-size: 12px !important;
    color: var(--primary-color) !important;
    text-decoration: none;
    font-weight: 600;
    transition: opacity 0.2s ease;
}

.dropdown-footer a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* =====================================================
   RESPONSIVE - MOBILE & TABLET
   ===================================================== */
@media (max-width: 1024px) {
    .menu-toggle {
        display: block !important;
    }
    
    .header-left {
        gap: 8px;
    }
    /* ✅ HIỆN TOGGLE BUTTON TRÊN TABLET/MOBILE */
    .sidebar-toggle-btn {
        display: flex !important;
    }
    
    .top-header {
        padding: 8px 16px !important;
    }
}

@media (max-width: 768px) {
    .top-header {
        padding: 8px 12px !important;
        gap: 8px;
    }
    .header-left {
        gap: 6px;
    }
    .header-right {
        gap: 6px;
    }

    /* Hide user info text on mobile */
    .user-info-header {
        display: none !important;
    }

    .dropdown-icon {
        display: none !important;
    }

    .header-btn {
        width: 34px !important;
        height: 34px !important;
        font-size: 14px !important;
    }
    
    .flag-icon-button {
        width: 16px !important;
        height: 16px !important;
    }
    
    .sidebar-toggle-btn {
        width: 34px !important;
        height: 34px !important;
        font-size: 16px !important;
    }

    .user-menu {
        padding: 4px !important;
        min-width: auto !important;
    }

    .user-avatar,
    .user-avatar-placeholder {
        width: 32px !important;
        height: 32px !important;
        font-size: 12px !important;
    }

    /* Dropdown full width on mobile */
    .dropdown-menu {
        width: calc(100vw - 32px) !important;
        right: 16px !important;
    }
}

@media (max-width: 480px) {
    .header-right {
        gap: 6px !important;
    }

    .header-btn {
        width: 32px !important;
        height: 32px !important;
        font-size: 13px !important;
    }
    
    .sidebar-toggle-btn {
        width: 32px !important;
        height: 32px !important;
        font-size: 15px !important;
    }
}
/* =====================================================
   DISABLE TRANSITIONS KHI LOAD TRANG
   Tránh flash khi reload trang
   ===================================================== */
.preload * {
    transition: none !important;
}

/* =====================================================
   PERFORMANCE OPTIMIZATION
   ===================================================== */
.top-header,
.header-btn,
.user-menu,
.login-btn,
.header-dropdown-menu,
.dropdown-menu {
    will-change: background-color, border-color, color;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
}

/* =====================================================
   ENSURE SMOOTH COLOR TRANSITION
   ===================================================== */
* {
    /* ✅ CHỈ TRANSITION CÁC THUỘC TÍNH COLOR-RELATED */
    transition-property: background-color, border-color, color, fill, stroke;
    transition-duration: 0.3s;
    transition-timing-function: ease;
}

/* Override cho transform và opacity */
*[style*="transform"],
*[style*="opacity"] {
    transition-property: background-color, border-color, color, fill, stroke, transform, opacity !important;
}

/* =====================================================
   SMOOTH TRANSITIONS & PERFORMANCE
   ===================================================== */
.top-header,
.header-btn,
.user-menu,
.notification-item {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
}

/* =====================================================
   DARK/LIGHT MODE TOGGLE EFFECTS
   ===================================================== */
html.dark .top-header {
    backdrop-filter: blur(10px);
}

html:not(.dark) .top-header {
    backdrop-filter: blur(5px);
}

/* =====================================================
   Z-INDEX MANAGEMENT
   ===================================================== */
.top-header {
    z-index: 100 !important;
}

.dropdown-menu {
    z-index: 2000 !important;
}

.sidebar-overlay {
    z-index: 999 !important;
}

/* =====================================================
   SIDEBAR & DASHBOARD LAYOUT
   ===================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--page-bg);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
    background-color: var(--page-bg);
}

.sidebar {
    width: 280px;
    background-color: var(--sidebar-bg) !important;
    box-shadow: none !important;
    border-right: 1px solid var(--border-color) !important;
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1000;
    transition: transform 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
}

.sidebar::-webkit-scrollbar {
    width: 5px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--sidebar-bg);
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

.sidebar-header {
    padding: 16px !important;
    border-bottom: none !important;
    background: var(--sidebar-bg);
    transition: padding 0.3s ease;
}
.sidebar-user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background-color: var(--input-bg) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 10px !important;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
}
/* ✅ User info và arrow ẨN khi sidebar đóng */
.sidebar:not(.active) .sidebar-user-info {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar:not(.active) .sidebar-user-arrow {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* ✅ Khi đóng, avatar căn giữa */
.sidebar:not(.active) .sidebar-user-menu {
    justify-content: center;
    padding: 10px;
    gap: 0;
}

/* Avatar khi sidebar đóng */
.sidebar:not(.active) .sidebar-user-avatar,
.sidebar:not(.active) .sidebar-user-avatar-placeholder {
    width: 40px !important;
    height: 40px !important;
}
.sidebar-user-menu:hover {
    background-color: var(--hover-bg) !important;
    border-color: var(--primary-color) !important;
    transform: translateX(2px);
}

/* =====================================================
   MENU ITEMS - ICON + TEXT
   ===================================================== */
.menu-item,
.submenu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: var(--text-secondary) !important;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
}

/* Icon trong menu */
.menu-item i,
.submenu-item i {
    width: 20px;
    flex-shrink: 0;
    font-size: 16px;
    transition: transform 0.2s ease;
}

/* ✅ TEXT ẨN khi sidebar đóng */
.sidebar:not(.active) .menu-item span,
.sidebar:not(.active) .submenu-item span {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* ✅ Khi đóng, menu item căn giữa */
.sidebar:not(.active) .menu-item,
.sidebar:not(.active) .submenu-item {
    justify-content: center;
    padding: 10px;
    gap: 0;
}

/* ✅ Arrow dropdown ẨN khi sidebar đóng */
.sidebar:not(.active) .menu-arrow {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* =====================================================
   MENU SECTION TITLE
   ===================================================== */
.menu-section-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 20px 20px 10px;
    letter-spacing: 1px;
    transition: all 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
}

/* ✅ Section title ẨN khi sidebar đóng */
.sidebar:not(.active) .menu-section-title {
    opacity: 0;
    height: 0;
    padding: 0;
}

/* Thay bằng separator line */
.sidebar:not(.active) .menu-section::before {
    content: '';
    display: block;
    width: 30px;
    height: 1px;
    background: var(--border-color);
    margin: 10px auto;
}

/* =====================================================
   SUBMENU (DROPDOWN)
   ===================================================== */
.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.submenu.active {
    max-height: 500px;
}

/* ✅ Submenu ẨN HOÀN TOÀN khi sidebar đóng */
.sidebar:not(.active) .submenu {
    display: none !important;
}

/* =====================================================
   LOGO (NẾU CÓ)
   ===================================================== */
.logo-text {
    font-size: 18px !important;
    font-weight: 700 !important;
    color: var(--text-color) !important;
    transition: opacity 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
}

/* ✅ Logo text ẨN khi sidebar đóng */
.sidebar:not(.active) .logo-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.sidebar:not(.active) .logo {
    justify-content: center;
}

/* =====================================================
   MAIN CONTENT - ĐIỀU CHỈNH THEO SIDEBAR
   ===================================================== */
.main-content {
    margin-left: 280px; /* Khi sidebar mở */
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ✅ Khi sidebar đóng, main content shift về trái */
.sidebar:not(.active) ~ .main-content {
    margin-left: 70px !important; /* Khoảng cách mini sidebar */
}

/* =====================================================
   SCROLLBAR - ẨN KHI SIDEBAR ĐÓNG
   ===================================================== */
.sidebar::-webkit-scrollbar {
    width: 5px;
}

.sidebar:not(.active)::-webkit-scrollbar {
    width: 0; /* Ẩn scrollbar khi đóng */
}

/* =====================================================
   TOOLTIP CHO MINI SIDEBAR (OPTIONAL)
   ===================================================== */
.sidebar:not(.active) .menu-item,
.sidebar:not(.active) .submenu-item {
    position: relative;
}

/* Hiện tooltip khi hover (desktop only) */
@media (min-width: 1025px) {
    .sidebar:not(.active) .menu-item:hover::after,
    .sidebar:not(.active) .submenu-item:hover::after {
        content: attr(data-title);
        position: absolute;
        left: 70px;
        top: 50%;
        transform: translateY(-50%);
        background: var(--input-bg);
        color: var(--text-color);
        padding: 6px 12px;
        border-radius: 6px;
        white-space: nowrap;
        font-size: 12px;
        z-index: 1001;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        border: 1px solid var(--border-color);
        opacity: 0;
        animation: fadeInTooltip 0.2s ease forwards;
    }
}

@keyframes fadeInTooltip {
    to {
        opacity: 1;
    }
}

/* =====================================================
   RESPONSIVE - MOBILE
   ===================================================== */
@media (max-width: 1024px) {
    /* Mobile: Sidebar luôn full width khi mở */
    .sidebar {
        width: 280px !important;
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    /* Main content luôn full width */
    .main-content {
        margin-left: 0 !important;
    }
    
    .sidebar:not(.active) ~ .main-content {
        margin-left: 0 !important;
    }
    
    /* Không có mini sidebar trên mobile */
    .sidebar:not(.active) {
        width: 280px !important;
        transform: translateX(-100%);
    }
}

/* =====================================================
   SMOOTH TRANSITIONS
   ===================================================== */
.sidebar-user-info,
.sidebar-user-arrow,
.menu-item span,
.submenu-item span,
.menu-arrow,
.logo-text,
.menu-section-title {
    transition: opacity 0.3s ease, width 0.3s ease;
}

/* =====================================================
   ACTIVE STATE
   ===================================================== */
.menu-item.active,
.submenu-item.active {
    background: var(--hover-bg);
    color: var(--primary-color) !important;
    border-left: 3px solid var(--primary-color);
}

/* ✅ Active border khi sidebar đóng */
.sidebar:not(.active) .menu-item.active,
.sidebar:not(.active) .submenu-item.active {
    border-left: none;
    border-radius: 8px;
    background: var(--input-bg);
}
.sidebar-user-avatar {
    width: 44px !important;
    height: 44px !important;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color) !important;
    transition: border-color 0.2s ease;
    flex-shrink: 0;
}
.sidebar-user-menu:hover .sidebar-user-avatar {
    border-color: var(--primary-color) !important;
}

/* Sidebar User Avatar Placeholder */
.sidebar-user-avatar-placeholder {
    width: 44px !important;
    height: 44px !important;
    border-radius: 50%;
    background: var(--primary-color) !important;
    color: var(--page-bg) !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px !important;
    font-weight: 700;
    text-transform: uppercase;
    flex-shrink: 0;
}
.sidebar-user-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: var(--text-color) !important;
    line-height: 1.3;
    transition: color 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 11px !important;
    color: var(--text-secondary) !important;
    line-height: 1;
    font-weight: 500;
    transition: color 0.2s ease;
}

/* Sidebar User Arrow Icon */
.sidebar-user-arrow {
    color: var(--text-secondary) !important;
    font-size: 14px !important;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.sidebar-user-menu:hover .sidebar-user-arrow {
    color: var(--primary-color) !important;
    transform: translateX(3px);
}
/* =====================================================
   SIDEBAR GUEST LOGIN BUTTON
   ===================================================== */
.sidebar-guest {
    padding: 8px 0;
}

.sidebar-login-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--primary-color) !important;
    color: var(--page-bg) !important;
    border-radius: 10px !important;
    text-decoration: none;
    font-weight: 600 !important;
    font-size: 13px !important;
    transition: all 0.2s ease;
    border: none;
}

.sidebar-login-btn:hover {
    background: var(--primary-hover) !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

html:not(.dark) .sidebar-login-btn:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.sidebar-login-btn i {
    font-size: 16px;
}

/* =====================================================
   RESPONSIVE - MOBILE
   ===================================================== */
@media (max-width: 768px) {
    .sidebar-header {
        padding: 12px !important;
    }
    
    .sidebar-user-menu {
        padding: 10px;
        gap: 10px;
    }
    
    .sidebar-user-avatar,
    .sidebar-user-avatar-placeholder {
        width: 40px !important;
        height: 40px !important;
        font-size: 16px !important;
    }
    
    .sidebar-user-name {
        font-size: 13px !important;
    }
    
    .sidebar-user-role {
        font-size: 10px !important;
    }
}

/* =====================================================
   DARK/LIGHT MODE SPECIFIC
   ===================================================== */
html.dark .sidebar-user-menu {
    background-color: var(--input-bg) !important;
}

html:not(.dark) .sidebar-user-menu {
    background-color: var(--input-bg) !important;
}

/* =====================================================
   PERFORMANCE OPTIMIZATION
   ===================================================== */
.sidebar-user-menu {
    transform: translateZ(0);
    backface-visibility: hidden;
}
.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.logo-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.logo-text {
    font-size: 18px !important;
    font-weight: 700 !important;
    color: var(--text-color) !important;
    transition: color 0.3s ease;
}

.main-content {
    flex: 1;
    margin-left: 280px;
    min-height: 100vh;
    background-color: var(--page-bg);
    display: flex;
    flex-direction: column;
}

.content-area {
    padding: 24px;
    flex: 1;
    background-color: var(--page-bg);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

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

.d-none {
    display: none !important;
}

/* =====================================================
   RESPONSIVE SIDEBAR
   ===================================================== */

@media (max-width: 1024px) {
    
    .sidebar.active ~ .sidebar-overlay {
        display: block;
        opacity: 1;
    }
    .sidebar {
        transform: translateX(-280px);
        box-shadow: 2px 0 20px rgba(0, 0, 0, 0.3) !important;
    }
    
    /* Khi active thì hiện */
    .sidebar.active {
        transform: translateX(0);
    }
    
    /* Main content luôn full width trên mobile */
    .main-content {
        margin-left: 0 !important;
    }
}
@media (max-width: 768px) {
    .sidebar-toggle-btn {
        width: 34px !important;
        height: 34px !important;
        font-size: 16px !important;
    }
}

@media (max-width: 480px) {
    .sidebar-toggle-btn {
        width: 32px !important;
        height: 32px !important;
        font-size: 15px !important;
    }
}
@media (max-width: 768px) {
    .content-area {
        padding: 16px;
    }
    
    .sidebar-header {
        padding: 16px !important;
    }
    
    .logo-text {
        font-size: 16px !important;
    }
    
    .logo-icon {
        width: 38px;
        height: 38px;
    }
}

html.dark .sidebar {
    background-color: var(--sidebar-bg) !important;
    border-right-color: var(--border-color) !important;
}

html:not(.dark) .sidebar {
    background-color: var(--sidebar-bg) !important;
    border-right-color: var(--border-color) !important;
    box-shadow: 1px 0 3px rgba(0, 0, 0, 0.05) !important;
}

.sidebar {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.sidebar,
.sidebar-header,
.logo {
    transform: translateZ(0);
    backface-visibility: hidden;
}
/* =====================================================
   LANGUAGE & THEME DROPDOWN CSS
   Thêm vào phần <style> trong header.php
   ===================================================== */

/* =====================================================
   HEADER DROPDOWN CONTAINER
   ===================================================== */
.header-dropdown-container {
    position: relative;
}

/* =====================================================
   HEADER DROPDOWN MENU - ✅ HIỆN BÊN PHẢI
   ===================================================== */
.header-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0 !important; /* ✅ CANH TỪ TRÁI BUTTON */
    right: auto !important; /* ✅ KHÔNG CANH PHẢI */
    min-width: 200px;
    background: var(--content-bg) !important;
    border: 1px solid var(--border-color) !important;
    border-radius: 10px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2) !important;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 2000;
    overflow: hidden;
}

html.dark .header-dropdown-menu {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5) !important;
}

.header-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
/* =====================================================
   DROPDOWN MENU - SMOOTH TRANSITION
   ===================================================== */
.header-dropdown-menu,
.dropdown-menu {
    /* ✅ SMOOTH TRANSITION */
    transition: opacity 0.3s ease, 
                visibility 0.3s ease, 
                transform 0.3s cubic-bezier(0.16, 1, 0.3, 1) !important;
}
.header-dropdown-menu,
.dropdown-menu {
    /* ✅ Dropdown đậm hơn header */
    background: rgba(15, 15, 15, 0.95) !important;
    backdrop-filter: blur(20px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(20px) saturate(180%) !important;
}

html:not(.dark) .header-dropdown-menu,
html:not(.dark) .dropdown-menu {
    background: rgba(255, 255, 255, 0.95) !important;
}
/* =====================================================
   Z-INDEX MANAGEMENT
   ===================================================== */
.header-dropdown-menu {
    z-index: 2001 !important; /* Cao hơn notification */
}

.dropdown-menu {
    z-index: 2000 !important;
}
/* =====================================================
   TEXT ELEMENTS - SMOOTH TRANSITION
   ===================================================== */
.user-name,
.user-role-badge,
.sidebar-user-name,
.sidebar-user-role,
.menu-item,
.submenu-item,
.dropdown-icon,
.sidebar-user-arrow {
    transition: color 0.3s ease !important;
}
/* =====================================================
   DROPDOWN HEADER
   ===================================================== */
.header-dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--sidebar-bg);
}

.header-dropdown-header span {
    font-size: 12px !important;
    font-weight: 700 !important;
    color: var(--text-color) !important;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* =====================================================
   DROPDOWN LIST
   ===================================================== */
.header-dropdown-list {
    padding: 6px;
}

/* =====================================================
   DROPDOWN ITEM
   ===================================================== */
.header-dropdown-item {
    display: flex !important;
    align-items: center;
    gap: 12px;
    padding: 10px 12px !important;
    border-radius: 6px !important;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none !important;
    background: transparent !important;
    border: none;
    width: 100%;
    color: var(--text-color) !important;
}

.header-dropdown-item:hover {
    background: var(--hover-bg) !important;
}

.header-dropdown-item.active {
    background: var(--input-bg) !important;
}

/* Dropdown Item Icon */
.dropdown-item-icon {
    font-size: 16px !important;
    color: var(--text-secondary) !important;
    transition: color 0.2s ease;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.header-dropdown-item:hover .dropdown-item-icon {
    color: var(--primary-color) !important;
}

.header-dropdown-item.active .dropdown-item-icon {
    color: var(--primary-color) !important;
}

/* Dropdown Item Text */
.header-dropdown-item span {
    font-size: 13px !important;
    font-weight: 500 !important;
    flex: 1;
}

/* Dropdown Item Check Icon */
.dropdown-item-check {
    font-size: 16px !important;
    color: var(--primary-color) !important;
    margin-left: auto;
    flex-shrink: 0;
}
/* =====================================================
   THEME ICONS - ABSOLUTE POSITIONING
   ===================================================== */
.header-btn {
    position: relative;
}

/* ✅ Tất cả icons đều absolute, chồng lên nhau */
.theme-icon-light,
.theme-icon-dark,
.theme-icon-system {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    font-size: 16px !important;
    transition: opacity 0.3s ease !important;
    pointer-events: none;
}

/* ✅ Default: tất cả ẩn */
.theme-icon-light,
.theme-icon-dark,
.theme-icon-system {
    opacity: 0 !important;
    visibility: hidden !important;
}

/* ✅ Class .active để hiện icon */
.theme-icon-light.active,
.theme-icon-dark.active,
.theme-icon-system.active {
    opacity: 1 !important;
    visibility: visible !important;
}

/* =====================================================
   OVERRIDE DISPLAY STYLES
   ===================================================== */
.theme-icon-light,
.theme-icon-dark,
.theme-icon-system {
    display: block !important; /* Luôn block, dùng opacity để ẩn/hiện */
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 768px) {
    .header-dropdown-menu {
        min-width: 180px;
    }
    
    .header-dropdown-item {
        padding: 9px 10px !important;
    }
    
    .header-dropdown-item span {
        font-size: 12px !important;
    }
    /* Notification dropdown full width trên mobile */
    .dropdown-menu {
        width: calc(100vw - 32px) !important;
        right: 16px !important;
    }
}

/* =====================================================
   PERFORMANCE
   ===================================================== */
.header-dropdown-menu {
    will-change: transform, opacity;
    backface-visibility: hidden;
}
/* =====================================================
   CSS CHO FLAG ICONS (TRÒN)
   Thêm vào phần <style> trong header.php
   ===================================================== */
/* =====================================================
   FLAG ICON - SMOOTH TRANSITION
   ===================================================== */
.flag-icon-button {
    width: 20px !important;
    height: 20px !important;
    border-radius: 50% !important;
    object-fit: cover;
    border: 2px solid var(--border-color);
    display: block;
    
    /* ✅ SMOOTH TRANSITION */
    transition: border-color 0.3s ease, transform 0.2s ease !important;
}

.header-btn:hover .flag-icon-button {
    border-color: var(--primary-color);
    transform: scale(1.1);
}

/* =====================================================
   FLAG ICON TRONG DROPDOWN
   ===================================================== */
.flag-icon-dropdown {
    width: 24px !important;
    height: 24px !important;
    border-radius: 50% !important;
    object-fit: cover;
    border: 2px solid var(--border-color);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.header-dropdown-item:hover .flag-icon-dropdown {
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.header-dropdown-item.active .flag-icon-dropdown {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}

html:not(.dark) .header-dropdown-item.active .flag-icon-dropdown {
    box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05);
}

/* =====================================================
   FALLBACK - NẾU KHÔNG TẢI ĐƯỢC ẢNH
   ===================================================== */
.flag-icon-button,
.flag-icon-dropdown {
    background: var(--input-bg);
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 768px) {
    .flag-icon-button {
        width: 18px !important;
        height: 18px !important;
        border-width: 1.5px;
    }
    
    .flag-icon-dropdown {
        width: 22px !important;
        height: 22px !important;
        border-width: 1.5px;
    }
}

/* =====================================================
   LOADING STATE (OPTIONAL)
   ===================================================== */
.flag-icon-button,
.flag-icon-dropdown {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}