/* Стили для страницы чата */

.chat-page-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
    min-height: 400px;
    background: #FFF;
    border-radius: 1.75rem;
    overflow: hidden;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
}

/* Информация о клиенте */
.chat-client-info {
    padding: 16px 24px;
    border-bottom: 1px solid #E5E7EB;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #FFF;
    flex-shrink: 0;
}

.chat-client-info .client-details {
    display: flex;
    align-items: center;
    gap: 14px;
}

.chat-client-info .avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #34589A;
    color: #FFF;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 18px;
    flex-shrink: 0;
}

.chat-client-info .info .name {
    font-weight: 600;
    color: #002853;
    font-size: 18px;
}

.chat-client-info .info .phone {
    font-size: 13px;
    color: #6B7280;
}

.chat-client-info .status-badge {
    font-size: 12px;
    padding: 4px 14px;
    border-radius: 20px;
    background: #D1FAE5;
    color: #065F46;
}

.chat-client-info .status-badge.offline {
    background: #FEE2E2;
    color: #991B1B;
}

.chat-client-info .guest-badge {
    font-size: 12px;
    padding: 4px 14px;
    border-radius: 20px;
    background: #FEF3C7;
    color: #92400E;
    margin-left: 8px;
}

/* Область сообщений */
.chat-messages-area {
    flex: 1;
    overflow-y: auto;
    padding: 16px 24px;
    display: flex;
    flex-direction: column;
    background: #FAFBFC;
    min-height: 200px;
}

/* Сообщения */
.message-item {
    max-width: 70%;
    margin-bottom: 12px;
    padding: 12px 16px;
    border-radius: 16px;
    word-wrap: break-word;
    position: relative;
    animation: messageIn 0.3s ease;
}

.message-item.client {
    align-self: flex-start;
    background: #FFF;
    border: 1px solid #E5E7EB;
    border-bottom-left-radius: 4px;
}

.message-item.operator {
    align-self: flex-end;
    background: #34589A;
    color: #FFF;
    border-bottom-right-radius: 4px;
}

.message-item .text {
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.message-item .time {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 4px;
    text-align: right;
}

.message-item .time.light {
    color: rgba(255, 255, 255, 0.7);
}

.message-item .time.dark {
    color: #9CA3AF;
}

.message-item .read-status {
    font-size: 10px;
    margin-left: 4px;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Индикатор набора текста */
.typing-indicator {
    display: none;
    padding: 6px 16px 12px 16px;
    font-size: 13px;
    color: #6B7280;
    font-style: italic;
    background: #FAFBFC;
    flex-shrink: 0;
}

.typing-indicator.show {
    display: block;
}

/* Поле ввода */
.chat-input-area {
    padding: 12px 24px 16px 24px;
    border-top: 1px solid #E5E7EB;
    background: #FFF;
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-shrink: 0;
}

.chat-input-area textarea {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #E5E7EB;
    border-radius: 20px;
    font-family: 'Cygre', sans-serif;
    font-size: 14px;
    resize: none;
    outline: none;
    transition: border-color 0.3s ease;
    min-height: 44px;
    max-height: 120px;
    line-height: 1.5;
    background: #F7F9FB;
}

.chat-input-area textarea:focus {
    border-color: #34589A;
    box-shadow: 0 0 0 2px rgba(52, 88, 154, 0.1);
}

.chat-input-area textarea::placeholder {
    color: #9CA3AF;
}

.chat-input-area .send-btn {
    padding: 10px 24px;
    background: #34589A;
    color: #FFF;
    border: none;
    border-radius: 40px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s ease;
    height: 44px;
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.chat-input-area .send-btn:hover {
    background: #002853;
    transform: translateY(-1px);
}

.chat-input-area .send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Пустой чат */
.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #9CA3AF;
    padding: 40px;
}

.chat-empty .icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.chat-empty h4 {
    font-size: 20px;
    color: #002853;
    margin-bottom: 8px;
}

/* Стили для скроллбара */
.chat-messages-area::-webkit-scrollbar {
    width: 4px;
}

.chat-messages-area::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages-area::-webkit-scrollbar-thumb {
    background: #D1D5DB;
    border-radius: 10px;
}

.chat-messages-area::-webkit-scrollbar-thumb:hover {
    background: #9CA3AF;
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .chat-page-container {
        height: calc(100vh - 130px);
        border-radius: 0;
        margin: -16px -16px 0 -16px;
    }
    
    .chat-client-info {
        padding: 12px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .chat-client-info .client-details {
        gap: 10px;
    }
    
    .chat-client-info .avatar {
        width: 40px;
        height: 40px;
        font-size: 15px;
    }
    
    .chat-client-info .info .name {
        font-size: 16px;
    }
    
    .chat-messages-area {
        padding: 12px 14px;
    }
    
    .message-item {
        max-width: 85%;
        padding: 10px 14px;
    }
    
    .message-item .text {
        font-size: 13px;
    }
    
    .chat-input-area {
        padding: 8px 12px 12px 12px;
        gap: 8px;
    }
    
    .chat-input-area textarea {
        font-size: 13px;
        min-height: 38px;
        padding: 8px 14px;
    }
    
    .chat-input-area .send-btn {
        padding: 8px 16px;
        font-size: 13px;
        height: 38px;
    }
}

/* Для очень маленьких экранов */
@media (max-width: 480px) {
    .chat-client-info .info .phone {
        font-size: 12px;
    }
    
    .chat-client-info .status-badge {
        font-size: 10px;
        padding: 2px 10px;
    }
}

/* Индикатор набора текста - только точки */
.typing-indicator {
    display: none;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    background: transparent;
    width: fit-content;
    margin: 4px 0 8px 16px;
}

.typing-indicator.show {
    display: flex;
}

.typing-dots {
    display: flex;
    gap: 5px;
    align-items: center;
}

.typing-dots .dot {
    width: 10px;
    height: 10px;
    background: #6B7280;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite both;
}

.typing-dots .dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots .dot:nth-child(2) {
    animation-delay: -0.16s;
}

.typing-dots .dot:nth-child(3) {
    animation-delay: 0s;
}

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

@media (max-width: 768px) {
    .typing-indicator {
        padding: 6px 12px;
        margin: 4px 0 8px 12px;
    }
    
    .typing-dots .dot {
        width: 8px;
        height: 8px;
    }
}

/* Стили для сообщений с кнопками */
.message-item {
    position: relative;
}

.message-content-wrapper {
    width: 100%;
}

.message-text {
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin-bottom: 6px;
}

.message-bottom-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.message-time {
    font-size: 10px;
    opacity: 0.7;
}

.message-time.light {
    color: rgba(255, 255, 255, 0.7);
}

.message-time.dark {
    color: #9CA3AF;
}

.message-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.message-item:hover .message-actions {
    opacity: 1;
}

/* Для мобильных устройств всегда показываем кнопки */
@media (max-width: 768px) {
    .message-actions {
        opacity: 1;
    }
}

.message-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    font-size: 14px;
    border-radius: 4px;
    transition: all 0.2s ease;
    line-height: 1;
    opacity: 0.6;
}

.message-action-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    opacity: 1;
}

.message-item.operator .message-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.message-item.operator .message-action-btn {
    color: #fff;
}

/* Стили для тоста */
.chat-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: #1F2937;
    color: #FFF;
    padding: 10px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-family: 'Cygre', sans-serif;
    z-index: 9999;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    white-space: nowrap;
    max-width: 90%;
}

.chat-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .chat-toast {
        bottom: 80px;
        font-size: 12px;
        padding: 8px 16px;
        white-space: normal;
        max-width: 85%;
        text-align: center;
    }
    
    .message-action-btn {
        font-size: 16px;
        padding: 6px 8px;
    }
}