/* =============================================
   CHAT.CSS — Интерфейс чата менеджера и клиента
   ============================================= */

.chat-interface {
    display: flex;
    width: 900px;
    height: 600px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    border: 1px solid #e1e8ed;
    overflow: hidden;
}

/* --- САЙДБАР --- */

.sidebar {
    width: 280px;
    background: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e1e8ed;
    height: 100%;
}

.profile-box {
    padding: 20px;
    background: #243342;
    border-bottom: 1px solid #1a252f;
}

.profile-box h4 {
    margin: 0 0 10px 0;
    font-size: 16px;
    word-break: break-all;
}

.btn-logout {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: bold;
}

.btn-logout:hover {
    background: #c0392b;
}

.channels-list {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    overflow-y: auto;
    max-height: calc(100vh - 150px);
}

/* --- ПЛАШКИ КЛИЕНТОВ В САЙДБАРЕ --- */

.channel-item {
    height: 52px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    border-left: 4px solid transparent;
    transition: background-color 0.4s ease, border-left 0.4s ease, box-shadow 0.4s ease;
    overflow: hidden;
}

/* Верхний этаж: индикатор и имя клиента */
.channel-title-row {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
}

/* Нижний этаж: источник рекламы */
.channel-source-row {
    font-size: 11px;
    opacity: 0.7;
    width: 100%;
    overflow: hidden;
}

/* Защита от вылезания длинных названий */
.channel-title-row .client-name,
.channel-source-row span {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel-item:hover {
    background: #34495e !important;
    border-left: 4px solid #bdc3c7;
    transition: background-color 0.15s ease, border-left 0.15s ease;
}

.channel-item.active {
    background: #34495e !important;
    border-left: 4px solid #3498db;
    font-weight: bold;
}

.channel-item.active:hover {
    background: #3e566f !important;
    border-left: 4px solid #3498db;
}

.channel-item.disabled {
    color: #7f8c8d;
    cursor: not-allowed;
    opacity: 0.6;
}

.channel-item.unread {
    background: #2980b9;
    border-left: 4px solid #2ecc71;
    font-weight: bold;
    animation: pulseGlow 1.8s infinite ease-in-out;
}

.channel-item.unread:hover {
    background: #5dade2 !important;
    box-shadow: 0 0 12px rgba(93, 173, 226, 0.8);
}

/* --- СТАТУС-ДОТЫ (ИНДИКАТОРЫ ОНЛАЙНА) --- */

/* Базовый дот — общие свойства для всех контекстов */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #e74c3c;
}

/* Дот в шапке окна чата менеджера */
.chat-header .status-dot {
    width: 10px;
    height: 10px;
    margin-right: 8px;
    transition: background-color 0.3s ease;
}

.chat-header.is-online .status-dot {
    background: #2ecc71;
}

/* Дот в плашке клиента в сайдбаре */
.channel-item .status-dot {
    margin-right: 5px;
}

.channel-item.is-online .status-dot {
    background: #2ecc71;
}

/* Дот в чате клиента (показывает онлайн менеджера) */
.client-chat-header .status-dot {
    width: 10px;
    height: 10px;
    margin-right: 8px;
    transition: background-color 0.3s ease;
}

.client-chat-header.is-manager-online .status-dot {
    background: #2ecc71;
}

/* --- ОКНО ЧАТА --- */

.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
}

.chat-header {
    padding: 20px;
    background: white;
    border-bottom: 1px solid #e1e8ed;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-messages-area {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* --- ПУЗЫРИ СООБЩЕНИЙ --- */

.message {
    display: flex;
    flex-direction: column;
    max-width: 70%;
    min-width: 0;
}

.message.system {
    max-width: 100%;
    text-align: center;
    color: #7f8c8d;
    font-size: 12px;
    font-style: italic;
    margin: 5px 0;
}

.message.agent {
    align-self: flex-start;
}

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

.bubble {
    padding: 12px 16px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.4;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    white-space: pre-wrap !important;
}

.message.agent .bubble {
    background: white;
    color: #2c3e50;
    border: 1px solid #e1e8ed;
    border-top-left-radius: 2px;
}

.message.client .bubble {
    background: #3498db;
    color: white;
    border-top-right-radius: 2px;
}

.time {
    font-size: 10px;
    color: #95a5a6;
    margin-top: 4px;
    padding: 0 4px;
}

.message.client .time {
    align-self: flex-end;
}

/* --- ИНПУТ ОТПРАВКИ СООБЩЕНИЯ --- */

.chat-input-bar {
    padding: 15px;
    background: white;
    border-top: 1px solid #e1e8ed;
    display: flex;
    gap: 10px;
}

.chat-input-bar input {
    flex: 1;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    outline: none;
    font-size: 16px;
}

.chat-input-bar input:focus {
    border-color: #3498db;
}

.chat-input-bar button {
    background: #3498db;
    color: white;
    border: none;
    padding: 0 20px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
}

.chat-input-bar button:hover {
    background: #2980b9;
}

.chat-input-bar button:active {
    background: #1f618d;
    transform: scale(0.96);
}

/* Инпут чата — hover и focus эффекты */
#inpMessage {
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease !important;
}

#inpMessage:hover {
    border-color: #3498db;
    background-color: #f7f9fa;
}

#inpMessage:focus {
    border-color: #3498db;
    background-color: #ffffff;
    box-shadow: 0 0 8px rgba(52, 152, 219, 0.4);
}

/* --- КНОПКА НАСТРОЕК В САЙДБАРЕ --- */

.btn-settings-panel {
    background: #34495e;
    color: #ffffff;
    border: none;
    border-radius: 4px;
    padding: 10px;
    font-size: 13px;
    font-weight: bold;
    cursor: pointer;
    outline: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: background-color 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease;
}

.btn-settings-panel:hover {
    background: #4e6a85;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.btn-settings-panel:active {
    background: #2c3e50;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transform: scale(0.97);
}

/* --- КРЕСТИК УДАЛЕНИЯ --- */

.delete-cross-btn {
    opacity: 0;
    pointer-events: none;
    color: #95a5a6;
    font-size: 16px;
    font-weight: normal !important;
    cursor: pointer;
    transition: opacity 0.2s ease, color 0.2s ease, transform 0.1s ease;
    padding: 0 6px;
    margin-left: 10px;
    line-height: 1;
    display: inline-block;
}

.generated-link-item:hover .delete-cross-btn,
.channel-item:hover .delete-cross-btn {
    opacity: 1;
    pointer-events: auto;
}

.delete-cross-btn:hover {
    color: #e74c3c !important;
    transform: scale(1.15);
}

.delete-modal-show {
    opacity: 1 !important;
    pointer-events: auto !important;
}
