/* Основной контейнер чата */
.global-chat-modal {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 400px;
    height: 520px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 10px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.2);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Заголовок */
.chat-header {
    background: #007bff;
    color: white;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.chat-header-info {
    flex: 1;
}

.chat-title {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 2px;
}

.chat-subtitle {
    font-size: 11px;
    opacity: 0.9;
}

.close-chat {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Тело чата */
.chat-body {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    width: 100%;
}

/* Левая панель - список чатов (всегда на 100% ширины) */
.chat-sidebar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 1;
}

/* Правая панель - сообщения (сдвинута вправо изначально) */
.chat-main {
    position: absolute;
    top: 0;
    left: 100%; /* Начинается за пределами справа */
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 2;
}

/* Когда активен чат, сдвигаем панели */
.chat-body.conversation-active .chat-sidebar {
    transform: translateX(-100%); /* Сдвигаем список влево */
}

.chat-body.conversation-active .chat-main {
    transform: translateX(-100%); /* Сдвигаем чат в видимую область */
}

/* Список чатов */
.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.chat-list-header {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.chat-list-header h3 {
    margin: 0;
    font-size: 16px;
    color: #333;
}

.chat-list-empty {
    padding: 40px 20px;
    text-align: center;
    color: #666;
    font-style: italic;
}

/* Элементы списка чатов */
.chat-item {
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s;
}

.chat-item:hover {
    background: #f8f9fa;
}

.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 5px;
}

.chat-item-name {
    font-weight: bold;
    color: #333;
    font-size: 14px;
}

.chat-item-job {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

.chat-item-time {
    font-size: 11px;
    color: #666;
}

.chat-item-preview {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-unread {
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 5px;
}

/* Кнопка назад в чате */
.chat-back-button {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    font-size: 14px;
    color: #007bff;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.chat-back-button:hover {
    background: #e9ecef;
}

.chat-back-button i {
    margin-right: 8px;
    font-size: 16px;
}

/* Сообщения */
.chat-messages-container {
    flex: 1;
    overflow-y: auto;
    background: #f8f9fa;
}

.chat-messages {
    min-height: 100%;
    padding: 15px;
}

.message {
    margin-bottom: 12px;
    max-width: 85%;
    padding: 8px 12px;
    border-radius: 12px;
    word-wrap: break-word;
}

.message-outgoing {
    background: #dcf8c6;
    margin-left: auto;
}

.message-incoming {
    background: white;
    border: 1px solid #e0e0e0;
    margin-right: auto;
}

.message-sender {
    font-weight: bold;
    margin-bottom: 3px;
    font-size: 12px;
}

.message-incoming .message-sender {
    color: #007bff;
}

.message-outgoing .message-sender {
    color: #2d5016;
}

.message-text {
    word-wrap: break-word;
}

.message-time {
    font-size: 10px;
    margin-top: 4px;
    opacity: 0.7;
    text-align: right;
}

/* Блок ввода сообщения */
.chat-input-container {
    border-top: 1px solid #e0e0e0;
    background: white;
    flex-shrink: 0;
}

.chat-input {
    display: flex;
    padding: 12px 15px;
    gap: 10px;
    align-items: center;
}

.chat-input input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    height: 40px;
    box-sizing: border-box;
}

.chat-input input:focus {
    border-color: #007bff;
}

.chat-input button {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 20px;
    padding: 0 16px;
    cursor: pointer;
    font-size: 14px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
    transition: background-color 0.2s;
}

.chat-input button:hover {
    background: #0056b3;
}

/* Кнопка открытия чата */
.chat-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: #ffc107;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    z-index: 1001;
    box-shadow: 0 3px 15px rgba(0,0,0,0.2);
    transition: all 0.3s ease;
}

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

.chat-toggle-btn.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Уведомления */
.chat-notification-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

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

/* Адаптивность */
@media (max-width: 768px) {
    .global-chat-modal {
        width: 95vw;
        height: 80vh;
        right: 2.5vw;
        bottom: 10vh;
    }
}
/* Стили для кнопки закрытия чата */
.chat-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.btn-close-chat {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.btn-close-chat:hover {
    background: transparent;
}

.btn-refresh {
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 5px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 12px;
}

/* Стиль для закрытых чатов */

.close-chat-item{
    border: none;
    background-color: transparent;
}
/* Стили для элемента чата */
.chat-item {
    position: relative;
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
}

.chat-item:hover {
    background: #f8f9fa;
}

.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 5px;
    position: relative;
}

/* Кнопка закрытия с подсказкой */
.close-chat-item {
    position: relative;
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
    opacity: 0.6;
    color: #000 !important;
    margin-left: 10px;
}

.close-chat-item:hover {
    opacity: 1;
    color: #000000 !important;
    transform: scale(1.1);
}

/* Всплывающая подсказка */
.close-tooltip {
    position: absolute;
    bottom: 100%;
    right: 0;
    background: #000;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
    transition: all 0.3s ease;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Стрелка подсказки */
.close-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 10px;
    border: 5px solid transparent;
    border-top-color: #000;
}

/* Показываем подсказку при наведении на кнопку */
.close-chat-item:hover .close-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(-5px);
}

/* Остальные стили */
.chat-item-name {
    font-weight: bold;
    margin-bottom: 2px;
    color: #000;
}

.chat-item-job {
    font-size: 12px;
    color: #6c757d;
}

.chat-item-time {
    font-size: 12px;
    color: #6c757d;
    white-space: nowrap;
}

.chat-item-preview {
    font-size: 14px;
    color: #6c757d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-unread {
    position: absolute;
    bottom: 10px;
    right: 15px;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}
     /* 🔥 СТИЛИ ДЛЯ СТАТУСОВ ОНЛАЙН */
 .chat-status {
     display: flex;
     align-items: center;
     gap: 6px;
     font-size: 12px;
     margin-top: 2px;
 }

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.online {
    background-color: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3);
}

.status-indicator.offline {
    background-color: #6b7280;
}

.status-indicator.away {
    background-color: #f59e0b;
}

.status-text {
    color: #6b7280;
    font-size: 11px;
}

/* 🔥 СТАТУС В СПИСКЕ ЧАТОВ */
/* 🔥 ОБНОВЛЕННЫЕ СТИЛИ ДЛЯ ЗАГОЛОВКА */
.chat-header-info {
    flex: 1;
}

.chat-title-line {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 2px;
}

.chat-title {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

.chat-subtitle {
    font-size: 14px;
    color: #ffffff;
    font-weight: 400;
}

.chat-status-line {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    margin-top: 2px;
}

/* 🔥 СТИЛИ ДЛЯ СТАТУСОВ */
.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.status-indicator.online {
    background-color: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3);
}

.status-indicator.offline {
    background-color: #6b7280;
}

.status-text {
    color: #22c55e;
    font-size: 12px;
    font-weight: 500;
}

.last-seen-text {
    color: #6b7280;
    font-size: 12px;
}

/* 🔥 СТАТУС В СПИСКЕ ЧАТОВ */
.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}

.chat-item-contact {
    flex: 1;
}

.chat-item-name {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 2px;
}

.chat-item-job {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 2px;
}

.chat-item-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
}

.chat-item-status .status-indicator {
    width: 6px;
    height: 6px;
}

.chat-item-time {
    font-size: 11px;
    color: #9ca3af;
    white-space: nowrap;
}

/* 🔥 ОСТАЛЬНЫЕ СТИЛИ */
.chat-list-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin: 0 0 12px 0;
}

.chat-list-empty {
    text-align: center;
    color: #6b7280;
    font-size: 14px;
    padding: 20px;
}

.chat-back-button {
    color: #3b82f6;
    cursor: pointer;
    font-size: 14px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-back-button:hover {
    color: #2563eb;
}

.chat-input input {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 14px;
}

.chat-input input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
/* 🔥 ОБНОВЛЕННЫЕ СТИЛИ ДЛЯ СТРОКИ С ИМЕНЕМ И СТАТУСОМ */
.chat-item-name-line {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.chat-item-name {
    font-weight: 600;
    color: #1f2937;
    font-size: 14px;
}

.chat-item-status {
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-item-status .status-indicator {
    width: 6px;
    height: 6px;
}

.chat-item-status .status-text {
    color: #22c55e;
    font-size: 11px;
    font-weight: 500;
}

.chat-item-status .last-seen-text {
    color: #6b7280;
    font-size: 11px;
}

.chat-item-job {
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 2px;
}

.chat-item-preview {
    font-size: 13px;
    color: #4b5563;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.chat-item-unread {
    position: absolute;
    top: 8px;
    right: 8px;
    background-color: #ef4444;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 🔥 ОБНОВЛЕННЫЕ СТИЛИ ДЛЯ ВСЕГО ЭЛЕМЕНТА ЧАТА */
.chat-item {
    position: relative;
    padding: 12px;
    border-bottom: 1px solid #f3f4f6;
    cursor: pointer;
    transition: background-color 0.2s;
}

.chat-item:hover {
    background-color: #f9fafb;
}

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

.chat-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 4px;
}

.chat-item-contact {
    flex: 1;
    min-width: 0; /* Для правильного обрезания текста */
}

.chat-item-time {
    font-size: 11px;
    color: #9ca3af;
    white-space: nowrap;
    margin-left: 8px;
}
