:root {
    --primary: #0088cc;
    --secondary: #f0f0f0;
    --background: #ffffff;
    --text-primary: #000000;
    --text-secondary: #707579;
    --border: #e7e7e7;
    --chat-background: #f5f5f5;
    --accent: #00af9c;
    --hover: #f5f5f5;
    --message-out: #e3f2fd;
    --message-in: #ffffff;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    --call-accept: #4CAF50;
    --call-decline: #F44336;
    --light-active:#eaf6ff;
    --light-active-hover:#007bff;
    --background-color: #f9f9f9;
    --border-color: #ddd;
    --box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    --btn-bg-color: #007bff;
    --btn-text-color: #fff;
    --btn-hover-color: #0056b3;
    --btn-active-color: #004085;
    --btn-border-color: #e0e0e0;    /* Светлая граница */
    --btn-hover-bg: #f5f5f5;        /* Фон при наведении */
    --btn-active-bg: #e9e9e9;       /* Фон при нажатии */
}


@media (prefers-color-scheme: dark) {
    :root {
        --primary: #2b5278;
        --secondary: #182533;
        --background: #17212b;
        --text-primary: #e6e6e6;
        --text-secondary: #7b8a98;
        --chat-background: #7b8a98;
        --border: #1f2c38;
        --accent: #00af9c;
        --hover: #1f2c38;
        --message-out: #2b5278;
        --message-in: #0e181d;
        --light-active:#1f2c38;
        --light-active-hover:#1e90ff;
        --background-color: #2e2e2e;  /* Темный фон */
        --border-color: #444;        /* Темная граница */
        --box-shadow: 0 2px 5px rgba(255, 255, 255, 0.1);
        --btn-bg-color: #4a90e2;     /* Голубоватая кнопка */
        --btn-text-color: #eaeaea;   /* Текст на кнопке */
        --btn-hover-color: #357abd;  /* Синий оттенок при наведении */
        --btn-active-color: #2a5d9e; /* Темно-синий при нажатии */
        --font-color: #f5f5f5;       /* Светлый шрифт на темном фоне */
        --dark-bg-color: #121212;
        --dark-btn-text-color: #ffffff;
        --dark-border-color: #333;
        --dark-hover-bg: #1e1e1e;
        --dark-active-bg: #2a2a2a;

    }
}

/* Для всех стандартных браузеров с поддержкой WebKit */
::-webkit-scrollbar {
    width: 12px; /* Ширина полосы прокрутки */
}

::-webkit-scrollbar-track {
    background: transparent; /* Прозрачный трек */
}

::-webkit-scrollbar-thumb {
    background-color: rgba(100, 100, 100, 0.5); /* Цвет и прозрачность ползунка */
    border-radius: 6px; /* Скругленные углы */
    border: 2px solid transparent; /* Добавление отступа вокруг ползунка */
}

::-webkit-scrollbar-thumb:hover {
    background-color: rgba(100, 100, 100, 0.7); /* Изменение прозрачности при наведении */
}



* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Скрываем стандартные элементы браузера */
@media all and (display-mode: standalone) {
    body {
        padding-top: env(safe-area-inset-top);
    }
}


body {
    background-color: var(--secondary);
    color: var(--text-primary);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s;
}

.no-contacts {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-size: 16px;
    font-style: italic;
}

/* Основной фон-заглушка для загрузки */
.loading-overlay {
    position: fixed; /* Абсолютное позиционирование относительно экрана */
    top: 0;
    left: 0;
    width: 100vw; /* На весь экран по ширине */
    height: 100vh; /* На весь экран по высоте */
    background: #dcdcdc; /* Полупрозрачный тёмный фон */
    display: flex; /* Идеальное центрирование спиннера */
    align-items: center;
    justify-content: center;
    z-index: 99999; /* Самый высокий уровень отображения */
}

/* Сам круг спиннера */
.loading-spinner {
    width: 80px;
    height: 80px;
    border: 8px solid rgba(255, 255, 255, 0.2); /* Полупрозрачная часть круга */
    border-top: 8px solid white; /* Непрозрачный белый сектор */
    border-radius: 50%; /* Делает элемент круглым */
    animation: spin 1.2s linear infinite; /* Анимация вращения */
}

/* Анимация вращения */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}


.container {
    display: flex; /* Выстраиваем sidebar и chat-area горизонтально */
    width: 100%;
    height: 100%;
    background-color: var(--background);
}

/* Общий контейнер авторизации */
.auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--secondary);
    padding: 20px;
    box-sizing: border-box;
}

/* Контейнер описания */
.app-description {
    text-align: center;
    padding: 25px;
    background: #388CFB;
    color: white;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    max-width: 650px;
    width: 100%;
    animation: fadeIn 0.8s ease;
    position: relative;
    overflow: hidden;
}

/* Иконка галочки перед пунктами */
.app-description ul li::before {
    content: '✔';
    font-size: 18px;
    margin-right: 8px;
    color: var(--background);
}

/* Заголовок */
.app-description h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 20px;
}

/* Пояснительный текст */
.app-description p {
    font-size: 16px;
    line-height: 1.8;
    margin-bottom: 20px;
    color: rgba(255, 255, 255, 0.9);
}

/* Маркированный список */
.app-description ul {
    text-align: left;
    margin: 0 auto;
    list-style: none;
    padding: 0;
    max-width: 500px;
}

.app-description ul li {
    font-size: 16px;
    margin-bottom: 12px;
    color: white;
    line-height: 1.6;
}

/* Формы */
.auth-form-wrapper {
    display: flex; /* Используем flexbox-расположение */
    flex-direction: row; /* Располагаем блоки (дети) в строку слева направо */
    align-items: flex-start; /* Выравниваем элементы по верхнему краю */
    justify-content: space-between; /* Добавляем равномерное расстояние между блоками */
    width: 100%;
    max-width: 800px; /* Общая ширина */
    background: var(--background);
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    animation: fadeIn 1s ease;
    gap: 20px; /* Расстояние между формами */
}

/* Если в мобильной версии нужно перейти к вертикальному расположению */
@media (max-width: 768px) {
    .auth-form-wrapper {
        flex-direction: column; /* Вертикальное расположение на узких экранах */
        align-items: center; /* Центрируем блоки */
        gap: 15px; /* Уменьшаем промежуток между элементами */
    }
}


/* Заголовок формы */
.auth-form h2 {
    text-align: center;
    color: var(--primary);
    margin-bottom: 20px;
    font-size: 24px;
}

/* Поля форм */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    background-color: var(--secondary);
    color: var(--text-primary);
    transition: border-color 0.3s ease, background-color 0.3s ease;
}

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

/* Кнопка */
.btn-primary {
    width: 100%;
    padding: 12px;
    background-color: var(--primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

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

/* Ссылки для переключения между авторизацией и регистрацией */
.auth-switch {
    margin-top: 15px;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-switch a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
}

.auth-switch a:hover {
    color: var(--accent);
}

/* Мобильные стили */
@media (max-width: 768px) {
    .app-description {
        padding: 20px;
    }

    .auth-form-wrapper {
        padding: 15px;
    }
}


/* Call UI */
.call-container {
    position: relative;
    /*top: 0;*/
    /*left: 0;*/
    /*right: 0;*/
    /*bottom: 0;*/
    background-color: #000;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: white;
    /*width: 800px;*/
    min-width: 550px
}

.call-info {
    text-align: center;
    margin-bottom: 30px;
}

.caller-name {
    font-size: 24px;
    margin-bottom: 10px;
}

.call-status {
    font-size: 16px;
    opacity: 0.8;
}

.call-actions {
    display: flex;
    gap: 20px;
    padding: 10px;
    justify-content: center;
}

.call-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    cursor: pointer;
    border: none;
}

.call-controls {
    position: absolute;
    /*display: flex;*/
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 999;
}

.call-accept {
    background-color: var(--call-accept);
    color: white;
}

.call-decline {
    background-color: var(--call-decline);
    color: white;
}

.call-end {
    background-color: var(--call-decline);
    color: white;
}

.call-mute, .call-speaker {
    background-color: rgba(255, 255, 255, 0.2);
    color: white;
}

.video-container {
    width: 100%;
    height: 100%;
    /*margin-bottom: 20px;*/
    position: relative;
    display: flex;
}

/* Контейнер для настроек */
.settings-container {
    flex: 1;
    overflow-y: auto;
}

/* Кнопки настроек */
.settings-btn {
    background: var(--background);
    padding: 12px 15px;
    display: flex;
    align-items: center;
    /* border-bottom: 1px solid var(--border); */
    cursor: pointer;
    transition: background-color 0.3s, border-color 0.3s;
    width: 100%;
    border: none;
    font-size: 15px;
}

.settings-btn:first-child {
    border-top: none; /* Убираем разделитель у первой кнопки */
}

.settings-btn:hover {
    background-color: var(--btn-hover-bg); /* Лёгкий фон при наведении */
}

.settings-btn:active {
    background-color: var(--btn-active-bg); /* Дефолтный фон при нажатии */
}


/* Общий стиль контейнера профиля */
.profile-area {
    background-color: #fff; /* Белый фон */
    padding: 20px;
    border-radius: 10px; /* Закругление углов */
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1); /* Нежная тень */
    max-width: 350px;
    margin: 20px auto; /* Центрирование */
    font-family: Arial, sans-serif;
}

/* Стиль шапки профиля */
.profile-header {
    display: flex;
    align-items: center; /* Выравнивание элементов по центру */
    margin-bottom: 20px;
}

/* Фото профиля */
.profile-photo-container {
    width: 80px;
    height: 80px;
    margin-right: 15px; /* Отступ справа */
}
.profile-photo {
    width: 100%; /* Фото занимает контейнер */
    height: 100%;
    object-fit: cover; /* Обрезка изображения при необходимости */
    border-radius: 50%; /* Круглая форма */
    border: 2px solid #ddd; /* Лёгкая рамка */
}

/* Информация о профиле */
.profile-info {
    flex-grow: 1; /* Расширение, чтобы занять оставшееся пространство */
}
.profile-name {
    font-size: 20px; /* Крупное имя */
    font-weight: bold;
    margin: 0; /* Убираем отступы */
    color: #000;
}
.profile-status {
    font-size: 14px; /* Маленький статус */
    color: #777; /* Серый цвет */
    margin: 5px 0 0; /* Отступ сверху */
}

/* Кнопки в блоке действий */
.profile-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px; /* Расстояние между кнопками */
}
.profile-btn {
    all: unset; /* Сбрасываем стандартные стили */
    display: block;
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd; /* Линии между кнопками */
    border-radius: 5px;
    text-align: center; /* Текст по центру кнопки */
    font-size: 14px;
    color: #007bff; /* Цвет текста */
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.profile-btn:hover {
    background-color: #f5f5f5; /* Фон при наведении */
}

.profile-btn:active {
    background-color: #e9e9e9; /* Фон при нажатии */
}

.remote-video {
    width: 100%;
    /*max-height: 900px;*/
    /*border-radius: 10px;*/
    background-color: black;
    height: 100%;
}

.bottom-nav {
    width: 100%;
    height: 61px;
    background-color: var(--background);
    display: flex;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -6px 7px rgba(0, 0, 0, 0.1);
    border-top: 1px solid var(--border);
    z-index: 999;
}

.nav-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
}

.nav-btn i {
    font-size: 20px;
    margin-bottom: 5px;
}

.nav-btn:active, .nav-btn:hover {
    color: var(--primary);
}

.local-video {
    position: absolute;
    bottom: 200px;
    right: 10px;
    width: 140px;
    height: 90px;
    border-radius: 5px;
    background-color: black;
    border: 2px solid white;
    /*transform: scaleX(-1); !* Зеркальное отображение по горизонтали *!*/
    object-fit: cover; /* Сохраняет пропорции видео */
}

.incoming-call {
    /*position: absolute;*/
    /*top: 20px;*/
    /*right: 20px;*/
    background-color: var(--background);
    border-radius: 10px;
    padding: 15px;
    box-shadow: var(--shadow);
    display: none;
    z-index: 1001;
    /*animation: pulse 1.5s infinite;*/
    /*max-width: 300px;*/
}

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

.incoming-call-info {
    margin-bottom: 15px;
    text-align: center;
}

.incoming-call-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

/* Auth Screens */
.auth-container {
    width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    background-color: var(--secondary);
    transition: background-color 0.3s;
}

.auth-form {
    width: 100%;
    max-width: 400px;
    background-color: var(--background);
    padding: 30px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    transition: background-color 0.3s;
}

.auth-form h2 {
    color: var(--primary);
    margin-bottom: 20px;
    text-align: center;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    background-color: var(--background);
    color: var(--text-primary);
    transition: border-color 0.3s, background-color 0.3s;
}

.btn {
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    transition: background-color 0.3s;
}

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

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

.auth-switch {
    margin-top: 15px;
    text-align: center;
    font-size: 14px;
    color: var(--text-secondary);
}

.call-video .fa-video-slash {
    color: #F44336;
}


.auth-switch a {
    color: var(--primary);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.3s;
}

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

.sidebar {
    display: flex; /* Отображаем sidebar как flex-контейнер */
    width: 350px; /* Фиксированная ширина для sidebar */
    border-right: 1px solid var(--border); /* Разделяем блоки */
    flex-direction: column;
}


.sidebar-header {
    padding: 15px;
    background-color: var(--background);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    transition: background-color 0.3s, border-color 0.3s;
}

.user-info {
    display: flex;
    align-items: center;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    margin-right: 10px;
}

.header-actions {
    display: flex;
    gap: 15px;
}

.header-actions i {
    font-size: 16px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.3s;
}

.header-actions i:hover {
    color: var(--primary);
}

.search-container {
    position: relative;
    padding: 10px 15px;
    background-color: var(--background);
    border-bottom: 1px solid var(--border);
    transition: background-color 0.3s, border-color 0.3s;
}

.search-input-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    padding: 10px 15px 10px 35px;
    border: none;
    border-radius: 20px;
    background-color: var(--secondary);
    color: var(--text-primary);
    transition: background-color 0.3s;
}

.search-input:focus {
    outline: none;
}

.search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-secondary);
}

.search-clear {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: none;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 15px;
    right: 15px;
    background-color: var(--background);
    border-radius: 0 0 8px 8px;
    box-shadow: var(--shadow);
    max-height: 300px;
    overflow-y: auto;
    z-index: 100;
    display: none;
}

.search-result-item {
    padding: 12px 15px;
    display: flex;
    align-items: center;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}

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

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

.no-results {
    padding: 15px;
    text-align: center;
    color: var(--text-secondary);
}

.search-section-title {
    padding: 10px 15px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    background-color: var(--secondary);
    text-transform: uppercase;
}

.contacts-list {
    flex: 1;
    overflow-y: auto;
}

.contact-item {
    padding: 12px 15px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background-color 0.3s, border-color 0.3s;
}

.contact-item:hover, .contact-item.active {
    background-color: var(--hover);
}

.contact-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    margin-right: 15px;
    position: relative;
}

.online-status {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    background-color: #00c900;
    border: 2px solid var(--background);
    border-radius: 50%;
    transition: border-color 0.3s;
}

.contact-info {
    flex: 1;
}

.contact-name {
    font-weight: 500;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.contact-lastmsg {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
    transition: color 0.3s;
}

.contact-meta {
    text-align: right;
    font-size: 12px;
    color: var(--text-secondary);
    transition: color 0.3s;
}

.unread-count {
    background-color: var(--primary);
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 12px;
    margin-top: 5px;
}

.chat-area {
    display: flex; /* Отображаем chat-area */
    flex: 1; /* Занимает всё оставшееся место */
    flex-direction: column; /* Располагаем элементы по вертикали */
    position: relative;
    overflow: hidden;
}


.chat-header {
    padding: 15px;
    background-color: var(--background);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background-color 0.3s, border-color 0.3s;
}

.chat-user {
    display: flex;
    align-items: center;
}

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

.chat-actions i {
    font-size: 18px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.3s;
}

.chat-actions i:hover {
    color: var(--primary);
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    /*background-image: url('cha5.jpg'); !* Указываем фоновое изображение *!*/
    /*background-size: cover; !* Подгоняем изображение под размер контейнера *!*/
    /*background-repeat: no-repeat; !* Запрещаем повторение изображения *!*/
    /*background-position: center; !* Центруем изображение *!*/
    background: var(--chat-background);
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s;
}

#fullscreenBtn {
    background-color: #4caf50; /* Зеленый цвет */
    color: white;
}

#fullscreenBtn:hover {
    background-color: #45a049; /* Более тёмный оттенок */
}



.message {
    max-width: 70%;
    padding: 10px 15px;
    margin-bottom: 10px;
    border-radius: 10px;
    position: relative;
    animation: fadeIn 0.3s;

    /* Добавим перенос текста */
    word-wrap: break-word; /* Перенос слов */
    word-break: break-word; /* Перенос длинных слов */
    overflow-wrap: anywhere; /* Переносит текст без разрыва */

}

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

.message-incoming {
    background-color: var(--message-in);
    align-self: flex-start;
    border-top-left-radius: 0;
}

.message-outgoing {
    background-color: var(--message-out);
    align-self: flex-end;
    border-top-right-radius: 0;
}

.message-time {
    font-size: 11px;
    text-align: right;
    margin-top: 5px;
    opacity: 0.8;
    color: var(--text-secondary);
}

.message-status {
    font-size: 11px;
    margin-left: 5px;
    color: var(--text-secondary);
}

/* Сообщения-системные события (звонки) */
.system-message {
    text-align: center;
    margin: 10px auto;
    font-size: 14px;
    /*font-weight: bold;*/
    border-radius: 10px;
    background-color: var(--message-in); /* Нежный серый фон */
    padding: 10px 15px;
    max-width: 80%;
    color: var(--text-primary); /* Темно-серый текст */
    display: flex;
    align-items: center;
    justify-content: center;
    /*box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); !* Тень для объема *!*/
}


.system-message .message-time {
    font-size: 12px;
    color: #999;
    margin-top: 5px;
}

/* Иконка в системных сообщениях */
.system-message .system-message-icon {
    font-size: 18px;
    color: #0078D7; /* Синий цвет для иконок */
    margin-right: 8px;
}

/* Текст в сообщениях о звонке */
.system-message .system-message-text {
    text-align: left;
    flex: 1;
    margin-right: 10px;
}

.contact-item {
    background-color: var(--background);
    transition: background-color 0.2s ease;
}

.contact-item.active {
    background-color: var(--light-active); /* Цвет подсветки */
    border-left: 4px solid var(--light-active-hover); /* Голубой маркер слева */
}

.contact-item:hover {
    background-color: var(--hover);
}


/* Иконки для звонков */
.system-message.call-end .system-message-icon {
    color: #32CD32; /* Зеленый цвет для завершения звонков */
}

.system-message.call-reject .system-message-icon {
    color: #FF4500; /* Красно-оранжевый цвет для отклоненных звонков */
}

.emoji-btn {
    border: none;
    background: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 10px;
}
.emoji-btn:hover {
    color: #f39c12;
}



.video-placeholder {
    display: none; /* По умолчанию скрыта */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    color: #fff;
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}


.chat-input-container {
    padding: 10px; /* Уменьшаем внутренние отступы */
    background-color: var(--background);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    position: sticky; /* Фиксируем внизу экрана */
    bottom: 0; /* Для фиксации в нижней части */
    z-index: 1000; /* Поверх других элементов */
}


.attachment-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    margin-right: 10px;
    cursor: pointer;
    transition: color 0.3s;
}

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

.message-input {
    flex: 1;
    padding: 12px 15px;
    border: none;
    border-radius: 20px;
    background-color: var(--secondary);
    color: var(--text-primary);
    resize: none;
    max-height: 120px;
    transition: background-color 0.3s;
}

.message-input:focus {
    outline: none;
}

.send-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    margin-left: 10px;
    transition: background-color 0.3s;
}

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

.encryption-indicator {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    transition: color 0.3s;
}

.theme-switch {
    position: absolute;
    top: 15px;
    right: 15px;
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: 20px;
    padding: 8px 15px;
    cursor: pointer;
    font-size: 12px;
    z-index: 100;
}

/* Loading animation */
.loading {
    display: flex;
    justify-content: center;
    padding: 20px;
}

.loading-dot {
    width: 8px;
    height: 8px;
    margin: 0 4px;
    background-color: var(--text-secondary);
    border-radius: 50%;
    animation: loading 1.4s infinite ease-in-out both;
}

.loading-dot:nth-child(1) { animation-delay: -0.32s; }
.loading-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes loading {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Error message */
.error-message {
    color: #ff3860;
    font-size: 14px;
    margin-top: 10px;
    text-align: center;
}

.toggle-sidebar-btn {
    display: none;
}

#logoutBtn {
    color: #ff3860;
}

/*!* Когда отображается sidebar *!*/
/*.app-container.show-contacts .sidebar {*/
/*    transform: translateX(0); !* Sidebar на экране *!*/
/*}*/

/*.app-container.show-contacts .chat-area {*/
/*    transform: translateX(100%); !* Chat-area скрывается вправо *!*/
/*}*/

/*!* Когда отображается chat-area *!*/
/*.app-container:not(.show-contacts) .sidebar {*/
/*    transform: translateX(-100%); !* Sidebar уходит влево *!*/
/*}*/

/*.app-container:not(.show-contacts) .chat-area {*/
/*    transform: translateX(0); !* Chat-area возвращается на экран *!*/
/*}*/


/* Responsive */
/* Responsive */
@media (max-width: 768px) {


    .container {
        display: flex; /* Блоки отображаются в строку */
    }

    .sidebar {
        display: none; /* Отображаем sidebar */
        width: 100%; /* Стандартная ширина */
    }

    .chat-area {
        display: flex; /* Отображаем chat-area */
        flex: 1; /* Занимает всё доступное пространство */
        flex-direction: column; /* Колонка для заголовка, сообщений и ввода */
    }


    /* Показываем sidebar, скрываем chat-area */
    .show-contacts .sidebar {
        display: flex; /* Делаем sidebar видимым */
    }

    .show-contacts .chat-area {
        display: none; /* Скрываем область чата */
    }


    .message {
        max-width: 85%;
    }

    .local-video {
        width: 80px;
        height: 60px;
    }

    /* Кнопка "Назад" рядом с аватаром */
    .toggle-sidebar-btn {
        background: none; /* Убираем фон */
        border: none; /* Убираем границы */
        display: flex;
        align-items: center;
        justify-content: center;
        margin-right: 8px; /* Расстояние от аватара */
        cursor: pointer;
        color: #555; /* Цвет иконки (серый в стиле Telegram) */
        font-size: 18px; /* Размер стрелки */
        padding: 0; /* Убираем внутренние отступы */
        line-height: 1; /* Убираем влияние текста на размер */
        transition: color 0.2s ease; /* Плавный эффект изменения цвета при наведении */
    }

    /* Эффект наведения */
    .toggle-sidebar-btn:hover {
        color: #000; /* Чёрный цвет стрелки при наведении */
    }

    /* Упрощённое расположение пользователя в чате */
    .chat-user {
        display: flex;
        align-items: center;
        gap: 4px; /* Минимальное расстояние между кнопкой и аватаром */
    }

    /* Аватар */
    .avatar {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background-color: #007bff; /* Синий фон как пример */
        color: white;
        font-size: 18px;
        display: flex;
        align-items: center;
        justify-content: center;
        text-transform: uppercase; /* Буквы в верхнем регистре (например, инициалы) */
    }

    body, html {
        width: 100%; /* Убираем горизонтальные проблемы */
        height: 100%; /* Растягиваем на 100% высоты экрана */
        margin: 0; /* Убираем отступы по умолчанию */
        /*overflow: hidden; !* Убираем прокрутку *!*/
    }

    .call-container {
        display: none; /* Выравниваем всё как flex-контейнер */
        flex-direction: column; /* Все элементы размещаются вертикально */
        justify-content: center; /* Центрируем содержимое по вертикали */
        align-items: center; /* Центрируем содержимое по горизонтали */
        width: 100%; /* Ширина контейнера по экрану */
        height: 100%; /* Высота контейнера соответствует высоте viewport */
        background-color: rgba(0, 0, 0); /* Прозрачный черный фон */
        overflow: hidden; /* Устраняем проблемы с прокруткой */
        position: fixed; /* Фиксируем относительно экрана */
        top: 0;
        left: 0;
        z-index: 100011; /* Поверх других элементов */
        color: white; /* Цвет текста внутри */
        /*padding: 10px;*/
        min-width: 0;
    }

    .call-controls {
        margin-bottom: 40px;
    }

    .video-container {
        width: 100%; /* Видео занимает всю ширину */
        /*max-width: 400px; !* Максимальная ширина для центровки *!*/
        aspect-ratio: 16 / 9; /* Пропорции видео */
        position: relative; /* Для размещения внутренних слоев */
        background-color: black; /* Резервный черный фон */
    }

    .remote-video,
    .local-video {
        width: 100%; /* Видео подстраивается под ширину контейнера */
        height: 100%; /* Занимает высоту контейнера */
        object-fit: cover; /* Показываем видео с сохранением пропорций */
        position: absolute; /* Накладываем одно видео на другое */
        top: 0;
        left: 0;
    }

    .local-video {
        width: 80px; /* Уменьшаем размер локального видео */
        height: 60px;
        border-radius: 5px;
        border: 2px solid white;
        bottom: 10px; /* Располагаем в правом нижнем углу */
        right: 10px;
        z-index: 10; /* Поверх удаленного видео */
    }

    .video-placeholder {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        background: black;
        color: white;
        font-weight: bold;
        font-size: 16px;
        z-index: 5; /* Выше видео */
    }

    .call-info {
        text-align: center;
        margin: 5px 0; /* Отступы сверху и снизу */
    }

    .caller-name {
        font-size: 18px;
        font-weight: 600; /* Полужирный текст */
    }

    .call-status {
        font-size: 14px; /* Чуть меньше шрифт */
        color: rgba(255, 255, 255, 0.8); /* Немного прозрачный текст */
    }

    .call-actions {
        display: flex;
        gap: 10px; /* Промежуток между кнопками */
        justify-content: center;
        align-items: center;
        flex-wrap: wrap; /* Для компактного размещения на маленьком экране */
        margin-top: 20px; /* Отступ сверху */
        padding: 0 10px; /* Границы от краев экрана */
    }

    .call-btn {
        display: flex;
        justify-content: center;
        align-items: center;
        width: 50px; /* Размер кнопки */
        height: 50px;
        border-radius: 50%; /* Круглая кнопка */
        font-size: 20px; /* Размер иконки */
        cursor: pointer;
        border: none;
        color: white;
        background-color: rgba(255, 255, 255, 0.2); /* Полупрозрачный фон */
        transition: background-color 0.3s ease;
    }

    .call-btn:hover {
        background-color: rgba(255, 255, 255, 0.4); /* Прозрачность при наведении */
    }

    .call-accept {
        background-color: var(--call-accept); /* Зеленый цвет ответа */
    }

    .call-decline {
        background-color: var(--call-decline); /* Красный цвет завершения */
    }

    #fullscreenBtn {
        display: none;
    }

}

/* iPhone Retina */
@media only screen and (max-device-width: 768px) and (-webkit-min-device-pixel-ratio: 2) {
    .chat-input-container {
        margin-bottom: 28px;
    }
    .bottom-nav {
        margin-bottom: 28px;
    }
}