.smart-chat {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: Arial, sans-serif;
    pointer-events: none;
}

/* Улучшаем видимость на мобильных устройствах */
@media (max-width: 768px) {
    .smart-chat {
        bottom: 20px;
        right: 10px;
    }
    
    .chat-button {
        width: 60px;
        height: 60px;
    }
    
    .chat-window {
        width: 90%;
        max-width: 350px;
        right: 5%;
        bottom: 85px;
        height: 60vh;
        max-height: 500px;
        position: fixed;
        z-index: 99999;
    }
}

/* Дополнительные настройки для очень узких экранов */
@media (max-width: 320px) {
    .smart-chat {
        bottom: 5px;
        right: 5px;
    }
    
    .chat-button {
        width: 50px;
        height: 50px;
    }
    
    .chat-button-icon svg {
        width: 20px;
        height: 20px;
    }
    
    .chat-window {
        bottom: 65px;
        width: 100%;
        max-width: 300px;
        right: 0;
        left: 0;
        margin: 0 auto;
    }
    
    /* Уменьшаем отступы внутри чата */
    .chat-messages {
        padding: 10px;
        gap: 8px;
    }
    
    .message {
        padding: 8px 12px;
        font-size: 13px;
        max-width: 85%;
    }
    
    .chat-header {
        padding: 10px;
    }
    
    .chat-input {
        padding: 8px;
        gap: 8px;
    }
    
    .chat-input input {
        padding: 6px 12px;
        font-size: 13px;
    }
}

.chat-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #2196F3;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(33, 150, 243, 0.4);
    transition: transform 0.3s ease;
    position: relative;
    /* Добавляем мягкую анимацию по умолчанию */
    animation: gentle-pulse 3s infinite;
    /* Гарантируем, что кнопка не выйдет за пределы экрана */
    max-width: 100%;
    max-height: 100%;
    pointer-events: auto;
}

/* Гарантируем, что chat-button-icon корректно центрируется и не выходит за границы */
.chat-button-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    pointer-events: auto;
}

.chat-button-icon svg {
    max-width: 60%;
    max-height: 60%;
}

.chat-button:hover {
    transform: scale(1.1);
}

/* Мягкая, ненавязчивая анимация для начального состояния */
@keyframes gentle-pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.03);
    }
    100% {
        transform: scale(1);
    }
}

/* Более активная анимация для привлечения внимания */
.chat-button.animate {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(33, 150, 243, 0.7);
    }
    70% {
        transform: scale(1.1);
        box-shadow: 0 0 0 15px rgba(33, 150, 243, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(33, 150, 243, 0);
    }
}

.chat-button.animate::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: #2196F3;
    opacity: 0.7;
    animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
    0% {
        transform: scale(0.8);
        opacity: 0.8;
    }
    70% {
        transform: scale(1.3);
        opacity: 0;
    }
    100% {
        transform: scale(0.8);
        opacity: 0;
    }
}

.chat-notification {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #FF5722;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    /* По умолчанию скрыт */
    display: none;
    pointer-events: auto;
}

.chat-window {
    position: fixed;
    bottom: 100px;
    right: 20px;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 40px rgba(0, 0, 0, 0.16);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: 99999;
    pointer-events: auto;
}

.chat-window.hidden {
    transform: translateY(20px);
    opacity: 0;
    pointer-events: none;
}

.chat-window.highlight {
    animation: highlight-chat 1.5s ease-in-out;
}

@keyframes highlight-chat {
    0% {
        box-shadow: 0 5px 40px rgba(33, 150, 243, 0.3);
    }
    50% {
        box-shadow: 0 5px 40px rgba(33, 150, 243, 0.8);
    }
    100% {
        box-shadow: 0 5px 40px rgba(33, 150, 243, 0.3);
    }
}

.chat-header {
    background: #2196F3;
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: auto;
}

.chat-title {
    font-weight: bold;
}

.chat-close {
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    pointer-events: auto;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: auto;
}

.message {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 15px;
    font-size: 14px;
    line-height: 1.4;
}

.message.operator {
    background: #E3F2FD;
    align-self: flex-start;
    border-bottom-left-radius: 5px;
}

.message.client {
    background: #2196F3;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 5px;
}

/* Стиль для системных сообщений */
.message.system {
    text-align: center;
    margin: 5px 0;
    padding: 6px 12px;
    font-size: 13px;
    color: #757575;
    background-color: #f5f5f5;
    border-radius: 10px;
    font-style: italic;
    max-width: 90%;
    align-self: center;
}

.chat-input-wrapper {
    border-top: 1px solid #E0E0E0;
    pointer-events: auto;
}

.chat-quick-replies {
    padding: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    pointer-events: auto;
}

.quick-reply {
    background: #E3F2FD;
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.3s ease;
    pointer-events: auto;
}

.quick-reply:hover {
    background: #BBDEFB;
}

.chat-input {
    display: flex;
    padding: 10px;
    gap: 10px;
    pointer-events: auto;
}

.chat-input input {
    flex: 1;
    border: 1px solid #E0E0E0;
    border-radius: 20px;
    padding: 8px 15px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s ease;
    pointer-events: auto;
}

.chat-input input:focus {
    border-color: #2196F3;
}

.chat-input button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #2196F3;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
    pointer-events: auto;
}

.chat-input button:hover {
    background: #1976D2;
}

.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 15px;
    background: #E3F2FD;
    border-radius: 15px;
    align-self: flex-start;
    margin-bottom: 10px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #2196F3;
    border-radius: 50%;
    animation: typing 1s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-4px);
    }
}

.phone-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 15px;
    background: #E3F2FD;
    border-radius: 10px;
    margin: 10px 0;
}

.phone-form input {
    padding: 8px 15px;
    border: 1px solid #BBDEFB;
    border-radius: 5px;
    font-size: 14px;
}

.phone-form button {
    background: #2196F3;
    color: white;
    border: none;
    padding: 8px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s ease;
}

.phone-form button:hover {
    background: #1976D2;
}

/* Стиль для текста о согласии на обработку персональных данных */
.privacy-consent {
    font-size: 11px;
    color: #888;
    text-align: center;
    margin-top: 10px;
    width: 100%;
    line-height: 1.3;
}

/* Для улучшения обнаружения нажатий на мобильных устройствах */
@media (max-width: 768px) {
    .chat-button, 
    .chat-close, 
    .chat-input button,
    .quick-reply,
    .phone-form button {
        cursor: pointer;
        -webkit-tap-highlight-color: transparent; /* Убираем выделение при тапе */
        touch-action: manipulation; /* Улучшаем отзывчивость */
    }
    
    /* Увеличиваем области нажатия для сенсорных устройств */
    .chat-close {
        padding: 10px;
        margin: -10px;
    }
    
    .chat-input button {
        padding: 12px;
    }
}

/* Стили для заблокированных элементов формы во время ожидания ответа */
.chat-input input.disabled {
    background-color: #f5f5f5;
    border-color: #ddd;
    color: #999;
    cursor: not-allowed;
}

.chat-input button.disabled {
    background-color: #aaccee;
    cursor: not-allowed;
    opacity: 0.7;
}

/* Анимация мигания для индикации невозможности отправки */
.chat-input input.waiting {
    animation: form-blink 0.5s ease;
}

@keyframes form-blink {
    0% {
        border-color: #ccc;
    }
    50% {
        border-color: #ff6b6b;
        background-color: #fff8f8;
    }
    100% {
        border-color: #ccc;
    }
}

/* Стили для фиксации окна чата над нижним меню на мобильных устройствах */
@media (max-width: 768px) {
    .chat-window {
        bottom: 80px !important; /* Обязательно должно быть выше нижнего меню */
        max-height: calc(100vh - 180px) !important; /* Ограничиваем высоту с учетом меню сверху и снизу */
        margin-bottom: 0 !important;
    }
    
    /* Уменьшаем кнопку, чтобы она не перекрывала меню */
    .chat-button {
        width: 56px !important;
        height: 56px !important;
        bottom: 15px !important;
        right: 15px !important;
    }
    
    /* Гарантируем, что окно закрывается по кнопке */
    .chat-close {
        padding: 10px !important;
        font-size: 22px !important;
    }
    
    /* Делаем форму удобной на мобильных */
    .phone-form {
        padding: 10px !important;
    }
    
    /* Фиксируем позицию окна чата */
    .smart-chat {
        position: fixed !important;
        bottom: 15px !important;
        right: 15px !important;
        z-index: 999999 !important; /* Максимальный z-index */
    }
} 