/* Базовые настройки */
* {
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    width: 100%;
    overflow: hidden;
    background-color: #fff;
    color: #333;
}


a { color: #0056b3; text-decoration: none; }
a:hover { text-decoration: underline; }

.auth-logo {
    text-align: center;
}
.auth-logo img {
    border-radius: 16px;
}

.rightbar-room {
    font-size: 12px;
    color: #95a5a6;
    white-space: nowrap;         /* Запрещаем перенос на новую строку */
    overflow: hidden;            /* Скрываем всё, что не влезает */
    text-overflow: ellipsis;     /* Добавляем троеточие в конце */
    min-width: 0;                /* Обязательно для работы flexbox с обрезкой */
    flex: 1;                     /* Позволяем элементу занимать оставшееся место */
}



/* Уведомления */
.alert {
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 14px;
}
.alert-error { background: #ffe6e6; color: #d8000c; border: 1px solid #ffb3b3; }
.alert-success { background: #e6ffe6; color: #270; border: 1px solid #b3ffb3; }

/* -------------------------------------
   Страница входа / регистрации
-------------------------------------- */
.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100dvh;
  padding: 20px;
}
.auth-card {
    background: #fff;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    width: 100%;
    max-width: 400px;
}
.auth-card h1 { text-align: center; margin-top: 0; color: #1a1a1a; }
.auth-card h2 { font-size: 18px; margin-bottom: 15px; border-bottom: 2px solid #eee; padding-bottom: 5px; }
.auth-card hr { border: none; border-top: 1px solid #eee; margin: 30px 0; }

.auth-form label {
    display: block;
    margin-top: 15px;
    font-size: 13px;
    color: #666;
    font-weight: 500;
}
.auth-form input[type="text"],
.auth-form input[type="password"] {
    width: 100%;
    padding: 10px;
    margin-top: 5px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 14px;
}
.auth-form input:focus { border-color: #0056b3; outline: none; }
.auth-form button {
    width: 100%;
    padding: 12px;
    margin-top: 20px;
    background: #0056b3;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}
.auth-form button:hover { background: #004494; }

.captcha-row {
display: flex;
align-items: center; /* Выравнивает элементы ровно по центру по вертикали */
gap: 10px;
margin-top: 5px;
}
.captcha-img {
cursor: pointer;
border-radius: 4px;
height: 42px; /* Чуть увеличили, чтобы совпадало с высотой поля ввода */
display: block;
}
.captcha-row input[type="text"] {
flex: 1;
margin-top: 0; /* Убираем смещение вниз, которое ломало верстку */
height: 42px;  /* Задаем такую же высоту, как у картинки */
}


/* Вкладки на странице входа */
.auth-tabs {
    display: flex;
    border-bottom: 2px solid #eee;
    margin-bottom: 20px;
}
.tab-btn {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 16px;
    font-weight: bold;
    color: #888;
    cursor: pointer;
    transition: all 0.2s;
}
.tab-btn:hover {
    color: #333;
}
.tab-btn.active {
    color: #0056b3;
    border-bottom-color: #0056b3;
}

/* Скрываем формы, оставляем только активную */
.auth-form {
    display: none;
}
.auth-form.active {
    display: block;
}


/* -------------------------------------
   Чат
-------------------------------------- */
.chat-layout {
    display: flex;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
}


/* Боковая панель */
.chat-sidebar {
    width: 260px;
    background: #2c3e50;
    color: #ecf0f1;
    display: flex;
    flex-direction: column;
}
.sidebar-header {
    padding: 0px 20px 0 20px;
    background: #1a252f;
    text-align: center;
}

.sidebar-logo {
    width: 64px;
    height: 64px;
    border-radius: 14px;
    display: block;
    margin: 0 auto;
}

.room {
    padding: 10px 20px;
    cursor: pointer;
    opacity: 0.7;
}
.room:hover { opacity: 1; background: rgba(255,255,255,0.05); }
.room.active { opacity: 1; font-weight: bold; background: rgba(255,255,255,0.1); border-left: 4px solid #3498db; }
.sidebar-user {
    padding: 15px;
    background: #1a252f;
    text-align: center;
}
.sidebar-user a { color: #e74c3c; }

/* Основная область */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #fff;
}
.chat-header {
display: flex;
align-items: center;
padding: 15px 20px;
background: #f8f9fa;
border-bottom: 1px solid #eee;
}

.chat-header h2 { margin: 0; font-size: 18px; color: #333; }

/* Сообщения */
.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #ffffff;
}
.chat-empty { text-align: center; color: #999; margin-top: 50px; }
.message {
    margin-bottom: 15px;
    /* max-width: 85%; */
}
.msg-user { font-weight: bold; color: #2c3e50; }
.msg-time { font-size: 11px; color: #aaa; margin-left: 8px; }
.msg-body {
    margin-top: 4px;
    padding: 10px 14px;
    background: #f1f3f5;
    border-radius: 0 15px 15px 15px;
    display: inline-block;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;   /* ← добавь */
    word-break: break-word;      /* ← добавь */
    max-width: 100%;             /* ← добавь */
}




/* Онлайн в сайдбаре */
.sidebar-online {
    flex: 1; /* Список онлайна займет всё оставшееся место снизу */
    overflow-y: auto;
    padding: 10px 14px 20px;
}
.sidebar-section-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #95a5a6; /* Светло-серый, чтобы читался на темном фоне */
    margin-bottom: 12px;
    font-weight: 600;
    padding-left: 6px;
}
.online-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.online-placeholder {
    color: #7f8c8d;
    font-size: 13px;
    padding: 4px 6px;
}
.online-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px;
    font-size: 14px;
    color: #ecf0f1; /* Белый цвет текста для ников! */
    border-radius: 4px;
    transition: background 0.2s;
}
.online-user:hover {
    background: rgba(255, 255, 255, 0.05); /* Легкая подсветка при наведении */
}
.online-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ecc71; /* Яркий зеленый */
    box-shadow: 0 0 5px rgba(46, 204, 113, 0.4); /* Легкое свечение точки */
    flex-shrink: 0;
}
.online-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Кнопка бургер-меню (скрыта на ПК) */
.burger-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0 10px 0 0;
    color: #333;
}

/* Оверлей для закрытия сайдбара по клику */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0,0,0,0.4);
    z-index: 90;
}

/* Форма отправки */
.chat-form {
padding: 8px 16px 12px;
background: #f8f9fa;
border-top: 1px solid #eee;
position: relative;
}

/* Контейнер поля ввода — выравнивание по нижнему краю */
.input-container {
    display: flex;
    align-items: flex-end;  /* БЫЛО center, СТАЛО flex-end */
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 24px;
    padding: 4px 8px 4px 8px;
    transition: border-color 0.2s;
}


.input-container:focus-within {
border-color: #3498db;
box-shadow: 0 0 0 2px rgba(52,152,219,0.15);
}

/* Поле ввода */
.chat-form textarea {
    flex: 1;
    resize: none;
    padding: 8px 4px;
    border: none;
    font-size: 14px;
    outline: none;
    line-height: 1.4;
    min-height: 22px;
    /* убрать max-height и overflow-y — ими управляет JS */
    background: transparent;
    font-family: inherit;
}


/* Кнопка смайлов — внутри поля слева */
.smile-toggle-inside {
    background: none;
    border: none;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    cursor: pointer;
    padding: 0;
    margin-bottom: 4px;  /* ← ДОБАВИТЬ */
    border-radius: 50%;
    transition: background 0.15s;
}

.smile-toggle-inside:hover {
background: #f0f0f0;
}

/* Кнопка отправки — стрелка в кружке */
.send-btn {
    background: #3498db;
    color: #fff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
    padding: 0;
    margin-left: 4px;
    margin-bottom: 4px;  /* ← ДОБАВИТЬ */
}

.send-btn:hover {
background: #2980b9;
transform: scale(1.05);
}
.send-btn:disabled {
  background: #b0c4de;
  cursor: not-allowed;
  transform: none;
  opacity: 0.5;
}

/* Выпадающая панель смайлов */
.smiles-dropdown {
position: absolute;
bottom: 70px;
left: 16px;
width: 266px;
max-height: 220px;
overflow-y: auto;
background: #fff;
border: 1px solid #ddd;
border-radius: 12px;
padding: 10px;
display: flex;
flex-wrap: wrap;
gap: 4px;
box-shadow: 0 8px 24px rgba(0,0,0,0.12);
z-index: 100;
}
.smiles-dropdown::-webkit-scrollbar {
width: 6px;
}
.smiles-dropdown::-webkit-scrollbar-thumb {
background: #ccc;
border-radius: 3px;
}
.smiles-dropdown.hidden {
display: none;
}

/* Кнопка смайла в панели */
.smile-btn {
width: 36px;
height: 36px;
font-size: 20px;
background: none;
border: 1px solid transparent;
border-radius: 8px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: background 0.15s, border-color 0.15s;
}
.smile-btn:hover {
background: #f1f3f5;
border-color: #ddd;
}

/* Смайлик в сообщении */
.smile {
display: inline-block;
font-size: 18px;
vertical-align: middle;
line-height: 1;
}



/* DM-кнопка в онлайне */
.dm-btn {
    margin-left: auto; background: none; border: none; font-size: 16px;
    cursor: pointer; padding: 2px 6px; border-radius: 4px; opacity: 0.6;
}
.dm-btn:hover { opacity: 1; background: rgba(255,255,255,0.1); }

/* Бейдж комнаты */
.room-badge { font-size: 12px; margin-left: 4px; opacity: 0.7; }

/* Модалка */
.modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); z-index: 200;
    display: flex; align-items: center; justify-content: center;
}
.modal-overlay.hidden { display: none; }
.modal-dialog {
    background: #fff; border-radius: 12px; padding: 24px;
    width: 90%; max-width: 360px; box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.modal-dialog h3 { margin: 0 0 16px; }
.modal-dialog input[type="text"] {
    width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 8px;
    font-size: 14px; margin-bottom: 12px;
}
.modal-dialog button[type="submit"] {
    width: 100%; padding: 10px; background: #3498db; color: #fff;
    border: none; border-radius: 8px; font-size: 14px; cursor: pointer;
}
.modal-dialog .modal-close {
    width: 100%;
    padding: 9px;
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 8px;
    color: #666;
    cursor: pointer;
    margin-top: 8px;
    font-size: 14px;
    transition: background 0.15s, border-color 0.15s;
}
.modal-dialog .modal-close:hover {
    background: #e8e8e8;
    border-color: #ccc;
    color: #333;
}


/* Блок заголовка раздела в сайдбаре */
.sidebar-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    margin-top: 15px;
    margin-bottom: 5px;
}

/* Новая аккуратная кнопка плюса */
.new-room-btn-sidebar {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: #888;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s;
}
.new-room-btn-sidebar:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

/* Строка комнаты */
.room {
    display: flex;
    align-items: center;
    gap: 6px;
}
.room-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Кнопка удаления */
.room-delete-btn {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    opacity: 0;
    transition: all 0.15s;
}
.room:hover .room-delete-btn {
    opacity: 0.6;
}
.room-delete-btn:hover {
    opacity: 1 !important;
    background: rgba(255, 60, 60, 0.15);
    color: #ff4d4d;
}

/* Выбор типа комнаты */
.room-type-select {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}
.room-type-label {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 6px;
    border: 1px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 13px;
}
.room-type-label:hover {
    border-color: #bbb;
    background: #fafafa;
}
.room-type-label input[type="radio"] {
    display: none;
}
.room-type-label:has(input:checked) {
    border-color: #3498db;
    background: #ebf5fb;
    color: #3498db;
}
.room-type-name {
    font-weight: 600;
    margin-bottom: 2px;
}
.room-type-desc {
    font-size: 11px;
    opacity: 0.7;
}

/* Кнопка приглашения в шапке */
.header-icon-btn {
    background: none;
    border: none;
    color: #666;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.header-icon-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #3498db;
}

/* Окно со списком для галочек (скролл если много юзеров) */
.invite-user-list {
    max-height: 250px;
    overflow-y: auto;
    margin-bottom: 15px;
    border: 1px solid #eee;
    border-radius: 8px;
    background: #fff;
}
.invite-user-label {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f5f5f5;
    transition: background 0.15s;
}
.invite-user-label:last-child {
    border-bottom: none;
}
.invite-user-label:hover {
    background: #f9f9f9;
}
.invite-user-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #3498db;
}
.invite-user-name {
    font-weight: 500;
    color: #333;
}

/* Плашка «В ответ» */
.reply-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 20px;
  background: #e8f0fe;
  border-bottom: 1px solid #c8d6e5;
  border-radius: 0;
  margin: 0;
  flex-shrink: 0;
}




.reply-bar.hidden { display: none; }
.reply-bar-content {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    flex: 1;
    display: flex;
    gap: 6px;
}
.reply-bar-label { color: #3498db; font-weight: 600; flex-shrink: 0; }
.reply-bar-to { color: #2c3e50; font-weight: 600; flex-shrink: 0; }
.reply-bar-preview { color: #888; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-bar-cancel {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
}
.reply-bar-cancel:hover { background: rgba(0,0,0,0.05); color: #e74c3c; }

/* Инфо-блок «↪ В ответ на...» внутри сообщения */
.msg-reply-info {
    font-size: 11px;
    color: #3498db;
    margin-bottom: 3px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    display: block; /* Было inline-block, стало block */
    /* width: fit-content; */ /* Чтобы фон цитаты не растягивался на весь экран */
    transition: background 0.15s;
	border: 1px solid #b3d7ffa8 !important;
    /* Добавленные свойства для фикса длинных слов: */
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;	
}

.msg-reply-info:hover {
    background: #eaf2fb;
    text-decoration: underline;
}

.message.highlight-reply {
background: #eef6ff;
border-radius: 8px;
transition: background 0.3s;
}

/* Ник кликабельный */
.msg-user {
    cursor: pointer;
    transition: color 0.15s;
}
.msg-user:hover {
    color: #3498db;
    text-decoration: underline;
}
/* Убираем фон и рамку со всего широкого блока */
.message.highlight-reply {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

/* Подсвечиваем только облачко с текстом */
.message.highlight-reply .msg-body {
    background-color: #e0f0ff !important; /* Светло-голубой фон */
    border: 1px solid #b3d7ff !important; /* Голубая рамка (если нужна) */
    transition: background-color 0.3s ease;
}

/* Опционально: подсвечиваем и сам блок цитаты над текстом */
.message.highlight-reply .msg-reply-info {
    background-color: #e0f0ff !important;
    border: 1px solid #b3d7ff !important;
}

.msg-header {
    margin-bottom: 2px;
}


.msg-header {
display: block;
}
.msg-user {
/* остаётся inline, время справа от ника */
}

.message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;

}
.msg-body {
    word-break: break-word;
	cursor: default !important;
	border: 1px solid #b3d7ffa8 !important;
}
.msg-body h1, .msg-body h2, .msg-body h3 {
    margin: 8px 0 4px 0;
    font-weight: bold;
}
.msg-body h1 { font-size: 1.3em; }
.msg-body h2 { font-size: 1.15em; }
.msg-body h3 { font-size: 1.05em; }

.msg-body blockquote {
    margin: 4px 0;
    padding: 4px 12px;
    border-left: 3px solid #888;
    color: #666;
    background: #f9f9f9;
}

.msg-body code {
    background: #eee;
    padding: 1px 5px;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.9em;
}
.msg-body pre {
    background: #282c34;
    color: #abb2bf;
    padding: 10px 12px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 13px;
    margin: 8px 0;
    white-space: pre-wrap; /* чтобы длинные строки не ломали верстку, а переносились */
}
.msg-body pre code {
    background: transparent;
    padding: 0;
    color: inherit;
}

.msg-body ul, .msg-body ol {
    margin: 8px 0 !important;
    padding: 0 0 0 35px !important;
    list-style-position: outside !important;
}
.msg-body ul {
    list-style-type: disc !important; /* Точки для маркированного */
}

.msg-body ol {
    list-style-type: decimal !important; /* Цифры для нумерованного */
}


/* Скрываем лишние пустые переносы строк, которые создает PHP между элементами списка */
.msg-body ul br, .msg-body ol br {
    display: none;
}

.msg-body li {
    margin: 4px 0 !important;
    padding: 0 !important;
    line-height: 1.5;
}


.msg-body li {
    margin: 2px 0;
}

.msg-body hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 8px 0;
}

.msg-body del {
    text-decoration: line-through;
    opacity: 0.7;
}



/* Правая панель */
.chat-rightbar {
    width: 220px;
    background: #2c3e50;
    color: #ecf0f1;
    display: flex;
    flex-direction: column;
    font-size: 13px;
	cursor: default !important;
}
.rightbar-user {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 7px 14px 11px 14px;
    background: #1a252f;
    position: relative; /* <-- Это нужно, чтобы стрелка не улетала за края */
}
.rightbar-user-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    max-width: 150px;
}
.rightbar-user-info .name {
    font-weight: 600;
    font-size: 13px;
    color: #ecf0f1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    text-align: center;
}
.rightbar-user-info .logout-link {
    display: inline-block;
    font-size: 11px;
    color: #ecf0f1;
    background: rgba(231,76,60,0.15);
    border: 1px solid rgba(231,76,60,0.3);
    padding: 3px 10px;
    border-radius: 4px;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
    white-space: nowrap;
}
.rightbar-user-info .logout-link:hover {
    background: rgba(231,76,60,0.3);
    border-color: rgba(231,76,60,0.5);
    text-decoration: none;
}



.rightbar-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #95a5a6;
    margin-bottom: 8px;
    font-weight: 600;
}
.rightbar-list {
    list-style: none;
    margin: 0 0 16px 0;
    padding: 0;
}
.rightbar-list li {
    padding: 4px 0;
    display: flex;
    align-items: center;
    gap: 4px;
}
.rightbar-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}
.rightbar-dot.online { background: #2ecc71; box-shadow: 0 0 4px rgba(46,204,113,0.4); }
.rightbar-dot.offline { background: #7f8c8d; }
.rightbar-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Кнопка открытия правой панели (в шапке) */
.rightbar-toggle-btn {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 0 0 0 10px;
    color: #333;
}

/* Боковая панель — скролл */
.sidebar-rooms {
    padding: 5px 0;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0; /* критично для flex-контейнера */
}

/* Стилизация скроллбара для боковой панели */
.sidebar-rooms::-webkit-scrollbar {
    width: 4px;
}
.sidebar-rooms::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-rooms::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}
.sidebar-rooms::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Стало */
.rightbar-section {
flex: 1;
overflow-y: auto;
overflow-x: hidden;
min-height: 0;
padding: 12px 14px;
}
.rightbar-section::-webkit-scrollbar {
width: 4px;
}
.rightbar-section::-webkit-scrollbar-track {
background: transparent;
}
.rightbar-section::-webkit-scrollbar-thumb {
background: rgba(255, 255, 255, 0.15);
border-radius: 2px;
}
.rightbar-section::-webkit-scrollbar-thumb:hover {
background: rgba(255, 255, 255, 0.25);
}

/* --- Комната в сайдбаре --- */
.room {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.15s, background 0.15s;
}
.room:hover { opacity: 1; background: rgba(255,255,255,0.05); }
.room.active { opacity: 1; font-weight: bold; background: rgba(255,255,255,0.1); border-left: 4px solid #3498db; }

/* Обёртка счётчика — всегда занимает место, даже когда пустая */
.room-counter-wrap {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    width: 24px;
    justify-content: center;
}
.room-counter-wrap.empty {
    visibility: hidden;
}

/* Сам счётчик */
.unread-counter {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 18px;
    padding: 0 6px;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    text-align: center;
}

/* Название чата */
.room-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
    min-width: 0;
}

/* Бейдж (💬 / 👥) */
.room-badge {
    flex-shrink: 0;
    font-size: 12px;
}

/* Кнопка удаления */
.room-delete-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    color: #95a5a6;
    cursor: pointer;
    padding: 2px;
    display: flex;
    align-items: center;
    opacity: 0;
    transition: opacity 0.15s;
}
.room:hover .room-delete-btn {
    opacity: 1;
}



.room-delete-btn:hover {
    opacity: 1 !important;
    background: rgba(255, 60, 60, 0.15);
    color: #ff4d4d;
}

/* Счётчик непрочитанных сообщений */
.unread-counter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
    padding: 0 5px;
    line-height: 1;
}

/* Кнопка настроек в правой панели */
.rightbar-settings {
    padding: 12px 16px;
    background: #1a252f;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: center;
}
.settings-btn {
    background: rgba(255,255,255,0.06);
    border: none;
    color: #95a5a6;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 13px;
    transition: all 0.2s;
    width: 100%;
    justify-content: center;
}
.settings-btn:hover {
    background: rgba(255,255,255,0.12);
    color: #ecf0f1;
}

/* Модалка настроек */
.settings-modal .modal-dialog {
    max-width: 390px;
    max-height: 90dvh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.settings-modal .modal-dialog::-webkit-scrollbar {
    width: 4px;
}
.settings-modal .modal-dialog::-webkit-scrollbar-track {
    background: transparent;
}
.settings-modal .modal-dialog::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 2px;
}


.settings-group {
    margin-bottom: 5px;
}
.settings-group-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #888;
    margin-bottom: 10px;
    font-weight: 600;
}
/* --- Строка настройки (выравнивание) --- */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px; /* Добавили отступ между текстом и полем */
	padding: 5px 0;
}
.setting-row:last-child {
    border-bottom: none;
}
.setting-label {
    font-size: 14px;
    color: #333;
    flex: 1;
    line-height: 1.3;
}
.setting-desc {
    font-size: 11px;
    color: #999;
    display: block;
    margin-top: 4px;
    line-height: 1.2;
}

/* Toggle switch */
.setting-toggle {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    margin-left: 12px;
}
.setting-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.setting-toggle .slider {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #ccc;
    border-radius: 24px;
    transition: 0.25s;
}
.setting-toggle .slider::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.25s;
}
.setting-toggle input:checked + .slider {
    background: #3498db;
}
.setting-toggle input:checked + .slider::before {
    transform: translateX(20px);
}

/* Обёртка кнопок теста звука */
.test-sound-row {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 12px;
}

/* Кнопка теста звука */
.test-sound-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 7px 16px;
    font-size: 13px;
    color: #555;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.test-sound-btn:hover {
    border-color: #3498db;
    color: #3498db;
    background: #f0f7ff;
}


/* --- Кнопка Звуки в левой панели (как Настройки справа) --- */
.sidebar-settings {
  padding: 12px 16px;
  background: #1a252f;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: auto;
}

.sound-btn-sidebar {
  background: rgba(255,255,255,0.06);
  border: none;
  color: #95a5a6;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  transition: all 0.2s;
  width: 100%;
  justify-content: center;
}

.sound-btn-sidebar:hover {
  background: rgba(255,255,255,0.12);
  color: #ecf0f1;
}

.sound-btn-sidebar svg {
  flex-shrink: 0;
}

/* --- Стили для формы настроек --- */
.settings-select,
.settings-input {
    width: 140px;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
    background: #fff;
    color: #333;
}
/* 👇 Вот эта строка чинит поле "Реальное имя" */
.modal-dialog .settings-input { width: 140px; margin-bottom: 0; }

.settings-input[type="date"] {
    width: 150px;
}
.settings-save-btn {
    width: 100%;
    padding: 10px;
    background: #3498db;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    margin-top: 5px;
    flex-shrink: 0;
}
.settings-save-btn:hover {
    background: #2980b9;
}
.settings-msg {
    text-align: center;
    font-size: 13px;
    min-height: 20px;
    flex-shrink: 0;
}

.settings-msg.success { color: #27ae60; }
.settings-msg.error { color: #e74c3c; }

.settings-divider {
    border-bottom: 1px solid #c3c3c3;
    margin: 7px 0 7px 0;
}

/* Статистика */
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
}
.stat-label { font-size: 14px; color: #333; }
.stat-value { font-size: 16px; font-weight: 700; color: #3498db; }
.stat-hint  { font-size: 11px; color: #999; }

/* --- Кликабельные пользователи в правой панели --- */
.rightbar-user-row {
    cursor: pointer;
    transition: background 0.15s;
    border-radius: 4px;
    padding: 3px 0;
}
.rightbar-user-row:hover {
    background: rgba(255,255,255,0.06);
}

/* --- Карточка пользователя --- */
.user-info-card {
    background: #1e2d3d;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 8px;
    padding: 10px 12px;
    margin: 6px 3px 6px 5px;
    font-size: 12px;
    animation: fadeIn 0.2s ease;
}
.user-info-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #ecf0f1;
    margin-bottom: 8px;
    font-size: 13px;
}
.user-info-status {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.user-info-status.online  { background: #2ecc71; }
.user-info-status.offline { background: #7f8c8d; }
.user-info-close {
    margin-left: auto;
    background: none;
    border: none;
    color: #7f8c8d;
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
}
.user-info-close:hover { color: #ecf0f1; }
.user-info-card-body { color: #bdc3c7; }
.uic-row {
    padding: 3px 0;
    display: flex;
    gap: 6px;
}
.uic-label { color: #7f8c8d; min-width: 65px; flex-shrink: 0; }

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.rightbar-user-row.active-row {
    background: rgba(52, 152, 219, 0.2) !important;
    border-radius: 4px;
}

/* Стрелка закрытия сайдбара */
.sidebar-close-arrow {
    display: none;
    background: none;
    border: none;
    color: #ecf0f1;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    margin-left: 8px;
    flex-shrink: 0;
    transition: background 0.15s;
}
.sidebar-close-arrow:hover {
    background: rgba(255,255,255,0.1);
}

/* Стрелка закрытия правой панели */
.rightbar-close-arrow {
    display: none;
    background: none;
    border: none;
    color: #ecf0f1;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    margin-right: 8px;
    flex-shrink: 0;
    transition: background 0.15s;
}
.rightbar-close-arrow:hover {
    background: rgba(255,255,255,0.1);
}

/* Тонкий скроллбар для поля ввода текста */
.chat-form textarea::-webkit-scrollbar {
    width: 4px;               /* Ширина скроллбара */
}

/* Фон скроллбара (трек) */
.chat-form textarea::-webkit-scrollbar-track {
    background: transparent;  /* Прозрачный фон */
}

/* Сама полоска скролла (ползунок) */
.chat-form textarea::-webkit-scrollbar-thumb {
    background: #bcc0c4;      /* Светло-серый цвет полоски */
    border-radius: 4px;       /* Закругленные края */
}

/* Убираем кнопки-стрелочки сверху и снизу */
.chat-form textarea::-webkit-scrollbar-button {
    display: none;
}

/* Поддержка тонкого скролла для Firefox */
.chat-form textarea {
    scrollbar-width: thin;
    scrollbar-color: #bcc0c4 transparent;
}


/* =============================================11
   Мобильная адаптация (≤ 768px)
   ============================================= */
@media (max-width: 768px) {

    html, body {
        background: #fff;
    }

    /* Бургер-кнопка — показываем */
    .burger-btn {
        display: block;
    }

    /* Сайдбар — уезжает за левый край */
    .chat-sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px;
        bottom: 0;
        z-index: 100;
        transition: left 0.3s ease;
    }

    .chat-sidebar.open {
        left: 0;
    }

    /* Оверлей — затемнение фона */
    .sidebar-overlay.show {
        display: block;
    }

    /* Чат — на всю ширину */
    .chat-main {
        width: 100%;
    }

    /* Шапка чата — флекс, чтобы бургер и заголовок были в ряд */
    .chat-header {
        display: flex;
        align-items: center;
    }

    /* Сообщения — почти на всю ширину */
    .message {
        /* max-width: 95%; */
    }
	.chat-form {
		padding: 6px 10px 10px;
	}
	
	.smiles-dropdown {
		width: 240px;
		max-height: 180px;
		bottom: 65px;
		left: 10px;
	}
	
	.smile-btn {
		width: 32px;
		height: 32px;
		font-size: 18px;
	}
	
	.input-container {
		border-radius: 20px;
	}
	
    .smile-toggle-inside {
        width: 32px;
        height: 32px;
        font-size: 18px;
        margin-bottom: 4px;  /* ← ДОБАВИТЬ */
    }

    .send-btn {
        width: 38px;
        height: 38px;
        font-size: 16px;
        margin-left: 2px;
        margin-bottom: 4px;  /* ← ДОБАВИТЬ */
    }
	
	
	.chat-rightbar {
		position: fixed;
		top: 0;
		right: -260px;
		width: 260px;
		bottom: 0;
		z-index: 100;
		transition: right 0.3s ease;
	}
	.chat-rightbar.open {
		right: 0;
	}
	.rightbar-toggle-btn {
		display: block;
	}
	/* Показываем стрелки на мобилке */
	.sidebar-close-arrow,
	.rightbar-close-arrow {
		display: flex;
		align-items: center;
		justify-content: center;
	}
	
	.sidebar-header {
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 0 16px;
		position: relative; /* <-- Добавляем это для работы absolute */
	}
		.sidebar-close-arrow {
		display: flex;
		align-items: center;
		justify-content: center;
		position: absolute; /* <-- Вырываем из потока, чтобы не сдвигало логотип */
		right: 16px;        /* <-- Прибиваем к правому краю */
		margin: 0 !important;
	}
	.rightbar-user {
		justify-content: center;
		padding: 5px 16px 10px 16px;
	}
	.rightbar-close-arrow {
		display: flex;
		align-items: center;
		justify-content: center;
		position: absolute; /* <-- Прибиваем стрелку влево */
		left: 12px;
		margin: 0 !important;
	}
	.rightbar-user-info {
		align-items: center;
		max-width: 170px;
		margin: 0;
	}
	.rightbar-user-info .name {
		font-size: 14px;
		text-align: center;
	}
	.rightbar-user-info .logout-link {
		font-size: 12px;
		padding: 4px 12px;
	}
}