/* assets/css/widget.min.css — СТАБИЛЬНЫЙ СО СВЕРТЫВАНИЕМ */

* {
    box-sizing: border-box;
}

.chat-widget-wrapper {
    position: fixed;
    bottom: 20px;
    z-index: 9999;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    overflow: hidden;
    font-family: Arial, sans-serif;
    max-width: 400px;
    width: 80%;
    margin: 0;
    padding: 0;
    transition: box-shadow 0.3s ease;
}

.chat-right { right: 20px; }
.chat-left { left: 20px; }

/* ШАПКА */
.chat-header {
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0;
    border-bottom: none;
    cursor: pointer; /* Делаем шапку кликабельной */
    user-select: none;
}

.chat-manager-info { 
    display: flex; 
    align-items: center; 
    flex: 1;
}

.chat-avatar { 
    border-radius: 50%; 
    margin-right: 10px; 
    object-fit: cover; 
}

.chat-manager-text strong { 
    display: block; 
    margin: 0; 
    line-height: 1.2; 
}

/* ПОДЗАГОЛОВОК + ИНДИКАТОР */
.chat-subtitle {
    font-size: 14px;
    opacity: 0.8;
    margin: 0;
    line-height: 1.2;
}

/* ИНДИКАТОР ПЕЧАТИ — АНИМАЦИЯ ВОЛНЫ + БЕГУЩАЯ СТРОКА */
.chat-typing-indicator {
    display: none;
    font-size: 12px;
    color: rgba(255,255,255,0.8);
    font-style: italic;
    margin-top: 2px;
    align-items: center;
    gap: 4px; /* Расстояние между текстом и точками */
}

.chat-typing-indicator.visible {
    display: inline-flex;
}

/* Точки — будут подпрыгивать волной */
.chat-typing-indicator .dot {
    width: 4px;
    height: 4px;
    background: rgba(255,255,255,0.8);
    border-radius: 50%;
    animation: bounce-wave 1.4s infinite ease-in-out both;
}

/* Задержка для каждой точки — создаёт волну */
.chat-typing-indicator .dot:nth-child(1) { animation-delay: -0.32s; }
.chat-typing-indicator .dot:nth-child(2) { animation-delay: -0.16s; }
.chat-typing-indicator .dot:nth-child(3) { animation-delay: 0s; }

/* Анимация подпрыгивания волны */
@keyframes bounce-wave {
    0%, 80%, 100% { 
        transform: translateY(0) scale(0.8); 
        opacity: 0.5; 
    }
    40% { 
        transform: translateY(-4px) scale(1.2); 
        opacity: 1; 
    }
}

/* КНОПКИ УПРАВЛЕНИЯ В ШАПКЕ */
.chat-controls {
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0;
    padding: 0;
}

.chat-toggle-btn, .chat-close-btn {
    background: none;
    border: none;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    color: inherit;
    line-height: 1;
    padding: 4px;
    margin: 0;
    transition: opacity 0.2s ease;
}

.chat-toggle-btn:hover, .chat-close-btn:hover {
    opacity: 0.7;
}

/* КОНТЕЙНЕР СООБЩЕНИЙ */
.chat-messages {
    display: none;
    padding: 15px;
    margin: 0;
    overflow-y: auto;
    scroll-behavior: smooth;
    max-height: 650px;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.chat-message {
    margin-bottom: 15px;
    margin-top: 0;
    padding: 0;
    display: none;
}

.chat-message .message-content p {
    margin: 0 !important;
    padding: 0 !important;
    line-height: 1.4;
}

.bot-message {
    display: flex !important;
    flex-direction: column;
    align-items: flex-start;
    width: 100%;
}

.bot-message .message-content {
    background: #f1f1f1;
    padding: 10px;
    border-radius: 10px 10px 10px 0;
    max-width: 85%;
    margin: 0;
    font-size: 16px;
}

/* СООБЩЕНИЕ ПОЛЬЗОВАТЕЛЯ */
.user-message {
    display: flex !important;
    flex-direction: column;
    align-items: flex-end; 
    width: 100%;
    margin-bottom: 15px;
    margin-top: 0;
    padding: 0;
}

.user-message .message-content {
    background: #007bff;
    color: white;
    padding: 10px;
    border-radius: 10px 10px 0 10px;
    max-width: 85%;
    margin-left: auto;
    margin-right: 0;
    font-size: 16px;
}

.message-time {
    display: block;
    font-size: 10px;
    opacity: 0.5;
    margin-top: 4px;
    margin-bottom: 0;
    line-height: 1;
}

/* ФОРМА С ТЕЛЕФОНОМ */
.chat-form-inline {
    margin-top: 8px;
    padding: 0;
}

.chat-form-inline form {
    display: flex;
    gap: 6px;
    align-items: center;
    margin: 0;
}

.chat-form-inline input {
    flex: 1;
    height: 38px;
    padding: 0 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin: 0;
    font-size: 14px;
}

.chat-form-inline button { 
    height: 38px;
    padding: 0 15px;
    border: none;
    border-radius: 5px;
     background: linear-gradient(
        to bottom,
        #9ECBF5 0%,
        #5DA3E6 45%,
        #1E73BE 100%
    );
    color: white;
    font-weight: bold;
    cursor: pointer; 
    margin: 0;
    font-size: 14px;
    white-space: nowrap;
}

.phone-error { 
    color: red; 
    font-size: 11px; 
    margin-top: 4px; 
    display: none; 
    margin-bottom: 0; 
    width: 100%;
}

/* ПОЛЕ ВВОДА ЮЗЕРА */
.chat-input-area {
    padding: 10px;
    border-top: 1px solid #eee;
    display: none;
    margin: 0;
    align-items: center;
    gap: 5px;
    background: #fff;
    transition: opacity 0.3s ease, padding 0.3s ease;
}

.chat-input-area textarea {
    flex: 1;
    resize: none;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    margin: 0;
    min-height: 44px;
    max-height: 100px;
    line-height: 1.4;
    height: 44px;
}

.chat-input-area button {
    border: none;
    border-radius: 5px;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    height: 44px;
    width: 44px;
     background: linear-gradient(
        to bottom,
        #9ECBF5 0%,
        #5DA3E6 45%,
        #1E73BE 100%
    );
    color: white;
    box-sizing: border-box;
}

/* МАГИЯ СВЕРНУТОГО СОСТОЯНИЯ ЧЕРЕЗ СТИЛИ */
.chat-widget-wrapper.is-minimized {
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.chat-widget-wrapper.is-minimized .chat-messages {
    max-height: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    overflow: hidden;
}

.chat-widget-wrapper.is-minimized .chat-input-area {
    display: none !important;
}

/* КНОПКА ЗВОНКА ДЛЯ МОБИЛОК */
.chat-call-button {
    position: fixed;
    bottom: 20px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    z-index: 9998;
    text-decoration: none;
    animation: ring 2s infinite;
}

.chat-call-button.right { right: 20px; }
.chat-call-button.left { left: 20px; }

@keyframes ring {
    0% { transform: rotate(0deg); }
    10% { transform: rotate(10deg); }
    20% { transform: rotate(-10deg); }
    30% { transform: rotate(10deg); }
    40% { transform: rotate(-10deg); }
    50% { transform: rotate(0deg); }
    100% { transform: rotate(0deg); }
}

.chat-call-button svg { width: 32px; height: 32px; }

@media (max-width: 767px) {
    .chat-widget-wrapper {
        display: none !important;
    }
    .chat-call-button {
        display: flex !important;
    }
}