/* ========== ОСНОВНЫЕ ПЕРЕМЕННЫЕ ========== */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafd;
    --bg-tertiary: #f1f5f9;
    --bg-chat: #e9eef3;
    --bg-message-in: #ffffff;
    --bg-message-out: #d1f1e6;
    --bg-header: #ffffff;
    --bg-sidebar: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --accent: #10b981;
    --accent-dark: #059669;
    --accent-light: #d1fae5;
    --border: #e2e8f0;
    --border-dark: #cbd5e1;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --info: #3b82f6;
    --chat-bg-pattern: none;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-chat: #0b1120;
    --bg-message-in: #1e293b;
    --bg-message-out: #065f46;
    --bg-header: #1e293b;
    --bg-sidebar: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #94a3b8;
    --accent: #10b981;
    --accent-dark: #059669;
    --accent-light: #064e3b;
    --border: #334155;
    --border-dark: #475569;
}

[data-theme="forest"] {
    --bg-primary: #ecfdf5;
    --bg-secondary: #d1fae5;
    --bg-tertiary: #a7f3d0;
    --bg-chat: #d1fae5;
    --bg-message-in: #ffffff;
    --bg-message-out: #6ee7b7;
    --bg-header: #059669;
    --bg-sidebar: #ffffff;
    --text-primary: #064e3b;
    --text-secondary: #047857;
    --accent: #059669;
    --accent-dark: #047857;
    --border: #6ee7b7;
}

[data-theme="ocean"] {
    --bg-primary: #f0f9ff;
    --bg-secondary: #e0f2fe;
    --bg-tertiary: #bae6fd;
    --bg-chat: #e0f2fe;
    --bg-message-in: #ffffff;
    --bg-message-out: #7dd3fc;
    --bg-header: #0284c7;
    --bg-sidebar: #ffffff;
    --text-primary: #075985;
    --text-secondary: #0369a1;
    --accent: #0284c7;
    --accent-dark: #0369a1;
    --border: #7dd3fc;
}

[data-theme="sunset"] {
    --bg-primary: #fff7ed;
    --bg-secondary: #ffedd5;
    --bg-tertiary: #fed7aa;
    --bg-chat: #ffedd5;
    --bg-message-in: #ffffff;
    --bg-message-out: #fdba74;
    --bg-header: #ea580c;
    --bg-sidebar: #ffffff;
    --text-primary: #7c2d12;
    --text-secondary: #9a3412;
    --accent: #ea580c;
    --accent-dark: #c2410c;
    --border: #fdba74;
}

/* ========== ГЛОБАЛЬНЫЕ СТИЛИ ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s, color 0.3s;
}

/* ========== СКРОЛЛБАР ========== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ========== ОСНОВНОЕ ПРИЛОЖЕНИЕ ========== */
#app {
    display: flex;
    width: 100%;
    height: 100vh;
}

/* ========== ЛЕВАЯ ПАНЕЛЬ ========== */
.chats-panel {
    width: 360px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    backdrop-filter: blur(10px);
    transition: all 0.3s;
}

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

.profile-btn {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: all 0.2s;
    overflow: hidden;
}

.profile-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

.profile-btn img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chats-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.chats-title i {
    color: var(--accent);
    font-size: 24px;
}

.header-icons {
    display: flex;
    gap: 16px;
    color: var(--text-secondary);
}

.header-icons i {
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.header-icons i:hover {
    color: var(--accent);
    transform: scale(1.1);
}

/* ========== ТАБЫ ========== */
.tabs {
    display: flex;
    background: var(--bg-tertiary);
    padding: 4px;
    margin: 16px 16px 8px;
    border-radius: 12px;
    gap: 4px;
}

.tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    cursor: pointer;
    border-radius: 8px;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
    transition: all 0.2s;
}

.tab i {
    font-size: 16px;
}

.tab.active {
    background: var(--accent);
    color: white;
}

/* ========== ПОИСК ========== */
.search-box {
    position: relative;
    padding: 0 16px 16px;
}

.search-box i {
    position: absolute;
    left: 28px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    font-size: 16px;
}

.search-box input {
    width: 100%;
    padding: 14px 18px 14px 45px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: 16px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

.search-box input:focus {
    border-color: var(--accent);
    background: var(--bg-secondary);
}

.search-box input::placeholder {
    color: var(--text-tertiary);
}

/* ========== СПИСКИ ========== */
.chats-list, .contacts-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 12px;
}

.chat-item, .contact-item {
    display: flex;
    padding: 12px;
    cursor: pointer;
    border-radius: 12px;
    margin-bottom: 4px;
    transition: all 0.2s;
    position: relative;
}

.chat-item:hover, .contact-item:hover {
    background: var(--bg-tertiary);
    transform: translateX(4px);
}

.chat-item.active {
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent) 100%);
}

.chat-item.active .chat-name,
.chat-item.active .chat-last-message,
.chat-item.active .chat-meta {
    color: white;
}

/* ========== АВАТАРЫ ========== */
.chat-avatar {
    width: 48px;
    height: 48px;
    border-radius: 16px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    margin-right: 12px;
    position: relative;
    flex-shrink: 0;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-avatar.group {
    background: linear-gradient(135deg, var(--warning) 0%, #d97706 100%);
}

.online-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: var(--success);
    border-radius: 50%;
    border: 2px solid var(--bg-sidebar);
}

/* ========== ИНФОРМАЦИЯ О ЧАТЕ ========== */
.chat-info {
    flex: 1;
    min-width: 0;
}

.chat-name {
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 6px;
}

.pinned-badge {
    font-size: 12px;
    color: var(--warning);
}

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

.chat-meta {
    text-align: right;
    font-size: 11px;
    margin-left: 8px;
    color: var(--text-tertiary);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.unread-badge {
    background: var(--accent);
    color: white;
    border-radius: 12px;
    min-width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 600;
    padding: 0 6px;
}

/* ========== ФУТЕР ЧАТОВ ========== */
.chats-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    background: var(--bg-header);
}

.chats-footer-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

#userFullName {
    font-weight: 600;
    font-size: 14px;
}

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

/* ========== ПАНЕЛЬ ЧАТА ========== */
.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-chat);
    position: relative;
    transition: background-image 0.3s;
}

.chat-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: var(--chat-bg-pattern);
    background-size: cover;
    background-position: center;
    opacity: 0.1;
    pointer-events: none;
}

/* ========== ХЕДЕР ЧАТА ========== */
.chat-header {
    padding: 12px 20px;
    background: var(--bg-header);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    z-index: 10;
    box-shadow: var(--shadow);
}

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

.chat-header-info {
    min-width: 0;
}

.chat-header-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.chat-header-icons {
    display: flex;
    gap: 16px;
    color: var(--text-secondary);
}

.chat-header-icons i {
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
}

.chat-header-icons i:hover {
    color: var(--accent);
    transform: scale(1.1);
}

/* ========== ЗАКРЕПЛЕННЫЕ СООБЩЕНИЯ ========== */
.pinned-messages-container {
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border-bottom: 2px solid var(--warning);
    padding: 12px 16px;
    position: relative;
    z-index: 9;
    backdrop-filter: blur(10px);
    max-height: 250px;
    overflow-y: auto;
    animation: slideDown 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.pinned-header {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--warning);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pinned-header i:first-child {
    color: var(--warning);
    font-size: 16px;
}

.pinned-header i:last-child {
    margin-left: auto;
    color: var(--text-secondary);
    transition: transform 0.3s;
}

.pinned-list {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pinned-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: var(--bg-primary);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border-left: 4px solid var(--warning);
    box-shadow: var(--shadow);
}

.pinned-item:hover {
    transform: translateX(4px) translateY(-2px);
    box-shadow: var(--shadow-lg);
    background: var(--bg-secondary);
}

.pinned-sender {
    font-size: 12px;
    font-weight: 700;
    color: var(--warning);
    min-width: 80px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pinned-text {
    flex: 1;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-primary);
    font-weight: 500;
}

.pinned-actions {
    display: flex;
    gap: 8px;
    opacity: 0.3;
    transition: opacity 0.2s;
}

.pinned-item:hover .pinned-actions {
    opacity: 1;
}

.pinned-actions i {
    color: var(--danger);
    cursor: pointer;
    font-size: 14px;
    padding: 6px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pinned-actions i:hover {
    transform: scale(1.1);
    background: var(--danger);
    color: white;
}

/* ========== СООБЩЕНИЯ ========== */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: relative;
    z-index: 5;
}

.message {
    max-width: 65%;
    margin-bottom: 4px;
    position: relative;
    animation: messageIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes messageIn {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

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

.message-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    box-shadow: var(--shadow);
    transition: all 0.2s;
}

.message-bubble:hover {
    transform: scale(1.01);
    box-shadow: var(--shadow-lg);
}

.message.outgoing .message-bubble {
    background: var(--bg-message-out);
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
}

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

.message-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    font-size: 12px;
}

.sender-name {
    font-weight: 600;
    color: var(--accent);
}

.forwarded-badge {
    font-size: 10px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.forwarded-badge i {
    margin-right: 4px;
    font-size: 10px;
}

.message-text {
    font-size: 14px;
    line-height: 1.5;
}

.message-media {
    max-width: 250px;
    max-height: 250px;
    border-radius: 12px;
    cursor: pointer;
    margin: 4px 0;
    transition: transform 0.2s;
}

.message-media:hover {
    transform: scale(1.05);
}

.message-file {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    text-decoration: none;
    color: inherit;
    transition: background 0.2s;
    font-size: 13px;
}

.message-file:hover {
    background: rgba(255,255,255,0.2);
}

.message-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    margin-top: 4px;
    font-size: 10px;
    color: var(--text-secondary);
}

.message-status {
    font-size: 11px;
}

.message-status.sent { color: var(--text-tertiary); }
.message-status.delivered { color: var(--text-secondary); }
.message-status.read { color: var(--info); }

/* ========== РЕАКЦИИ ========== */
.reactions {
    display: flex;
    gap: 4px;
    margin-top: 6px;
    flex-wrap: wrap;
}

.reaction {
    background: var(--bg-tertiary);
    border-radius: 16px;
    padding: 3px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.reaction:hover {
    transform: scale(1.1);
    background: var(--accent-light);
}

/* ========== ГОЛОСОВЫЕ СООБЩЕНИЯ ========== */
.voice-message {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: rgba(255,255,255,0.1);
    border-radius: 24px;
    min-width: 200px;
}

.voice-play-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.voice-play-btn:hover {
    transform: scale(1.1);
}

.voice-waveform-mini {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 24px;
    flex: 1;
}

.voice-waveform-bar {
    flex: 1;
    height: calc(20% + var(--height, 0%));
    background: var(--accent);
    border-radius: 2px;
    transition: height 0.1s;
    min-height: 2px;
    max-height: 24px;
}

.voice-progress {
    flex: 1;
    height: 4px;
    background: rgba(255,255,255,0.2);
    border-radius: 2px;
    position: relative;
    cursor: pointer;
}

.voice-progress-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0%;
    background: var(--accent);
    border-radius: 2px;
    transition: width 0.1s linear;
}

.voice-time {
    font-size: 11px;
    color: var(--text-secondary);
    min-width: 60px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ========== ПАНЕЛЬ ЗАПИСИ ГОЛОСА ========== */
.voice-recording-panel {
    padding: 12px 20px;
    background: var(--bg-header);
    border-top: 1px solid var(--border);
    position: relative;
    z-index: 10;
    backdrop-filter: blur(10px);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.voice-recording-container {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.voice-waveform {
    flex: 1;
    height: 48px;
    background: var(--bg-tertiary);
    border-radius: 24px;
    overflow: hidden;
    display: flex;
    align-items: center;
    padding: 0 10px;
    min-width: 150px;
}

.voice-waveform-bars {
    display: flex;
    align-items: center;
    gap: 2px;
    width: 100%;
    height: 100%;
}

.voice-waveform-bars .voice-waveform-bar {
    flex: 1;
    height: calc(20% + var(--height, 0%));
    background: var(--accent);
    border-radius: 2px;
    transition: height 0.1s ease;
    min-height: 4px;
    max-height: 70%;
}

.voice-timer {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    min-width: 60px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

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

.voice-action-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 18px;
    box-shadow: var(--shadow);
    border: none;
    color: white;
}

.voice-action-btn.send {
    background: var(--success);
}

.voice-action-btn.cancel {
    background: var(--danger);
}

.voice-action-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

.voice-action-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========== ПАНЕЛЬ ВВОДА ========== */
.input-area {
    padding: 12px 20px;
    background: var(--bg-header);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 10;
}

.attach-btn, .emoji-btn, .send-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.2s;
    padding: 4px;
}

.attach-btn:hover, .emoji-btn:hover {
    color: var(--accent);
    transform: scale(1.1);
}

.send-btn {
    color: var(--accent);
}

.send-btn:hover {
    transform: scale(1.1);
}

.input-area input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: 24px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
}

.input-area input:focus {
    border-color: var(--accent);
    background: var(--bg-secondary);
}

.input-area input::placeholder {
    color: var(--text-tertiary);
}

.voice-record-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
    border: none;
}

.voice-record-btn:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-lg);
}

.voice-record-btn.recording {
    animation: pulse 1.5s infinite;
    background: linear-gradient(135deg, var(--danger) 0%, #b91c1c 100%);
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

/* ========== ПУСТОЕ СОСТОЯНИЕ ========== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 64px;
    margin-bottom: 16px;
    color: var(--accent);
    opacity: 0.3;
}

.empty-state h2 {
    font-size: 20px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.empty-state p {
    margin-bottom: 20px;
    font-size: 14px;
}

.empty-state-sub {
    font-size: 13px;
    color: var(--text-tertiary);
}

.empty-state button {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

.empty-state button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

/* ========== МОДАЛЬНЫЕ ОКНА ========== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.2s ease;
}

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

.modal-content {
    background: var(--bg-primary);
    border-radius: 20px;
    width: 500px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: var(--shadow-lg);
    animation: modalSlideUp 0.3s ease;
}

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

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

.modal-header h3 {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    font-size: 20px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.modal-close:hover {
    color: var(--danger);
}

.modal-body {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-body input,
.modal-body textarea,
.modal-body select {
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    width: 100%;
}

.modal-body input:focus,
.modal-body textarea:focus,
.modal-body select:focus {
    border-color: var(--accent);
    background: var(--bg-secondary);
}

.modal-body textarea {
    resize: vertical;
    min-height: 80px;
}

.modal-body button {
    padding: 10px;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.modal-body button:hover {
    background: var(--accent-dark);
    transform: translateY(-2px);
}

.modal-body button.btn-danger {
    background: var(--danger);
}

.modal-body button.btn-danger:hover {
    background: #dc2626;
}

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.modal-actions button {
    flex: 1;
}

/* ========== АВАТАР В МОДАЛЬНОМ ОКНЕ ========== */
.avatar-upload {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
}

.avatar-preview {
    width: 80px;
    height: 80px;
    border-radius: 20px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-preview:hover::after {
    content: "📷";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.file-input {
    display: none;
}

/* ========== ПРОФИЛЬ ПОЛЯ ========== */
.profile-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.profile-field label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ========== ТЕЛЕФОННЫЙ ВВОД ========== */
.input-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon i {
    position: absolute;
    left: 12px;
    color: var(--text-tertiary);
    font-size: 16px;
}

.input-icon input {
    padding-left: 40px !important;
}

/* ========== АВТОРИЗАЦИЯ ========== */
#auth {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.auth-box {
    background: var(--bg-primary);
    padding: 32px;
    border-radius: 20px;
    width: 400px;
    max-width: 100%;
    box-shadow: var(--shadow-lg);
    animation: fadeIn 0.5s ease;
}

.auth-logo {
    text-align: center;
    margin-bottom: 24px;
}

.auth-logo i {
    font-size: 48px;
    color: var(--accent);
    margin-bottom: 8px;
}

.auth-logo h2 {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 4px;
}

.auth-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    padding: 10px;
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.auth-tab.active {
    background: var(--accent);
    color: white;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.auth-form input {
    padding: 12px 14px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: all 0.2s;
    width: 100%;
}

.auth-form input:focus {
    border-color: var(--accent);
    background: var(--bg-secondary);
}

.auth-form button {
    padding: 12px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.auth-form button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.auth-links {
    text-align: center;
    margin-top: 8px;
}

.auth-links a {
    color: var(--accent);
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
}

.auth-links a:hover {
    text-decoration: underline;
}

#smsTimer {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ========== НАСТРОЙКИ ========== */
.settings-section {
    margin-bottom: 20px;
}

.settings-section h4 {
    font-size: 15px;
    margin-bottom: 12px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-section h4 i {
    color: var(--accent);
    width: 20px;
}

.settings-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.settings-item:last-child {
    border-bottom: none;
}

.settings-item-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.settings-item-left i {
    width: 20px;
    color: var(--accent);
    font-size: 16px;
}

.settings-item-info h4 {
    font-size: 14px;
    margin-bottom: 2px;
}

.settings-item-info p {
    font-size: 12px;
    color: var(--text-secondary);
}

/* ========== ПЕРЕКЛЮЧАТЕЛЬ ========== */
.switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 22px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .3s;
    border-radius: 22px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--accent);
}

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

/* ========== ТЕМЫ ========== */
.theme-selector {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 8px 0;
}

.theme-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 20px 12px;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: 16px;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.theme-btn i {
    font-size: 32px;
    margin-bottom: 4px;
    transition: transform 0.3s;
}

.theme-btn:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-light);
}

.theme-btn:hover i {
    transform: scale(1.1);
}

.theme-btn.active {
    border-color: var(--accent);
    background: var(--accent-light);
    color: var(--accent-dark);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

.theme-btn.active::after {
    content: '✓';
    position: absolute;
    top: 8px;
    right: 8px;
    color: var(--accent);
    font-size: 16px;
    font-weight: bold;
}

.chat-bg-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.chat-bg-option {
    cursor: pointer;
    text-align: center;
}

.bg-preview {
    height: 60px;
    border-radius: 8px;
    margin-bottom: 4px;
    border: 2px solid transparent;
    transition: all 0.2s;
}

.chat-bg-option:hover .bg-preview {
    transform: scale(1.05);
    border-color: var(--accent);
}

.bg-none {
    background: var(--bg-chat);
}
.bg-waves {
    background: repeating-linear-gradient(45deg, rgba(0,0,0,0.05) 0px, rgba(0,0,0,0.05) 2px, transparent 2px, transparent 8px);
}
.bg-dots {
    background: radial-gradient(circle at 30% 40%, rgba(0,0,0,0.1) 1px, transparent 1px);
}
.bg-lines {
    background: repeating-linear-gradient(90deg, rgba(0,0,0,0.1) 0px, rgba(0,0,0,0.1) 1px, transparent 1px, transparent 10px);
}
.bg-nature {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
}
.bg-abstract {
    background: linear-gradient(135deg, #e0f2fe 0%, #bae6fd 100%);
}

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

.chat-bg-upload {
    margin-top: 12px;
}

.upload-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.upload-label:hover {
    background: var(--border);
}

/* ========== КОНТЕКСТНОЕ МЕНЮ ========== */
.context-menu {
    position: fixed;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px 0;
    z-index: 3000;
    min-width: 200px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
    animation: fadeIn 0.2s ease;
}

.context-menu-item {
    padding: 8px 16px;
    cursor: pointer;
    color: var(--text-primary);
    transition: all 0.2s;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.context-menu-item:hover {
    background: var(--bg-tertiary);
}

.context-menu-item.danger {
    color: var(--danger);
}

.context-menu-item i {
    width: 18px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* ========== ЭМОДЗИ ПИКЕР ========== */
.emoji-picker {
    position: fixed;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
    z-index: 1500;
    max-height: 300px;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
    width: 350px;
    max-width: 90vw;
}

.emoji {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    padding: 6px;
    text-align: center;
    transition: all 0.2s;
    border-radius: 8px;
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji:hover {
    background: var(--bg-tertiary);
    transform: scale(1.2);
}

/* ========== ЗВОНКИ ========== */
.call-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    z-index: 4000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.call-window {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border-radius: 30px;
    padding: 40px;
    text-align: center;
    min-width: 350px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: slideUp 0.4s ease;
}

.call-avatar-large {
    width: 120px;
    height: 120px;
    border-radius: 30px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    margin: 0 auto 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    border: 4px solid rgba(255, 255, 255, 0.2);
}

.call-name {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 10px;
    color: white;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.call-status {
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 30px;
    font-size: 16px;
    letter-spacing: 0.5px;
}

.call-timer {
    font-size: 48px;
    font-weight: 700;
    color: white;
    margin-bottom: 30px;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    background: rgba(0, 0, 0, 0.2);
    padding: 15px 25px;
    border-radius: 60px;
    display: inline-block;
}

.call-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
}

.call-button {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    color: white;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.call-button:hover {
    transform: scale(1.1) translateY(-5px);
    box-shadow: 0 20px 30px rgba(0, 0, 0, 0.3);
}

.call-button.accept {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
}

.call-button.reject, .call-button.end {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
}

.video-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: black;
    z-index: 4000;
}

.remote-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #1a1a1a;
}

.local-video {
    position: absolute;
    bottom: 100px;
    right: 20px;
    width: 200px;
    height: 150px;
    border-radius: 12px;
    object-fit: cover;
    border: 3px solid var(--accent);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    background: #2a2a2a;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 4001;
}

.local-video:hover {
    transform: scale(1.05);
    border-color: var(--accent-dark);
}

.call-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    background: rgba(0, 0, 0, 0.6);
    padding: 15px 25px;
    border-radius: 60px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: slideUp 0.4s ease;
    z-index: 4002;
}

.control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
    color: white;
    background: rgba(255, 255, 255, 0.2);
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.control-btn.end-call {
    background: linear-gradient(135deg, var(--danger) 0%, #dc2626 100%);
    width: 60px;
}

.control-btn.end-call:hover {
    transform: scale(1.1) translateY(-2px);
}

.control-btn.muted {
    background: var(--danger);
}

/* ========== ИСТОРИЯ ЗВОНКОВ ========== */
.calls-list {
    max-height: 400px;
    overflow-y: auto;
}

.call-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.call-item:last-child {
    border-bottom: none;
}

.call-item-avatar {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-right: 12px;
}

.call-item-info {
    flex: 1;
}

.call-item-name {
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 14px;
}

.call-item-details {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

.call-item-status.missed {
    color: var(--danger);
}

.call-item-status.answered {
    color: var(--success);
}

.call-item-status.rejected {
    color: var(--warning);
}

.call-item-duration {
    color: var(--text-tertiary);
}

/* ========== ГРУППЫ ========== */
.members-list {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px;
}

.member-item {
    display: flex;
    align-items: center;
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
    position: relative;
}

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

.member-item.selected {
    background: var(--accent-light);
}

.member-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    margin-right: 10px;
    overflow: hidden;
}

.member-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.member-info {
    flex: 1;
}

.member-name {
    font-weight: 500;
    font-size: 13px;
}

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

.check-icon {
    color: var(--success);
    font-size: 16px;
}

/* ========== ПОИСК В ЧАТЕ ========== */
.chat-search-container {
    padding: 10px 20px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 9;
    backdrop-filter: blur(10px);
    animation: slideDown 0.3s ease;
}

.chat-search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-tertiary);
    border-radius: 20px;
    padding: 6px 12px;
}

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

.chat-search-box i {
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 14px;
}

.chat-search-results {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 10px;
    border-radius: 8px;
    background: var(--bg-secondary);
}

/* ========== ЗАГРУЗКА ========== */
.loading-spinner {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.loading-spinner i {
    font-size: 36px;
    margin-bottom: 12px;
    color: var(--accent);
}

/* ========== УЛУЧШЕННЫЕ УВЕДОМЛЕНИЯ ========== */
.toast-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 14px 24px;
    background: var(--bg-primary);
    color: var(--text-primary);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 14px;
    z-index: 5000;
    transform: translateX(400px);
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    max-width: 380px;
    border-left: 6px solid;
    backdrop-filter: blur(10px);
    font-weight: 500;
    animation: toastIn 0.3s ease;
}

.toast-notification.show {
    transform: translateX(0);
}

.toast-success {
    border-left-color: var(--success);
    background: linear-gradient(135deg, var(--bg-primary) 0%, rgba(16, 185, 129, 0.1) 100%);
}
.toast-success i {
    color: var(--success);
    font-size: 24px;
}

.toast-error {
    border-left-color: var(--danger);
    background: linear-gradient(135deg, var(--bg-primary) 0%, rgba(239, 68, 68, 0.1) 100%);
}
.toast-error i {
    color: var(--danger);
    font-size: 24px;
}

.toast-warning {
    border-left-color: var(--warning);
    background: linear-gradient(135deg, var(--bg-primary) 0%, rgba(245, 158, 11, 0.1) 100%);
}
.toast-warning i {
    color: var(--warning);
    font-size: 24px;
}

.toast-info {
    border-left-color: var(--info);
    background: linear-gradient(135deg, var(--bg-primary) 0%, rgba(59, 130, 246, 0.1) 100%);
}
.toast-info i {
    color: var(--info);
    font-size: 24px;
}

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

/* ========== УЛУЧШЕННЫЙ ПОИСК ========== */
.search-highlight {
    background: rgba(245, 158, 11, 0.3);
    color: var(--warning);
    padding: 2px 6px;
    border-radius: 6px;
    font-weight: 600;
    box-shadow: 0 2px 4px rgba(245, 158, 11, 0.2);
}

.search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 4px;
}

.search-result-item:hover {
    background: var(--bg-tertiary);
    transform: translateX(4px);
    box-shadow: var(--shadow);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-sender {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-result-text {
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.5;
}

.search-result-time {
    font-size: 11px;
    color: var(--text-tertiary);
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ========== КОНТАКТЫ ========== */
.contact-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transition: opacity 0.2s;
}

.contact-item:hover .contact-actions {
    opacity: 1;
}

.contact-actions i {
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 18px;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
    background: var(--bg-tertiary);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.contact-actions i:hover {
    color: white;
    background: var(--accent);
    transform: scale(1.1);
    box-shadow: var(--shadow);
}

/* ========== УЛУЧШЕННЫЕ ЧАТЫ ========== */
.chat-item {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

.chat-item:hover {
    transform: translateX(4px) translateY(-2px);
    border-color: var(--accent-light);
    box-shadow: var(--shadow);
}

.chat-item.active {
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent) 100%);
    border-color: var(--accent);
    box-shadow: var(--shadow-lg);
}

.chat-item.active .chat-name,
.chat-item.active .chat-last-message,
.chat-item.active .chat-meta {
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* ========== АНИМАЦИИ ========== */
@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

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

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 0 0 10px rgba(16, 185, 129, 0);
    }
}

.pulse {
    animation: pulse 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== АДАПТИВНОСТЬ ========== */
@media (max-width: 768px) {
    .chats-panel {
        width: 100%;
        position: absolute;
        z-index: 100;
        height: 100%;
    }
    
    .chat-panel {
        width: 100%;
    }
    
    .message {
        max-width: 80%;
    }
    
    .voice-message {
        min-width: 180px;
    }
    
    .voice-recording-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .voice-waveform {
        width: 100%;
        order: -1;
    }
    
    .voice-actions {
        width: 100%;
        justify-content: center;
    }
    
    .chat-bg-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .toast-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        transform: translateY(-200px);
    }
    
    .toast-notification.show {
        transform: translateY(0);
    }
    
    .theme-selector {
        grid-template-columns: 1fr;
    }
    
    .theme-btn {
        padding: 15px;
        flex-direction: row;
        justify-content: flex-start;
    }
    
    .theme-btn i {
        font-size: 24px;
        margin-bottom: 0;
    }
    
    .pinned-item {
        flex-wrap: wrap;
    }
    
    .pinned-sender {
        min-width: 100%;
        margin-bottom: 4px;
    }
    
    .pinned-text {
        width: calc(100% - 40px);
    }
}

@media (max-width: 480px) {
    .chats-header h2 {
        font-size: 18px;
    }
    
    .header-icons {
        gap: 12px;
    }
    
    .chat-avatar {
        width: 40px;
        height: 40px;
    }
    
    .input-area {
        padding: 10px;
        gap: 8px;
    }
    
    .voice-record-btn {
        width: 40px;
        height: 40px;
    }
    
    .chat-bg-grid {
        grid-template-columns: 1fr;
    }
    
    .toast-notification {
        padding: 12px 16px;
        font-size: 13px;
    }
    
    .contact-actions {
        opacity: 1;
    }
    
    .contact-actions i {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .pinned-header {
        font-size: 12px;
    }
    
    .search-result-item {
        padding: 10px 12px;
    }
    
    .search-result-sender {
        font-size: 11px;
    }
    
    .search-result-text {
        font-size: 13px;
    }
}

/* ========== УТИЛИТЫ ========== */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
