* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f8f9fa;
    color: #333;
    height: 100vh;
    overflow: hidden;
    font-size: 16px;
}

.app-container {
    display: flex;
    height: 100vh;
    position: relative;
}

/* Левая панель - список чатов */
.chats-panel {
    width: 100%;
    background: #fff;
    display: flex;
    flex-direction: column;
    position: absolute;
    height: 100%;
    z-index: 100;
    transition: transform 0.3s ease;
}

.chats-header {
    background: linear-gradient(135deg, #8B0000 0%, #A52A2A 100%);
    color: white;
    padding: 15px;
    text-align: center;
    position: relative;
}

.chats-header h2 {
    font-size: 1.2em;
    margin-bottom: 5px;
    font-weight: 600;
}

.chats-stats {
    font-size: 0.85em;
    opacity: 0.9;
}

.search-box {
    padding: 12px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #eee;
}

.search-box input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 15px;
    background: white;
}

.chats-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.chat-item {
    padding: 15px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
}

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

.chat-item.active {
    background-color: #fff3f3;
    border-left: 3px solid #8B0000;
}

.chat-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: linear-gradient(135deg, #8B0000 0%, #A52A2A 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 16px;
    margin-right: 12px;
    flex-shrink: 0;
}

.chat-info {
    flex: 1;
    min-width: 0;
}

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

.chat-name {
    font-weight: 600;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-time {
    font-size: 13px;
    color: #888;
    flex-shrink: 0;
}

.chat-preview {
    font-size: 14px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 5px;
}

.chat-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-topic {
    font-size: 12px;
    background: #8B0000;
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    white-space: nowrap;
}

.unread-count {
    background: #dc3545;
    color: white;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    flex-shrink: 0;
}

/* Правая панель - диалог */
.dialog-panel {
    width: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
    position: absolute;
    height: 100%;
    z-index: 90;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.dialog-panel.active {
    transform: translateX(0);
}

.dialog-header {
    background: #fff;
    border-bottom: 1px solid #eee;
    padding: 12px 15px;
    display: flex;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.back-button {
    background: none;
    border: none;
    font-size: 20px;
    margin-right: 10px;
    cursor: pointer;
    color: #8B0000;
    padding: 5px;
}

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

.dialog-header h3 {
    font-size: 17px;
    margin-bottom: 3px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.dialog-status {
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 12px;
    font-weight: 500;
    flex-shrink: 0;
}

.status-open {
    background: #d4edda;
    color: #155724;
}

.status-in-progress {
    background: #fff3cd;
    color: #856404;
}

.status-closed {
    background: #f8d7da;
    color: #721c24;
}

.dialog-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f8f9fa;
    -webkit-overflow-scrolling: touch;
    /* Убираем display: flex, если он там есть */
}.message {
    margin-bottom: 15px;
    display: flex;
    width: 100%;
}

.message-user {
    flex-direction: row;
}

.message-operator {
    flex-direction: row-reverse;
}

.message-user .message-content {
    margin-right: auto;
    max-width: 85%;
}

.message-operator .message-content {
    margin-left: auto;
    max-width: 85%;
}

.message-operator .message-content-wrapper {
    flex-direction: row-reverse;
    max-width: 85%;
}


.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
    flex-shrink: 0;
}

.user-avatar {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
}

.operator-avatar {
    background: linear-gradient(135deg, #28a745 0%, #1e7e34 100%);
}

.system-avatar {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
}

.message-content {
    background: white;
    padding: 12px 15px;
    border-radius: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    position: relative;
}

.message-user .message-content {
    border-bottom-left-radius: 4px;
    background: #e3f2fd;
}

.message-operator .message-content {
    border-bottom-right-radius: 4px;
    background: #d4edda;
}

.message-system .message-content {
    background: #fff3cd;
    text-align: center;
    font-size: 12px;
    padding: 8px 16px;
    border-radius: 12px;
    max-width: 100%;
    margin: 0 auto;
}

.message-text {
    font-size: 15px;
    line-height: 1.4;
    word-wrap: break-word;
}

.message-photo {
    margin-top: 8px;
    margin-bottom: 8px;
}

.message-photo img {
    max-width: 100%;
    border-radius: 12px;
    display: block;
    object-fit: cover;
}

.message-time {
    font-size: 11px;
    color: #888;
    text-align: right;
    margin-top: 5px;
}

.dialog-input {
    padding: 12px 15px;
    background: white;
    border-top: 1px solid #eee;
}

.input-container {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.message-input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 25px;
    font-size: 15px;
    resize: none;
    min-height: 50px;
    max-height: 120px;
    outline: none;
    transition: border-color 0.3s ease;
}

.message-input:focus {
    border-color: #8B0000;
}

.send-button {
    background: linear-gradient(135deg, #8B0000 0%, #A52A2A 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(139, 0, 0, 0.3);
}

.dialog-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.action-button {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 15px;
    background: white;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
    flex: 1;
    text-align: center;
}

.action-button:hover {
    background: #f8f9fa;
}

.close-ticket {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.close-ticket:hover {
    background: #c82333;
}

/* Состояния пустых панелей */
.no-chat-selected {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #888;
    font-size: 16px;
    text-align: center;
    padding: 20px;
}

.welcome-message {
    max-width: 400px;
}

.welcome-message h3 {
    color: #8B0000;
    margin-bottom: 15px;
}

/* Скроллбары */
::-webkit-scrollbar {
    width: 4px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Классы для управления видимостью */
.chats-panel.hidden {
    transform: translateX(-100%);
}

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

/* Адаптивность для планшетов */
@media (min-width: 768px) {
    .chats-panel {
        width: 350px;
        position: relative;
        transform: none !important;
    }
    
    .dialog-panel {
        left: 350px;
        width: calc(100% - 350px);
        transform: none !important;
    }
    
    .dialog-panel.active {
        transform: none !important;
    }
    
    .back-button {
        display: none;
    }
}

/* Большие экраны */
@media (min-width: 1024px) {
    .chats-panel {
        width: 380px;
    }
    
    .dialog-panel {
        left: 380px;
        width: calc(100% - 380px);
    }
}


.city-selector {
    margin-top: 10px;
}

.city-selector select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: white;
    font-size: 14px;
}

.chat-city {
    font-size: 12px;
    color: #666;
    background-color: #f0f0f0;
    padding: 2px 6px;
    border-radius: 10px;
    display: inline-block;
    margin-top: 2px;
}

@media (max-width: 768px) {
    .chats-header {
        padding: 15px;
    }
    
    .city-selector {
        margin-top: 8px;
    }
    
    .city-selector select {
        font-size: 13px;
        padding: 6px;
    }
}

.disabled {
    background-color: #f5f5f5;
    cursor: not-allowed;
    opacity: 0.7;
}

.message-sender {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 4px;
    color: #333;
}

.message-operator .message-sender {
    color: #2196F3;
}

.message-user .message-sender {
    color: #4CAF50;
}

.message-system .message-sender {
    color: #9E9E9E;
}

/* Добавим стили для информации о заказе */
.order-info {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.order-header {
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
    margin-bottom: 10px;
}

.order-header h4 {
    color: #8B0000;
    margin: 0;
    font-size: 16px;
}

.order-content p {
    margin: 8px 0;
    font-size: 14px;
    color: #555;
}

.order-content strong {
    color: #333;
}

.messages-separator {
    text-align: center;
    position: relative;
    margin: 20px 0;
}

.messages-separator span {
    background: #f8f9fa;
    padding: 0 15px;
    color: #888;
    font-size: 13px;
    position: relative;
    z-index: 1;
}

.messages-separator:before {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: #ddd;
    z-index: 0;
}


.chat-section-header {
    font-weight: bold;
    padding: 5px 10px;
    background-color: #f0f0f0;
    color: #333;
    font-size: 14px;
}

.chat-closed {
    opacity: 0.5;
    background-color: #eee;
}
