﻿/* ==================== ROOT VARIABLES ==================== */
:root {
    /* Colors */
    --primary-blue: #4A9FF5;
    --primary-purple: #9B5FC0;
    --primary-pink: #E94B8B;
    --gradient-bg: linear-gradient(135deg, #4A9FF5 0%, #9B5FC0 50%, #E94B8B 100%);
    --white: #FFFFFF;
    --black: #000000;
    --light-gray: #F5F5F5;
    --gray: #E0E0E0;
    --dark-gray: #333333;
    --text-gray: #666666;
    --border-color: #E5E7EB;
    --success-color: #4CAF50;
    --error-color: #F44336;
    --warning-color: #FF9800;

    /* Sidebar Widths */
    --main-sidebar-width: 80px;
    --sidebar-width: 320px;
    --info-panel-width: 320px;

    /* Other */
    --border-radius: 10px;
    --transition: all 0.3s ease;
    --logo-max-width: 190px;
    --logo-max-height: 56px;
}

/* ==================== GLOBAL STYLES ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Sarabun', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #F5F5F5;
    color: var(--dark-gray);
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
}

button {
    border: none;
    outline: none;
    cursor: pointer;
    font-family: inherit;
}

input,
select,
textarea {
    font-family: inherit;
}

/* ==================== MAIN SIDEBAR (LEFT MENU) ==================== */
.main-sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    width: var(--main-sidebar-width);
    height: 100vh;
    background: var(--gradient-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 0;
    gap: 10px;
    z-index: 999;
    transition: left 0.3s ease;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.main-sidebar.show {
    left: 0;
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 15px 0;
}

.sidebar-menu-btn {
    width: 55px;
    height: 55px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: var(--white);
    font-size: 26px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    text-decoration: none;
    backdrop-filter: blur(5px);
}

.sidebar-menu-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.sidebar-menu-btn.active {
    background: rgba(255, 255, 255, 0.4);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Floating Sidebar Toggle Button */
.floating-sidebar-toggle {
    position: fixed;
    left: calc(var(--main-sidebar-width) + 15px);
    bottom: 20px;
    width: 55px;
    height: 55px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4A9FF5 0%, #9B5FC0 50%, #E94B8B 100%);
    color: var(--white);
    font-size: 26px;
    border: 3px solid rgba(255, 255, 255, 0.5);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 30px rgba(74, 159, 245, 0.7), 0 0 50px rgba(155, 95, 192, 0.4);
    z-index: 1001;
    transition: transform 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55),
        box-shadow 0.3s ease,
        border-color 0.3s ease;
    animation: glowPulse 3s ease-in-out infinite;
}

.floating-sidebar-toggle:hover {
    transform: rotate(360deg) scale(1.2);
    box-shadow: 0 8px 40px rgba(74, 159, 245, 0.9), 0 0 70px rgba(155, 95, 192, 0.6);
    border-color: rgba(255, 255, 255, 0.8);
    animation: glowPulse 0.5s ease-in-out infinite;
}

.floating-sidebar-toggle:active {
    transform: rotate(360deg) scale(0.9);
}

body.sidebar-collapsed .floating-sidebar-toggle {
    left: 20px;
}

@keyframes glowPulse {

    0%,
    100% {
        box-shadow: 0 6px 30px rgba(74, 159, 245, 0.7), 0 0 50px rgba(155, 95, 192, 0.4);
        filter: brightness(1);
    }

    50% {
        box-shadow: 0 10px 40px rgba(74, 159, 245, 0.9), 0 0 70px rgba(155, 95, 192, 0.6);
        filter: brightness(1.15);
    }
}

/* ==================== MAIN CONTENT WRAPPER ==================== */
.main-content-wrapper {
    margin-left: 0;
    width: 100%;
    transition: margin-left 0.3s ease, width 0.3s ease;
}

body:not(.sidebar-collapsed) .main-content-wrapper {
    margin-left: var(--main-sidebar-width);
    width: calc(100% - var(--main-sidebar-width));
}

/* ==================== CHAT LAYOUT ==================== */
.chat-layout {
    display: flex;
    width: 100%;
    height: 100vh;
    position: relative;
}

/* ==================== SIDEBAR LEFT (CONTACT LIST) ==================== */
.sidebar,
.sidebar-left {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    height: 100vh;
    flex-shrink: 0;
    position: relative;
}

.sidebar-header {
    padding: 15px 15px 0 15px;
    background: var(--gradient-bg);
    color: var(--white);
    flex-shrink: 0;
    position: relative;
    overflow: visible;
}

.sidebar-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.1) 0%, transparent 70%);
    animation: shimmer 8s ease-in-out infinite;
    pointer-events: none;
}

@keyframes shimmer {

    0%,
    100% {
        transform: translate(0, 0) rotate(0deg);
    }

    50% {
        transform: translate(30px, 30px) rotate(180deg);
    }
}

/* Admin Profile Fixed to Top Right */
.admin-profile-fixed {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

@media (max-width: 768px) {
    .admin-profile-fixed {
        top: 15px;
        right: 15px;
    }
}

.admin-profile-fixed .admin-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    border: 3px solid rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.admin-profile-fixed .admin-avatar::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shine 3s infinite;
}

.admin-profile-fixed .admin-avatar:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

@keyframes shine {
    0% {
        transform: translateX(-100%) translateY(-100%) rotate(45deg);
    }

    100% {
        transform: translateX(100%) translateY(100%) rotate(45deg);
    }
}

.avatar-text {
    position: relative;
    z-index: 1;
}

/* Sidebar Header Layout */
.sidebar-logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 10px;
    position: relative;
    z-index: 1;
}

.sidebar-logo,
.header-brand-logo,
.page-header-logo img {
    max-width: var(--logo-max-width);
    max-height: var(--logo-max-height);
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.sidebar-logo {
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
    animation: logoFloat 3s ease-in-out infinite;
    transition: transform 0.3s ease;
}

.main-sidebar .sidebar-logo {
    max-width: clamp(40px, calc(var(--main-sidebar-width) - 20px), var(--logo-max-width));
    max-height: clamp(30px, calc(var(--logo-max-height) - 10px), var(--logo-max-height));
}

.sidebar-logo:hover {
    transform: scale(1.05);
}

@keyframes logoFloat {

    0%,
    100% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-5px);
    }
}

.header-actions-row .connection-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    position: relative;
    z-index: 1;
}

.header-actions-row .connection-status .status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #4CAF50;
    animation: pulse 2s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.6);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

.header-actions-row {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    position: relative;
    z-index: 1;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.admin-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--white);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    margin-bottom: 4px;
}

.admin-role {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.header-actions-row .action-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(5px);
}

.header-actions-row .action-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.header-actions-row .action-btn:hover::before {
    left: 100%;
}

.header-actions-row .action-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.header-actions-row .action-btn .btn-icon {
    font-size: 13px;
}

.header-actions-row .action-btn .btn-text {
    font-size: 12px;
}

/* Modern Language Selector - 2025 Style (Consistent with other buttons) */
.header-actions-row .language-selector,
.language-selector,
#languageSelect {
    position: relative;
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    padding-right: 32px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    color: #2f3a57;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    outline: none;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    min-width: 80px;
    height: auto;
    line-height: 1.4;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 12px;
}

.header-actions-row .language-selector {
    color: var(--white);
}

.header-actions-row .language-selector:hover,
.language-selector:hover,
#languageSelect:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.header-actions-row .language-selector:active,
.language-selector:active,
#languageSelect:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.header-actions-row .language-selector:focus,
.language-selector:focus,
#languageSelect:focus {
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    outline: none;
}

.header-actions-row .language-selector option,
.language-selector option,
#languageSelect option,
select.language-selector option,
select#languageSelect option {
    background: #2d3748 !important;
    background-color: #2d3748 !important;
    color: #ffffff !important;
    padding: 10px 12px !important;
    font-weight: 500 !important;
    border-radius: 0;
    border: none !important;
}

/* ⭐ เพิ่มสำหรับทุก browser */
.header-actions-row .language-selector option:hover,
.language-selector option:hover,
#languageSelect option:hover {
    background: #4a5568 !important;
    background-color: #4a5568 !important;
}

.header-actions-row .language-selector option:checked,
.language-selector option:checked,
#languageSelect option:checked {
    background: #667eea !important;
    background-color: #667eea !important;
}


.btn-faq-manager {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
    white-space: nowrap;
    backdrop-filter: blur(5px);
}

.btn-faq-manager:hover {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Channel Filter */
.channel-filter {
    margin: 0 15px 8px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
    position: relative;
}

.channel-filter label {
    font-size: 13px;
    font-weight: 500;
    color: var(--white);
    white-space: nowrap;
}

.channel-filter select {
    flex: 1;
    padding: 6px 12px;
    border: none;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 13px;
    color: var(--dark-gray);
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

.channel-filter select:hover {
    background: rgba(255, 255, 255, 0.35);
    border-color: rgba(255, 255, 255, 0.4);
}

.channel-filter select:focus {
    background: rgba(255, 255, 255, 0.4);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Stats Toggle Button */
.toggle-stats-btn,
.stats-toggle-btn {
    width: calc(100% - 30px);
    padding: 10px;
    margin: 0 15px 10px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25), rgba(255, 255, 255, 0.15));
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    color: var(--white);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(5px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1;
}

.toggle-stats-btn::before {
    content: '▲';
    margin-right: 8px;
    transition: transform 0.3s ease;
    font-size: 10px;
    display: inline-block;
}

.toggle-stats-btn.collapsed::before {
    content: '▼';
}

.toggle-stats-btn:hover,
.stats-toggle-btn:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.25));
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

/* Connection Status */
.connection-status {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--white);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse-dot 2s ease-in-out infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

.status-dot.online {
    background-color: #4CAF50;
}

.status-dot.offline {
    background-color: #F44336;
}

.status-text {
    font-weight: 500;
}

/* Dashboard Stats */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 10px;
    margin: 0 15px 10px 15px;
    background: transparent;
    border-radius: 8px;
    transition: all 0.3s ease;
    overflow: hidden;
    max-height: 500px;
}

.dashboard-stats.collapsed {
    max-height: 0;
    padding: 0 15px;
    margin: 0 15px;
    opacity: 0;
}

.stat-card {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.25) 0%, rgba(255, 255, 255, 0.15) 100%);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    padding: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.3);
    min-height: 60px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* ⏰ การ์ดแชทค้าง - เปลี่ยนสีเป็นแดงเมื่อมีแชทค้าง */
.stat-card:has(#statPendingChats:not(:empty)) {
    background: linear-gradient(135deg, rgba(255, 68, 68, 0.1) 0%, rgba(255, 100, 100, 0.15) 100%) !important;
    border: 1px solid rgba(255, 68, 68, 0.3) !important;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0.25) 100%);
}

.stat-card-clickable {
    cursor: pointer;
}

.stat-card-clickable:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.4) 0%, rgba(255, 255, 255, 0.3) 100%);
    border-color: rgba(255, 255, 255, 0.5);
}

.stat-card-clickable.active {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.45) 0%, rgba(255, 255, 255, 0.35) 100%);
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.stat-icon {
    font-size: 24px;
    flex-shrink: 0;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.stat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--white);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.stat-label {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
    font-weight: 500;
}

/* Gradient Background Extension */
.sidebar-left::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 580px;
    background: var(--gradient-bg);
    z-index: 0;
    pointer-events: none;
}

.sidebar-left>* {
    position: relative;
    z-index: 1;
}

/* Search Box */
.search-box {
    position: relative;
    padding: 0 15px 15px;
    z-index: 1;
}

.search-box input {
    width: 100%;
    padding: 10px 15px;
    border: none;
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 14px;
    color: var(--dark-gray);
    outline: none;
    transition: all 0.3s ease;
}

.search-box input:focus {
    background: rgba(255, 255, 255, 0.4);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.search-box input::placeholder {
    color: rgba(255, 255, 255, 0.8);
}

.contact-list {
    flex: 1;
    overflow-y: auto;
    background: var(--white);
    min-height: 0;
    position: relative;
    z-index: 2;
}

.contact-item {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.contact-item:hover {
    background: var(--light-gray);
}

.contact-item.active {
    background: #E3F2FD;
    border-left: 4px solid var(--primary-blue);
}

.contact-item.unread {
    background: #FFF9E6;
}

/* ⏰ แชทค้าง - กรอบสีแดงกระพริบ */
.contact-item.pending-response {
    border: 2px solid #ff4444 !important;
    border-radius: 8px;
    animation: pendingBlink 1.5s ease-in-out infinite;
    box-shadow: 0 0 10px rgba(255, 68, 68, 0.5);
}

@keyframes pendingBlink {

    0%,
    100% {
        border-color: #ff4444;
        box-shadow: 0 0 10px rgba(255, 68, 68, 0.5);
    }

    50% {
        border-color: #ff8888;
        box-shadow: 0 0 20px rgba(255, 68, 68, 0.8);
    }
}

/* Dark mode สำหรับ pending-response */
body.dark-mode .contact-item.pending-response {
    border-color: #ff6666 !important;
    box-shadow: 0 0 15px rgba(255, 102, 102, 0.6);
    animation: pendingBlinkDark 1.5s ease-in-out infinite;
}

@keyframes pendingBlinkDark {

    0%,
    100% {
        border-color: #ff6666;
        box-shadow: 0 0 15px rgba(255, 102, 102, 0.6);
    }

    50% {
        border-color: #ff9999;
        box-shadow: 0 0 25px rgba(255, 102, 102, 0.9);
    }
}

.contact-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    margin-right: 10px;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.contact-avatar:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.contact-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.contact-info {
    flex: 1;
    min-width: 0;
    margin-right: 12px;
    /* ⭐ เพิ่มระยะห่างระหว่าง contact-info กับ contact-meta */
}

.contact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.contact-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--dark-gray);
    display: flex;
    align-items: center;
    gap: 5px;
    line-height: 1.4;
    margin-bottom: 4px;
    /* ⭐ เพิ่มระยะห่างระหว่างชื่อกับข้อความล่าสุด */
}

.contact-platform {
    font-size: 12px;
    margin-left: 5px;
}

.platform-icon {
    width: 16px;
    height: 16px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 4px;
}

.contact-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    /* ⭐ เพิ่มระยะห่างระหว่าง timestamp กับ unread badge */
    flex-shrink: 0;
    min-width: 80px;
    /* ⭐ กำหนดความกว้างขั้นต่ำเพื่อไม่ให้ชิดกัน */
}

.contact-time {
    font-size: 12px;
    color: var(--text-gray);
    white-space: nowrap;
    /* ⭐ ป้องกันการขึ้นบรรทัดใหม่ */
}

.contact-preview,
.contact-last-message {
    font-size: 12px;
    color: var(--text-gray);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    max-height: 32px;
    line-height: 16px;
    min-height: 16px;
    /* ⭐ เพิ่ม min-height เพื่อให้แสดงผลแม้ว่าจะไม่มีข้อความ */
    visibility: visible !important;
    /* ⭐ บังคับให้แสดง */
    opacity: 1 !important;
    /* ⭐ บังคับให้แสดง */
    margin-top: 2px;
    /* ⭐ เพิ่มระยะห่างเล็กน้อยด้านบน */
}

.unread-badge {
    position: absolute;
    top: 10px;
    right: 15px;
    background: var(--error-color);
    color: var(--white);
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

/* ==================== CHAT AREA ==================== */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: row;
    min-width: 0;
    position: relative;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--white);
    min-width: 0;
}

.chat-header {
    padding: 20px 25px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border-bottom: none;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    min-height: 80px;
    position: relative;
    overflow: hidden;
}

.chat-header::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
}

/* User Avatar in Chat Header */
.chat-user-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    border: 3px solid transparent;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 2px;
    transition: all 0.3s ease;
    position: relative;
}

.chat-user-avatar::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2, #f093fb);
    opacity: 0;
    animation: avatarPulse 3s ease-in-out infinite;
}

@keyframes avatarPulse {

    0%,
    100% {
        opacity: 0;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.1);
    }
}

.chat-user-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.5);
}

.chat-user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    background: white;
}

/* Chat Header Info */
.chat-header-info {
    flex: 1;
    min-width: 0;
    margin-left: 15px;
}

.chat-header-info h3 {
    font-size: 18px;
    font-weight: 700;
    color: #2d3748;
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-header-info #chatUserName {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.edit-name-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: all 0.2s ease;
    opacity: 0.6;
}

.edit-name-btn:hover {
    opacity: 1;
    background: rgba(102, 126, 234, 0.1);
    transform: scale(1.1);
}

.chat-header-info span {
    font-size: 13px;
    color: #718096;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* User Status Badge */
.user-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    background: linear-gradient(135deg, #f5f7fa 0%, #e9ecef 100%);
    color: #718096;
    border: 1.5px solid #e2e8f0;
    transition: all 0.3s ease;
}

.user-status-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cbd5e0;
    display: inline-block;
}

/* When user is online */
.user-status-badge.online {
    background: linear-gradient(135deg, #c6f6d5 0%, #9ae6b4 100%);
    color: #22543d;
    border-color: #9ae6b4;
}

.user-status-badge.online::before {
    background: #48bb78;
    box-shadow: 0 0 8px rgba(72, 187, 120, 0.6);
    animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {

    0%,
    100% {
        box-shadow: 0 0 8px rgba(72, 187, 120, 0.6);
    }

    50% {
        box-shadow: 0 0 15px rgba(72, 187, 120, 0.9);
    }
}

/* When user is offline */
.user-status-badge.offline {
    background: linear-gradient(135deg, #fed7d7 0%, #fc8181 100%);
    color: #742a2a;
    border-color: #fc8181;
}

.user-status-badge.offline::before {
    background: #f56565;
}

/* AI Toggle Container */
.ai-toggle-container {
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    padding: 10px 18px;
    border-radius: 50px;
    border: 2px solid transparent;
    background-clip: padding-box;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.15);
    transition: all 0.3s ease;
}

.ai-toggle-container:hover {
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.25);
    transform: translateY(-1px);
}

.ai-toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    margin: 0;
    user-select: none;
}

#aiToggleText {
    font-size: 14px;
    font-weight: 600;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: 0.3px;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
    margin: 0;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #cbd5e0 0%, #a0aec0 100%);
    transition: all 0.4s ease;
    border-radius: 34px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    transition: all 0.4s ease;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked+.toggle-slider {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.5);
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(24px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.toggle-slider:after {
    content: '✓';
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.toggle-switch input:checked+.toggle-slider:after {
    opacity: 1;
}

/* Old styles for compatibility */
.chat-header-left {
    display: flex;
    align-items: center;
    gap: 15px;
    flex: 1;
    min-width: 0;
}

.chat-contact-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.chat-contact-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-contact-info {
    flex: 1;
    min-width: 0;
}

.chat-contact-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark-gray);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-contact-status {
    font-size: 13px;
    color: var(--text-gray);
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--light-gray);
    border: none;
    color: var(--dark-gray);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.chat-action-btn:hover {
    background: var(--gray);
    transform: scale(1.1);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #F8F9FA;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 75%;
    animation: messageSlideIn 0.3s ease;
    margin-bottom: 16px;
}

/* Message from customer (left side) */
.message.received {
    align-self: flex-start;
    flex-direction: row;
}

/* Message from bot/admin (right side) */
.message.sent {
    align-self: flex-end;
    flex-direction: row-reverse;
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease;
}

.message.sent .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.message-avatar img:hover {
    transform: scale(1.1);
}

.message.received .message-avatar {
    cursor: pointer;
}

.message.received .message-avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    word-wrap: break-word;
    word-break: break-word;
    position: relative;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
}

.message-bubble:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
}

.message.sent .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received .message-bubble {
    background: white;
    color: #2d3748;
    border-bottom-left-radius: 4px;
    border: 1px solid #e2e8f0;
}

.message-text {
    font-size: 14px;
    line-height: 1.6;
    margin: 0;
    word-break: break-word;
}

.message-time {
    font-size: 11px;
    color: #a0aec0;
    align-self: flex-end;
    margin-top: 4px;
}

.message.sent .message-time {
    color: #a0aec0;
    /* ⭐ ใช้สีเดียวกับฝั่งลูกค้า */
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.15);
    border: none;
    border-radius: 6px;
    padding: 5px;
    cursor: pointer;
    opacity: 0;
    transition: all 0.2s ease;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.message.received .copy-btn {
    background: rgba(0, 0, 0, 0.05);
    color: #718096;
}

.message-bubble:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: rgba(0, 0, 0, 0.25);
    transform: scale(1.1);
}

.message.received .copy-btn:hover {
    background: rgba(0, 0, 0, 0.1);
}

.message-image {
    max-width: 100%;
    border-radius: 12px;
    margin-top: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.message-media-wrapper {
    margin-bottom: 8px;
}

.message-media {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.chat-input-container {
    padding: 20px;
    background: white;
    border-top: none;
    box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
    margin-top: auto;
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.chat-input-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
}

#adminReplyInput {
    width: 100%;
    min-height: 70px;
    max-height: 130px;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 18px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    background: #f8f9fa;
    transition: all 0.3s ease;
    box-sizing: border-box;
    line-height: 1.5;
}

#adminReplyInput:focus {
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

#adminReplyInput::placeholder {
    color: #a0aec0;
}

.admin-reply-box {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.reply-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: #718096;
    padding: 0 4px;
    width: 100%;
}

.reply-hint {
    color: #a0aec0;
    flex: 1;
}

.char-counter {
    color: #718096;
    font-weight: 500;
}

.input-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    width: 100%;
}

.btn-attach-image {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #f1f3f5;
    border: 2px solid #e9ecef;
    color: #667eea;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.btn-attach-image:hover {
    background: #e9ecef;
    border-color: #667eea;
    transform: scale(1.05);
}

.btn-cancel-reply {
    padding: 10px 22px;
    border-radius: 25px;
    background: #f1f3f5;
    border: 2px solid #e9ecef;
    color: #718096;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.btn-cancel-reply:hover {
    background: #e9ecef;
    border-color: #dee2e6;
}

.btn-send-reply {
    padding: 12px 28px;
    border-radius: 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    flex-shrink: 0;
    margin-left: auto;
}

.btn-send-reply:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.btn-send-reply:active {
    transform: scale(0.98);
}

.typing-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffecb5 100%);
    border: 2px solid #ffc107;
    border-radius: 12px;
    padding: 12px 16px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #856404;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.2);
    width: 100%;
    box-sizing: border-box;
}

#imagePreviewContainer {
    width: 100%;
    margin-bottom: 12px;
}

/* Legacy styles for compatibility */
.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.chat-input-box {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--light-gray);
    border-radius: 25px;
    padding: 10px 15px;
}

.chat-input {
    border: none;
    outline: none;
    background: transparent;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    min-height: 24px;
}

.chat-input-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 5px;
}

.input-action-btn {
    background: none;
    border: none;
    color: var(--text-gray);
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.input-action-btn:hover {
    color: var(--primary-blue);
    transform: scale(1.1);
}

.send-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--gradient-bg);
    border: none;
    color: var(--white);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 15px rgba(74, 159, 245, 0.4);
}

/* ==================== CHAT INFO PANEL (RIGHT SIDEBAR) ==================== */
.chat-info-panel {
    width: var(--info-panel-width);
    background: #f8f9fa;
    border-left: 1px solid var(--border-color);
    overflow-y: auto;
    transition: transform 0.3s ease;
    flex-shrink: 0;
    padding: 20px;
}

.chat-info-panel::-webkit-scrollbar {
    width: 8px;
}

.chat-info-panel::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 10px;
}

.chat-info-panel::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

.chat-info-panel::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.chat-info-panel.hidden {
    transform: translateX(100%);
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
}

.info-panel-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 12px;
    padding: 0;
}

.chat-info-panel h4 {
    display: none;
}

/* Admin Menu Dropdown - Modern 2025 Style */
.admin-menu-dropdown {
    position: relative;
}

.admin-menu-btn {
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.12) 0%, rgba(118, 75, 162, 0.12) 100%);
    border: none;
    color: #3949ab;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 6px 14px 6px 8px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    min-width: 0;
}

.admin-menu-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(102, 126, 234, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.admin-menu-btn:active::before {
    width: 100%;
    height: 100%;
}

.admin-menu-btn:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.2) 0%, rgba(118, 75, 162, 0.2) 100%);
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.admin-menu-btn:active {
    transform: scale(0.95);
}

.admin-menu-btn svg {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    color: inherit;
}

.admin-menu-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8e9dff, #a48bff);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #fff;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.admin-menu-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    display: block;
}

.admin-menu-info {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
}

.admin-menu-name {
    font-weight: 600;
    font-size: 14px;
    color: #2f2f54;
    max-width: 160px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-menu-role {
    font-size: 12px;
    color: #6b6b94;
    text-transform: capitalize;
}

.admin-menu-caret {
    transition: transform 0.2s ease;
}

.admin-menu-btn.open .admin-menu-caret {
    transform: rotate(180deg);
}

.admin-dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(102, 126, 234, 0.1);
    min-width: 240px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 1000;
    overflow: hidden;
}

.admin-dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.dropdown-menu-header {
    padding: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.admin-profile-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-avatar-small {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid rgba(255, 255, 255, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    overflow: hidden;
    flex-shrink: 0;
    backdrop-filter: blur(10px);
    position: relative;
}

.admin-avatar-small.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }

    100% {
        transform: translateX(100%);
    }
}

.admin-avatar-small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    animation: fadeIn 0.3s ease;
}

.admin-info-text {
    flex: 1;
    min-width: 0;
}

.admin-name-small {
    font-size: 14px;
    font-weight: 700;
    color: white;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-email-small {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-title {
    font-size: 14px;
    font-weight: 700;
    color: white;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: #2d3748;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    border-left: 3px solid transparent;
}

.dropdown-item:hover {
    background: linear-gradient(90deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.05) 100%);
    border-left-color: #667eea;
    padding-left: 23px;
}

.dropdown-item:active {
    transform: scale(0.98);
}

.dropdown-item.danger {
    transition: all 0.3s ease;
}

.dropdown-item.danger:hover {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.08) 0%, rgba(220, 38, 38, 0.05) 100%);
    border-left-color: #ef4444;
    color: #dc2626;
}

.dropdown-item.danger .dropdown-icon {
    transition: transform 0.3s ease;
}

.dropdown-item.danger:hover .dropdown-icon {
    transform: rotate(20deg);
}

.dropdown-icon {
    font-size: 18px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    position: relative;
}

.dropdown-icon .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.dropdown-text {
    font-size: 14px;
    font-weight: 500;
    flex: 1;
}

.dropdown-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent 0%, rgba(102, 126, 234, 0.2) 50%, transparent 100%);
    margin: 8px 12px;
}

/* Animation for dropdown items */
.admin-dropdown-menu.show .dropdown-item {
    animation: slideInRight 0.3s ease forwards;
    opacity: 0;
}

.admin-dropdown-menu.show .dropdown-item:nth-child(2) {
    animation-delay: 0.05s;
}

.admin-dropdown-menu.show .dropdown-item:nth-child(3) {
    animation-delay: 0.1s;
}

.admin-dropdown-menu.show .dropdown-item:nth-child(5) {
    animation-delay: 0.15s;
}

.admin-dropdown-menu.show .dropdown-item:nth-child(6) {
    animation-delay: 0.2s;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.info-header {
    padding: 20px;
    background: var(--gradient-bg);
    color: var(--white);
    text-align: center;
}

.info-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    margin: 0 auto 15px;
    border: 3px solid var(--white);
}

.info-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.info-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 5px;
}

.info-platform {
    font-size: 14px;
    opacity: 0.9;
}

.info-section {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.info-section-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-gray);
    margin-bottom: 15px;
    text-transform: uppercase;
}

.info-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
}

.info-item-icon {
    font-size: 18px;
    color: var(--primary-blue);
}

.info-item-content {
    flex: 1;
}

.info-item-label {
    font-size: 12px;
    color: var(--text-gray);
    margin-bottom: 2px;
}

.info-item-value {
    font-size: 14px;
    color: var(--dark-gray);
    font-weight: 500;
}

.info-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px;
}

.info-action-btn {
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: var(--light-gray);
    color: var(--dark-gray);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.info-action-btn:hover {
    background: var(--gray);
    transform: translateY(-2px);
}

.info-action-btn.danger {
    background: #FFEBEE;
    color: var(--error-color);
}

.info-action-btn.danger:hover {
    background: #FFCDD2;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1200px) {
    .chat-info-panel {
        position: absolute;
        right: 0;
        top: 0;
        height: 100%;
        transform: translateX(100%);
        z-index: 10;
        box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    }

    .chat-info-panel.show {
        transform: translateX(0);
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
        --info-panel-width: 100%;
    }

    .main-sidebar {
        width: 70px;
    }

    .sidebar-menu-btn {
        width: 50px;
        height: 50px;
        font-size: 22px;
    }

    .sidebar-left {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .sidebar-left.show {
        transform: translateX(0);
    }

    .chat-area {
        width: 100%;
    }

    .chat-header {
        padding: 15px;
    }

    .chat-messages {
        padding: 15px;
    }

    .message {
        max-width: 85%;
    }

    .chat-info-panel {
        width: 100%;
    }

    .admin-dropdown-menu {
        right: -10px;
        min-width: 220px;
    }

    .dropdown-item {
        padding: 10px 16px;
        font-size: 13px;
    }

    .dropdown-icon {
        font-size: 16px;
        width: 20px;
        height: 20px;
    }

    .admin-avatar-small {
        width: 38px;
        height: 38px;
        font-size: 18px;
    }

    .admin-name-small {
        font-size: 13px;
    }

    .admin-email-small {
        font-size: 10px;
    }

    .dropdown-menu-header {
        padding: 12px;
    }
}

/* ==================== PROFILE IMAGE MODAL ==================== */
.profile-modal {
    display: none;
    position: fixed;
    z-index: 9999;
    padding-top: 50px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.9);
    animation: fadeIn 0.3s ease;
}

.profile-modal-content {
    margin: auto;
    display: block;
    max-width: 90%;
    max-height: 80vh;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    animation: zoomIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.profile-modal-close {
    position: absolute;
    top: 20px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
    z-index: 10000;
}

.profile-modal-close:hover,
.profile-modal-close:focus {
    color: #bbb;
    text-decoration: none;
    cursor: pointer;
}

#profileModalCaption {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
    text-align: center;
    color: #ccc;
    padding: 10px 0;
    font-size: 16px;
    font-weight: 600;
}

/* ==================== EDIT NAME MODAL ==================== */
.edit-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

.edit-modal-content {
    background: white;
    margin: 10% auto;
    padding: 0;
    border-radius: 16px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.edit-modal-header {
    padding: 20px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px 16px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.edit-modal-header h3 {
    margin: 0;
    color: white;
    font-size: 18px;
    font-weight: 600;
}

.edit-modal-close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.edit-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.edit-modal-body {
    padding: 24px;
}

.edit-modal-body label {
    display: block;
    margin-bottom: 8px;
    color: #2d3748;
    font-weight: 600;
    font-size: 14px;
}

.edit-modal-body input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 14px;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.edit-modal-body input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.edit-modal-footer {
    padding: 16px 24px;
    background: #f8f9fa;
    border-radius: 0 0 16px 16px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-cancel,
.btn-save {
    padding: 10px 24px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

.btn-cancel {
    background: #e9ecef;
    color: #495057;
}

.btn-cancel:hover {
    background: #dee2e6;
}

.btn-save {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-save:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

/* ==================== UTILITY CLASSES ==================== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.mt-10 {
    margin-top: 10px;
}

.mb-10 {
    margin-bottom: 10px;
}

.p-20 {
    padding: 20px;
}

/* ==================== SCROLLBAR STYLING ==================== */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--light-gray);
}

::-webkit-scrollbar-thumb {
    background: var(--gray);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-gray);
}

/* ==================== ANIMATIONS ==================== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(20px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-20px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ==================== LOADING STATES ==================== */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-gray);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ==================== EMPTY STATES ==================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    color: var(--text-gray);
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 20px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--dark-gray);
    margin-bottom: 10px;
}

.empty-state-text {
    font-size: 14px;
    color: var(--text-gray);
}

/* ======================================
   DARK MODE - หน้าแชท
   ====================================== */

body.dark-mode {
    background: #1a1a1a;
    color: #ffffff;
}

/* Sidebar - เหมือนหน้า Admin Settings */
body.dark-mode .main-sidebar {
    background: linear-gradient(180deg,
            rgba(45, 90, 123, 0.95) 0%,
            rgba(61, 77, 92, 0.95) 50%,
            rgba(74, 61, 82, 0.95) 100%);
}

body.dark-mode .sidebar-menu-btn {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

body.dark-mode .sidebar-menu-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 20px rgba(255, 255, 255, 0.15);
}

body.dark-mode .sidebar-menu-btn.active {
    background: rgba(102, 126, 234, 0.4);
    border-color: #667eea;
}

body.dark-mode .sidebar-left {
    background: #2d3748;
}

body.dark-mode .sidebar-left::before {
    background: linear-gradient(135deg, rgba(45, 90, 123, 0.3) 0%, rgba(74, 61, 82, 0.3) 100%);
}

body.dark-mode .sidebar-header {
    background: rgba(45, 90, 123, 0.2);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .sidebar-logo-container {
    background: rgba(255, 255, 255, 0.08);
}

body.dark-mode .admin-info-section {
    background: rgba(255, 255, 255, 0.08);
    border-top-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .admin-name {
    color: #ffffff;
}

body.dark-mode .admin-role {
    color: #b0b0b0;
}

body.dark-mode .connection-status-bar {
    background: rgba(255, 255, 255, 0.05);
}

body.dark-mode .connection-status {
    color: #ffffff;
}

body.dark-mode .action-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

body.dark-mode .action-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Dark Mode Language Selector */
body.dark-mode .language-selector,
body.dark-mode #languageSelect {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.15);
}

body.dark-mode .language-selector:hover,
body.dark-mode #languageSelect:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.25);
}

body.dark-mode .language-selector option,
body.dark-mode #languageSelect option,
body.dark-mode select.language-selector option,
body.dark-mode select#languageSelect option {
    background: #2d3748 !important;
    background-color: #2d3748 !important;
    color: #ffffff !important;
}

body.dark-mode .language-selector option:hover,
body.dark-mode #languageSelect option:hover {
    background: #4a5568 !important;
    background-color: #4a5568 !important;
}

body.dark-mode .language-selector option:checked,
body.dark-mode #languageSelect option:checked {
    background: #667eea !important;
    background-color: #667eea !important;
}

/* Dashboard Stats */
body.dark-mode .dashboard-stats {
    background: transparent;
}

body.dark-mode .stat-card {
    background: rgba(255, 255, 255, 0.05);
    border-color: #3d3d3d;
}

body.dark-mode .stat-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: #667eea;
}

body.dark-mode .stat-value {
    color: #ffffff;
}

body.dark-mode .stat-label {
    color: #b0b0b0;
}

body.dark-mode .toggle-stats-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

body.dark-mode .toggle-stats-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Channel Filter & Search */
body.dark-mode .channel-filter {
    background: transparent;
}

body.dark-mode .channel-filter select {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .search-box input {
    background: rgba(0, 0, 0, 0.3);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .search-box input:focus {
    background: rgba(0, 0, 0, 0.4);
    border-color: #667eea;
}

body.dark-mode .search-box input::placeholder {
    color: #ffffff;
}

/* Message Date Divider */
.message-date-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 20px 0;
    text-align: center;
}

.message-date-divider span {
    background: rgba(255, 255, 255, 0.1);
    color: #999;
    padding: 6px 16px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

body.dark-mode .message-date-divider span {
    background: rgba(255, 255, 255, 0.1);
    color: #999;
}

/* Contact List */
body.dark-mode .contact-list {
    background: #2d3748;
}

body.dark-mode .contact-item {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .contact-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

body.dark-mode .contact-item.active {
    background: rgba(102, 126, 234, 0.3);
    border-color: #667eea;
}

body.dark-mode .contact-name {
    color: #ffffff;
}

body.dark-mode .contact-preview,
body.dark-mode .contact-last-message {
    color: #b0b0b0;
}

body.dark-mode .contact-meta {
    gap: 4px;
    /* ⭐ ระยะห่างระหว่าง timestamp กับ unread badge ใน dark mode */
}

body.dark-mode .contact-time {
    color: #808080;
    white-space: nowrap;
    /* ⭐ ป้องกันการขึ้นบรรทัดใหม่ใน dark mode */
}

body.dark-mode .unread-badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

body.dark-mode .platform-icon {
    filter: brightness(0.8);
}

/* Chat Area */
body.dark-mode .chat-area {
    background: #2d3748;
}

body.dark-mode .chat-header {
    background: linear-gradient(135deg, rgba(45, 90, 123, 0.4) 0%, rgba(61, 77, 92, 0.4) 100%);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .chat-header::before {
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

body.dark-mode .chat-header-info h3,
body.dark-mode #chatUserName {
    color: #ffffff;
}

body.dark-mode .chat-user-status,
body.dark-mode .user-status-badge {
    color: #b0b0b0;
}

body.dark-mode .edit-name-btn {
    color: #b0b0b0;
}

body.dark-mode .edit-name-btn:hover {
    color: #667eea;
}

body.dark-mode .ai-toggle-container {
    background: rgba(255, 255, 255, 0.05);
}

body.dark-mode .toggle-slider {
    background-color: #3d3d3d;
}

body.dark-mode input:checked+.toggle-slider {
    background-color: #667eea;
}

/* Chat Messages */
body.dark-mode .chat-messages {
    background: #2d3748;
}

body.dark-mode .message.received .message-bubble {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.15);
}

body.dark-mode .message.sent .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

body.dark-mode .message-time {
    color: #666;
}

body.dark-mode .copy-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
}

body.dark-mode .copy-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

body.dark-mode .typing-indicator {
    background: #252525;
}

body.dark-mode .typing-indicator span {
    color: #999;
}

body.dark-mode .typing-dot {
    background: #667eea;
}

/* Chat Input */
body.dark-mode .chat-input-container {
    background: rgba(45, 90, 123, 0.3);
    border-top-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .chat-input-container::before {
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

body.dark-mode #adminReplyInput {
    background: rgba(0, 0, 0, 0.3);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode #adminReplyInput:focus {
    border-color: #667eea;
    background: rgba(0, 0, 0, 0.4);
    color: #ffffff;
}

body.dark-mode #adminReplyInput::placeholder {
    color: #444444;
}

body.dark-mode .btn-attach-image,
body.dark-mode .btn-cancel-reply {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

body.dark-mode .btn-attach-image:hover,
body.dark-mode .btn-cancel-reply:hover {
    background: rgba(255, 255, 255, 0.15);
}

body.dark-mode .typing-warning {
    background: rgba(255, 152, 0, 0.2);
    border-color: rgba(255, 152, 0, 0.4);
    color: #ffb74d;
}

body.dark-mode #imagePreviewContainer {
    background: #252525;
    border-color: #3d3d3d;
}

/* Info Panel */
body.dark-mode .chat-info-panel {
    background: #2d3748;
}

body.dark-mode .info-panel-header h4 {
    color: #ffffff;
    font-weight: 600;
}

body.dark-mode .admin-menu-btn {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.3) 0%, rgba(118, 75, 162, 0.3) 100%);
    color: #f7f7ff;
}

body.dark-mode .admin-menu-avatar {
    background: linear-gradient(135deg, #8c9eff, #b388ff);
}

body.dark-mode .admin-menu-name {
    color: #ffffff;
}

body.dark-mode .admin-menu-role {
    color: #d1c4e9;
}

body.dark-mode .admin-dropdown-menu {
    background: rgba(45, 55, 72, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.15);
}

body.dark-mode .dropdown-menu-header {
    background: linear-gradient(135deg, rgba(45, 90, 123, 0.8) 0%, rgba(74, 61, 82, 0.8) 100%);
}

body.dark-mode .admin-name-small {
    color: #ffffff;
}

body.dark-mode .admin-email-small {
    color: #b0b0b0;
}

body.dark-mode .dropdown-item {
    color: #ffffff;
}

body.dark-mode .dropdown-item:hover {
    background: rgba(102, 126, 234, 0.1);
}

body.dark-mode .dropdown-divider {
    background: #3d3d3d;
}

body.dark-mode #chatMetadata {
    color: #999;
}

body.dark-mode #chatMetadata p {
    background: #252525;
    border-left-color: #667eea;
}

body.dark-mode #chatMetadata strong {
    color: #e0e0e0;
}

/* Modals */
body.dark-mode .profile-modal {
    background-color: rgba(0, 0, 0, 0.95);
}

body.dark-mode .edit-modal {
    background-color: rgba(0, 0, 0, 0.7);
}

body.dark-mode .edit-modal-content {
    background: #1e1e1e;
}

body.dark-mode .edit-modal-header {
    background: linear-gradient(135deg, #1e1e1e 0%, #2d2d2d 100%);
}

body.dark-mode .edit-modal-header h2 {
    color: #ffffff;
}

body.dark-mode .modal-input {
    background: #252525;
    border-color: #3d3d3d;
    color: #ffffff;
}

body.dark-mode .modal-input:focus {
    border-color: #667eea;
    background: #2d2d2d;
}

body.dark-mode .modal-btn-secondary {
    background: #3d3d3d;
    color: #ffffff;
}

body.dark-mode .modal-btn-secondary:hover {
    background: #4d4d4d;
}

/* Scrollbar */
body.dark-mode .contact-list::-webkit-scrollbar-track,
body.dark-mode .chat-messages::-webkit-scrollbar-track,
body.dark-mode .chat-info-panel::-webkit-scrollbar-track {
    background: #1e1e1e;
}

body.dark-mode .contact-list::-webkit-scrollbar-thumb,
body.dark-mode .chat-messages::-webkit-scrollbar-thumb,
body.dark-mode .chat-info-panel::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Floating Toggle Button */
body.dark-mode .floating-sidebar-toggle {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: rgba(255, 255, 255, 0.3);
}

/* ==================== MEDIA GALLERY MODAL ==================== */
.media-gallery-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 30px 20px;
    background: rgba(8, 10, 35, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 4000;
}

.media-gallery-modal.show {
    display: flex;
}

.media-gallery-content {
    width: min(1100px, 100%);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 28px;
    border-radius: 28px;
    background: radial-gradient(circle at top right, rgba(123, 97, 255, 0.25), rgba(33, 35, 68, 0.95));
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 30px 120px rgba(15, 19, 40, 0.6);
    overflow: hidden;
}

.media-gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.media-gallery-header h3 {
    margin: 0;
    font-size: 22px;
    font-weight: 600;
    color: #f6f7ff;
    display: flex;
    align-items: center;
    gap: 8px;
}

.media-gallery-close {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.media-gallery-close:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.media-gallery-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.media-gallery-filters input,
.media-gallery-filters select {
    height: 44px;
    border-radius: 14px;
    border: none;
    padding: 0 18px;
    background: rgba(255, 255, 255, 0.16);
    color: #fdfdff;
    font-size: 15px;
    font-weight: 500;
    flex: 1;
    min-width: 200px;
    outline: none;
    transition: background 0.2s ease, transform 0.2s ease;
}

.media-gallery-filters input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

.media-gallery-filters input:focus,
.media-gallery-filters select:focus,
.media-gallery-filters input:hover,
.media-gallery-filters select:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-1px);
}

.media-gallery-body {
    flex: 1;
    overflow: auto;
    padding: 5px 4px 5px 0;
}

.media-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 18px;
}

.media-item {
    position: relative;
    border-radius: 20px;
    padding: 12px;
    background: rgba(24, 27, 58, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.08);
    cursor: pointer;
    overflow: hidden;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: all 0.25s ease;
}

.media-item:hover {
    transform: translateY(-6px);
    border-color: rgba(255, 255, 255, 0.35);
    box-shadow: 0 16px 40px rgba(15, 19, 40, 0.45);
}

.media-item img,
.media-item video {
    width: 100%;
    height: 130px;
    object-fit: cover;
    border-radius: 14px;
    background: #0d0f1f;
}

.media-type-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
}

.media-item-info {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.4;
    min-height: 38px;
}

.media-item-info strong {
    display: block;
    margin-bottom: 4px;
    color: #fff;
}

.media-gallery-footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.media-gallery-footer button {
    flex: 1;
    height: 48px;
    border-radius: 16px;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-upload-new {
    background: linear-gradient(130deg, #7b61ff, #8f67ff);
    color: #fff;
    box-shadow: 0 15px 35px rgba(123, 97, 255, 0.35);
}

.btn-upload-new:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 38px rgba(123, 97, 255, 0.45);
}

.media-gallery-footer .btn-cancel {
    background: rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.9);
}

.media-gallery-footer .btn-cancel:hover {
    background: rgba(255, 255, 255, 0.22);
}

.media-hover-preview {
    position: fixed;
    pointer-events: none;
    z-index: 5000;
    width: 360px;
    max-width: 45vw;
    border-radius: 24px;
    background: rgba(2, 3, 15, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 25px 60px rgba(5, 6, 22, 0.6);
    padding: 12px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
    transform: scale(0.95) translateY(-10px);
}

.media-hover-preview.show {
    opacity: 1;
    visibility: visible;
    transform: scale(1) translateY(0);
}

.media-hover-preview img,
.media-hover-preview video {
    width: 100%;
    height: auto;
    border-radius: 18px;
    object-fit: contain;
    max-height: 70vh;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.media-hover-preview.show img,
.media-hover-preview.show video {
    opacity: 1;
}

.loading-spinner {
    text-align: center;
    padding: 40px 0;
    color: rgba(255, 255, 255, 0.8);
    font-weight: 500;
}

@media (max-width: 768px) {
    .media-gallery-content {
        padding: 20px;
        border-radius: 20px;
    }

    .media-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }

    .media-gallery-filters input,
    .media-gallery-filters select {
        min-width: 100%;
    }

    .media-gallery-footer {
        flex-direction: column;
    }
}