:root {
    --primary-blue: #1890ff;
    --light-blue: #e3f2fd;
    --bg-color: #f5f7fa;
    --panel-bg: #ffffff;
    --border-color: #e0e6ed;
    --text-primary: #2c3e50;
    --text-secondary: #7f8c8d;
    --success-green: #27ae60;
    --warning-orange: #f39c12;
    --danger-red: #e74c3c;
    --mutual-limit: #ff6b6b;
    --sidebar-dark: #001529;
}

* { 
    margin: 0; 
    padding: 0; 
    box-sizing: border-box; 
}

html, body {
    height: 100vh;
    margin: 0;
    padding: 0;
    overflow: hidden; /* CRITICAL: Prevents the whole page from scrolling */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-size: 13px;
}

/* ==================== APP WRAPPER ==================== */
.app-wrapper {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: 250px;
    background-color: var(--sidebar-dark);
    color: rgba(255, 255, 255, 0.65);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    flex-shrink: 0;
    overflow: hidden;
    z-index: 1000;
}

.sidebar.collapsed {
    width: 0;
}

.sidebar-header {
    height: 60px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-size: 18px;
    font-weight: bold;
    color: white;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    white-space: nowrap;
    flex-shrink: 0;
}

.sidebar-header i {
    margin-right: 10px;
    font-size: 22px;
}

.sidebar-menu {
    padding: 10px 0;
    overflow-y: auto;
}

.menu-item {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
    white-space: nowrap;
}

.menu-item:hover {
    color: white;
}

.menu-item.active {
    background-color: var(--primary-blue);
    color: white;
}

.menu-item i {
    margin-right: 10px;
    font-size: 16px;
}

.submenu {
    background-color: #000c17;
    display: none;
}

.submenu .menu-item {
    padding-left: 50px;
    font-size: 13px;
}

/* ==================== MAIN CONTENT ==================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--bg-color);
    min-width: 0;
    min-height: 0;
}

/* ==================== TOP NAVBAR ==================== */
.top-navbar {
    height: 60px;
    background-color: var(--primary-blue);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 999;
    flex-shrink: 0;
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

#toggleSidebar {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
}

.navbar-brand {
    font-size: 18px;
    font-weight: 600;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.nav-icon {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    position: relative;
}

/* User Profile Dropdown */
.user-profile {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: #faad14;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
}

.user-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 10px;
    background: white;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    min-width: 220px;
    display: none;
    z-index: 1001;
    overflow: hidden;
}


/*.user-profile:hover .user-dropdown {
    display: block;
}*/
.user-profile.active .user-dropdown {
    display: block;

}

.dropdown-item {
    padding: 10px 20px;
    color: #333;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background-color: var(--primary-blue);
}
.user-dropdown.active {
    background-color: var(--primary-blue)!important;
}

.dropdown-item.text-danger:hover {
    background-color: #fff1f0;
}

.dropdown-divider {
    margin: 0;
    border-top: 1px solid #f0f0f0;
}

/* ==================== STATS BAR ==================== */
.stats-bar {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    background: var(--bg-color);
    border-radius: 4px;
    font-size: 12px;
}

.stat-label { 
    color: var(--text-secondary); 
    font-weight: 500; 
}

.stat-value { 
    font-weight: 700; 
    font-size: 14px; 
    color: var(--text-primary); 
}

.stat-item.highlight { 
    background: var(--light-blue); 
    border: 1px solid var(--primary-blue); 
}

.stat-item.highlight .stat-value { 
    color: var(--primary-blue); 
}

.current-seat { 
    margin-left: auto; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    font-weight: 600; 
    font-size: 13px; 
}

/* ==================== SEARCH BAR ==================== */
.search-bar {
    background: white;
    padding: 8px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    max-width: 500px;
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    outline: none;
    font-size: 13px;
}

.search-input:focus { 
    border-color: var(--primary-blue); 
}

.btn-locate {
    padding: 6px 15px;
    background: var(--light-blue);
    color: var(--primary-blue);
    border: none;
    border-radius: 4px;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
}

.btn-locate:hover { 
    background: var(--primary-blue); 
    color: white; 
}

/* ==================== DASHBOARD CONTAINER ==================== */
.dashboard-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    min-height: 0;
}

/* ==================== PANELS ==================== */
.panel {
    background: var(--panel-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
    min-height: 0;
}

.panel-header {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.record-count { 
    font-size: 11px; 
    color: var(--text-secondary); 
    font-weight: 600; 
    text-transform: uppercase; 
}

.panel-controls { 
    display: flex; 
    gap: 6px; 
    align-items: center; 
    flex-wrap: wrap; 
    width: 100%; 
}

.search-small {
    flex: 1; 
    min-width: 100px;
    padding: 4px 8px; 
    border: 1px solid var(--border-color);
    border-radius: 4px; 
    font-size: 12px; 
    outline: none;
}

.btn-small {
    padding: 4px 8px; 
    background: var(--bg-color);
    border: 1px solid var(--border-color); 
    border-radius: 4px;
    font-size: 12px; 
    font-weight: 500; 
    cursor: pointer; 
    white-space: nowrap;
}

.btn-small:hover { 
    background: var(--light-blue); 
    border-color: var(--primary-blue); 
}

.checkbox-label { 
    display: flex; 
    align-items: center; 
    gap: 4px; 
    font-size: 12px; 
    cursor: pointer; 
}

/* ==================== ACCOUNTS PANEL ==================== */
.accounts-panel {
    border-right: 1px solid var(--border-color);
    min-width: 220px;
}

.accounts-list { 
    flex: 1; 
    overflow-y: auto; 
    padding: 8px; 
    min-height: 0;
}

.account-card {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
}

.account-card:hover { 
    border-color: var(--primary-blue); 
    box-shadow: 0 1px 4px rgba(0,136,204,0.1); 
}

.account-card.active { 
    border-color: var(--primary-blue); 
    background: var(--light-blue); 
}

.account-card-header { 
    display: flex; 
    align-items: center; 
    justify-content: space-between; 
    margin-bottom: 4px; 
}

.account-avatar { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
}

.avatar-badge {
    width: 36px; 
    height: 36px;
    border-radius: 6px;
    display: flex; 
    align-items: center; 
    justify-content: center;
    color: white; 
    font-weight: 700; 
    font-size: 11px; 
    position: relative;
}

.avatar-badge.ro { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.avatar-badge.ho { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }
.avatar-badge.ab { background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%); }
.avatar-badge.gl { background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%); }
.avatar-badge.lo { background: linear-gradient(135deg, #fa709a 0%, #fee140 100%); }

.online-indicator {
    position: absolute; 
    bottom: -2px; 
    right: -2px;
    width: 10px; 
    height: 10px; 
    background: var(--success-green);
    border: 2px solid white; 
    border-radius: 50%;
}

.account-name { 
    font-weight: 600; 
    font-size: 13px; 
    color: var(--text-primary); 
}

.account-time { 
    font-size: 11px; 
    color: var(--text-secondary); 
}

.account-phone { 
    font-size: 11px; 
    color: var(--text-secondary); 
    margin-bottom: 4px; 
    font-family: monospace; 
}

.account-statuses { 
    display: flex; 
    gap: 4px; 
    flex-wrap: wrap; 
}

.status-badge {
    padding: 2px 6px; 
    border-radius: 3px;
    font-size: 10px; 
    font-weight: 600; 
    text-transform: uppercase;
}

.status-online { background: #d4edda; color: var(--success-green); }
.status-mutual { background: #ffe0e0; color: var(--mutual-limit); }
.status-sync { background: #ffe0e0; color: var(--danger-red); }

/* ==================== CONVERSATIONS PANEL ==================== */
.conversations-panel {
    border-right: 1px solid var(--border-color);
    min-width: 280px;
}

.conversations-list { 
    flex: 1; 
    overflow-y: auto;
    min-height: 0;
    height: 0; 
}

.conversation-item {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    gap: 10px;
}

.conversation-item:hover { 
    background: var(--bg-color); 
}

.conversation-item.active { 
    background: var(--light-blue); 
    border-left: 3px solid var(--primary-blue); 
}

.conversation-item.unread { 
    background: #fff8e1; 
}

.conv-avatar {
    width: 40px; 
    height: 40px;
    border-radius: 6px;
    background: var(--light-blue);
    display: flex; 
    align-items: center; 
    justify-content: center;
    font-weight: 700; 
    color: var(--primary-blue);
    flex-shrink: 0; 
    font-size: 12px;
}

.conv-content { 
    flex: 1; 
    min-width: 0; 
}

.conv-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 2px; 
}

.conv-name { 
    font-weight: 600; 
    font-size: 13px; 
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-time { 
    font-size: 11px; 
    color: var(--text-secondary); 
    flex-shrink: 0;
    margin-left: 5px;
}

.conv-message {
    font-size: 12px; 
    color: var(--text-secondary);
    white-space: nowrap; 
    overflow: hidden; 
    text-overflow: ellipsis;
    display: flex; 
    align-items: center; 
    gap: 4px;
}

.read-indicator { 
    color: var(--primary-blue); 
    font-size: 11px; 
}

/* ==================== CHAT PANEL ==================== */
.chat-panel {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg-color);
}

.chat-header { 
    padding: 12px 15px; 
    background: var(--panel-bg); 
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.customer-name { 
    font-size: 16px; 
    font-weight: 700; 
    margin-bottom: 4px; 
}

.customer-meta { 
    font-size: 11px; 
    color: var(--text-secondary); 
    margin-bottom: 8px; 
}

.business-code {
    display: inline-flex; 
    align-items: center; 
    gap: 4px;
    padding: 3px 8px; 
    background: var(--light-blue);
    border-radius: 4px; 
    font-size: 11px; 
    font-weight: 600;
    color: var(--primary-blue); 
    font-family: monospace;
}

.chat-actions { 
    display: flex; 
    gap: 8px; 
    margin-top: 10px; 
    flex-wrap: wrap; 
}

.btn-action {
    padding: 5px 12px; 
    border: 1px solid var(--border-color);
    background: white; 
    border-radius: 4px;
    font-size: 12px; 
    font-weight: 500; 
    cursor: pointer;
    display: flex; 
    align-items: center; 
    gap: 5px;
}

.btn-action:hover { 
    background: var(--bg-color); 
    border-color: var(--primary-blue); 
}

.btn-primary { 
    background: var(--primary-blue); 
    color: white; 
    border-color: var(--primary-blue); 
}

.btn-primary:hover { 
    background: #0077b3; 
}

/* Chat Messages - SCROLLABLE AREA */
.chat-messages { 
    flex: 1; 
    overflow-y: auto; 
    padding: 15px; 
    display: flex; 
    flex-direction: column; 
    gap: 10px;
    min-height: 0;
}

.message {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 8px;
    position: relative;
    word-wrap: break-word;
}

.message.received { 
    align-self: flex-start; 
    background: white; 
    border-bottom-left-radius: 4px; 
    box-shadow: 0 1px 2px rgba(0,0,0,0.05); 
}

.message.sent { 
    align-self: flex-end; 
    background: var(--primary-blue); 
    color: white; 
    border-bottom-right-radius: 4px; 
}

.message-content { 
    font-size: 13px; 
    line-height: 1.4; 
    margin-bottom: 4px; 
}

.message-time { 
    font-size: 10px; 
    opacity: 0.8; 
    text-align: right; 
    display: flex; 
    align-items: center; 
    justify-content: flex-end; 
    gap: 3px; 
}

/* Chat Input Area */
.chat-input-area { 
    padding: 12px 15px; 
    background: var(--panel-bg); 
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.chat-input-wrapper { 
    display: flex; 
    flex-direction: column; 
    gap: 6px; 
}

.chat-input {
    width: 100%; 
    padding: 10px 12px;
    border: 1px solid var(--border-color); 
    border-radius: 6px;
    outline: none; 
    resize: none; 
    font-family: inherit;
    font-size: 13px; 
    min-height: 50px;
}

.chat-input:focus { 
    border-color: var(--primary-blue); 
}

.input-hint { 
    font-size: 11px; 
    color: var(--text-secondary); 
}

.input-actions { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
}

.input-buttons { 
    display: flex; 
    gap: 6px; 
}

.btn-icon {
    padding: 5px 12px; 
    border: 1px solid var(--border-color);
    background: white; 
    border-radius: 4px;
    font-size: 12px; 
    cursor: pointer; 
    display: flex; 
    align-items: center; 
    gap: 4px;
}

.btn-icon:hover { 
    background: var(--bg-color); 
}

/* ==================== SCROLLBAR ==================== */
::-webkit-scrollbar { 
    width: 6px; 
    height: 6px; 
}

::-webkit-scrollbar-track { 
    background: var(--bg-color); 
}

::-webkit-scrollbar-thumb { 
    background: #c1c1c1; 
    border-radius: 3px; 
}

::-webkit-scrollbar-thumb:hover { 
    background: #a8a8a8; 
}

/* ==================== LOGIN PAGE ==================== */
.login-container { 
    height: 100vh; 
    display: flex; 
    align-items: center; 
    justify-content: center; 
    background: linear-gradient(135deg, var(--primary-blue) 0%, #0056b3 100%); 
}

.login-card { 
    width: 100%; 
    max-width: 400px; 
    padding: 40px; 
    background: white; 
    border-radius: 8px; 
    box-shadow: 0 10px 40px rgba(0,0,0,0.2); 
}

/* Ensure submenu links look like normal menu items */
.submenu .menu-item {
    text-decoration: none;
    color: inherit; /* Inherits the white/gray color from parent */
}

.submenu .menu-item:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.05); /* Subtle hover effect */
}

.submenu .menu-item.active {
    background-color: var(--primary-blue);
    color: white;
}




/* ==================== RESPONSIVE ==================== */
@media (max-width: 992px) {
    .dashboard-container {
        flex-direction: column;
        overflow-y: auto;
    }
    
    .panel {
        height: 50vh;
        min-height: 300px;
        border-right: none !important;
        border-bottom: 1px solid var(--border-color);
    }
    
    .chat-panel {
        height: 60vh;
    }
}

@media (max-width: 768px) {
    .stats-bar { 
        gap: 6px; 
        padding: 6px 10px; 
    }
    
    .stat-item { 
        padding: 3px 8px; 
        font-size: 11px; 
    }
    
    .stat-value { 
        font-size: 12px; 
    }
    
    .current-seat { 
        display: none; 
    }
    
    .search-bar { 
        flex-direction: column; 
        padding: 8px 10px; 
    }
    
    .search-input { 
        max-width: none; 
    }
    
    .message {
        max-width: 85%;
    }
}