@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #0a0b0d;
    --bg-secondary: #111318;
    --bg-tertiary: #171b22;
    --bg-card: #1f242e;
    --bg-unread-item: #07080a;
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --color-primary: #6366f1;
    --color-primary-hover: #4f46e5;
    --color-primary-glow: rgba(99, 102, 241, 0.15);
    
    --color-telegram: #229ed9;
    --color-telegram-glow: rgba(34, 158, 217, 0.15);
    --color-whatsapp: #25d366;
    --color-whatsapp-glow: rgba(37, 211, 102, 0.15);
    
    --border-color: #242b35;
    
    --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    --sidebar-width: 80px;
    --chat-list-width: 320px;
    --details-width: 300px;

    /* Glass variables */
    --bg-main: #0a0b0d;
    --bg-glass: rgba(17, 19, 24, 0.7);
    --blur-glass: blur(16px);
    --border-glass: rgba(255, 255, 255, 0.08);
    --shadow-premium: 0 8px 32px 0 rgba(0, 0, 0, 0.5);

    /* Glass Panel background variables */
    --bg-body-glass: #050608;
    --bg-sidebar-glass: rgba(17, 19, 24, 0.4);
    --bg-list-glass: rgba(17, 19, 24, 0.3);
    --bg-header-glass: rgba(17, 19, 24, 0.2);
    --bg-input-glass: rgba(17, 19, 24, 0.2);
    --bg-details-glass: rgba(17, 19, 24, 0.4);
    --bg-card-glass: rgba(23, 27, 34, 0.5);

    /* Chat dot pattern */
    --chat-pattern-color: rgba(255, 255, 255, 0.035);
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #fdfdfd;
    --bg-card: #ffffff;
    --bg-unread-item: #e2e8f0;
    
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    
    --color-primary: #4f46e5;
    --color-primary-hover: #3730a3;
    --color-primary-glow: rgba(79, 70, 229, 0.1);
    
    --border-color: #94a3b8;  /* Более темная и выразительная серая рамка */
    
    --bg-main: #f8fafc;
    --bg-glass: rgba(255, 255, 255, 0.85);
    --border-glass: #94a3b8;
    --shadow-premium: 0 8px 32px 0 rgba(15, 23, 42, 0.08);

    /* Glass Panel background variables for Light Mode */
    --bg-body-glass: #f8fafc;
    --bg-sidebar-glass: rgba(255, 255, 255, 0.5);
    --bg-list-glass: rgba(255, 255, 255, 0.4);
    --bg-header-glass: rgba(255, 255, 255, 0.3);
    --bg-input-glass: rgba(255, 255, 255, 0.3);
    --bg-details-glass: rgba(255, 255, 255, 0.5);
    --bg-card-glass: rgba(255, 255, 255, 0.65);
    
    --chat-pattern-color: rgba(71, 85, 105, 0.06);
}

/* Настройка фонового свечения в светлом режиме для нежных пастельных переливов */
[data-theme="light"] .bg-glow {
    mix-blend-mode: multiply;
    opacity: 0.06;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    -webkit-font-smoothing: antialiased;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* App Layout */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar navigation */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 12px;
    justify-content: space-between;
    transition: width var(--transition-normal);
    overflow: hidden;
}

.sidebar.expanded {
    --sidebar-width: 240px;
}

.sidebar-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    width: 100%;
    margin-bottom: 24px;
    transition: all var(--transition-normal);
}

.sidebar.expanded .sidebar-header {
    flex-direction: row;
    justify-content: space-between;
    padding: 0 8px;
}

.sidebar-toggle {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    transition: all var(--transition-fast);
}

.sidebar-toggle:hover {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
}

.sidebar-toggle svg {
    width: 20px;
    height: 20px;
    transition: transform var(--transition-normal);
}

.sidebar.expanded .sidebar-toggle svg {
    transform: scaleX(-1);
}

.logo-container {
    font-size: 28px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--color-primary), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    cursor: pointer;
}

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

.nav-item {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    position: relative;
    gap: 12px;
}

.sidebar.expanded .nav-item {
    width: 100%;
    justify-content: flex-start;
    padding: 0 16px;
}

.sidebar.expanded .nav-item.active::before {
    left: -12px;
}

.nav-label {
    display: none;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.sidebar.expanded .nav-label {
    display: inline-block;
    opacity: 1;
}

.nav-item:hover, .nav-item.active {
    color: var(--text-primary);
    background-color: var(--bg-tertiary);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 12px;
    bottom: 12px;
    width: 4px;
    background-color: var(--color-primary);
    border-radius: 0 4px 4px 0;
}

.nav-item svg {
    width: 20px;
    height: 20px;
    stroke-width: 2;
    fill: none;
    stroke: currentColor;
}

.user-profile {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 48px;
    gap: 12px;
    transition: all var(--transition-fast);
}

.sidebar.expanded .user-profile {
    justify-content: flex-start !important;
    padding-left: 20px;
}

.user-avatar-initials {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--color-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    border: 2px solid var(--border-color);
}

/* Main content screens */
.screen {
    display: none;
    flex: 1;
    height: 100%;
}

.screen.active {
    display: flex;
}

/* Chat Screen Layout */
.chats-screen {
    display: none; /* Handled by screen.active */
    flex-direction: row;
    flex: 1;
}

/* Left Chat List Column */
.chat-list-column {
    width: var(--chat-list-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.chat-list-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
}

.chat-list-header h2 {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 0;
}

.sound-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 15px;
    padding: 0;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    width: 32px;
    height: 32px;
}

.sound-toggle-btn:hover {
    background-color: var(--bg-card);
    transform: scale(1.05);
    color: var(--text-primary);
}

.sound-toggle-btn.sound-muted {
    opacity: 0.6;
}

.search-box {
    position: relative;
    width: 100%;
}

.search-box input {
    width: 100%;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 16px 10px 40px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    outline: none;
    transition: var(--transition-fast);
}

.search-box input:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary-glow);
}

.search-box svg {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

/* Channels Filter */
.channel-filters {
    display: flex;
    gap: 8px;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.filter-btn {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-btn:hover, .filter-btn.active {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

.filter-btn.active.telegram {
    background-color: var(--color-telegram-glow);
    border-color: var(--color-telegram);
    color: var(--color-telegram);
}

.filter-btn.active.whatsapp {
    background-color: var(--color-whatsapp-glow);
    border-color: var(--color-whatsapp);
    color: var(--color-whatsapp);
}

/* Conversation list items */
.conversations-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.conversation-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition-fast);
    margin-bottom: 4px;
    position: relative;
}

.conversation-item:hover {
    background-color: var(--bg-tertiary);
}

.conversation-item.active {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
}

.delete-conv-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 16px;
    font-weight: 600;
    transition: var(--transition-fast);
    opacity: 0;
    z-index: 10;
}

.conversation-item:hover .delete-conv-btn {
    opacity: 1;
}

.delete-conv-btn:hover {
    background-color: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.avatar-wrapper {
    position: relative;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--bg-tertiary);
    border-radius: 12px;
    font-size: 20px;
}

.channel-badge {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: white;
    border: 2px solid var(--bg-secondary);
}

.channel-badge.telegram {
    background-color: var(--color-telegram);
}

.channel-badge.whatsapp {
    background-color: var(--color-whatsapp);
}

.conv-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.conv-meta {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 4px;
}

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

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

.conv-last-msg {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background-color: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    margin-left: 8px;
}

/* Chat Main Area */
.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-primary);
}

.chat-header {
    height: 72px;
    border-bottom: 1px solid var(--border-color);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--bg-secondary);
}

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

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

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

.chat-actions {
    display: flex;
    gap: 12px;
}

.action-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: var(--transition-fast);
}

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

.action-btn svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* Messages Area */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-color: var(--bg-primary);
    background-image: radial-gradient(var(--chat-pattern-color) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: center;
}

.message-bubble {
    max-width: 70%;
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: bubbleFadeIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.message-bubble.client {
    align-self: flex-start;
}

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

.message-content {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.message-bubble.client .message-content {
    background-color: var(--bg-tertiary);
    color: var(--text-primary);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

.message-bubble.agent .message-content {
    background: linear-gradient(135deg, var(--color-primary), #5345d9);
    color: white;
    border-bottom-right-radius: 4px;
}

.message-meta {
    font-size: 10px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.message-bubble.agent .message-meta {
    justify-content: flex-end;
}

/* Input Area */
.input-area {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-secondary);
}

.input-container {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: var(--transition-fast);
}

.input-container:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-primary-glow);
}

.input-container textarea {
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    resize: none;
    outline: none;
    width: 100%;
    min-height: 44px;
    max-height: 120px;
}

.input-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.toolbar-actions {
    display: flex;
    gap: 8px;
}

.send-btn {
    background-color: var(--color-primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 8px 16px;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 6px;
}

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

.send-btn svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
}

/* CRM Details Column */
.details-column {
    width: var(--details-width);
    background-color: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 24px;
    overflow-y: auto;
}

.details-avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-color);
}

.details-avatar {
    width: 72px;
    height: 72px;
    background-color: var(--bg-tertiary);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    margin-bottom: 12px;
    border: 2px solid var(--border-color);
}

.details-name {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.details-handle {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.channel-tag {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
    text-transform: uppercase;
}

.channel-tag.telegram {
    background-color: var(--color-telegram-glow);
    color: var(--color-telegram);
    border: 1px solid rgba(34, 158, 217, 0.3);
}

.channel-tag.whatsapp {
    background-color: var(--color-whatsapp-glow);
    color: var(--color-whatsapp);
    border: 1px solid rgba(37, 211, 102, 0.3);
}

.details-section {
    padding: 20px 0;
    border-bottom: 1px solid var(--border-color);
}

.details-section h4 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.client-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 11px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 4px;
}

.tag.add-tag {
    cursor: pointer;
    border-style: dashed;
}

.tag.add-tag:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.tag-cold {
    background-color: #2563eb !important;
    border-color: #3b82f6 !important;
    color: #ffffff !important;
}

.tag-warm {
    background-color: #dc2626 !important;
    border-color: #ef4444 !important;
    color: #ffffff !important;
}

.tag-neutral {
    background-color: #f8fafc !important;
    border-color: #cbd5e1 !important;
    color: #0f172a !important;
}

.remove-tag-btn {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-left: 4px;
    opacity: 0.7;
    transition: var(--transition-fast);
}

.remove-tag-btn:hover {
    opacity: 1;
    color: #ff4d4d !important;
}

.tag-helper {
    cursor: pointer;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    transition: var(--transition-fast);
    opacity: 0.4;
    border: 1px solid transparent;
}

.tag-helper:hover {
    opacity: 0.85;
}

.tag-helper.active {
    opacity: 1;
    font-weight: 600;
}

.tag-helper.tag-cold {
    background-color: #1e3a8a;
    border-color: #2563eb;
    color: #93c5fd;
}
.tag-helper.tag-cold.active {
    background-color: #2563eb;
    color: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 0 8px rgba(37, 99, 235, 0.4);
}

.tag-helper.tag-warm {
    background-color: #7f1d1d;
    border-color: #dc2626;
    color: #fca5a5;
}
.tag-helper.tag-warm.active {
    background-color: #dc2626;
    color: #ffffff;
    border-color: #ef4444;
    box-shadow: 0 0 8px rgba(220, 38, 38, 0.4);
}

.tag-helper.tag-neutral {
    background-color: #1e293b;
    border-color: #475569;
    color: #cbd5e1;
}
.tag-helper.tag-neutral.active {
    background-color: #f8fafc;
    color: #0f172a;
    border-color: #cbd5e1;
    box-shadow: 0 0 8px rgba(248, 250, 252, 0.4);
}

.notes-area {
    width: 100%;
    min-height: 80px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    resize: none;
    outline: none;
    line-height: 1.4;
}

.notes-area:focus {
    border-color: var(--color-primary);
}

.save-notes-btn {
    margin-top: 8px;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: 6px;
    font-family: var(--font-sans);
    font-size: 12px;
    cursor: pointer;
    transition: var(--transition-fast);
    width: 100%;
}

.save-notes-btn:hover {
    background-color: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--text-muted);
}

/* Empty State */
.chat-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    gap: 16px;
}

.chat-empty-state svg {
    width: 64px;
    height: 64px;
    color: var(--text-muted);
}

/* General Layout for Non-Chat Screens */
.screen-content {
    flex: 1;
    padding: 40px;
    overflow-y: auto;
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
}

.screen-header {
    margin-bottom: 32px;
}

.screen-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
}

.screen-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* Integrations Grid */
.integrations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 24px;
}

.integration-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: var(--transition-normal);
}

.integration-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
}

.integration-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 20px;
}

.integration-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
}

.brand-icon.telegram {
    background-color: var(--color-telegram);
}

.brand-icon.whatsapp {
    background-color: var(--color-whatsapp);
}

.brand-details h3 {
    font-size: 16px;
    font-weight: 600;
}

.brand-details span {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
}

.integration-status-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
}

.integration-status-badge.active {
    background-color: rgba(37, 211, 102, 0.1);
    color: var(--color-whatsapp);
    border: 1px solid rgba(37, 211, 102, 0.3);
}

.integration-status-badge.inactive {
    background-color: rgba(107, 114, 128, 0.1);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.integration-card-body {
    margin-bottom: 24px;
}

.integration-card-body p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 16px;
}

.integration-form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.integration-form-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.integration-form-group input {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    outline: none;
}

.integration-form-group input:focus {
    border-color: var(--color-primary);
}

.integration-card-footer {
    display: flex;
    gap: 12px;
}

.btn {
    flex: 1;
    padding: 10px 16px;
    border-radius: 8px;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: center;
    border: none;
}

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

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

.btn-secondary {
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

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

/* Analytics Cards */
.analytics-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 8px;
}

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

.chart-placeholder {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 24px;
    height: 350px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.chart-bar-container {
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    height: 200px;
    margin-top: 24px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 12px;
}

.chart-bar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 60px;
}

.chart-bar {
    width: 24px;
    border-radius: 6px 6px 0 0;
    transition: height 1s ease-in-out;
}

.chart-bar.telegram {
    background-color: var(--color-telegram);
}

.chart-bar.whatsapp {
    background-color: var(--color-whatsapp);
}

.chart-label {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* WhatsApp Simulator Panel */
.simulator-box {
    margin-top: 16px;
    border: 1px dashed var(--border-color);
    border-radius: 8px;
    padding: 16px;
    background-color: rgba(255, 255, 255, 0.01);
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: -320px;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--color-primary);
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 1000;
    transition: right 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 280px;
}

.toast.show {
    right: 24px;
}

.toast-header {
    font-weight: 600;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 6px;
}

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

/* Contacts screen styles */
.contacts-table-container {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    overflow: hidden;
}

.contacts-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.contacts-table th, .contacts-table td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
}

.contacts-table th {
    background-color: rgba(255, 255, 255, 0.02);
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
}

.contacts-table td {
    font-size: 14px;
}

.contacts-table tr:last-child td {
    border-bottom: none;
}

.contacts-table tr:hover td {
    background-color: rgba(255, 255, 255, 0.01);
}

/* ==========================================================================
   ADDED: Premium Animated Glow Background, Glassmorphism, and Translation UI
   ========================================================================== */

/* 1. Animated background glow spheres */
.bg-glow {
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(130px);
    pointer-events: none;
    z-index: -1;
    opacity: 0.35;
    mix-blend-mode: screen;
    animation: floatGlow 25s infinite alternate ease-in-out;
}
.bg-glow-1 {
    background: radial-gradient(circle, var(--color-primary) 0%, rgba(0,0,0,0) 70%);
    top: -200px;
    left: -200px;
}
.bg-glow-2 {
    background: radial-gradient(circle, #a855f7 0%, rgba(0,0,0,0) 70%);
    bottom: -200px;
    right: -200px;
    animation-delay: -5s;
    animation-duration: 30s;
}
.bg-glow-3 {
    background: radial-gradient(circle, var(--color-whatsapp) 0%, rgba(0,0,0,0) 70%);
    top: 40%;
    left: 30%;
    width: 400px;
    height: 400px;
    opacity: 0.12;
    animation-delay: -12s;
    animation-duration: 20s;
}

@keyframes floatGlow {
    0% {
        transform: translate(0, 0) scale(1);
    }
    50% {
        transform: translate(80px, 60px) scale(1.05);
    }
    100% {
        transform: translate(-40px, 120px) scale(0.95);
    }
}

/* 2. Glassmorphism Overrides */
body {
    background-color: var(--bg-body-glass) !important;
    position: relative;
}

.sidebar {
    background-color: var(--bg-sidebar-glass) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
}

.chat-list-column {
    background-color: var(--bg-list-glass) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
}

.chat-window {
    background-color: transparent !important;
}

.chat-header {
    background-color: var(--bg-header-glass) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
}

.input-area {
    background-color: var(--bg-input-glass) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
}

.details-column {
    background-color: var(--bg-details-glass) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
}

.integration-card, .stat-card, .chart-placeholder, .contacts-table-container {
    background-color: var(--bg-card-glass) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    border: 1px solid var(--border-color) !important;
}

/* 3. Translation UI Styling */
.lang-select {
    width: 100%;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    outline: none;
    cursor: pointer;
    margin-top: 4px;
    transition: var(--transition-fast);
}

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

.translation-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 4px;
    transition: var(--transition-fast);
    margin-top: 4px;
    align-self: flex-start;
}

.translation-toggle-btn:hover {
    color: var(--text-secondary);
    background-color: rgba(255, 255, 255, 0.05);
}

.message-bubble.agent .translation-toggle-btn {
    align-self: flex-end;
}

.translate-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    padding: 2px 6px;
    border-radius: 4px;
    background-color: rgba(255, 255, 255, 0.02);
}

/* 4. Unread Messages Indicators */
.nav-item .nav-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background-color: #ef4444; /* vibrant red */
    color: white;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.4);
    animation: badgePulse 2s infinite;
}

@keyframes badgePulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* Unread chat items in list */
.conversation-item.unread {
    background-color: var(--bg-unread-item) !important;
    border-left: 3px solid #ef4444 !important;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.conversation-item.unread .conv-name {
    font-weight: 700 !important;
    color: var(--text-primary) !important;
}

.conversation-item.unread .conv-last-msg {
    color: var(--text-primary) !important;
    font-weight: 500 !important;
}

/* Unread message bubbles in chat */
.message-bubble.client.unread-msg .message-content {
    background-color: rgba(99, 102, 241, 0.18) !important;
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 10px rgba(99, 102, 241, 0.25);
}

/* 5. Client Simulation Toggle Switch */
.switch-container {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    user-select: none;
}

.switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    transition: .3s;
    border-radius: 20px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background-color: var(--text-muted);
    transition: .3s;
    border-radius: 50%;
}

.switch input:checked + .slider {
    background-color: rgba(99, 102, 241, 0.1);
    border-color: var(--color-primary);
}

.switch input:checked + .slider:before {
    transform: translateX(18px);
    background-color: var(--color-primary);
}

/* Outgoing send button variants when simulating client */
.send-btn.client-mode-tg {
    background: linear-gradient(135deg, var(--color-telegram), #1c82b3) !important;
    box-shadow: 0 0 10px rgba(34, 158, 217, 0.3);
}

.send-btn.client-mode-wa {
    background: linear-gradient(135deg, var(--color-whatsapp), #1c9c4b) !important;
    box-shadow: 0 0 10px rgba(37, 211, 102, 0.3);
}

/* Mobile Back Button - Desktop Hidden */
.mobile-back-btn {
    display: none;
}

/* Responsive / Mobile styles */
@media (max-width: 768px) {
    /* 1. App Layout */
    .app-container {
        flex-direction: column-reverse !important;
    }
    
    /* 2. Sidebar to Bottom Bar */
    .sidebar {
        width: 100% !important;
        height: 60px !important;
        flex-direction: row !important;
        padding: 0 16px !important;
        border-right: none !important;
        border-top: 1px solid var(--border-color) !important;
        justify-content: space-between !important;
        align-items: center !important;
        z-index: 100;
    }
    
    .logo-container {
        display: none !important;
    }
    
    .nav-menu {
        flex-direction: row !important;
        justify-content: space-around !important;
        flex: 1 !important;
        gap: 0 !important;
        margin: 0 !important;
        width: auto !important;
    }
    
    .nav-item {
        width: 44px !important;
        height: 44px !important;
    }
    
    .nav-item.active::before {
        left: 10px !important;
        right: 10px !important;
        top: auto !important;
        bottom: 0 !important;
        height: 3px !important;
        width: auto !important;
        border-radius: 4px 4px 0 0 !important;
    }
    
    .sidebar-bottom-group {
        flex-direction: row !important;
        width: auto !important;
        gap: 16px !important;
    }
    
    .user-profile {
        width: auto !important;
        height: auto !important;
    }
    
    .user-avatar-initials {
        width: 36px !important;
        height: 36px !important;
    }

    /* 3. Screen containers and layouts */
    .screen-content {
        padding: 16px !important;
    }
    
    /* 4. Chats Screen Stack on Mobile */
    .chats-screen {
        position: relative !important;
        width: 100vw !important;
        overflow: hidden !important;
    }
    
    .chat-list-column {
        width: 100% !important;
        flex: 1 !important;
        border-right: none !important;
    }
    
    .chat-window {
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        z-index: 50 !important;
        background-color: var(--bg-primary) !important;
        display: none !important; /* Hide unless chat-open */
    }
    
    .chat-open .chat-window {
        display: flex !important;
    }
    
    #active-details-panel {
        display: none !important; /* Force hide on mobile */
    }

    /* 5. Mobile Back Button */
    .mobile-back-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: var(--text-primary);
        cursor: pointer;
        padding: 4px;
        margin-right: 8px;
        border-radius: 8px;
        transition: var(--transition-fast);
    }
    
    .mobile-back-btn:hover {
        background-color: var(--bg-tertiary);
    }
    
    .mobile-back-btn svg {
        width: 24px;
        height: 24px;
    }
    
    /* 6. Integration and Analytics Grid Adaptability */
    .integrations-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .sidebar-toggle {
        display: none !important;
    }

    .nav-label {
        display: none !important;
    }
}
