/* ============================================
   RESET & BASE
   ============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --sidebar-width: 72px;
    --panel-width: 340px;
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --bg-dark: #1e1e2e;
    --bg-sidebar: #111827;
    --bg-primary: #ffffff;
    --bg-panel: #ffffff;
    --bg-secondary: #f3f4f6;
    --bg-chat: #efeae2;
    --bg-chat-pattern: #d9d2c7;
    --bg-message-agent: #6366f1;
    --bg-message-contact: #ffffff;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-light: #9ca3af;
    --text-white: #ffffff;
    --border-color: #e5e7eb;
    --border-light: #f3f4f6;
    --online-color: #22c55e;
    --offline-color: #ef4444;
    --connecting-color: #f59e0b;
    --hover-bg: rgba(255, 255, 255, 0.08);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    --transition: 0.2s ease;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ============================================
   APP CONTAINER
   ============================================ */
.app-container {
    display: flex;
    height: 100vh;
    width: 100%;
    overflow: hidden;
}

/* ============================================
   SIDEBAR (72px)
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    z-index: 10;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.sidebar-logo {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    cursor: pointer;
    transition: transform var(--transition);
}

.sidebar-logo:hover {
    transform: scale(1.08);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
}

.sidebar-btn {
    position: relative;
    width: 48px;
    height: 48px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.45);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    transition: all var(--transition);
}

.sidebar-btn:hover {
    background: var(--hover-bg);
    color: rgba(255, 255, 255, 0.9);
}

.sidebar-btn.active {
    background: rgba(99, 102, 241, 0.2);
    color: var(--primary-light);
}

.sidebar-btn.active::before {
    content: '';
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.sidebar-bottom {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
}

/* Badge */
.badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ============================================
   CONVERSATIONS PANEL (340px)
   ============================================ */
.conversations-panel {
    width: var(--panel-width);
    min-width: var(--panel-width);
    background: var(--bg-panel);
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    z-index: 5;
}

/* Channel Info */
.channel-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: #fafafa;
    border-bottom: 1px solid var(--border-color);
}

.channel-avatar {
    position: relative;
    flex-shrink: 0;
}

.channel-avatar img {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    object-fit: cover;
}

.status-indicator {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: var(--radius-full);
    border: 2px solid #fafafa;
    transition: background var(--transition);
}

.status-indicator.online {
    background: var(--online-color);
}

.status-indicator.offline {
    background: var(--offline-color);
}

.status-indicator.connecting {
    background: var(--connecting-color);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.channel-details {
    flex: 1;
    min-width: 0;
}

.channel-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-phone {
    font-size: 12px;
    color: var(--text-secondary);
}

.channel-status {
    flex-shrink: 0;
}

.status-text {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-text.online {
    color: var(--online-color);
    background: rgba(34, 197, 94, 0.1);
}

.status-text.offline {
    color: var(--offline-color);
    background: rgba(239, 68, 68, 0.1);
}

.status-text.connecting {
    color: var(--connecting-color);
    background: rgba(245, 158, 11, 0.1);
}

/* Search Bar */
.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 12px;
    padding: 0 14px;
    height: 40px;
    background: #f3f4f6;
    border-radius: var(--radius-full);
    border: 1px solid transparent;
    transition: all var(--transition);
}

.search-bar:focus-within {
    background: #ffffff;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.search-bar svg {
    flex-shrink: 0;
    color: var(--text-light);
}

.search-bar input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13px;
    font-family: inherit;
    color: var(--text-primary);
    outline: none;
}

.search-bar input::placeholder {
    color: var(--text-light);
}

/* Conversations List */
.conversations-list {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

.conversations-list::-webkit-scrollbar {
    width: 5px;
}

.conversations-list::-webkit-scrollbar-track {
    background: transparent;
}

.conversations-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background var(--transition);
    border-bottom: 1px solid var(--border-light);
    position: relative;
}

.conversation-item:hover {
    background: #f9fafb;
}

.conversation-item.active {
    background: #eef2ff;
}

.conversation-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary);
}

.conversation-avatar {
    position: relative;
    flex-shrink: 0;
}

.conversation-avatar img {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    object-fit: cover;
}

.conversation-content {
    flex: 1;
    min-width: 0;
}

.conversation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
}

.conversation-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 170px;
}

.conversation-time {
    font-size: 11px;
    color: var(--text-light);
    flex-shrink: 0;
    margin-left: 8px;
}

.conversation-item.unread .conversation-time {
    color: var(--primary);
    font-weight: 600;
}

.conversation-preview {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.conversation-last-message {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 210px;
}

.conversation-item.unread .conversation-last-message {
    color: var(--text-primary);
    font-weight: 500;
}

.unread-count {
    flex-shrink: 0;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--primary);
    color: white;
    font-size: 11px;
    font-weight: 700;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
}

/* ============================================
   CHAT AREA
   ============================================ */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
    background: var(--bg-chat);
}

/* Chat Background Pattern */
.chat-area::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.04;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23000000' fill-opacity='1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    pointer-events: none;
    z-index: 0;
}

/* Chat Empty State */
.chat-empty {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    background: #f0f2f5;
}

.chat-empty-content {
    text-align: center;
    padding: 40px;
}

.chat-empty-content h2 {
    font-size: 28px;
    font-weight: 300;
    color: var(--text-primary);
    margin: 24px 0 8px;
}

.chat-empty-content p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Chat Active */
.chat-active {
    display: flex;
    flex-direction: column;
    height: 100%;
    z-index: 1;
    position: relative;
}

/* Chat Header */
.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #fafafa;
    border-bottom: 1px solid var(--border-color);
    z-index: 2;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    min-width: 0;
}

.chat-header-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    object-fit: cover;
    flex-shrink: 0;
}

.chat-header-details h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-header-details span {
    font-size: 12px;
    color: var(--text-secondary);
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.header-action-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    transition: all var(--transition);
}

.header-action-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

/* Chat Body */
.chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 60px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 1;
}

.chat-body::-webkit-scrollbar {
    width: 6px;
}

.chat-body::-webkit-scrollbar-track {
    background: transparent;
}

.chat-body::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 10px;
}

/* Message Date Separator */
.message-date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 12px 0;
}

.message-date-separator span {
    background: rgba(225, 218, 208, 0.9);
    color: #54656f;
    font-size: 12px;
    font-weight: 500;
    padding: 5px 14px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

/* Message Bubbles */
.message {
    display: flex;
    margin-bottom: 2px;
    max-width: 65%;
    animation: messageIn 0.25s ease;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.agent {
    align-self: flex-end;
}

.message.contact {
    align-self: flex-start;
}

.message-bubble {
    padding: 8px 12px;
    border-radius: var(--radius-md);
    position: relative;
    max-width: 100%;
    word-wrap: break-word;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.06);
}

.message.agent .message-bubble {
    background: var(--bg-message-agent);
    color: var(--text-white);
    border-top-right-radius: 4px;
}

.message.contact .message-bubble {
    background: var(--bg-message-contact);
    color: var(--text-primary);
    border-top-left-radius: 4px;
}

/* Message context menu button */
.msg-ctx-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(0,0,0,0.08);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s;
    z-index: 2;
    padding: 0;
    color: var(--text-secondary);
}
.message:hover .msg-ctx-btn { opacity: 1; }
.msg-ctx-btn:hover { background: rgba(0,0,0,0.15); }
.message.agent .msg-ctx-btn { background: rgba(255,255,255,0.15); color: #fff; }
.message.agent .msg-ctx-btn:hover { background: rgba(255,255,255,0.25); }

/* Context menu dropdown */
.msg-ctx-menu {
    position: fixed;
    z-index: 10000;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    min-width: 150px;
    padding: 4px;
    animation: ctxFadeIn 0.12s ease;
}
@keyframes ctxFadeIn { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:translateY(0); } }
.msg-ctx-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.12s;
}
.msg-ctx-item:hover { background: var(--bg-secondary); }
.msg-ctx-item.msg-ctx-danger { color: #ef4444; }
.msg-ctx-item.msg-ctx-danger:hover { background: rgba(239,68,68,0.08); }

/* Delete conversation button (red tint) */
.btn-delete-conv { color: var(--text-secondary); }
.btn-delete-conv:hover { color: #ef4444 !important; background: rgba(239,68,68,0.08) !important; }

/* Checkbox label in modals */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}
.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.message-text {
    font-size: 14px;
    line-height: 1.45;
    margin-bottom: 2px;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 2px;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
}

.message.agent .message-time {
    color: rgba(255, 255, 255, 0.75);
}

.message.contact .message-time {
    color: var(--text-light);
}

/* Message Status Icons */
.message-status {
    display: flex;
    align-items: center;
}

.message-status svg {
    width: 16px;
    height: 16px;
}

.message-status.sent svg {
    color: rgba(255, 255, 255, 0.6);
}

.message-status.delivered svg {
    color: rgba(255, 255, 255, 0.6);
}

.message-status.read svg {
    color: #34d399;
}

/* Chat Footer */
.chat-footer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: #f0f2f5;
    z-index: 2;
}

.footer-btn {
    width: 42px;
    height: 42px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full);
    transition: all var(--transition);
    flex-shrink: 0;
}

.footer-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

.footer-btn.send-btn {
    background: var(--primary);
    color: white;
}

.footer-btn.send-btn:hover {
    background: var(--primary-dark);
    color: white;
}

.message-input-wrapper {
    flex: 1;
}

.message-input-wrapper input {
    width: 100%;
    height: 42px;
    border: none;
    background: #ffffff;
    border-radius: var(--radius-md);
    padding: 0 16px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    outline: none;
    transition: box-shadow var(--transition);
}

.message-input-wrapper input:focus {
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.message-input-wrapper input::placeholder {
    color: var(--text-light);
}

/* ============================================
   TOOLTIP
   ============================================ */
.tooltip {
    position: fixed;
    background: #1f2937;
    color: white;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 9999;
    white-space: nowrap;
    box-shadow: var(--shadow-md);
}

.tooltip.visible {
    opacity: 1;
}

/* ============================================
   EMOJI PICKER
   ============================================ */
.emoji-picker {
    position: fixed;
    bottom: 70px;
    left: calc(var(--sidebar-width) + var(--panel-width) + 16px);
    width: 320px;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
    z-index: 100;
    overflow: hidden;
}

.emoji-picker-header {
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.emoji-picker-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
    padding: 8px;
    max-height: 220px;
    overflow-y: auto;
}

.emoji-picker-grid::-webkit-scrollbar {
    width: 4px;
}

.emoji-picker-grid::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

.emoji-item {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
    border: none;
    background: transparent;
}

.emoji-item:hover {
    background: #f3f4f6;
}

/* ============================================
   SCROLLBAR GLOBAL
   ============================================ */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 10px;
}

/* ============================================
   NO CONVERSATIONS FOUND
   ============================================ */
.no-results {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

.no-results svg {
    margin-bottom: 12px;
    opacity: 0.4;
}

.no-results p {
    font-size: 13px;
}

/* ============================================
   LOGIN SCREEN
   ============================================ */
.login-screen {
    position: fixed;
    inset: 0;
    background: var(--login-bg, linear-gradient(135deg, #1e1b4b 0%, #312e81 50%, #4338ca 100%));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: background 0.4s ease;
}

.login-card {
    width: 400px;
    background: white;
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo svg {
    margin-bottom: 12px;
}

.login-logo h1 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.login-logo p {
    font-size: 13px;
    color: var(--text-secondary);
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.form-group input {
    width: 100%;
    height: 44px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    outline: none;
    transition: all var(--transition);
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.login-error {
    background: #fef2f2;
    color: #dc2626;
    font-size: 13px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    border: 1px solid #fecaca;
}

.btn-login {
    width: 100%;
    height: 46px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition);
}

.btn-login:hover {
    background: var(--primary-dark);
}

.btn-login:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================
   SIDEBAR AGENT AVATAR
   ============================================ */
.sidebar-agent {
    width: 40px;
    height: 40px;
    margin-bottom: 8px;
    cursor: pointer;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.15);
    transition: border-color var(--transition);
}

.sidebar-agent:hover {
    border-color: var(--primary-light);
}

.sidebar-agent img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ============================================
   SECTOR TABS
   ============================================ */
.sector-tabs-wrapper {
    position: relative;
    display: flex;
    align-items: stretch;
    border-bottom: 1px solid var(--border-color);
}

.sector-tabs {
    display: flex;
    gap: 0;
    padding: 0;
    overflow-x: auto;
    scrollbar-width: none;
    scroll-behavior: smooth;
    flex: 1;
    min-width: 0;
}

.sector-tabs::-webkit-scrollbar {
    display: none;
}

.sector-tabs-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    min-width: 28px;
    border: none;
    background: linear-gradient(to right, white 60%, transparent);
    color: var(--text-secondary);
    cursor: pointer;
    z-index: 2;
    padding: 0;
    transition: color var(--transition);
}

.sector-tabs-arrow:hover {
    color: var(--primary);
}

.sector-tabs-arrow-left {
    background: linear-gradient(to right, white 60%, transparent);
}

.sector-tabs-arrow-right {
    background: linear-gradient(to left, white 60%, transparent);
}

.sector-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    border: none;
    background: transparent;
    font-size: 12px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    white-space: nowrap;
    position: relative;
    transition: all var(--transition);
    flex-shrink: 0;
}

.sector-tab:hover {
    color: var(--text-primary);
    background: #f9fafb;
}

.sector-tab.active {
    color: var(--primary);
    font-weight: 600;
}

.sector-tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary);
    border-radius: 2px 2px 0 0;
}

.sector-tab-count {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: #e5e7eb;
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 700;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sector-tab.active .sector-tab-count {
    background: var(--primary);
    color: white;
}

/* ============================================
   STATUS FILTER
   ============================================ */
.status-filter {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-light);
    overflow-x: auto;
    scrollbar-width: none;
}

.status-filter::-webkit-scrollbar {
    display: none;
}

.filter-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border: 1px solid var(--border-color);
    background: white;
    font-size: 11px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-full);
    transition: all var(--transition);
    white-space: nowrap;
}

.filter-btn:hover {
    background: #f9fafb;
}

.filter-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.filter-dot {
    width: 7px;
    height: 7px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.filter-dot.waiting {
    background: var(--connecting-color);
}

.filter-dot.active-dot {
    background: var(--online-color);
}

.filter-dot.closed {
    background: #9ca3af;
}

.filter-btn.active .filter-dot {
    background: white;
}

/* ============================================
   CONVERSATION ITEM - STATUS INDICATOR
   ============================================ */
.conversation-sector-dot {
    width: 8px;
    height: 8px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.conversation-status-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.conversation-status-badge.waiting {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.conversation-status-badge.active {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
}

/* ============================================
   CHAT HEADER TAGS
   ============================================ */
.chat-header-tags {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0 12px;
    flex-shrink: 0;
}

.chat-sector-tag {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.chat-status-tag {
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.chat-status-tag.waiting {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
}

.chat-status-tag.active {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
}

.chat-status-tag.closed {
    background: rgba(107, 114, 128, 0.1);
    color: #6b7280;
}

.chat-protocol {
    font-size: 11px;
    color: var(--text-light);
    font-family: 'SF Mono', 'Fira Code', monospace;
}

/* ============================================
   SYSTEM MESSAGE
   ============================================ */
.message.system {
    align-self: center;
    max-width: 80%;
}

.message.system .message-bubble {
    background: rgba(225, 218, 208, 0.7);
    color: #54656f;
    font-size: 12px;
    text-align: center;
    border-radius: var(--radius-sm);
    padding: 5px 14px;
}

/* ============================================
   LOADING SPINNER
   ============================================ */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 12px;
    color: var(--text-light);
    font-size: 13px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
    backdrop-filter: blur(2px);
}

.modal-card {
    width: 440px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 22px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.modal-close:hover {
    background: #f3f4f6;
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-body p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 14px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 14px 20px;
    border-top: 1px solid var(--border-color);
}

.btn-cancel {
    padding: 8px 18px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-cancel:hover {
    background: #f9fafb;
}

.btn-confirm {
    padding: 8px 18px;
    border: none;
    background: var(--primary);
    color: white;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-confirm:hover {
    background: var(--primary-dark);
}

/* Transfer Sector Options */
.transfer-sectors {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.transfer-sector-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    background: white;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    font-family: inherit;
    text-align: left;
    width: 100%;
}

.transfer-sector-option:hover {
    border-color: var(--primary-light);
    background: #fafafe;
}

.transfer-sector-option.selected {
    border-color: var(--primary);
    background: #eef2ff;
}

.transfer-sector-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.transfer-sector-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

/* ============================================
   CHAT EMPTY STATS
   ============================================ */
.chat-empty-stats {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-top: 24px;
}

.stat-card {
    background: white;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    text-align: center;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    min-width: 100px;
}

.stat-card .stat-number {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.stat-card .stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ============================================
   SETTINGS PANEL
   ============================================ */
.settings-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8f9fb;
    min-width: 0;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    background: white;
    border-bottom: 1px solid var(--border-color);
}

.settings-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.settings-close {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.settings-close:hover {
    background: #f3f4f6;
    color: var(--text-primary);
}

.settings-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Settings Navigation */
.settings-nav {
    width: 200px;
    min-width: 200px;
    background: white;
    border-right: 1px solid var(--border-color);
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.settings-nav-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: none;
    background: transparent;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: all var(--transition);
    text-align: left;
    width: 100%;
}

.settings-nav-btn:hover {
    background: #f3f4f6;
    color: var(--text-primary);
}

.settings-nav-btn.active {
    background: #eef2ff;
    color: var(--primary);
    font-weight: 600;
}

/* Settings Content */
.settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.settings-content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.settings-content-header h3 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.settings-content-header p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

.btn-primary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border: none;
    background: var(--primary);
    color: white;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

/* Sectors Grid */
.sectors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.sector-card {
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: all var(--transition);
}

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

.sector-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-light);
}

.sector-card-dot {
    width: 14px;
    height: 14px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.sector-card-info {
    flex: 1;
    min-width: 0;
}

.sector-card-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sector-card-desc {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sector-card-toggle {
    position: relative;
    width: 40px;
    height: 22px;
    border: none;
    border-radius: var(--radius-full);
    cursor: pointer;
    transition: background var(--transition);
    flex-shrink: 0;
    padding: 0;
}

.sector-card-toggle.active {
    background: var(--primary);
}

.sector-card-toggle.inactive {
    background: #d1d5db;
}

.sector-card-toggle::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    top: 3px;
    transition: left var(--transition);
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.sector-card-toggle.active::after {
    left: 21px;
}

.sector-card-toggle.inactive::after {
    left: 3px;
}

.sector-card-body {
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sector-card-stats {
    display: flex;
    gap: 16px;
}

.sector-card-stat {
    text-align: center;
}

.sector-card-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.sector-card-stat-label {
    font-size: 11px;
    color: var(--text-secondary);
}

.sector-card-actions {
    display: flex;
    gap: 4px;
}

.sector-card-btn {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}

.sector-card-btn:hover {
    background: #f3f4f6;
    color: var(--text-primary);
}

.sector-card-btn.btn-delete:hover {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}

/* Settings Placeholder */
.settings-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
}

.settings-placeholder p {
    font-size: 14px;
    color: var(--text-light);
    margin-top: 16px;
}

/* ============================================
   SECTOR FORM COMPONENTS
   ============================================ */
.modal-card-lg {
    width: 520px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .form-group {
    flex: 1;
}

.color-picker-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.color-input {
    width: 44px;
    height: 44px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    padding: 2px;
    background: white;
}

.color-input::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-input::-webkit-color-swatch {
    border: none;
    border-radius: 6px;
}

.color-presets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.color-swatch {
    width: 28px;
    height: 28px;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    padding: 0;
}

.color-swatch:hover {
    transform: scale(1.15);
}

.color-swatch.selected {
    border-color: var(--text-primary);
    box-shadow: 0 0 0 2px white, 0 0 0 4px var(--text-primary);
}

/* ============================================
   AGENT CARDS
   ============================================ */
.agents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.agent-card {
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: all var(--transition);
}

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

.agent-card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-light);
}

.agent-card-avatar {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    object-fit: cover;
    flex-shrink: 0;
}

.agent-card-info {
    flex: 1;
    min-width: 0;
}

.agent-card-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.agent-card-email {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.agent-status-dot.online { background: var(--success); }
.agent-status-dot.offline { background: #d1d5db; }

.role-badge {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}

.role-badge.admin { background: #eef2ff; color: #4f46e5; }
.role-badge.supervisor { background: #fef3c7; color: #92400e; }
.role-badge.agent { background: #f0fdf4; color: #166534; }

.agent-card-sectors {
    padding: 10px 18px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-height: 38px;
    align-items: center;
}

.agent-sector-tag {
    font-size: 11px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    color: white;
    white-space: nowrap;
}

.agent-no-sectors {
    font-size: 12px;
    color: var(--text-light);
    font-style: italic;
}

.agent-card-footer {
    padding: 10px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--border-light);
}

.agent-card-stats {
    display: flex;
    gap: 16px;
}

.agent-card-stat {
    text-align: center;
}

.agent-card-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}

.agent-card-stat-label {
    font-size: 11px;
    color: var(--text-secondary);
}

.agent-card-actions {
    display: flex;
    gap: 4px;
}

/* ============================================
   FORM COMPONENTS (select, checkboxes)
   ============================================ */
.form-select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 13px;
    font-family: inherit;
    color: var(--text-primary);
    background: white;
    outline: none;
    transition: border-color var(--transition);
    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='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-select:focus {
    border-color: var(--primary);
}

.sector-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
}

.sector-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
}

.sector-checkbox:hover {
    border-color: #a5b4fc;
    background: #fafafe;
}

.sector-checkbox.checked {
    border-color: var(--primary);
    background: #eef2ff;
}

.sector-checkbox input[type="checkbox"] {
    display: none;
}

.sector-checkbox-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    flex-shrink: 0;
}

.sector-checkbox-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.sector-checkbox-check {
    width: 16px;
    height: 16px;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.sector-checkbox.checked .sector-checkbox-check {
    background: var(--primary);
    border-color: var(--primary);
}

.sector-checkbox.checked .sector-checkbox-check svg {
    display: block;
}

.sector-checkbox .sector-checkbox-check svg {
    display: none;
}

/* ============================================
   PROFILE MODAL
   ============================================ */
.profile-avatar-section {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0 18px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border-light);
}

.profile-avatar-wrapper {
    position: relative;
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    cursor: pointer;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.profile-avatar-preview {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-md);
    object-fit: cover;
    background: #f3f4f6;
}

.profile-avatar-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition);
    color: white;
    border-radius: var(--radius-md);
}

.profile-avatar-wrapper:hover .profile-avatar-overlay {
    opacity: 1;
}

.profile-avatar-hint {
    font-size: 11px;
    color: var(--text-light);
}

.profile-avatar-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.profile-avatar-info .profile-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.profile-avatar-info .profile-role {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: capitalize;
}

.form-divider {
    height: 1px;
    background: var(--border-light);
    margin: 16px 0 12px;
}

.form-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.sidebar-agent {
    cursor: pointer;
}

/* ============================================
   SECTION PANELS (Contacts, Reports, Notifications)
   ============================================ */
.section-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    overflow: hidden;
}

.section-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-light);
}

.section-panel-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
}

.section-panel-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-md);
}

.btn-text:hover {
    background: var(--primary-bg);
}

.section-panel-toolbar {
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-light);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    padding: 8px 14px;
    color: var(--text-light);
}

.search-box input {
    border: none;
    background: transparent;
    flex: 1;
    font-size: 13px;
    outline: none;
    color: var(--text-primary);
}

.section-panel-body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.section-panel-body-scroll {
    flex-direction: column;
    overflow-y: auto;
    padding: 24px;
    gap: 24px;
}

/* --- Contacts Panel --- */
.contacts-header-count {
    background: var(--text-light);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    margin-left: 6px;
    vertical-align: middle;
}

.contacts-list-panel {
    width: 380px;
    border-right: 1px solid var(--border-light);
    overflow-y: auto;
}

.contact-letter-header {
    padding: 6px 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--primary);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    position: sticky;
    top: 0;
    z-index: 1;
}

.contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: all 0.15s ease;
}

.contact-item:hover { background: var(--bg-secondary); }
.contact-item.active {
    background: rgba(99, 102, 241, 0.06);
    border-left: 3px solid var(--primary);
    padding-left: 17px;
}

.contact-item-avatar {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 600;
    font-size: 15px;
    color: #fff;
    position: relative;
    overflow: hidden;
}

.contact-item-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-md);
}

.contact-item-info {
    flex: 1;
    min-width: 0;
}

.contact-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-item-phone {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 1px;
}

.contact-item-meta {
    text-align: right;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}

.contact-item-count {
    font-size: 10px;
    color: #fff;
    background: var(--primary);
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 600;
}

.contact-item-count.zero {
    background: var(--text-light);
    opacity: 0.5;
}

.contact-item-time {
    font-size: 11px;
    color: var(--text-light);
}

.contact-detail-panel {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.contact-detail-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 8px;
    color: var(--text-light);
    text-align: center;
    padding: 40px;
}

.contact-detail-empty-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    opacity: 0.5;
}

.contact-detail-empty p {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-secondary);
}

.contact-detail-empty span {
    font-size: 13px;
    max-width: 260px;
    line-height: 1.5;
}

.contact-detail-banner {
    padding: 28px 24px;
    text-align: center;
    position: relative;
}

.contact-detail-avatar {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 28px;
    flex-shrink: 0;
    margin: 0 auto 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.12);
    overflow: hidden;
}

.contact-detail-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-md);
}

.contact-detail-banner h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.contact-detail-banner .contact-detail-phone {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.contact-detail-banner .contact-detail-phone svg {
    color: var(--success);
}

.contact-detail-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 14px;
}

.contact-detail-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.contact-detail-action-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.contact-detail-action-btn.primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.contact-detail-action-btn.primary:hover {
    opacity: 0.9;
}

.contact-detail-body {
    padding: 0 24px 24px;
}

.contact-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
}

.contact-stat {
    text-align: center;
    padding: 14px 8px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
}

.contact-stat.stat-total { border-left: 3px solid var(--primary); }
.contact-stat.stat-active { border-left: 3px solid var(--success); }
.contact-stat.stat-closed { border-left: 3px solid var(--text-light); }

.contact-stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    display: block;
    line-height: 1;
}

.contact-stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
    display: block;
}

.contact-detail-section {
    margin-bottom: 20px;
}

.contact-detail-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.contact-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.contact-info-card {
    padding: 10px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
}

.contact-info-card-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: var(--text-light);
    margin-bottom: 2px;
}

.contact-info-card-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.contact-notes-box {
    padding: 12px;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: var(--radius-md);
    font-size: 13px;
    color: #92400e;
    line-height: 1.5;
}

[data-theme="dark"] .contact-notes-box {
    background: rgba(251, 191, 36, 0.08);
    border-color: rgba(251, 191, 36, 0.2);
    color: #fbbf24;
}

.contact-history h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.contact-history-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-light);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition);
}

.contact-history-item:hover {
    background: var(--bg-secondary);
    border-color: var(--primary);
}

.contact-history-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.05);
}

.contact-history-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.contact-history-content {
    flex: 1;
    min-width: 0;
}

.contact-history-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

.contact-history-sub {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-history-time {
    font-size: 11px;
    color: var(--text-light);
    flex-shrink: 0;
}

/* --- Reports Panel --- */
.report-period-filter {
    display: flex;
    gap: 4px;
}

.period-btn {
    padding: 6px 16px;
    border: 1px solid var(--border-light);
    background: white;
    border-radius: var(--radius-full);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
}

.period-btn:hover { border-color: var(--primary); color: var(--primary); }
.period-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

.report-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.report-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
}

.report-card-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.report-card-icon.blue { background: #dbeafe; color: #3b82f6; }
.report-card-icon.orange { background: #ffedd5; color: #f97316; }
.report-card-icon.green { background: #dcfce7; color: #22c55e; }
.report-card-icon.purple { background: #ede9fe; color: #8b5cf6; }
.report-card-icon.gray { background: #f3f4f6; color: #6b7280; }
.report-card-icon.red { background: #fee2e2; color: #ef4444; }

.report-card-data {
    display: flex;
    flex-direction: column;
}

.report-card-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.report-card-label {
    font-size: 12px;
    color: var(--text-secondary);
}

.report-section {
    margin-top: 0;
}

.report-section h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.report-table {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.report-table-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid white;
    font-size: 13px;
}

.report-table-row:last-child { border-bottom: none; }

.report-table-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.report-table-bar {
    width: 120px;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}

.report-table-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.4s ease;
}

.report-table-value {
    font-weight: 600;
    color: var(--text-primary);
    width: 40px;
    text-align: right;
}

.report-table-badges {
    display: flex;
    gap: 6px;
}

.report-mini-badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 500;
}

.report-mini-badge.waiting { background: #ffedd5; color: #c2410c; }
.report-mini-badge.active { background: #dcfce7; color: #15803d; }
.report-mini-badge.closed { background: #f3f4f6; color: #6b7280; }

.report-table-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.report-table-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--text-light);
}

.report-table-status .online { color: var(--success); }

/* --- Notifications Panel --- */
.notif-header-count {
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 7px;
    border-radius: 10px;
    margin-left: 6px;
    vertical-align: middle;
}

.notif-filters {
    display: flex;
    gap: 6px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border-light);
    overflow-x: auto;
    flex-shrink: 0;
}

.notif-filter-btn {
    padding: 5px 12px;
    border-radius: 16px;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: all var(--transition);
}

.notif-filter-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.notif-filter-btn.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.notif-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    margin: 0 16px 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    flex-shrink: 0;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.notif-search-wrap:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background: var(--bg-primary);
}

.notif-search-wrap svg {
    flex-shrink: 0;
    color: var(--text-light);
}

.notif-search-wrap input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 13px;
    padding: 4px 0;
    color: var(--text-primary);
    font-family: inherit;
}

.notif-search-wrap input::placeholder {
    color: var(--text-light);
}

.notif-search-clear {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 18px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.notif-search-clear:hover {
    color: var(--text-primary);
}

.notif-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 10px 20px;
    border-top: 1px solid var(--border-light);
    flex-shrink: 0;
    background: var(--bg-primary);
}

.notif-page-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.notif-page-btn:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(99, 102, 241, 0.05);
}

.notif-page-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.notif-page-info {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    min-width: 50px;
    text-align: center;
}

.btn-icon-sm {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.btn-icon-sm:hover {
    background: var(--bg-secondary);
    color: var(--primary);
}

#notifications-panel .section-panel-body-scroll {
    padding: 0;
    gap: 0;
}

.notifications-list {
    display: flex;
    flex-direction: column;
}

.notif-group-header {
    padding: 8px 20px 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
}

.notification-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: all 0.15s ease;
    position: relative;
}

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

.notification-item:active {
    transform: scale(0.995);
}

.notification-item.unread {
    background: rgba(99, 102, 241, 0.04);
    border-left: 3px solid var(--primary);
    padding-left: 17px;
}

.notification-item.unread:hover {
    background: rgba(99, 102, 241, 0.08);
}

.notification-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 18px;
}

.notification-icon.new_conversation { background: #dcfce7; color: #16a34a; }
.notification-icon.transfer { background: #dbeafe; color: #2563eb; }
.notification-icon.mention { background: #ede9fe; color: #7c3aed; }
.notification-icon.waiting_long { background: #ffedd5; color: #ea580c; }
.notification-icon.system { background: #f3f4f6; color: #6b7280; }

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 3px;
    line-height: 1.3;
}

.notification-item.unread .notification-title {
    color: var(--primary);
}

.notification-body {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.notification-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 5px;
}

.notification-time {
    font-size: 11px;
    color: var(--text-light);
}

.notification-action-hint {
    font-size: 10px;
    color: var(--primary);
    font-weight: 500;
    opacity: 0;
    transition: opacity var(--transition);
}

.notification-item:hover .notification-action-hint {
    opacity: 1;
}

.notification-unread-dot {
    position: absolute;
    top: 18px;
    right: 16px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--primary);
    box-shadow: 0 0 0 2px var(--bg-primary);
}

.notifications-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    color: var(--text-light);
    gap: 12px;
    text-align: center;
}

.notifications-empty svg {
    opacity: 0.25;
}

.notifications-empty p {
    font-size: 14px;
    font-weight: 500;
}

.notifications-empty span {
    font-size: 12px;
    max-width: 280px;
    line-height: 1.5;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    border-radius: var(--radius-lg);
    background: white;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    pointer-events: auto;
    animation: toastIn 0.3s ease;
    max-width: 380px;
    border-left: 4px solid #6366f1;
}

.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: #dc2626; }
.toast.toast-warning { border-left-color: #f59e0b; }

.toast.toast-out {
    animation: toastOut 0.25s ease forwards;
}

.toast-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-success .toast-icon { color: var(--success); }
.toast-error .toast-icon { color: #dc2626; }
.toast-warning .toast-icon { color: #f59e0b; }

.toast-message {
    flex: 1;
    line-height: 1.4;
}

.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 16px;
    padding: 0 0 0 8px;
    line-height: 1;
}

.toast-close:hover {
    color: var(--text-primary);
}

@keyframes toastIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes toastOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(40px); }
}

.btn-danger {
    background: #dc2626 !important;
}

.btn-danger:hover {
    background: #b91c1c !important;
}

/* ============================================
   DARK MODE
   ============================================ */
[data-theme="dark"] {
    --bg-dark: #0f0f1a;
    --bg-sidebar: #0a0a14;
    --bg-primary: #1a1a2e;
    --bg-panel: #1a1a2e;
    --bg-secondary: #1e1e32;
    --bg-chat: #12121e;
    --bg-chat-pattern: #1a1a2e;
    --bg-message-agent: #6366f1;
    --bg-message-contact: #252540;
    --text-primary: #e5e5ef;
    --text-secondary: #9ca3af;
    --text-light: #6b7280;
    --text-white: #ffffff;
    --border-color: #2a2a40;
    --border-light: #1e1e32;
    --hover-bg: rgba(255, 255, 255, 0.06);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .login-card,
[data-theme="dark"] .modal-card {
    background: var(--bg-panel);
    color: var(--text-primary);
}

/* .login-input removido — inputs do login usam .login-card .form-group input */

[data-theme="dark"] .conversation-item:hover,
[data-theme="dark"] .conversation-item.active {
    background: var(--bg-secondary);
}

[data-theme="dark"] .message.contact .message-bubble {
    color: var(--text-primary);
}

[data-theme="dark"] .chat-header {
    background: var(--bg-panel);
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .chat-footer {
    background: var(--bg-panel);
    border-top-color: var(--border-color);
}

[data-theme="dark"] #message-input {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] .settings-panel,
[data-theme="dark"] .section-panel {
    background: var(--bg-panel);
    color: var(--text-primary);
}

[data-theme="dark"] .sector-card,
[data-theme="dark"] .agent-card {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .modal-overlay .modal-card {
    background: var(--bg-panel);
}

[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-footer {
    border-color: var(--border-color);
}

.modal-input,
.modal-textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    resize: vertical;
}
.modal-input:focus,
.modal-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
}
.modal-textarea {
    min-height: 80px;
    line-height: 1.5;
}

[data-theme="dark"] .modal-input,
[data-theme="dark"] .modal-select,
[data-theme="dark"] .modal-textarea {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .channel-info {
    background: var(--bg-panel);
    border-bottom-color: var(--border-color);
}

[data-theme="dark"] .conversations-panel {
    background: var(--bg-panel);
    border-right-color: var(--border-color);
}

[data-theme="dark"] .search-input {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
}

[data-theme="dark"] .contact-item:hover,
[data-theme="dark"] .contact-item.active {
    background: var(--bg-secondary);
}

[data-theme="dark"] .report-card {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .notification-item:hover {
    background: var(--bg-secondary);
}

[data-theme="dark"] .notification-item.unread {
    background: rgba(99, 102, 241, 0.1);
}

[data-theme="dark"] .notif-group-header {
    background: var(--bg-secondary);
}

[data-theme="dark"] .notification-icon.new_conversation { background: rgba(22, 163, 106, 0.15); }
[data-theme="dark"] .notification-icon.transfer { background: rgba(37, 99, 235, 0.15); }
[data-theme="dark"] .notification-icon.mention { background: rgba(124, 58, 237, 0.15); }
[data-theme="dark"] .notification-icon.waiting_long { background: rgba(234, 88, 12, 0.15); }
[data-theme="dark"] .notification-icon.system { background: rgba(107, 114, 128, 0.15); }

[data-theme="dark"] .toast {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .settings-nav-btn {
    color: var(--text-secondary);
}

[data-theme="dark"] .sector-tab {
    color: var(--text-secondary);
}

[data-theme="dark"] .period-btn {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

/* Login form inputs */
[data-theme="dark"] .login-card .form-group input {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

[data-theme="dark"] .login-card .form-group label {
    color: var(--text-secondary);
}

[data-theme="dark"] .login-error {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
}

/* Buttons: cancel */
[data-theme="dark"] .btn-cancel {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

[data-theme="dark"] .btn-cancel:hover {
    background: var(--border-color);
}

/* Context menu */
[data-theme="dark"] .msg-ctx-menu {
    background: var(--bg-panel);
    border-color: var(--border-color);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

/* Emoji picker */
[data-theme="dark"] .emoji-picker-header {
    border-bottom-color: var(--border-color);
}

/* Contact info panel */
[data-theme="dark"] .contact-info-section input,
[data-theme="dark"] .contact-info-section textarea,
[data-theme="dark"] .contact-info-section select {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* Chat empty state */
[data-theme="dark"] .chat-empty {
    color: var(--text-secondary);
}

/* Tag badges */
[data-theme="dark"] .tag-badge {
    border-color: var(--border-color);
}

/* Form group general */
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

/* Scrollbars */
[data-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #3a3a55;
}

[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--bg-panel);
}

/* ============================================
   INTERNAL NOTES
   ============================================ */
.internal-note-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #fef3c7;
    color: #92400e;
    font-size: 12px;
    font-weight: 500;
    border-top: 2px solid #f59e0b;
}

[data-theme="dark"] .internal-note-bar {
    background: #422006;
    color: #fbbf24;
    border-top-color: #d97706;
}

.internal-note-bar span {
    flex: 1;
}

.internal-note-bar button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    opacity: 0.7;
}

.internal-note-bar button:hover {
    opacity: 1;
}

#btn-internal-note.active {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.15);
    border-radius: var(--radius-sm);
}

.message.internal .message-bubble {
    background: #fef3c7 !important;
    color: #92400e !important;
    border: 1px dashed #f59e0b;
    position: relative;
}

[data-theme="dark"] .message.internal .message-bubble {
    background: #422006 !important;
    color: #fbbf24 !important;
    border-color: #d97706;
}

.message.internal .message-bubble::before {
    content: '🔒 Nota interna';
    display: block;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
    opacity: 0.7;
}

.message.internal .message-meta .message-status {
    display: none;
}

/* ============================================
   MEDIA MESSAGES
   ============================================ */
.message-media {
    margin-bottom: 4px;
    border-radius: var(--radius-md);
    overflow: hidden;
    max-width: 300px;
}

.message-media img {
    width: 100%;
    max-height: 300px;
    object-fit: cover;
    display: block;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: opacity var(--transition);
}

.message-media img:hover {
    opacity: 0.9;
}

.message-media audio {
    display: none;
}

/* Custom Audio Player */
.message-audio-player {
    min-width: 240px;
    max-width: 320px;
}

.audio-player-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 4px;
}

.audio-play-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.08);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background var(--transition);
}

.audio-play-btn:hover {
    background: rgba(0,0,0,0.15);
}

.message.agent .audio-play-btn {
    background: rgba(255,255,255,0.2);
    color: white;
}

.message.agent .audio-play-btn:hover {
    background: rgba(255,255,255,0.3);
}

.audio-wave-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.audio-progress-bar {
    height: 6px;
    background: rgba(0,0,0,0.1);
    border-radius: 3px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.message.agent .audio-progress-bar {
    background: rgba(255,255,255,0.2);
}

.audio-progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    width: 0%;
    transition: width 0.1s linear;
}

.message.agent .audio-progress-fill {
    background: rgba(255,255,255,0.8);
}

.audio-duration {
    font-size: 11px;
    color: var(--text-light);
    font-variant-numeric: tabular-nums;
}

.message.agent .audio-duration {
    color: rgba(255,255,255,0.7);
}

.message-media video {
    width: 100%;
    max-height: 300px;
    border-radius: var(--radius-md);
}

.message-media-doc {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(0,0,0,0.05);
    border-radius: var(--radius-md);
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    transition: background var(--transition);
}

.message-media-doc:hover {
    background: rgba(0,0,0,0.1);
}

[data-theme="dark"] .message-media-doc {
    background: rgba(255,255,255,0.05);
}

[data-theme="dark"] .message-media-doc:hover {
    background: rgba(255,255,255,0.1);
}

.message-media-doc-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message-media-doc-info {
    flex: 1;
    min-width: 0;
}

.message-media-doc-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-media-doc-size {
    font-size: 11px;
    color: var(--text-light);
}

.message.agent .message-media-doc {
    background: rgba(255,255,255,0.15);
}

.message.agent .message-media-doc:hover {
    background: rgba(255,255,255,0.2);
}

.message.agent .message-media-doc-name,
.message.agent .message-media-doc-size {
    color: rgba(255,255,255,0.9);
}

/* Image lightbox */
.lightbox-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    cursor: pointer;
    animation: fadeIn 0.2s ease;
}

.lightbox-overlay img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ============================================
   WHATSAPP SETTINGS
   ============================================ */
.wa-connection-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--bg-secondary, #f8fafc);
    border-radius: var(--radius-md);
    margin-bottom: 20px;
}

[data-theme="dark"] .wa-connection-status {
    background: var(--bg-secondary);
}

.wa-status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 15px;
}

.wa-status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.wa-status-dot.connected {
    background: #22c55e;
    box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

.wa-status-dot.disconnected {
    background: #ef4444;
}

.wa-status-dot.connecting {
    background: #f59e0b;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.wa-status-phone {
    color: var(--text-secondary);
    font-size: 13px;
}

.wa-qrcode-area {
    text-align: center;
    margin-bottom: 20px;
}

.wa-qr-instruction {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.wa-qrcode-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 280px;
    height: 280px;
    background: white;
    border-radius: var(--radius-lg);
    border: 2px solid var(--border-color);
    padding: 16px;
    margin: 0 auto;
}

.wa-qrcode-box img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.wa-qr-tip {
    font-size: 12px;
    color: var(--text-light);
    margin-top: 12px;
}

.wa-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.wa-settings-form {
    border-top: 1px solid var(--border-color);
    padding-top: 8px;
}

.wa-form-group {
    margin-bottom: 16px;
}

.wa-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.wa-form-group input,
.wa-form-group textarea {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-primary);
    outline: none;
    transition: all var(--transition);
    box-sizing: border-box;
}

.wa-form-group input {
    height: 44px;
}

.wa-form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.wa-form-group input:focus,
.wa-form-group textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.wa-form-group input::placeholder,
.wa-form-group textarea::placeholder {
    color: var(--text-light);
}

[data-theme="dark"] .wa-form-group input,
[data-theme="dark"] .wa-form-group textarea {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.wa-form-group small {
    display: block;
    margin-top: 4px;
}

/* ============================================
   APPEARANCE SETTINGS
   ============================================ */
.appearance-settings {
    padding: 0 4px;
}

.appearance-section {
    margin-bottom: 28px;
}

.appearance-section h4 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.theme-presets {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.theme-preset-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-panel);
    cursor: pointer;
    transition: var(--transition);
}

.theme-preset-btn:hover {
    border-color: var(--primary-light);
}

.theme-preset-btn.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

.preset-colors {
    display: flex;
    gap: 3px;
}

.preset-colors span {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.1);
}

.preset-name {
    font-size: 11px;
    color: var(--text-secondary);
    font-weight: 500;
}

.color-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}

.color-field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.color-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--border-light);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
}

.color-input-wrap input[type="color"] {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    padding: 0;
    background: none;
}

.color-input-wrap input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

.color-input-wrap input[type="color"]::-webkit-color-swatch {
    border: 1px solid rgba(0,0,0,0.15);
    border-radius: 4px;
}

.color-hex {
    width: 80px;
    border: none;
    background: transparent;
    font-family: monospace;
    font-size: 13px;
    color: var(--text-primary);
    outline: none;
}

.chat-bg-options label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.chat-bg-opacity-wrap input[type="range"] {
    width: 100%;
    margin-top: 4px;
    accent-color: var(--primary);
}

/* Font Selector */
.font-selector {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.font-selector select {
    max-width: 300px;
}

.appearance-settings .modal-input,
.appearance-settings select.modal-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    outline: none;
    transition: border-color var(--transition);
}

.appearance-settings .modal-input:focus,
.appearance-settings select.modal-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.15);
}

.font-preview {
    background: var(--bg-chat);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.font-preview-text {
    font-size: 18px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Theme Preview */
.theme-preview {
    display: flex;
    height: 180px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.preview-sidebar {
    width: 40px;
    background: var(--bg-sidebar);
}

.preview-panel {
    width: 120px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border-color);
}

.preview-header {
    height: 28px;
    background: var(--primary);
    opacity: 0.8;
}

.preview-items {
    padding: 8px 6px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.preview-item {
    height: 20px;
    background: var(--border-light);
    border-radius: 4px;
}

.preview-item.active {
    background: var(--primary);
    opacity: 0.2;
}

.preview-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.preview-chat-header {
    height: 28px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
}

.preview-chat-body {
    flex: 1;
    background: var(--bg-chat);
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    justify-content: center;
}

.preview-msg {
    height: 16px;
    border-radius: 8px;
    max-width: 70%;
}

.preview-msg.agent {
    background: var(--bg-message-agent);
    align-self: flex-end;
    opacity: 0.85;
}

.preview-msg.contact {
    background: var(--bg-message-contact);
    border: 1px solid var(--border-color);
    align-self: flex-start;
}

/* ============================================
   STICKER
   ============================================ */
.message-sticker {
    background: transparent !important;
    max-width: 160px;
}

.message-sticker img {
    max-width: 160px;
    max-height: 160px;
    object-fit: contain;
    border-radius: 8px;
    cursor: pointer;
}

.message:has(.message-sticker) .message-bubble,
.message:has(.message-sticker-placeholder) .message-bubble {
    background: transparent !important;
    box-shadow: none !important;
    border: none !important;
    padding: 4px !important;
}

.message-sticker-placeholder {
    width: 120px;
    height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--border-light);
    border-radius: 12px;
    opacity: 0.7;
}

.sticker-placeholder-icon {
    font-size: 40px;
    line-height: 1;
}

.sticker-placeholder-text {
    font-size: 11px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ============================================
   TAGS DROPDOWN
   ============================================ */
.tag-dropdown-wrap {
    position: relative;
}

.tag-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    width: 260px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    overflow: hidden;
}

.tag-dropdown-header {
    padding: 10px 14px;
    font-weight: 600;
    font-size: 13px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}

.tag-dropdown-list {
    max-height: 200px;
    overflow-y: auto;
    padding: 6px 0;
}

.tag-dropdown-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 14px;
    cursor: pointer;
    font-size: 13px;
    transition: background var(--transition);
}

.tag-dropdown-item:hover {
    background: var(--border-light);
}

.tag-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    flex-shrink: 0;
}

.tag-check {
    margin-left: auto;
    color: var(--primary);
    font-weight: 700;
}

.tag-dropdown-footer {
    display: flex;
    gap: 6px;
    padding: 8px 10px;
    border-top: 1px solid var(--border-color);
}

.tag-dropdown-footer input[type="text"] {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 5px 8px;
    font-size: 12px;
    background: var(--bg-panel);
    color: var(--text-primary);
    outline: none;
}

.tag-dropdown-footer input[type="color"] {
    width: 28px;
    height: 28px;
    border: none;
    padding: 0;
    cursor: pointer;
    border-radius: 4px;
}

.btn-primary-sm {
    padding: 5px 10px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.btn-primary-sm:hover {
    background: var(--primary-dark);
}

.conv-tags {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
    margin-top: 2px;
}

.conv-tag-pill {
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    line-height: 16px;
}

.chat-conv-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.chat-tag-pill {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    color: white;
    font-weight: 500;
}

/* ============================================
   CONTACT INFO PANEL
   ============================================ */
.contact-info-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 340px;
    height: 100vh;
    background: var(--bg-panel);
    border-left: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.contact-info-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.contact-info-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.contact-info-close {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
}

.contact-info-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.contact-info-avatar {
    text-align: center;
    margin-bottom: 12px;
}

.contact-info-avatar img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
}

.contact-info-name {
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.contact-info-phone {
    text-align: center;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.contact-info-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 16px;
}

.ci-stat {
    text-align: center;
    padding: 8px;
    background: var(--border-light);
    border-radius: var(--radius-sm);
}

.ci-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

.ci-stat-label {
    font-size: 10px;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.contact-info-tags {
    margin-bottom: 16px;
}

.contact-info-section {
    margin-bottom: 20px;
}

.contact-info-section h4 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.contact-info-section textarea {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    font-size: 13px;
    font-family: inherit;
    line-height: 1.5;
    background: var(--bg-secondary);
    color: var(--text-primary);
    resize: vertical;
    outline: none;
    min-height: 80px;
    transition: border-color var(--transition), box-shadow var(--transition);
    box-sizing: border-box;
}

.contact-info-section textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
    background: var(--bg-primary);
}

.ci-history-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 12px;
    cursor: pointer;
}

.ci-history-item:hover {
    color: var(--primary);
}

.ci-history-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ci-history-info {
    flex: 1;
    min-width: 0;
}

.ci-history-protocol {
    font-weight: 600;
    color: var(--text-primary);
}

.ci-history-sector {
    color: var(--text-secondary);
}

.ci-history-date {
    color: var(--text-light);
    font-size: 11px;
    white-space: nowrap;
}

/* ============================================
   SEARCH MODAL
   ============================================ */
.search-modal {
    width: 560px;
    max-height: 70vh;
}

.search-modal-input-wrap {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.search-modal-input-wrap input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--bg-panel);
    color: var(--text-primary);
    outline: none;
}

.search-modal-input-wrap input:focus {
    border-color: var(--primary);
}

.search-msg-results {
    max-height: 400px;
    overflow-y: auto;
}

.search-msg-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 14px;
}

.search-result-item {
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: background var(--transition);
    border-radius: var(--radius-sm);
}

.search-result-item:hover {
    background: var(--border-light);
}

.search-result-avatar {
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    color: white;
    font-weight: 600;
    height: fit-content;
    white-space: nowrap;
}

.search-result-body {
    flex: 1;
    min-width: 0;
}

.search-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}

.search-result-name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}

.search-result-time {
    font-size: 11px;
    color: var(--text-light);
}

.search-result-text {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-text mark {
    background: #fde68a;
    color: #92400e;
    padding: 0 2px;
    border-radius: 2px;
}

/* ============================================
   REPORTS DASHBOARD
   ============================================ */
.report-period-selector {
    display: flex;
    gap: 6px;
}

.report-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 28px;
}

.report-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px 12px;
    text-align: center;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.report-card-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 6px;
    order: 1;
}

.report-card-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    order: 3;
    margin-top: 6px;
}

.report-card-label {
    font-size: 11px;
    color: var(--text-secondary);
    line-height: 1.3;
    order: 2;
}

.report-section {
    margin-bottom: 28px;
}

.report-section h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.report-chart {
    display: flex;
    align-items: flex-end;
    gap: 4px;
    height: 120px;
    padding: 0 4px;
}

.report-bar-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    justify-content: flex-end;
}

.report-bar {
    width: 100%;
    max-width: 24px;
    background: var(--primary);
    border-radius: 3px 3px 0 0;
    min-height: 2px;
    opacity: 0.75;
}

.report-bar-label {
    font-size: 9px;
    color: var(--text-light);
    margin-top: 4px;
}

.report-table {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.report-table-row {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    gap: 10px;
}

.report-table-row:last-child {
    border-bottom: none;
}

.report-table-row.header {
    background: var(--border-light);
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
}

.report-table-name {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.report-table-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.report-table-val {
    width: 60px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* ============================================
   BUSINESS HOURS
   ============================================ */
.bh-settings {
    max-width: 600px;
}

.bh-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.bh-toggle {
    position: relative;
    width: 48px;
    height: 26px;
    cursor: pointer;
}

.bh-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.bh-toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #ccc;
    border-radius: 26px;
    transition: 0.3s;
}

.bh-toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

.bh-toggle input:checked + .bh-toggle-slider {
    background: var(--primary);
}

.bh-toggle input:checked + .bh-toggle-slider::before {
    transform: translateX(22px);
}

.bh-toggle-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.bh-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.bh-row {
    display: flex;
    gap: 16px;
}

.bh-field {
    flex: 1;
}

.bh-field label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.bh-field textarea {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-panel);
    color: var(--text-primary);
    resize: vertical;
    outline: none;
}

.bh-field textarea:focus {
    border-color: var(--primary);
}

.bh-days {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.bh-day {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 13px;
    transition: var(--transition);
}

.bh-day:has(input:checked) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.bh-day input {
    display: none;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
    .conversations-panel {
        width: 280px;
        min-width: 280px;
    }

    .chat-body {
        padding: 16px 20px;
    }

    .message {
        max-width: 80%;
    }

    .chat-header-tags {
        display: none;
    }

    .login-card {
        width: 90%;
        max-width: 400px;
    }
}

/* ============================================
   TEAM CHAT (Chat Interno entre Agentes)
   ============================================ */
.team-chat-panel {
    z-index: 20;
}

.tc-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.tc-sidebar {
    width: 280px;
    min-width: 280px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: var(--bg-panel);
}

.tc-search-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    margin: 12px 12px 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.tc-search-wrap:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    background: var(--bg-primary);
}

.tc-search-wrap svg {
    flex-shrink: 0;
    color: var(--text-light);
}

.tc-search-wrap input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-size: 13px;
    padding: 4px 0;
    color: var(--text-primary);
    font-family: inherit;
}

.tc-agents-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.tc-agent-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background var(--transition);
    border-left: 3px solid transparent;
}

.tc-agent-item:hover {
    background: var(--hover-bg);
}

.tc-agent-item.active {
    background: var(--hover-bg);
    border-left-color: var(--primary);
}

.tc-agent-avatar {
    position: relative;
    flex-shrink: 0;
}

.tc-agent-avatar img {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    object-fit: cover;
}

.tc-agent-avatar .tc-online-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--bg-panel);
    background: #9ca3af;
}

.tc-agent-avatar .tc-online-dot.online {
    background: #22c55e;
}

.tc-agent-info {
    flex: 1;
    min-width: 0;
}

.tc-agent-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tc-agent-role {
    font-size: 11px;
    color: var(--text-light);
    display: block;
}

.tc-agent-preview {
    font-size: 11px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    margin-top: 2px;
}

.tc-agent-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.tc-agent-time {
    font-size: 10px;
    color: var(--text-light);
}

.tc-agent-unread {
    background: var(--primary);
    color: white;
    font-size: 10px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

/* Chat Area */
.tc-chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--chat-bg);
}

.tc-chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-light);
    font-size: 14px;
}

.tc-chat-active {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.tc-chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.tc-chat-header .tc-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    object-fit: cover;
}

.tc-chat-header-info {
    display: flex;
    flex-direction: column;
}

.tc-chat-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.tc-chat-status {
    font-size: 11px;
    color: var(--text-light);
}

.tc-chat-status.online {
    color: #22c55e;
}

/* Messages */
.tc-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tc-msg {
    display: flex;
    flex-direction: column;
    max-width: 65%;
    position: relative;
}

.tc-msg.mine {
    align-self: flex-end;
}

.tc-msg.theirs {
    align-self: flex-start;
}

.tc-msg-bubble {
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.45;
    word-wrap: break-word;
    position: relative;
}

.tc-msg.mine .tc-msg-bubble {
    background: var(--msg-agent-bg, #dcf8c6);
    color: var(--msg-agent-text, #111);
    border-bottom-right-radius: 4px;
}

.tc-msg.theirs .tc-msg-bubble {
    background: var(--msg-contact-bg, #fff);
    color: var(--msg-contact-text, #111);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-light);
}

.tc-msg-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 2px;
    font-size: 10px;
    color: var(--text-light);
}

.tc-msg.mine .tc-msg-meta {
    justify-content: flex-end;
}

.tc-msg-edited {
    font-style: italic;
    font-size: 10px;
    color: var(--text-light);
}

.tc-msg-deleted {
    font-style: italic;
    color: var(--text-light);
    opacity: 0.7;
}

.tc-msg-media img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    cursor: pointer;
    display: block;
    margin-bottom: 4px;
}

.tc-msg-media video {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
    display: block;
    margin-bottom: 4px;
}

.tc-msg-status {
    display: inline-flex;
    align-items: center;
}

.tc-msg-status svg {
    width: 14px;
    height: 14px;
}

.tc-msg-status.sent svg { color: var(--text-light); }
.tc-msg-status.delivered svg { color: var(--text-light); }
.tc-msg-status.read svg { color: #53bdeb; }

/* Context menu button on hover */
.tc-msg-bubble:hover .tc-msg-ctx-btn {
    opacity: 1;
}

.tc-msg-ctx-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    background: rgba(0,0,0,0.06);
    border: none;
    border-radius: 4px;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    color: var(--text-secondary);
}

.tc-msg.theirs .tc-msg-ctx-btn {
    display: none;
}

.tc-msg-ctx-btn:hover {
    background: rgba(0,0,0,0.12);
}

/* Input Area */
.tc-input-area {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-panel);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.tc-input-area input[type="text"] {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 10px 16px;
    font-size: 13px;
    font-family: inherit;
    background: var(--bg-secondary);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.tc-input-area input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.tc-attach-btn,
.tc-send-btn {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition), transform var(--transition);
    flex-shrink: 0;
}

.tc-attach-btn {
    background: transparent;
    color: var(--text-secondary);
}

.tc-attach-btn:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
}

.tc-send-btn {
    background: var(--primary);
    color: white;
}

.tc-send-btn:hover {
    filter: brightness(1.1);
    transform: scale(1.05);
}

/* Date separator */
.tc-date-separator {
    text-align: center;
    padding: 8px 0;
}

.tc-date-separator span {
    background: rgba(0,0,0,0.08);
    color: var(--text-secondary);
    font-size: 11px;
    padding: 4px 12px;
    border-radius: 8px;
}

[data-theme="dark"] .tc-date-separator span {
    background: rgba(255,255,255,0.08);
}

/* Dark mode overrides */
[data-theme="dark"] .tc-msg.mine .tc-msg-bubble {
    background: var(--msg-agent-bg, #005c4b);
    color: var(--msg-agent-text, #e9edef);
}

[data-theme="dark"] .tc-msg.theirs .tc-msg-bubble {
    background: var(--msg-contact-bg, #202c33);
    color: var(--msg-contact-text, #e9edef);
    border-color: var(--border-color);
}

/* Context menu */
.tc-ctx-menu {
    position: fixed;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    z-index: 9999;
    min-width: 140px;
    padding: 4px 0;
}

.tc-ctx-item {
    padding: 8px 16px;
    font-size: 13px;
    cursor: pointer;
    color: var(--text-primary);
    transition: background 0.1s;
}

.tc-ctx-item:hover {
    background: var(--hover-bg);
}

.tc-ctx-item.danger {
    color: #ef4444;
}

.tc-ctx-item.danger:hover {
    background: rgba(239, 68, 68, 0.08);
}
