/**
 * 🦁 Лёва — ИИ-помощник для 34stroyki.ru
 * Стили чат-виджета
 * version: 1.1.4
 */

/* ==========================================
   Кнопка-пузырёк (fixed, bottom-right)
   ========================================== */

#leva-wrap {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    z-index: 99999;
}

#leva-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #1565c0, #0d47a1);
    box-shadow: 0 4px 20px rgba(21, 101, 192, 0.4);
    cursor: pointer;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#leva-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(21, 101, 192, 0.55);
}

#leva-btn.leva-btn-active {
    transform: scale(0.9);
    opacity: 0.7;
}

.leva-btn-icon {
    font-size: 28px;
    line-height: 1;
}

/* Пульсация */
.leva-btn-pulse {
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    border: 2px solid rgba(21, 101, 192, 0.5);
    animation: levaPulse 2s ease-in-out infinite;
}

@keyframes levaPulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.15); opacity: 0; }
    100% { transform: scale(1); opacity: 0; }
}

/* ==========================================
   Окно чата
   ========================================== */

#leva-chat {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    max-height: 520px;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    z-index: 100001;
    overflow: hidden;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

#leva-chat.leva-chat-hidden {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
}

#leva-chat.leva-chat-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* ==========================================
   Заголовок чата
   ========================================== */

.leva-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, #1565c0, #0d47a1);
    color: #fff;
}

.leva-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.leva-avatar {
    font-size: 32px;
    line-height: 1;
}

.leva-name {
    font-size: 16px;
    font-weight: 700;
}

.leva-status {
    font-size: 12px;
    opacity: 0.85;
}

.leva-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 0 4px;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.leva-close:hover {
    opacity: 1;
}

/* ==========================================
   Сообщения
   ========================================== */

.leva-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 280px;
    max-height: 340px;
    background: #f8f9fa;
}

.leva-msg {
    display: flex;
    gap: 8px;
    max-width: 90%;
    animation: levaMsgIn 0.3s ease;
}

@keyframes levaMsgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.leva-msg-user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.leva-msg-assistant {
    align-self: flex-start;
}

.leva-msg-avatar {
    font-size: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.leva-msg-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.leva-msg-assistant .leva-msg-bubble {
    background: #fff;
    color: #333;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.leva-msg-user .leva-msg-bubble {
    background: linear-gradient(135deg, #1565c0, #1976d2);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* ==========================================
   Анимация «Лёва думает...»
   ========================================== */

.leva-typing {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 18px !important;
}

.leva-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #90a4ae;
    animation: levaDot 1.4s ease-in-out infinite;
}

.leva-dot:nth-child(2) { animation-delay: 0.2s; }
.leva-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes levaDot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* ==========================================
   Ввод сообщения
   ========================================== */

.leva-input-wrap {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    gap: 8px;
}

#leva-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

#leva-input:focus {
    border-color: #1565c0;
}

#leva-input:disabled {
    background: #f0f0f0;
}

#leva-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #1565c0, #0d47a1);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s, opacity 0.2s;
}

#leva-send:hover {
    transform: scale(1.08);
}

#leva-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ==========================================
   Подвал
   ========================================== */

.leva-footer {
    text-align: center;
    padding: 6px 12px;
    font-size: 11px;
    color: #90a4ae;
    background: #fff;
    border-top: 1px solid #f0f0f0;
}

/* ==========================================
   Мобильная адаптация
   ========================================== */

@media (max-width: 480px) {
    #leva-chat {
        right: 8px;
        left: 8px;
        bottom: 80px;
        width: auto;
        max-height: 70vh;
    }

    #leva-btn {
        bottom: 16px;
        right: 16px;
        width: 52px;
        height: 52px;
    }

    .leva-btn-icon {
        font-size: 24px;
    }

    .leva-messages {
        min-height: 200px;
        max-height: 50vh;
    }
}
