/* ===== АБСОЛЮТНЫЙ МИНИМУМ ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    width: 100%;
    height: 100%;
    background: #0b1a25;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    overflow: hidden;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

body {
    display: flex;
    justify-content: center;
    align-items: center;
}

.chat {
    width: 100%;
    max-width: 900px;
    height: 100%;
    background: #12232e;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@media (min-width: 768px) {
    html, body {
        position: static;
    }
    body { padding: 20px; }
    .chat { height: 90vh; border-radius: 24px; border: 1px solid #2a404e; }
}

/* ===== ХЕДЕР ===== */
.header {
    padding: 8px 16px;
    background: #0e1c26;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #2e4a5a;
    flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 8px; }
.header-right { display: flex; align-items: center; }

.header-btn {
    background: none; border: none; color: white; font-size: 1.6rem;
    cursor: pointer; padding: 8px; border-radius: 50%; width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
}

.online { font-size: 1.2rem; }
.unread-badge { background: #ff3b30; color: white; border-radius: 50px; padding: 2px 8px; font-size: 0.75rem; display: none; }

/* ===== СООБЩЕНИЯ ===== */
.messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #0e1a22;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.messages::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
}

.empty {
    color: #6f9faf;
    text-align: center;
    padding: 30px;
    font-style: italic;
}

/* ===== СООБЩЕНИЕ ===== */
.message {
    max-width: 85%;
    display: flex;
    flex-direction: column;
}

.my-message {
    align-self: flex-end;
}

.bubble {
    background: #1e3a47;
    color: white;
    padding: 10px 14px;
    border-radius: 18px 18px 4px 18px;
    word-break: break-word;
    display: inline-block;
    max-width: 100%;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.my-message .bubble {
    background: #005c4b;
    border-radius: 18px 18px 18px 4px;
}

.meta {
    font-size: 0.65rem;
    color: #a0c0d0;
    margin-top: 4px;
    padding-left: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.my-message .meta {
    justify-content: flex-end;
    padding-right: 6px;
}

.message.unread .bubble {
    border: 2px solid #ffcc00;
}

.message.removing {
    animation: fadeOut 0.2s ease;
}

@keyframes fadeOut {
    to { opacity: 0; transform: translateX(10px); }
}

/* ===== ИЗОБРАЖЕНИЯ И ФАЙЛЫ ===== */
.chat-image {
    max-width: 200px;
    max-height: 160px;
    border-radius: 12px;
    margin-top: 4px;
    border: 1px solid #3d7a8c;
    cursor: pointer;
}

.file-attachment {
    display: flex; align-items: center; gap: 8px;
    background: rgba(255,255,255,0.1); padding: 8px 12px;
    border-radius: 12px; margin-top: 4px; max-width: 250px; cursor: pointer;
}
.file-icon { font-size: 1.5rem; }
.file-info { flex: 1; overflow: hidden; }
.file-name { font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 0.65rem; opacity: 0.7; }

/* ===== РЕАКЦИИ ===== */
.reactions {
    display: flex; align-items: center; gap: 4px; margin-top: 2px;
    padding: 2px 4px; background: rgba(255,255,255,0.05);
    border-radius: 50px; width: fit-content;
}
.my-message .reactions { margin-left: auto; }
.reaction-btn {
    background: none; border: none; font-size: 0.9rem; cursor: pointer;
    padding: 3px 6px; border-radius: 50px; color: #a0c0d0;
    display: flex; align-items: center; gap: 3px;
}
.reaction-btn.active { background: rgba(255,255,255,0.1); color: white; }
.reaction-btn.like.active { color: #4caf50; }
.reaction-btn.dislike.active { color: #ff6b6b; }
.reaction-count { font-size: 0.7rem; min-width: 14px; text-align: center; }

/* ===== КНОПКА УДАЛЕНИЯ - УБИРАЕМ ===== */
.delete-btn {
    display: none;
}

/* ===== ПРЕВЬЮ ФАЙЛОВ ===== */
.preview-area {
    background: #0e1c26; padding: 12px 16px; border-top: 1px solid #2a4a5a;
    display: none; flex-shrink: 0;
}
.preview-box {
    display: flex; align-items: center; gap: 12px; background: #1a2f3a;
    padding: 8px 12px; border-radius: 16px; flex-wrap: wrap;
}
.preview-img { max-width: 60px; max-height: 50px; border-radius: 8px; object-fit: cover; }
.remove-preview {
    background: none; border: none; color: #ffa098; font-size: 1.3rem;
    cursor: pointer; padding: 0 6px; margin-left: auto;
}

/* ===== ПОЛЕ ВВОДА ===== */
.input-row {
    display: flex; gap: 8px; padding: 12px 16px; background: #0e1c26;
    flex-shrink: 0; border-top: 1px solid #2a4a5a; align-items: flex-end;
}
.attach-btn {
    background: none; border: none; color: #a0c0d0; font-size: 1.5rem;
    cursor: pointer; padding: 8px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
textarea {
    flex: 1; background: #1a2f3c; border: 1px solid #3a5f6e;
    border-radius: 24px; padding: 10px 16px; color: white; font-size: 16px;
    resize: none; outline: none; min-height: 46px;
}
.send-btn {
    background: #0078ff; border: none; color: white; font-weight: 700;
    padding: 0 20px; border-radius: 30px; font-size: 1rem;
    cursor: pointer; height: 46px; flex-shrink: 0;
}
#fileInput { display: none; }

/* ===== ПЛАВАЮЩИЙ ПОИСК ===== */
.floating-search {
    position: sticky; top: 0; width: 100%;
    background: #0e1c26;
    padding: 12px 16px;
    display: none;
    align-items: center;
    gap: 12px;
    z-index: 100;
    border-bottom: 1px solid #2e4a5a;
    flex-shrink: 0;
}
.floating-search.show { display: flex; }
.search-container {
    flex: 1; display: flex; align-items: center; background: #1a2f3c;
    border-radius: 24px; padding: 0 16px; border: 1px solid #3a5f6e;
}
.search-icon { color: #a0c0d0; margin-right: 8px; }
#searchInput {
    flex: 1; background: none; border: none; padding: 12px 0;
    color: white; font-size: 16px; outline: none;
}
.clear-search-btn {
    background: none; border: none; color: #a0c0d0; font-size: 1.2rem;
    cursor: pointer; padding: 4px 8px; display: none;
}
.clear-search-btn.show { display: block; }
.search-navigation {
    display: flex; align-items: center; gap: 8px; background: #1a2f3c;
    border-radius: 24px; padding: 4px;
}
#searchResultsCount { color: white; font-size: 0.85rem; padding: 0 8px; min-width: 60px; text-align: center; }
.nav-arrow {
    background: none; border: none; color: white; font-size: 1.1rem;
    cursor: pointer; padding: 6px 10px; border-radius: 50%;
}

/* ===== ПРАВОЕ МЕНЮ (ТОЛЬКО ОДНА ВЕРСИЯ!) ===== */
/* ===== ПРАВОЕ МЕНЮ ===== */
.menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    /* backdrop-filter: blur(3px);  ← ПОЛНОСТЬЮ УБИРАЕМ! */
    z-index: 3000;
    display: none;
}

.menu-overlay.show {
    display: block;
}

.side-menu {
    position: absolute;
    top: 0;
    right: -85%;
    width: 85%;
    max-width: 380px;
    height: 100%;
    background: #0e1c26;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5);
    transition: right 0.25s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.menu-overlay.show .side-menu {
    right: 0;
}

/* ХЕДЕР МЕНЮ — КРЕСТИК */
.menu-header {
    padding: 20px 16px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    border-bottom: 1px solid #2e4a5a;
}

.close-menu-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.close-menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* ПРОФИЛЬ В МЕНЮ */
.user-profile {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid #2e4a5a;
    cursor: pointer;
    transition: 0.2s;
}

.user-profile:hover {
    background: rgba(255, 255, 255, 0.05);
}

.user-avatar {
    width: 60px;
    height: 60px;
    background: #1e3a47;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid #0078ff;
}

.avatar-emoji {
    font-size: 2rem;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-name {
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
}

.user-phone {
    color: #a0c0d0;
    font-size: 0.85rem;
    text-decoration: none;
}

.user-status {
    font-size: 0.75rem;
    color: #a0c0d0;
    font-style: italic;
}

/* СТАТИСТИКА */
.stats-section {
    padding: 20px 16px;
    display: flex;
    justify-content: space-around;
    border-bottom: 1px solid #2e4a5a;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.stat-label {
    color: #a0c0d0;
    font-size: 0.75rem;
}

.stat-value {
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
}

/* КНОПКИ МЕНЮ */
.menu-actions {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.menu-action-btn {
    background: #1a2f3c;
    border: none;
    border-radius: 12px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
    transition: 0.2s;
    width: 100%;
    color: white;
}

.menu-action-btn:hover {
    background: #1e3640;
    transform: scale(1.02);
}

.menu-action-btn:active {
    transform: scale(0.98);
}

.action-icon {
    font-size: 1.3rem;
    width: 24px;
    text-align: center;
}

.action-text {
    font-size: 1rem;
    font-weight: 500;
}

/* Кнопка выхода */
.menu-action-btn.logout {
    background: rgba(255, 80, 80, 0.1);
    border: 1px solid rgba(255, 80, 80, 0.2);
    margin-top: 8px;
}

.menu-action-btn.logout:hover {
    background: rgba(255, 80, 80, 0.2);
}

.menu-action-btn.logout .action-text {
    color: #ff6b6b;
}

/* Адаптация */
@media (max-width: 480px) {
    .side-menu {
        width: 85%;
        right: -85%;
    }
    
    .user-avatar {
        width: 54px;
        height: 54px;
    }
    
    .user-name {
        font-size: 1.1rem;
    }
    
    .stat-value {
        font-size: 1.1rem;
    }
    
    .menu-action-btn {
        padding: 12px 16px;
    }
}

/* ===== КОНТЕКСТНОЕ МЕНЮ ===== */
.context-menu {
    position: fixed;
    background: #1a2f3c;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    border: 1px solid #3a5f6e;
    z-index: 10000;
    min-width: 240px;
    max-width: 280px;
    display: none;
}

.context-menu.show {
    display: block;
}

.context-menu-header {
    padding: 16px;
    border-bottom: 1px solid #2e4a5a;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.context-menu-title {
    color: white;
    font-size: 1rem;
    font-weight: 600;
}

.close-context-menu {
    background: none;
    border: none;
    color: #a0c0d0;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 50%;
}

.context-menu-items {
    padding: 8px;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: 0.2s;
    color: white;
}

.context-menu-item:hover {
    background: rgba(255,255,255,0.1);
}

.context-menu-item.delete-action .item-text {
    color: #ff6b6b;
}

.item-icon {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.item-text {
    font-size: 0.95rem;
    flex: 1;
}

/* ===== TOAST УВЕДОМЛЕНИЯ ===== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 0.95rem;
    z-index: 10001;
    opacity: 0;
    transition: 0.3s;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ===== ИНДИКАТОР ОТВЕТА ===== */
.reply-indicator {
    background: rgba(255,255,255,0.1);
    border-left: 4px solid #0078ff;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.reply-sender {
    color: #0078ff;
    font-weight: 600;
    margin-bottom: 4px;
}

.reply-text {
    color: #a0c0d0;
    font-style: italic;
}

.message.selected .bubble {
    border: 2px solid #0078ff;
    background: rgba(0,120,255,0.1);
}

.message.pinned .bubble {
    border: 2px solid #ffc107;
    position: relative;
}

.message.pinned .bubble::before {
    content: "📌";
    position: absolute;
    top: -10px;
    left: -10px;
    background: #ffc107;
    color: #1e2a36;
    padding: 4px;
    border-radius: 50%;
    font-size: 0.8rem;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ===== ГАЛЕРЕЯ ===== */
.modal {
    display: none; position: fixed; z-index: 9999; top: 0; left: 0;
    width: 100%; height: 100%; background: black;
}
.modal.show { display: flex; justify-content: center; align-items: center; }
.modal-content { position: relative; width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; }
.modal-image { max-width: 100%; max-height: 100%; object-fit: contain; }
.close-btn {
    position: absolute; top: 20px; right: 20px; color: white; font-size: 30px;
    width: 44px; height: 44px; background: rgba(0,0,0,0.5); border-radius: 50%;
    display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.nav-btn {
    position: absolute; top: 50%; transform: translateY(-50%);
    background: rgba(0,0,0,0.5); color: white; border: none; width: 44px;
    height: 44px; border-radius: 50%; font-size: 24px; cursor: pointer;
}
.prev-btn { left: 20px; }
.next-btn { right: 20px; }
.image-counter {
    position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
    color: white; background: rgba(0,0,0,0.6); padding: 6px 16px;
    border-radius: 50px; font-size: 14px;
}

.search-highlight { background: #ffc107; color: #1e2a36; padding: 2px 4px; border-radius: 4px; font-weight: 600; }
.search-highlight.current { background: #ff9500; color: white; box-shadow: 0 0 10px rgba(255,149,0,0.5); }
.phone-badge, .logout-btn, .clear-chat-btn { display: none !important; }

/* ===== ФИКС ДЛЯ iOS PWA ===== */
.ios-pwa-fix {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: env(safe-area-inset-top);
    background: #0e1c26;
    z-index: 10000;
    display: none;
    pointer-events: none;
}

@media (display-mode: standalone) {
    body {
        background: #0b1a25;
    }
    
    .chat,
    .contacts-container,
    .profile-container {
        border-radius: 0 !important;
    }
    
    .ios-pwa-fix {
        display: block;
    }
}

@supports (padding-top: env(safe-area-inset-top)) {
    .chat {
        padding-top: env(safe-area-inset-top);
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .header {
        padding-top: max(8px, env(safe-area-inset-top)) !important;
        padding-left: max(16px, env(safe-area-inset-left)) !important;
        padding-right: max(16px, env(safe-area-inset-right)) !important;
    }
    
    .messages {
        padding-top: max(16px, env(safe-area-inset-top)) !important;
        padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
        padding-left: max(16px, env(safe-area-inset-left)) !important;
        padding-right: max(16px, env(safe-area-inset-right)) !important;
    }
    
    .input-row {
        padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
        padding-left: max(16px, env(safe-area-inset-left)) !important;
        padding-right: max(16px, env(safe-area-inset-right)) !important;
    }
}

/* ===== КНОПКИ ЗВОНКОВ ===== */
#audioCallBtn, #videoCallBtn {
    font-size: 1.3rem;
    margin-right: 4px;
}

#audioCallBtn:hover, #videoCallBtn:hover {
    background: rgba(0,120,255,0.2);
}

/* ===== ИНДИКАТОР ЗВОНКА ===== */
.call-indicator {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #1a2f3c;
    border: 1px solid #0078ff;
    border-radius: 50px;
    padding: 12px 24px;
    color: white;
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 10001;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5);
    animation: slideDown 0.3s ease;
}

.call-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #1e3a47;
    display: flex;
    align-items: center;
    justify-content: center;
}

.call-info {
    display: flex;
    flex-direction: column;
}

.call-name {
    font-weight: 600;
}

.call-status {
    font-size: 0.8rem;
    color: #4caf50;
}

.call-actions {
    display: flex;
    gap: 12px;
    margin-left: 20px;
}

.call-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.call-accept {
    background: #4caf50;
    color: white;
}

.call-decline {
    background: #ff3b30;
    color: white;
}

/* ===== МОДАЛЬНОЕ ОКНО ЗВОНКА ===== */
.call-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 10002;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.call-modal.show {
    display: flex;
}

.local-video {
    position: absolute;
    bottom: 100px;
    right: 20px;
    width: 150px;
    height: 200px;
    background: #1a2f3c;
    border-radius: 16px;
    border: 2px solid #0078ff;
    object-fit: cover;
}

.remote-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: black;
}

.call-controls {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    background: rgba(0,0,0,0.7);
    padding: 16px 24px;
    border-radius: 50px;
    backdrop-filter: blur(10px);
}

.control-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: #4a5c66;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.control-btn:hover {
    transform: scale(1.1);
}

.control-btn.end-call {
    background: #ff3b30;
}

.control-btn.mute.active {
    background: #ff3b30;
}

.control-btn.video.active {
    background: #0078ff;
}

/* ===== ФИКС ДЛЯ ТЕЛЕФОНОВ ===== */
@media (max-width: 480px) {
    .side-menu {
        width: 85% !important;
        right: -85% !important;
    }
    
    .user-avatar {
        width: 54px !important;
        height: 54px !important;
    }
    
    .menu-action-btn {
        padding: 12px 16px !important;
    }
    
    /* Фикс для аватарки */
    .user-avatar img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
    }
}

/* ===== ЖЁСТКИЙ ФИКС ДЛЯ ТЕЛЕФОНОВ ===== */
@media (max-width: 768px) {
    .side-menu {
        width: 85% !important;
        right: -85% !important;
    }
    
    .user-avatar {
        width: 60px !important;
        height: 60px !important;
        min-width: 60px !important;
    }
    
    .user-avatar img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover !important;
        border-radius: 50% !important;
    }
    
    .menu-action-btn {
        padding: 14px 16px !important;
    }
}

/* ===== ЖЁСТКИЙ ФИКС ДЛЯ ТЕЛЕФОНОВ ===== */
@media (max-width: 768px) {
    .menu-overlay {
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    
    .side-menu {
        width: 85% !important;
        right: -85% !important;
    }
    
    .menu-overlay.show .side-menu {
        right: 0 !important;
    }
    
    /* Убираем все анимации на телефонах */
    .side-menu {
        transition: right 0.2s ease-out !important;
    }
}


/* ===== КОНТЕКСТНОЕ МЕНЮ ===== */
.context-menu {
    position: fixed;
    background: #1a2f3c;
    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    border: 1px solid #3a5f6e;
    z-index: 10000;
    min-width: 240px;
    max-width: 280px;
    display: none;
}

.context-menu.show {
    display: block;
}

.context-menu-header {
    padding: 16px;
    border-bottom: 1px solid #2e4a5a;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.context-menu-title {
    color: white;
    font-size: 1rem;
    font-weight: 600;
}

.close-context-menu {
    background: none;
    border: none;
    color: #a0c0d0;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 50%;
}

.context-menu-items {
    padding: 8px;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: 0.2s;
    color: white;
}

.context-menu-item:hover {
    background: rgba(255,255,255,0.1);
}

.item-icon {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.item-text {
    font-size: 0.95rem;
    flex: 1;
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 0.95rem;
    z-index: 10001;
    opacity: 0;
    transition: 0.3s;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}



/* ===== ИНДИКАТОР ОТВЕТА ===== */
.reply-indicator {
    background: rgba(255,255,255,0.1);
    border-left: 4px solid #0078ff;
    padding: 8px 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 0.85rem;
}

.reply-sender {
    color: #0078ff;
    font-weight: 600;
    margin-bottom: 4px;
}

.reply-text {
    color: #a0c0d0;
    font-style: italic;
}

/* ===== TOAST ===== */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: rgba(0,0,0,0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 0.95rem;
    z-index: 10001;
    opacity: 0;
    transition: 0.3s;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}


/* ===== КНОПКА ДОБАВЛЕНИЯ В КОНТАКТЫ ===== */
.add-contact-chat-btn {
    background: #0078ff;
    border: none;
    color: white;
    padding: 6px 16px;
    border-radius: 50px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    margin-left: 12px;
    white-space: nowrap;
    transition: 0.2s;
}

.add-contact-chat-btn:hover {
    background: #0066dd;
    transform: scale(1.05);
}

.add-contact-chat-btn:active {
    transform: scale(0.95);
}


.avatar-menu {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: 0.2s;
}

.avatar-menu:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

.avatar-small {
    width: 40px;
    height: 40px;
    background: #1e3a47;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid #0078ff;
}

.avatar-small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-emoji {
    font-size: 1.5rem;
}

/* ===== ЖЁСТКИЙ ФИКС ДЛЯ МЕНЮ ===== */
.menu-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    background: rgba(0, 0, 0, 0.7) !important;
    z-index: 9999 !important;
    display: none !important;
}

.menu-overlay.show {
    display: block !important;
}

.side-menu {
    position: fixed !important;
    top: 0 !important;
    right: -85% !important;
    width: 85% !important;
    max-width: 380px !important;
    height: 100% !important;
    background: #0e1c26 !important;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5) !important;
    transition: right 0.25s ease !important;
    display: flex !important;
    flex-direction: column !important;
    overflow-y: auto !important;
}

.menu-overlay.show .side-menu {
    right: 0 !important;
}

/* ===== АВАТАР СОБЕСЕДНИКА = КЛИКАБЕЛЬНЫЙ ===== */
#chatAvatar {
    cursor: pointer;
    transition: 0.2s;
}

#chatAvatar:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

/* ===== ИНДИКАТОР "ПЕЧАТАЕТ" ===== */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50px;
    margin: 8px 0;
    width: fit-content;
    animation: fadeIn 0.3s ease;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: #0078ff;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }
.typing-dot:nth-child(3) { animation-delay: 0s; }

.typing-text {
    color: #a0c0d0;
    font-size: 0.85rem;
    font-style: italic;
}

@keyframes typing {
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.5; }
    40% { transform: scale(1.2); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ===== УЛУЧШЕННЫЕ МОДАЛЬНЫЕ ОКНА ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(5px);
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-image {
    max-width: 95%;
    max-height: 95%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
}

/* КРЕСТИК вместо стрелки */
.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 30px;
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    transition: 0.2s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* Стрелки навигации */
.nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-50%) scale(1.1);
}

.prev-btn {
    left: 20px;
}

.next-btn {
    right: 20px;
}

.image-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 20px;
    border-radius: 50px;
    font-size: 14px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ===== КНОПКА "ДОБАВИТЬ В КОНТАКТЫ" ДЛЯ НЕЗНАКОМЦЕВ ===== */
.add-contact-chat-btn {
    background: linear-gradient(135deg, #0078ff, #00a8ff);
    border: none;
    color: white;
    padding: 8px 20px;
    border-radius: 50px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    margin-left: 12px;
    white-space: nowrap;
    transition: 0.2s;
    box-shadow: 0 4px 12px rgba(0, 120, 255, 0.3);
}

.add-contact-chat-btn:hover {
    background: linear-gradient(135deg, #0066dd, #0090e0);
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 120, 255, 0.4);
}

.add-contact-chat-btn:active {
    transform: scale(0.95);
}

/* ===== АНИМАЦИЯ НОВЫХ СООБЩЕНИЙ ===== */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.new {
    animation: slideIn 0.3s ease;
}

/* ===== ПЛАВНЫЙ СКРОЛЛ ===== */
.messages {
    scroll-behavior: smooth;
}

/* ===== ФИКС ДЛЯ iOS SAFE-AREA ===== */
@supports (padding-top: env(safe-area-inset-top)) {
    .header {
        padding-top: max(8px, env(safe-area-inset-top)) !important;
    }
    
    .messages {
        padding-top: max(16px, env(safe-area-inset-top)) !important;
        padding-bottom: max(16px, env(safe-area-inset-bottom)) !important;
    }
    
    .input-row {
        padding-bottom: max(12px, env(safe-area-inset-bottom)) !important;
    }
}

/* ===== КНОПКА "ДОБАВИТЬ В КОНТАКТЫ" ===== */
.add-contact-chat-btn {
    background: rgba(0, 120, 255, 0.2);
    border: 1px solid rgba(0, 120, 255, 0.5);
    color: #0078ff;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 12px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.add-contact-chat-btn:hover {
    background: rgba(0, 120, 255, 0.3);
    transform: scale(1.05);
}

.add-contact-chat-btn:active {
    transform: scale(0.95);
}

/* ===== МОДАЛЬНОЕ ОКНО НАСТРОЕК ЧАТА ===== */
#chatSettingsModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

#chatSettingsModal .modal-content {
    background: #1e3a47;
    border-radius: 16px;
    padding: 0;
    overflow: hidden;
    max-width: 400px;
    width: 100%;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #2e4a5a;
}

.modal-header h3 {
    margin: 0;
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
}

.modal-header .close-btn {
    background: none;
    border: none;
    color: #a0c0d0;
    font-size: 1.5rem;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: 0.2s;
}

.modal-header .close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.modal-body {
    padding: 20px;
}

.settings-section {
    margin-bottom: 24px;
}

.settings-section h4 {
    color: #a0c0d0;
    margin: 0 0 12px 0;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.settings-action-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 8px;
    text-align: left;
    font-family: inherit;
}

.settings-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.settings-action-btn:active {
    transform: translateY(0);
}

.settings-action-btn .action-icon {
    font-size: 1.2rem;
    min-width: 24px;
}

.settings-action-btn .action-text {
    flex: 1;
}

.toggle-setting {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.toggle-setting:last-child {
    border-bottom: none;
}

.toggle-setting span {
    color: white;
    font-size: 1rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #2e4a5a;
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #0078ff;
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* ===== КНОПКИ ЗВОНКОВ И НАСТРОЕК В ХЕДЕРЕ ===== */
.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-right: 12px;
}

.call-btn, .settings-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.call-btn:hover, .settings-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
}

.call-btn:active, .settings-btn:active {
    transform: scale(0.95);
}

.call-btn {
    color: #4caf50;
}

.settings-btn {
    color: #a0c0d0;
}

.call-btn.audio {
    color: #2196f3;
}

.call-btn.video {
    color: #f44336;
}

/* ===== КЛИК НА АВАТАРКУ СОБЕСЕДНИКА ===== */
#chatAvatar {
    cursor: pointer;
    transition: transform 0.2s;
}

#chatAvatar:hover {
    transform: scale(1.05);
}

#chatAvatar:active {
    transform: scale(0.95);
}

/* ===== АВАТАРКА В ХЕДЕРЕ ===== */
.avatar-menu {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: 0.2s;
    margin-left: 8px;
}

.avatar-menu:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

.avatar-menu:active {
    transform: scale(0.95);
}

.avatar-small {
    width: 44px;
    height: 44px;
    background: #1e3a47;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 2px solid #0078ff;
}

.avatar-small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-emoji {
    font-size: 1.6rem;
}

.avatar-emoji-small {
    font-size: 1.2rem;
}

/* ===== КНОПКА НАЗАД ===== */
.back-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.8rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.back-btn:hover {
    background: rgba(255,255,255,0.1);
    transform: scale(1.05);
}

.back-btn:active {
    transform: scale(0.95);
}

/* ===== ИНФОРМАЦИЯ О ЧАТЕ ===== */
.chat-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    cursor: pointer;
    transition: opacity 0.2s;
}

.chat-info:hover {
    opacity: 0.8;
}

.chat-avatar-small {
    width: 40px;
    height: 40px;
    min-width: 40px;
    max-width: 40px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid #0078ff;
    background: #1e3a47;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-avatar-small img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.chat-name {
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.chat-status {
    color: #a0c0d0;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

/* ===== ОТЗЫВЧИВОСТЬ ===== */
@media (max-width: 768px) {
    .chat-name {
        max-width: 150px;
    }
    
    .chat-status {
        max-width: 150px;
    }
    
    .header-actions {
        gap: 4px;
        margin-right: 8px;
    }
    
    .call-btn, .settings-btn {
        width: 36px;
        height: 36px;
        font-size: 1.2rem;
    }
    
    .avatar-small {
        width: 40px;
        height: 40px;
    }
    
    .back-btn {
        width: 40px;
        height: 40px;
        font-size: 1.6rem;
    }
}

@media (max-width: 480px) {
    .chat-name {
        max-width: 120px;
    }
    
    .chat-status {
        max-width: 120px;
    }
    
    .chat-avatar-small {
        width: 36px;
        height: 36px;
        min-width: 36px;
        max-width: 36px;
    }
    
    .add-contact-chat-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
        margin-left: 8px;
    }
}
