﻿:root {
    --primary: #0077FF;
    --secondary: #6c757d;
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    --light: #f8f9fa;
    --dark: #343a40;
}

body {
    background-color: #f5f5f5;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.sidebar {
    background: linear-gradient(135deg, var(--primary), #0056b3);
    color: white;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    overflow-y: auto;
}

.sidebar .nav-link {
    color: rgba(255,255,255,.8);
    padding: 12px 20px;
    margin: 4px 0;
    border-radius: 8px;
    transition: all 0.3s;
}

.sidebar .nav-link:hover, .sidebar .nav-link.active {
    color: white;
    background: rgba(255,255,255,.2);
}

.sidebar .nav-link i {
    margin-right: 10px;
    width: 20px;
    text-align: center;
}

.main-content {
    margin-left: 250px;
    padding: 20px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transition: transform 0.3s;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card i {
    font-size: 2rem;
    margin-bottom: 10px;
}

.login-container {
    max-width: 400px;
    margin: 100px auto;
    padding: 40px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

.table-container {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    overflow-x: auto;
}

.toast-container {
    z-index: 9999;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.stat-card, .table-container {
    transition: all 0.3s ease;
}

.modal-content {
    border-radius: 12px;
    border: none;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.modal-header {
    border-bottom: 1px solid #e9ecef;
    padding: 1.5rem;
}

.modal-footer {
    border-top: 1px solid #e9ecef;
    padding: 1.5rem;
}

.table th {
    border-top: none;
    font-weight: 600;
    color: #495057;
    background-color: #f8f9fa;
}

.table td {
    vertical-align: middle;
}

.btn-group-actions .btn {
    margin: 0 2px;
}

.role-badge {
    font-size: 0.7em;
    margin-left: 5px;
}

.history-list {
    margin-top: 20px;
    max-height: 300px;
    overflow-y: auto;
    border-top: 1px solid #eee;
    padding-top: 10px;
}
.history-item {
    margin-bottom: 15px;
    padding: 10px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}
.history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 5px;
}
.history-action {
    font-size: 0.8em;
    flex-shrink: 0;
}
.history-user {
    font-size: 0.9em;
    font-weight: 600;
    flex-grow: 1;
}
.history-date {
    font-size: 0.8em;
    flex-shrink: 0;
}
.history-body {
    font-size: 0.9em;
}
.history-details {
    color: #212529;
    word-break: break-word;
}
.history-notes {
    margin-top: 5px;
    padding-top: 5px;
    border-top: 1px dashed #ccc;
    color: #495057;
    word-break: break-word;
}

/* Стили для страницы Категорий */
.page-title {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--dark);
    margin-bottom: 0.5rem;
}

.page-subtitle {
    color: var(--secondary);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

.category-grid { 
    display: flex;
    flex-direction: column; 
    gap: 0.75rem;
}

.category-card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 12px; 
    padding: 1.25rem 1.5rem;
    transition: all 0.2s ease; 
    position: relative;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.category-card:not(.hidden):hover { 
    background: #f0f6ff;
    border-color: var(--primary);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.category-card-content {
    display: flex;
    justify-content: space-between;
    align-items: center; 
}

.list-info {
    flex-grow: 1;
}
.list-info h4 {
    color: var(--dark);
    margin-bottom: 0.25rem;
    font-weight: 600;
}
.list-info p {
    color: var(--secondary);
    margin-bottom: 0;
    font-size: 0.85rem;
}

.list-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    opacity: 0;
    transition: opacity 0.2s;
}

.category-card:not(.hidden):hover .list-actions {
    opacity: 1;
}

/* Стиль для СКРЫТОЙ категории */
.category-card.hidden {
    opacity: 0.7;
    background: var(--light);
    border-color: #e9ecef;
    cursor: default;
    box-shadow: none;
    color: #9CA3AF;
}
.category-card.hidden h4 { color: #9CA3AF !important; }
.category-card.hidden .list-actions { opacity: 1; }

/* Стиль для кнопок действий */
.btn-action { 
    width: 36px;
    height: 36px; 
    border: none; 
    background: transparent;
    color: var(--secondary);
    border-radius: 8px;
    font-size: 0.8rem; 
    padding: 0; 
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.btn-action:hover { 
    background: var(--primary);
    color: white; 
}

.list-actions .btn-danger-custom {
    background-color: transparent !important;
    color: var(--danger) !important;
    border: 1px solid var(--danger);
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    line-height: 1;
}
.list-actions .btn-danger-custom:hover {
    background-color: var(--danger) !important;
    color: white !important;
}

.list-actions .btn-success-custom {
    background-color: var(--success) !important;
    color: white !important;
    border: none !important;
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    line-height: 1;
}
.list-actions .btn-success-custom:hover {
    background-color: #16a096 !important;
}

/* Price Table Styles */
#categoryDetailModal .card {
    border-radius: 12px;
    border: 1px solid #e9ecef; 
    box-shadow: 0 4px 6px rgba(0,0,0,0.1); 
    overflow: hidden;
    background: white;
}
#categoryDetailModal .card-header { 
    background: var(--light);
    border-bottom: 1px solid #e9ecef; 
    font-weight: 600; 
    padding: 1rem 1.5rem;
    color: var(--dark);
}

.price-table {
    width: 100%;
    border-collapse: collapse; 
    font-size: 0.9rem;
}

.price-table th {
    background: var(--light);
    color: var(--dark);
    padding: 0.8rem 0.5rem;
    text-align: center;
    font-weight: 600;
    border: 1px solid #e9ecef;
    min-width: 60px;
}

.price-table th:first-child { 
    background: var(--light);
    color: var(--dark);
    font-weight: 700;
    min-width: 100px;
    position: sticky;
    left: 0;
    z-index: 1;
}

.price-table td {
    padding: 0.6rem;
    text-align: center;
    border: 1px solid #e9ecef;
    background: white;
    color: var(--dark);
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.price-table td.dimension-header {
    background: var(--light);
    color: var(--dark);
    font-weight: 600;
    text-align: left; 
    padding-left: 15px;
    position: sticky;
    left: 0;
    z-index: 1;
    cursor: default;
}

.price-table td:hover {
    background-color: #f0f6ff;
}

/* Стили для формы ввода значений */
.price-input-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
    margin-top: 15px;
}
.price-input-group {
    display: flex;
    flex-direction: column;
}
.price-input-label {
    font-size: 0.8rem;
    color: var(--secondary);
    margin-bottom: 5px;
}

/* Стили для статуса "Скрыто" */
.hidden-badge {
    display: inline-block;
    background: #9CA3AF;
    color: white;
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 6px;
    margin-left: 8px;
    vertical-align: middle;
}

.fabric-sample {
    width: 50px;
    height: 50px; 
    border-radius: 8px; 
    margin-right: 1rem; 
    border: 2px solid #e9ecef;
    background: var(--primary);
    background-size: cover;
    background-position: center;
}

.color-dot {
    width: 20px;
    height: 20px; 
    border-radius: 50%; 
    margin-right: 10px; 
    border: 1px solid #e9ecef;
}

/* Анимации */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.category-card {
    animation: fadeIn 0.3s ease-out;
}

.fabric-item {
    border-radius: 8px;
    border: 1px solid #e9ecef;
    transition: all 0.2s;
}
.fabric-item:hover {
    background: #f8f9fa;
}

.color-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px;
    border-radius: 6px;
}
.color-item:hover {
    background-color: #f8f9fa;
}

/* Стили для перетаскивания */
.category-card.dragging {
    opacity: 0.5;
    background: #f8f9fa;
}

.drag-handle {
    cursor: grab;
}

.drag-handle:active {
    cursor: grabbing;
}

.category-card.dragover {
    border: 2px dashed var(--primary);
}

/* Улучшенные стили для карточек категорий */
.category-card {
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
}

.category-card:not(.hidden):hover {
    border-left-color: var(--primary);
    transform: translateX(5px);
}

.category-card.hidden {
    border-left-color: #6c757d;
}

/* Стили для кнопок перемещения */
.btn-action.move-btn {
    background: transparent;
    border: 1px solid var(--secondary);
    color: var(--secondary);
}

.btn-action.move-btn:hover {
    background: var(--secondary);
    color: white;
}

/* Стили для просмотра файлов в заказе */
.file-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
    margin-top: 15px;
}

.file-preview-item {
    position: relative;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    overflow: hidden;
    aspect-ratio: 1;
    cursor: pointer;
    transition: transform 0.2s;
}

.file-preview-item:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.file-preview-item img, 
.file-preview-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-preview-icon {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    color: var(--secondary);
}

.file-preview-icon i {
    font-size: 2rem;
    margin-bottom: 5px;
}

/* Стили для статусов заказов */
.status-deleted {
    background: #f8f9fa;
    color: #6c757d;
    border: 1px solid #dee2e6;
}

/* Скрытие элементов по ролям */
.hidden-for-assembler {
    display: none !important;
}

/* Стили для кнопок действий в зависимости от статуса */
.btn-status-action {
    font-size: 0.8rem;
    padding: 0.25rem 0.5rem;
}

/* Стили для комментариев оператора */
.operator-comment {
    background-color: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 10px;
    margin: 10px 0;
    border-radius: 4px;
    font-size: 0.9em;
}

/* Адаптивные стили для мобильных устройств */
@media (max-width: 768px) {
    .sidebar {
        width: 70px !important;
    }
    
    .sidebar .nav-link span:not(.fas) {
        display: none;
    }
    
    .main-content {
        margin-left: 70px !important;
    }
    
    .stat-card {
        padding: 15px;
    }
    
    .table-container {
        overflow-x: auto;
    }
}

/* Анимация для уведомлений */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.toast {
    animation: fadeInUp 0.3s ease-out;
}

/* Стили для временных меток */
.time-ago {
    font-size: 0.8em;
    color: #6c757d;
    font-style: italic;
}

/* Стили для важных уведомлений */
.alert-important {
    border-left: 4px solid #dc3545;
    background-color: #f8d7da;
}

/* Стили для заказов, которые скоро будут удалены */
.order-soon-delete {
    background-color: #fff3cd !important;
    border-left: 4px solid #ffc107 !important;
}

/* Стили для отключенных кнопок */
.btn-disabled-reason {
    position: relative;
    cursor: not-allowed;
}

.btn-disabled-reason:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.8em;
    white-space: nowrap;
    z-index: 1000;
}

/* Цвета строк таблицы для Админки */
.table-primary { background-color: #cfe2ff; }
.table-secondary { background-color: #e2e3e5; }
.table-success { background-color: #d1e7dd; }
.table-danger { background-color: #f8d7da; }
.table-warning { background-color: #fff3cd; }
.table-info { background-color: #cff4fc; }
.table-light { background-color: #f8f9fa; }

/* Цвет бейджика для Дилера */
.bg-purple {
    background-color: #6f42c1 !important;
    color: white;
}

/* ФИКСИРОВАННЫЙ ЧАТ */
/* Главный контейнер страницы чата */
#chatPage {
    height: calc(100vh - 100px); /* Вычитаем высоту хедера, чтобы не было прокрутки всей страницы */
    overflow: hidden; /* Скрываем скролл страницы */
    display: none; /* JS сам переключит на flex/block */
}

/* Карточка чата */
#chatPage .card {
    height: 100%;
    border: none;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: row;
}

/* Область сообщений */
#chatContentArea {
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: #f8f9fa;
    position: relative;
    overflow: hidden;
}

/* Сам список сообщений - он должен скроллиться */
#chatMessages {
    flex: 1 1 auto; /* Растягивается на все доступное место */
    overflow-y: auto; /* Прокрутка только внутри этого блока */
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f0f2f5; /* Светлый фон вместо белого */
    height: 0; /* Важно для flex-grow */
}

/* Список чатов */
#chatList {
    overflow-y: auto;
    /* Убираем скроллбар если не нужен, или стилизуем */
}

/* Скрываем область ввода если чат не выбран */
.chat-input-area {
    display: none; /* По умолчанию скрыто */
}
.chat-input-area.active {
    display: flex !important;
}

/* Цвета статусов заявок (как в заказах) */
.req-status-new { background-color: #cfe2ff; color: #084298; }
.req-status-accepted { background-color: #fff3cd; color: #664d03; }
.req-status-completed { background-color: #d1e7dd; color: #0f5132; }
.req-status-cancelled { background-color: #f8d7da; color: #842029; }

/* ГОЛОСОВЫЕ СООБЩЕНИЯ */
.audio-msg {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 200px;
}
.audio-controls button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
}
.audio-wave {
    height: 30px;
    flex-grow: 1;
    background: url('https://png.klev.club/uploads/posts/2024-04/png-klev-club-tq5t-p-golosovoe-soobshchenie-png-2.png') repeat-x center;
    background-size: contain;
    opacity: 0.5;
}

/* Анимация записи */
.recording-wave {
    display: none;
    align-items: center;
    gap: 5px;
    color: #dc3545;
    font-weight: bold;
    animation: pulseRed 1.5s infinite;
}
@keyframes pulseRed {
    0% { opacity: 0.5; }
    50% { opacity: 1; }
    100% { opacity: 0.5; }
}

/* Контекстное меню сообщения (редактировать/удалить) */
.msg-options {
    opacity: 0;
    transition: opacity 0.2s;
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255,255,255,0.8);
    border-radius: 4px;
    padding: 2px;
}
.msg-bubble:hover .msg-options {
    opacity: 1;
}

/* Предпросмотр файлов */
.file-preview-mini {
    max-width: 150px;
    max-height: 150px;
    object-fit: cover;
    border-radius: 8px;
    margin-top: 5px;
}

/* Скрываем стандартный инпут файла */
input[type="file"].d-none {
    display: none !important;
}

/* Убираем фиолетовые оттенки, если они остались */
.bg-primary {
    background-color: #0d6efd !important; /* Стандартный синий Bootstrap */
}

/* 1. Задаем высоту главному контейнеру, иначе внутри все схлопнется */
#chatPage {
    height: calc(100vh - 80px) !important; /* Высота экрана минус хедер */
    display: none; /* Скрыт пока не нажмут кнопку */
    overflow: hidden; /* Чтобы не было двойных скроллов */
}

/* 2. Растягиваем карточку на всю высоту */
#chatPage .card {
    height: 100%;
    display: flex;
    flex-direction: row; /* Список слева, чат справа */
    border: 1px solid #e0e0e0;
}

/* 3. Левая колонка (Список) */
#chatList {
    overflow-y: auto;
    height: 100%; 
    /* Важно: задать высоту списку, иначе он вылезет */
}

/* 4. Правая колонка (Окно чата) */
#chatContentArea {
    display: flex; /* Flex чтобы прижать футер ввода вниз */
    flex-direction: column;
    height: 100%;
    background-color: #f4f6f8;
    width: 100%;
}

/* 5. Сами сообщения (Центральная часть) */
#chatMessages {
    flex-grow: 1; /* Занимает все свободное место */
    overflow-y: auto; /* Скроллится только эта часть */
    padding: 20px;
    height: 0; /* Хак для flexbox, чтобы скролл работал корректно */
}

/* 6. Заглушка "Выберите чат" */
#chatPlaceholder {
    height: 100%;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* ================= CHAT STYLES ================= */

#chatPage {
    height: calc(100vh - 200px);
    display: flex;
    flex-direction: column;
}

#chatList {
    overflow-y: auto;
    flex: 1;
}

.chat-item {
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.2s;
}

.chat-item:hover {
    background-color: #f8f9fa;
}

.chat-item.active {
    background-color: #e3f2fd;
    border-left: 3px solid #2196f3;
}

.chat-item.unread {
    background-color: #fff8e1;
}

.chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
}

.chat-avatar.group-chat {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.chat-avatar.private-chat {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.chat-info {
    min-width: 0;
}

.chat-name {
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.chat-time {
    font-size: 11px;
    color: #999;
}

.chat-preview {
    font-size: 13px;
    color: #666;
    margin-top: 2px;
}

.unread-badge {
    display: inline-block;
    background: #ff5252;
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-right: 5px;
}

.chat-divider {
    padding: 8px 15px;
    background: #f8f9fa;
    font-size: 12px;
    color: #666;
    border-bottom: 1px solid #e9ecef;
}

.chat-divider span {
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Сообщения */
#chatMessages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f5f5f5;
    display: none;
}

.message-row {
    display: flex;
    margin-bottom: 15px;
}

.message-row.message-out {
    justify-content: flex-end;
}

.message-content {
    max-width: 70%;
    padding: 10px 15px;
    border-radius: 18px;
    position: relative;
}

.message-in .message-content {
    background: white;
    border: 1px solid #e0e0e0;
}

.message-out .message-content {
    background: #2196f3;
    color: white;
}

.message-sender {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-bottom: 4px;
}

.message-text {
    word-break: break-word;
}

.message-time {
    font-size: 11px;
    opacity: 0.8;
    margin-top: 5px;
    display: flex;
    align-items: center;
}

.message-attachment {
    margin-top: 8px;
}

.message-attachment img {
    border-radius: 10px;
    max-width: 100%;
}

.message-attachment.file {
    background: #f5f5f5;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid #ddd;
}

.message-actions {
    display: inline-flex;
    margin-left: 10px;
}

/* Форма отправки */
#chatForm {
    border-top: 1px solid #e0e0e0;
    padding: 15px;
    background: white;
    display: none;
}

.voice-recording-indicator {
    background: #fff3e0;
    border: 1px solid #ffcc80;
    border-radius: 10px;
    padding: 10px 15px;
    margin: 10px 15px;
}

.voice-waves {
    display: flex;
    align-items: center;
    gap: 3px;
}

.voice-waves .wave {
    width: 3px;
    height: 20px;
    background: #ff9800;
    border-radius: 3px;
    animation: wave 1s infinite ease-in-out;
}

.voice-waves .wave:nth-child(2) { animation-delay: 0.1s; }
.voice-waves .wave:nth-child(3) { animation-delay: 0.2s; }
.voice-waves .wave:nth-child(4) { animation-delay: 0.3s; }

@keyframes wave {
    0%, 100% { height: 10px; }
    50% { height: 20px; }
}

/* Контекстное меню чата */
.chat-context-menu {
    background: white;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border: 1px solid #e0e0e0;
    min-width: 180px;
}

/* Кнопка возврата к списку чатов */
#backToChatList {
    display: none;
}

/* Адаптивность */
@media (max-width: 768px) {
    .message-content {
        max-width: 85%;
    }
    
    #chatPage {
        height: calc(100vh - 150px);
    }
}

/* Основной контейнер чата */
.chat-section {
    display: flex;
    height: calc(100vh - 100px); /* Вычитаем высоту шапки админки */
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    overflow: hidden;
    margin-top: 10px;
}

/* Список чатов слева */
.chat-sidebar {
    width: 320px;
    border-right: 1px solid #edf2f7;
    display: flex;
    flex-direction: column;
    background: #fcfcfc;
}

.chat-sidebar-header {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid #edf2f7;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

/* Элемент списка контактов */
.contact-item {
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid #f8f9fa;
    display: flex;
    align-items: center;
    gap: 12px;
}

.contact-item:hover { background-color: #f0f7ff; }
.contact-item.active { 
    background-color: #e7f1ff; 
    border-left: 4px solid var(--bs-primary); 
}

/* Окно сообщений */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8fbff;
}

.chat-header {
    height: 70px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #fff;
    border-bottom: 1px solid #edf2f7;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Пузыри сообщений */
.message {
    max-width: 75%;
    padding: 10px 15px;
    border-radius: 18px;
    font-size: 0.95rem;
    position: relative;
    line-height: 1.4;
}

.message.sent {
    align-self: flex-end;
    background-color: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received {
    align-self: flex-start;
    background-color: #fff;
    color: #333;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

/* Область ввода */
.chat-footer {
    padding: 15px 20px;
    background: #fff;
    border-top: 1px solid #edf2f7;
}

.chat-input-area {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f1f3f4;
    padding: 5px 10px;
    border-radius: 30px;
}

.input-wrapper { flex: 1; }
.btn-round {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.chat-empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
}

/* Адаптивность для мобильных */
@media (max-width: 768px) {
    .chat-sidebar { width: 100%; }
    .chat-main { display: none; } /* Скрываем окно чата, пока не выбран контакт */
    body.chat-open .chat-sidebar { display: none; }
    body.chat-open .chat-main { display: flex; position: fixed; inset: 0; z-index: 1050; }
}

/* Исправление отображения контейнера чата */
#activeChatContent {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Это позволит сообщениям скроллиться, не задевая поле ввода */
.messages-container {
    flex: 1 1 auto; 
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Фиксация футера внизу */
.chat-footer {
    flex: 0 0 auto;
    background: #fff;
    border-top: 1px solid #edf2f7;
    padding: 15px;
}

/* Принудительно разрешаем переносы строк в блоке сообщения */
.message-text {
    white-space: pre-line !important; /* Это заставит браузер учитывать даже обычные переносы \n */
    word-wrap: break-word;
    word-break: break-word;
}

.message-content {
    max-width: 80%;
    display: inline-block;
}

.message-text, .text-break {
    white-space: pre-wrap !important; /* Сохраняет переносы строк и переносит текст по ширине */
    word-break: break-word;           /* Чтобы длинные слова не вылезали за края */
}

/* В разделе стилей для сообщений чата добавьте: */
.message-text {
    white-space: normal !important; /* Изменено с pre-line */
    word-wrap: break-word;
    word-break: break-word;
    line-height: 1.4;
}

/* Убедитесь, что у родительских элементов нет стилей влияющих на переносы */
.message-content {
    max-width: 80%;
    display: inline-block;
}

/* Добавьте в конец файла admin.css */
.message-text, 
.message-content > div:not(small) {
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.4 !important;
    display: block !important;
}

/* Отключите все возможные переносы в тексте сообщений */
#wMessages * {
    white-space: normal !important;
}

/* Исправьте или добавьте эти стили для сообщений чата: */
.message-content {
    max-width: 80%;
    display: inline-block;
    min-width: 50px; /* Минимальная ширина чтобы текст не переносился на каждом слове */
}

.message-text, 
.message-content > div:not(small) {
    white-space: normal !important;
    word-break: normal !important; /* Измените с break-word на normal */
    word-wrap: normal !important;
    overflow-wrap: normal !important;
    line-height: 1.4 !important;
    display: inline !important;
}

/* Для очень длинных слов все же разрешим перенос */
.message-content {
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* --- НОВЫЙ ДИЗАЙН ЧАТА --- */

/* 1. Сайдбар и список чатов */
.chat-sidebar {
    background: #fff;
    border-right: 1px solid #eef2f5;
}

.search-box input {
    background-color: #f1f3f4;
    border: none;
    border-radius: 20px;
    padding-left: 15px;
}

.contact-item {
    padding: 12px 15px;
    border-bottom: 1px solid #f5f7f9;
    border-radius: 8px;
    margin: 4px 8px;
    transition: all 0.2s;
}

.contact-item:hover {
    background-color: #f4f6f8;
}

.contact-item.active {
    background-color: #e6f2ff; /* Светло-синий активный */
    border-left: none; /* Убираем старую полоску */
}

/* 2. Область сообщений */
.chat-main {
    background-color: #8E9EAB; /* Фон как в Telegram (примерно) */
    background-image: url('https://web.telegram.org/img/bg_0.png'); /* Или паттерн */
    background-size: cover;
}

.messages-container {
    padding: 20px 40px; /* Больше отступов */
    display: flex;
    flex-direction: column;
    gap: 8px; /* Расстояние между сообщениями */
}

/* 3. Пузыри сообщений */
.message {
    max-width: 65%;
    padding: 8px 12px;
    border-radius: 12px;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
    font-size: 14px;
    line-height: 1.5;
    animation: fadeIn 0.2s ease;
}

.message.sent {
    align-self: flex-end;
    background-color: #effdde; /* Светло-зеленый (как в WhatsApp/TG) */
    color: #000;
    border-bottom-right-radius: 2px; /* Хвостик */
}

.message.received {
    align-self: flex-start;
    background-color: #fff;
    color: #000;
    border-bottom-left-radius: 2px; /* Хвостик */
}

/* Время сообщения */
.msg-time {
    float: right;
    font-size: 11px;
    color: #aebac1;
    margin-left: 8px;
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 3px;
}
.message.sent .msg-time { color: #5fb392; } /* Зеленоватый для своих */

/* 4. Разделитель даты */
.date-separator {
    text-align: center;
    margin: 15px 0;
    position: relative;
}
.date-separator span {
    background-color: rgba(0, 0, 0, 0.3);
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

/* 5. Контекстное меню (ПКМ и действия) */
.chat-context-menu {
    position: fixed;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10000;
    min-width: 160px;
    overflow: hidden;
    padding: 5px 0;
}

.chat-context-menu-item {
    padding: 8px 15px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #333;
}
.chat-context-menu-item:hover { background-color: #f5f5f5; }
.chat-context-menu-item.danger { color: #dc3545; }

/* 6. Действия с сообщением (навести мышкой) */
.msg-actions-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    opacity: 0;
    transition: opacity 0.2s;
    background: rgba(255,255,255,0.8);
    border-radius: 4px;
    padding: 2px 5px;
    cursor: pointer;
    font-size: 12px;
    color: #555;
}
.message:hover .msg-actions-btn { opacity: 1; }

/* 7. Закрепленное сообщение (хедер) */
.pinned-msg-bar {
    background: #fff;
    padding: 8px 15px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    animation: slideDown 0.3s;
}
.pinned-content {
    border-left: 2px solid #007bff;
    padding-left: 10px;
    font-size: 13px;
}
.pinned-title { color: #007bff; font-weight: 600; font-size: 12px; }
.pinned-text { color: #555; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 300px; }

/* Анимации */
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }
.highlight-msg { animation: highlight 2s; }
@keyframes highlight { 0% { background-color: #ffeeba; } 100% { background-color: inherit; } }

/* ================= MODERN CHAT REDESIGN ================= */

/* Основные переменные для чата */
:root {
    --chat-primary: #2A6BF2; /* Красивый синий */
    --chat-primary-light: #E8F0FF;
    --chat-bg: #F8FAFF;
    --chat-white: #FFFFFF;
    --chat-gray-light: #F5F7FB;
    --chat-gray: #8B98A9;
    --chat-gray-dark: #5A6575;
    --chat-shadow: 0 4px 20px rgba(42, 107, 242, 0.08);
    --chat-border: 1px solid #E8ECF5;
    --chat-radius: 16px;
    --chat-radius-sm: 12px;
}

/* Контейнер страницы чата */
#chatPage {
    height: calc(100vh - 120px);
    background: var(--chat-bg);
    border-radius: var(--chat-radius);
    overflow: hidden;
    box-shadow: var(--chat-shadow);
    margin: 10px;
}

/* Раздел чата */
.chat-section {
    display: flex;
    height: 100%;
    background: var(--chat-white);
}

/* ================= БОКОВАЯ ПАНЕЛЬ ЧАТА ================= */
.chat-sidebar {
    width: 360px;
    background: var(--chat-white);
    border-right: var(--chat-border);
    display: flex;
    flex-direction: column;
    box-shadow: 2px 0 15px rgba(42, 107, 242, 0.05);
}

.chat-sidebar-header {
    padding: 24px 20px;
    background: var(--chat-white);
    border-bottom: var(--chat-border);
}

.chat-sidebar-header h5 {
    color: var(--chat-gray-dark);
    font-weight: 600;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-sidebar-header h5 i {
    color: var(--chat-primary);
}

.chat-sidebar-header .btn-primary {
    background: var(--chat-primary);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(42, 107, 242, 0.2);
}

.chat-sidebar-header .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(42, 107, 242, 0.3);
}

.search-box {
    padding: 0 20px;
    margin-top: 15px;
}

.search-box .form-control {
    background: var(--chat-gray-light);
    border: none;
    border-radius: 24px;
    padding: 10px 16px 10px 40px;
    font-size: 14px;
    color: var(--chat-gray-dark);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
}

.search-box .form-control:focus {
    box-shadow: inset 0 2px 8px rgba(42, 107, 242, 0.1);
}

/* Список чатов */
.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 0;
}

.chat-list::-webkit-scrollbar {
    width: 4px;
}

.chat-list::-webkit-scrollbar-track {
    background: transparent;
}

.chat-list::-webkit-scrollbar-thumb {
    background: var(--chat-gray-light);
    border-radius: 4px;
}

/* Элемент чата в списке */
.contact-item {
    padding: 16px 20px;
    margin: 0 10px;
    border-radius: var(--chat-radius-sm);
    display: flex;
    align-items: center;
    gap: 15px;
    cursor: pointer;
    transition: all 0.3s;
    border: none;
    background: transparent;
    position: relative;
}

.contact-item:hover {
    background: var(--chat-primary-light);
    transform: translateX(4px);
}

.contact-item.active {
    background: linear-gradient(135deg, var(--chat-primary-light), #E1EAFE);
    box-shadow: 0 4px 12px rgba(42, 107, 242, 0.15);
    border-left: 4px solid var(--chat-primary);
}

.contact-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.contact-avatar i {
    font-size: 20px;
}

/* Статус онлайн */
.contact-avatar::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 12px;
    height: 12px;
    background: #4CAF50;
    border: 2px solid var(--chat-white);
    border-radius: 50%;
    display: none;
}

.contact-item.active .contact-avatar::after {
    display: block;
}

.contact-info {
    flex: 1;
    min-width: 0;
}

.contact-name {
    font-weight: 600;
    color: var(--chat-gray-dark);
    font-size: 15px;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.contact-name .fa-thumbtack {
    color: var(--chat-primary);
    font-size: 12px;
}

.contact-last-message {
    font-size: 13px;
    color: var(--chat-gray);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.contact-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
}

.contact-time {
    font-size: 11px;
    color: var(--chat-gray);
    white-space: nowrap;
}

.contact-unread {
    background: var(--chat-primary);
    color: white;
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    box-shadow: 0 2px 4px rgba(42, 107, 242, 0.3);
}

/* Разделитель */
.chat-divider {
    padding: 8px 20px;
    font-size: 11px;
    color: var(--chat-gray);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    margin-top: 10px;
    background: var(--chat-gray-light);
    margin: 10px 10px 0;
    border-radius: var(--chat-radius-sm);
}

/* ================= ОСНОВНОЕ ОКНО ЧАТА ================= */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-white);
}

/* Шапка активного чата */
.chat-header {
    padding: 0 24px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--chat-white);
    border-bottom: var(--chat-border);
    box-shadow: 0 2px 8px rgba(42, 107, 242, 0.05);
    z-index: 10;
}

.chat-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-info .contact-avatar {
    width: 44px;
    height: 44px;
    font-size: 16px;
}

#chatTitle {
    font-weight: 600;
    color: var(--chat-gray-dark);
    font-size: 17px;
    margin-bottom: 2px;
}

#chatStatus {
    color: var(--chat-primary);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

#chatStatus::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4CAF50;
    border-radius: 50%;
    display: inline-block;
}

/* Контейнер сообщений */
#wMessages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--chat-bg);
    display: flex;
    flex-direction: column;
    gap: 16px;
}

#wMessages::-webkit-scrollbar {
    width: 6px;
}

#wMessages::-webkit-scrollbar-track {
    background: transparent;
}

#wMessages::-webkit-scrollbar-thumb {
    background: var(--chat-gray-light);
    border-radius: 3px;
}

#wMessages::-webkit-scrollbar-thumb:hover {
    background: var(--chat-gray);
}

/* Сообщения */
.message {
    max-width: 70%;
    animation: fadeInUp 0.3s ease-out;
    display: flex;
    flex-direction: column;
}

.message.sent {
    align-self: flex-end;
}

.message.received {
    align-self: flex-start;
}

.message-content {
    padding: 14px 18px;
    border-radius: var(--chat-radius-sm);
    position: relative;
    word-wrap: break-word;
    white-space: pre-wrap;
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.message.sent .message-content {
    background: linear-gradient(135deg, var(--chat-primary), #3A7BFF);
    color: white;
    border-bottom-right-radius: 4px;
    box-shadow: 0 4px 12px rgba(42, 107, 242, 0.2);
}

.message.received .message-content {
    background: var(--chat-white);
    color: var(--chat-gray-dark);
    border: var(--chat-border);
    border-bottom-left-radius: 4px;
}

.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 6px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
}

.message.sent .message-time {
    color: rgba(255, 255, 255, 0.8);
}

.message.received .message-time {
    color: var(--chat-gray);
}

/* Панель ввода сообщений */
.chat-footer {
    padding: 20px 24px;
    background: var(--chat-white);
    border-top: var(--chat-border);
    box-shadow: 0 -2px 8px rgba(42, 107, 242, 0.05);
}

.chat-input-area {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--chat-gray-light);
    padding: 4px 4px 4px 20px;
    border-radius: 30px;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.03);
}

.input-wrapper {
    flex: 1;
}

#wMsgInput {
    background: transparent;
    border: none;
    padding: 12px 0;
    font-size: 15px;
    color: var(--chat-gray-dark);
    outline: none;
    width: 100%;
}

#wMsgInput::placeholder {
    color: var(--chat-gray);
}

.chat-input-area .btn-link {
    color: var(--chat-gray);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.chat-input-area .btn-link:hover {
    background: var(--chat-primary-light);
    color: var(--chat-primary);
}

.chat-input-area .btn-primary {
    background: var(--chat-primary);
    border: none;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(42, 107, 242, 0.3);
}

.chat-input-area .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(42, 107, 242, 0.4);
}

/* Заглушка при выборе чата */
.chat-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--chat-gray);
    padding: 40px;
    text-align: center;
}

.chat-empty-state i {
    font-size: 64px;
    color: var(--chat-primary-light);
    margin-bottom: 20px;
    opacity: 0.6;
}

.chat-empty-state p {
    font-size: 16px;
    color: var(--chat-gray-dark);
    max-width: 300px;
    line-height: 1.6;
}

/* ================= МОДАЛЬНОЕ ОКНО НОВОГО ЧАТА ================= */
#newChatModal .modal-content {
    border-radius: var(--chat-radius);
    border: var(--chat-border);
    box-shadow: var(--chat-shadow);
}

#newChatModal .modal-header {
    background: var(--chat-white);
    border-bottom: var(--chat-border);
    padding: 24px;
}

#newChatModal .modal-title {
    color: var(--chat-gray-dark);
    font-weight: 600;
}

#newChatModal .modal-body {
    padding: 0;
}

#userChatSearch {
    background: var(--chat-gray-light);
    border: none;
    border-radius: 20px;
    padding: 12px 16px 12px 45px;
    margin-bottom: 10px;
}

#userListForChat .list-group-item {
    border: none;
    border-bottom: var(--chat-border);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s;
}

#userListForChat .list-group-item:hover {
    background: var(--chat-primary-light);
    transform: translateX(4px);
}

#userListForChat .avatar-circle {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--chat-primary), #3A7BFF);
    color: white;
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    box-shadow: 0 4px 8px rgba(42, 107, 242, 0.2);
}

/* ================= АНИМАЦИИ ================= */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Индикатор набора текста */
.typing-indicator {
    background: var(--chat-white);
    border: var(--chat-border);
    border-radius: var(--chat-radius-sm);
    padding: 12px 18px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--chat-gray);
    border-radius: 50%;
    animation: pulse 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

/* ================= ГОЛОСОВЫЕ СООБЩЕНИЯ ================= */
.voice-message {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    min-width: 180px;
}

.voice-wave {
    flex: 1;
    height: 30px;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.3) 25%,
        rgba(255, 255, 255, 0.6) 50%,
        rgba(255, 255, 255, 0.3) 75%,
        transparent 100%);
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}

.voice-wave::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, 
        transparent 0%, 
        rgba(255, 255, 255, 0.8) 50%,
        transparent 100%);
    animation: waveMove 2s infinite;
}

@keyframes waveMove {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* ================= АДАПТИВНОСТЬ ================= */
@media (max-width: 992px) {
    .chat-sidebar {
        width: 100%;
    }
    
    .chat-main {
        display: none;
    }
    
    body.chat-open .chat-sidebar {
        display: none;
    }
    
    body.chat-open .chat-main {
        display: flex;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1050;
    }
}

@media (max-width: 768px) {
    #chatPage {
        margin: 0;
        height: calc(100vh - 80px);
        border-radius: 0;
    }
    
    .chat-section {
        border-radius: 0;
    }
    
    .chat-sidebar-header,
    .chat-header,
    .chat-footer {
        padding: 16px;
    }
    
    #wMessages {
        padding: 16px;
    }
}

/* Индикатор записи голоса */
.voice-recording-indicator {
    background: linear-gradient(135deg, var(--chat-primary), #3A7BFF);
    color: white;
    border-radius: var(--chat-radius-sm);
    padding: 16px 20px;
    margin: 10px 24px;
    animation: slideInUp 0.3s ease-out;
    box-shadow: 0 4px 15px rgba(42, 107, 242, 0.3);
}

@keyframes slideInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Анимация появления новых сообщений */
.new-message {
    animation: messageAppear 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Стили для файлов в чате */
.file-message {
    padding: 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    margin-top: 4px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    max-width: 250px;
}

.file-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-size {
    font-size: 11px;
    opacity: 0.8;
    margin-top: 2px;
}

/* Анимация загрузки файла */
.file-uploading {
    position: relative;
    opacity: 0.7;
}

.file-uploading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Улучшенный скроллбар для Firefox */
#wMessages {
    scrollbar-width: thin;
    scrollbar-color: var(--chat-gray-light) transparent;
}

/* Эффект глубины для активного сообщения */
.message.sent .message-content:hover,
.message.received .message-content:hover {
    transform: translateY(-2px);
    transition: transform 0.2s;
}

/* ================= IMPROVED CHAT MESSAGES ================= */

/* Убираем желтую обводку и исправляем сообщения */
.message.sent {
    align-self: flex-end;
    max-width: 75%;
    margin-left: auto;
}

.message.received {
    align-self: flex-start;
    max-width: 75%;
    margin-right: auto;
}

/* Улучшенные пузыри сообщений */
.message-content {
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    word-wrap: break-word;
    white-space: pre-wrap;
    line-height: 1.5;
    max-width: 100%;
    border: none; /* Убираем желтую обводку */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
}

/* Отправленные сообщения */
.message.sent .message-content {
    background: linear-gradient(135deg, var(--chat-primary), #3A7BFF);
    color: white;
    border-bottom-right-radius: 4px;
    border-top-right-radius: 18px;
    border-top-left-radius: 18px;
    border-bottom-left-radius: 18px;
    margin-left: 20px; /* Отступ слева для стрелочки */
}

.message.sent .message-content::before {
    content: '';
    position: absolute;
    right: -8px;
    top: 12px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-left: 8px solid var(--chat-primary);
    display: none; /* Убираем стрелочку для более чистого вида */
}

/* Полученные сообщения */
.message.received .message-content {
    background: var(--chat-white);
    color: var(--chat-gray-dark);
    border-bottom-left-radius: 4px;
    border-top-right-radius: 18px;
    border-top-left-radius: 18px;
    border-bottom-right-radius: 18px;
    margin-right: 20px;
    border: 1px solid #E8ECF5;
}

.message.received .message-content::before {
    content: '';
    position: absolute;
    left: -8px;
    top: 12px;
    width: 0;
    height: 0;
    border-top: 8px solid transparent;
    border-bottom: 8px solid transparent;
    border-right: 8px solid #E8ECF5;
    display: none;
}

/* Имя отправителя в полученных сообщениях */
.message.received .sender-name {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--chat-primary);
    margin-bottom: 4px;
    opacity: 0.9;
}

/* Время сообщения */
.message-time {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 6px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 4px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.message.sent .message-time {
    color: rgba(255, 255, 255, 0.8);
}

.message.received .message-time {
    color: var(--chat-gray);
}

/* Галочки прочтения */
.read-indicator {
    font-size: 9px;
    margin-left: 4px;
}

.read-indicator.read {
    color: #4CAF50;
}

/* ================= ИСПРАВЛЕНИЕ РАСПОЛОЖЕНИЯ ЧАТА ================= */

/* Контейнер чата на всю ширину */
.chat-section {
    display: flex;
    height: calc(100vh - 100px);
    background: var(--chat-white);
    border-radius: var(--chat-radius);
    overflow: hidden;
    margin: 10px;
    width: calc(100% - 20px);
    box-shadow: var(--chat-shadow);
}

/* Боковая панель чата */
.chat-sidebar {
    width: 320px;
    background: var(--chat-white);
    border-right: var(--chat-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0; /* Не позволяет сжиматься */
}

/* Основное окно чата - занимает все оставшееся пространство */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--chat-white);
    min-width: 0; /* Важно для правильной работы flex */
}

/* Контейнер сообщений - растягиваем */
#wMessages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--chat-bg);
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0; /* Важно для flex */
}

/* ================= УЛУЧШЕННАЯ ЗАГЛУШКА ВЫБОРА ЧАТА ================= */

.chat-empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--chat-gray);
    padding: 40px;
    text-align: center;
    background: linear-gradient(135deg, #F8FAFF, #FFFFFF);
    height: 100%;
}

.chat-empty-state .empty-icon {
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, var(--chat-primary-light), #E8F0FF);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    box-shadow: 0 8px 25px rgba(42, 107, 242, 0.15);
}

.chat-empty-state .empty-icon i {
    font-size: 48px;
    color: var(--chat-primary);
    opacity: 0.8;
}

.chat-empty-state h4 {
    color: var(--chat-gray-dark);
    font-weight: 600;
    margin-bottom: 12px;
    font-size: 20px;
}

.chat-empty-state p {
    color: var(--chat-gray);
    font-size: 15px;
    max-width: 400px;
    line-height: 1.6;
    margin-bottom: 32px;
    opacity: 0.8;
}

.chat-empty-state .btn-primary {
    background: linear-gradient(135deg, var(--chat-primary), #3A7BFF);
    border: none;
    padding: 12px 28px;
    border-radius: 25px;
    font-weight: 500;
    font-size: 15px;
    box-shadow: 0 6px 20px rgba(42, 107, 242, 0.3);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.chat-empty-state .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(42, 107, 242, 0.4);
}

.chat-empty-state .btn-primary:active {
    transform: translateY(0);
}

/* ================= АДАПТИВНОСТЬ И ДОПОЛНИТЕЛЬНЫЕ УЛУЧШЕНИЯ ================= */

/* Для очень широких экранов - ограничиваем ширину */
@media (min-width: 1600px) {
    .chat-section {
        max-width: 1600px;
        margin: 10px auto;
    }
}

/* Для узких экранов */
@media (max-width: 1200px) {
    .chat-sidebar {
        width: 280px;
    }
}

@media (max-width: 992px) {
    .chat-section {
        margin: 0;
        border-radius: 0;
        height: calc(100vh - 80px);
    }
    
    .chat-sidebar {
        width: 100%;
    }
    
    .chat-main {
        display: none;
    }
}

/* Плавное появление сообщений */
@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message {
    animation: messageSlideIn 0.3s ease-out;
}

/* Эффект при наведении на сообщение */
.message-content:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* Стиль для системных сообщений */
.message.system {
    align-self: center;
    max-width: 80%;
}

.message.system .message-content {
    background: var(--chat-gray-light);
    color: var(--chat-gray);
    font-size: 13px;
    padding: 8px 16px;
    border-radius: 12px;
    text-align: center;
    border: none;
    box-shadow: none;
}

/* Стиль для сообщений с файлами */
.file-attachment {
    margin-top: 8px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.message.received .file-attachment {
    border-color: var(--chat-border);
}

/* Стиль для ссылок в сообщениях */
.message-content a {
    color: inherit;
    text-decoration: underline;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.message-content a:hover {
    opacity: 1;
}

.message.sent .message-content a {
    color: rgba(255, 255, 255, 0.95);
}

/* Улучшенный скроллбар */
#wMessages::-webkit-scrollbar {
    width: 6px;
}

#wMessages::-webkit-scrollbar-track {
    background: transparent;
    margin: 4px 0;
}

#wMessages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
    transition: background 0.3s;
}

#wMessages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Индикатор новых сообщений */
.new-messages-indicator {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--chat-primary);
    color: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(42, 107, 242, 0.3);
    cursor: pointer;
    z-index: 100;
    display: none;
    align-items: center;
    gap: 8px;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(42, 107, 242, 0.3);
    }
    50% {
        box-shadow: 0 4px 20px rgba(42, 107, 242, 0.5);
    }
}

/* Поле ввода растягиваем */
.chat-input-area {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--chat-gray-light);
    padding: 8px 8px 8px 20px;
    border-radius: 30px;
    box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.03);
    margin: 0 20px 20px;
    border: 1px solid transparent;
    transition: border-color 0.3s;
}

.chat-input-area:focus-within {
    border-color: var(--chat-primary-light);
    box-shadow: inset 0 2px 8px rgba(42, 107, 242, 0.1);
}

/* Улучшаем внешний вид кнопки отправки */
.btn-round {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--chat-primary), #3A7BFF);
    border: none;
    color: white;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(42, 107, 242, 0.3);
}

.btn-round:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(42, 107, 242, 0.4);
}

.btn-round:active {
    transform: scale(0.98);
}

/* Индикатор набора сообщения */
.typing-indicator {
    background: var(--chat-white);
    border: var(--chat-border);
    border-radius: 18px;
    padding: 12px 18px;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    align-self: flex-start;
    max-width: 120px;
}

.typing-text {
    font-size: 13px;
    color: var(--chat-gray);
}

.typing-dots {
    display: flex;
    gap: 3px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--chat-gray);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Фиксируем ширину всего раздела чата */
#chatPage {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 100px);
    background: var(--chat-white);
    border-radius: var(--chat-radius);
    overflow: hidden;
    margin: 10px;
    width: calc(100% - 20px);
    position: relative;
}

/* Гарантируем, что чат растягивается на всю ширину */
#chatPage > .chat-section {
    flex: 1;
    width: 100%;
    min-width: 0; /* Важно для flexbox */
}

/* Делаем сообщения красиво оформленными */
.message {
    max-width: 75%;
    min-width: 50px; /* Минимальная ширина пузыря */
}

/* Улучшаем отступы между сообщениями */
#wMessages {
    padding: 20px 24px;
}

/* Делаем отступы между сообщениями в зависимости от отправителя */
.message.sent + .message.sent .message-content {
    margin-top: 4px;
    border-top-right-radius: 4px;
}

.message.received + .message.received .message-content {
    margin-top: 4px;
    border-top-left-radius: 4px;
}

/* Добавляем отступ между сообщениями разных отправителей */
.message.sent + .message.received,
.message.received + .message.sent {
    margin-top: 16px;
}

/* Стиль для таблицы заявок - обычный текст вместо жирного */
.table-requests td {
    font-weight: 400 !important;
    vertical-align: middle;
}

/* Новые карточки статистики */
.stat-card {
    background: white;
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.04);
    transition: transform 0.2s ease;
    border: 1px solid #f0f0f0;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.money-card h3 {
    color: #28a745;
    font-weight: 700;
}

.icon-circle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.bg-success-light { background-color: #d1e7dd; }
.bg-primary-light { background-color: #cfe2ff; }
.bg-warning-light { background-color: #fff3cd; }

/* Убираем стили бейджей для статусов в таблице заявок, делаем их просто текстом */
.status-text-new { color: #0d6efd; font-weight: 500; }
.status-text-accepted { color: #fd7e14; font-weight: 500; }
.status-text-completed { color: #198754; font-weight: 500; }
.status-text-cancelled { color: #dc3545; font-weight: 500; }


/* Добавьте/Обновите этот класс в admin.css */

.icon-circle {
    width: 54px;  /* Чуть увеличим размер */
    height: 54px;
    border-radius: 50%;
    display: flex;             /* Включаем Flexbox */
    align-items: center;       /* Центр по вертикали */
    justify-content: center;   /* Центр по горизонтали */
    font-size: 1.5rem;
    flex-shrink: 0;            /* Чтобы круг не сжимался */
}

/* Убедимся, что у самой иконки нет лишних отступов */
.icon-circle i {
    margin: 0;
    padding: 0;
    line-height: 1;
}

.btn-white {
    background-color: #fff;
    color: #333;
}
.btn-white:hover {
    background-color: #f8f9fa;
}

#usersPage .card strong {
    font-size: 1.1rem;
    display: block;
}

#usersPage .col {
    min-width: 100px; /* Чтобы на маленьких экранах не сжимались слишком сильно */
}

/* Фильтры заявок */
#requestFilterForm label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

/* Финансы */
.finance-months-sidebar {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 15px 0;
}

.month-mini-chart-wrapper {
    cursor: pointer;
    transition: transform 0.2s;
    text-align: center;
    opacity: 0.7;
}

.month-mini-chart-wrapper:hover,
.month-mini-chart-wrapper.active {
    transform: scale(1.05);
    opacity: 1;
}

.month-mini-chart-wrapper.active .month-label {
    font-weight: bold;
    color: var(--primary);
}

.month-label {
    font-size: 0.8rem;
    margin-top: 5px;
    display: block;
}

/* Скроллбар для списка месяцев */
#finance-months-container::-webkit-scrollbar {
    width: 6px;
}
#finance-months-container::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 4px;
}

.finance-scroll-container::-webkit-scrollbar {
    width: 6px;
}
.finance-scroll-container::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

.month-mini-card {
    cursor: pointer;
    transition: all 0.3s;
    border: 1px solid #eee;
    margin-bottom: 10px;
    background: #fff;
}

.month-mini-card:hover, .month-mini-card.active {
    border-color: var(--primary);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    transform: translateX(5px);
}

.month-mini-card canvas {
    max-width: 60px;
    max-height: 60px;
}

/* === НОВЫЕ СТИЛИ ДЛЯ ФИНАНСОВ === */

.finance-month-card {
    background: #fff;
    border-radius: 16px;
    padding: 20px 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    transition: transform 0.2s;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    border: 1px solid transparent;
}

.finance-month-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
}

.finance-chart-wrapper {
    position: relative;
    width: 140px;  /* Уменьшенный размер круга */
    height: 140px; /* Уменьшенный размер круга */
    margin-bottom: 20px;
}

.finance-chart-center-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    line-height: 1.2;
    pointer-events: none;
}

.finance-stats-block {
    width: 100%;
    font-size: 0.9rem;
}

.finance-stat-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid #f0f0f0;
}

.finance-stat-row:last-child {
    border-bottom: none;
}

.finance-stat-label {
    color: #6c757d;
    font-weight: 500;
}

.finance-stat-value {
    font-weight: 700;
    color: #333;
}

.val-green { color: var(--success); }
.val-blue { color: var(--primary); }
.val-red { color: var(--danger); }


/* Финансы */
.bg-danger {
    background-color: #dc3545 !important;
}

#financeChartView, #financeTableView {
    animation: fadeIn 0.3s ease-out;
}

/* Склад */
.card-img-top-wrapper {
    height: 160px;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #eee;
}

.warehouse-card {
    transition: transform 0.2s;
}
.warehouse-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* Исправление бага "график падает вниз" */
/* Убедитесь, что контейнер месяца имеет фиксированную высоту или flex */
#monthlyChartsContainer {
    height: calc(100vh - 250px); /* Фикс высоты */
    min-height: 400px;
}

#monthlyChartsContainer {
    max-height: 70vh;
    overflow-y: auto;
    position: sticky;
    top: 20px;
}