/**
 * RushKurazh AI Chat Widget - Стили
 * Версия: 2.0
 * Дата: 25.01.2025
 */

/* ==========================================
   КРУГЛАЯ ПЛАВАЮЩАЯ КНОПКА
   ========================================== */

#rk-ai-float-btn {
    position: fixed;
    bottom: 40px;
    right: 40px;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #F64909 0%, #dc3200 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(246, 73, 9, 0.4);
    z-index: 9998;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: rk-pulse 2s infinite;
}

#rk-ai-float-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(246, 73, 9, 0.5);
}

#rk-ai-float-btn::after {
    content: 'ИИ-помощник 24/7';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
    color: #333;
    font-size: 11px;
    font-family: "Roboto", Arial, sans-serif;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(255,255,255,0.8);
    background: rgba(255,255,255,0.9);
    padding: 4px 8px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.rk-ai-float-btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes rk-pulse {
    0% { box-shadow: 0 4px 20px rgba(246, 73, 9, 0.4); }
    50% { box-shadow: 0 4px 30px rgba(246, 73, 9, 0.6); }
    100% { box-shadow: 0 4px 20px rgba(246, 73, 9, 0.4); }
}

/* ==========================================
   КОНТЕЙНЕР ЧАТА
   ========================================== */

#rk-ai-chat {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 520px;
    max-height: calc(100vh - 40px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    font-family: "Roboto", Arial, sans-serif;
}

/* ==========================================
   ШАПКА ЧАТА
   ========================================== */

#rk-ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: linear-gradient(135deg, #F64909 0%, #dc3200 100%);
    color: #fff;
    flex-shrink: 0;
}

.rk-ai-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rk-ai-chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rk-ai-chat-title {
    display: flex;
    flex-direction: column;
}

.rk-ai-chat-name {
    font-weight: 600;
    font-size: 15px;
}

.rk-ai-chat-status {
    font-size: 12px;
    opacity: 0.9;
}

.rk-ai-chat-header-actions {
    display: flex;
    gap: 8px;
}

.rk-ai-chat-header-actions button {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.rk-ai-chat-header-actions button:hover {
    background: rgba(255,255,255,0.3);
}

/* ==========================================
   ОБЛАСТЬ СООБЩЕНИЙ
   ========================================== */

#rk-ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fa;
    -webkit-overflow-scrolling: touch;
}

.rk-ai-message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.rk-ai-message-wrapper.user {
    align-self: flex-end;
    align-items: flex-end;
}

.rk-ai-message-wrapper.bot {
    align-self: flex-start;
    align-items: flex-start;
}

.rk-ai-message {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.rk-ai-message.user {
    background: linear-gradient(135deg, #F64909 0%, #dc3200 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.rk-ai-message.bot {
    background: #fff;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* ==========================================
   QUICK REPLY КНОПКИ
   ========================================== */

.rk-ai-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    max-width: 100%;
}

.rk-ai-quick-reply-btn {
    background: linear-gradient(135deg, #F64909 0%, #dc3200 100%);
    color: #fff;
    border: none;
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-family: "Roboto", Arial, sans-serif;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(246, 73, 9, 0.25);
    white-space: nowrap;
}

.rk-ai-quick-reply-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(246, 73, 9, 0.35);
}

.rk-ai-quick-reply-btn:active {
    transform: translateY(0);
}

/* ==========================================
   ИНДИКАТОР НАБОРА
   ========================================== */

.rk-ai-typing {
    display: flex;
    gap: 4px;
    padding: 16px !important;
}

.rk-ai-typing span {
    width: 8px;
    height: 8px;
    background: #F64909;
    border-radius: 50%;
    animation: rk-typing-dot 1.4s infinite ease-in-out both;
}

.rk-ai-typing span:nth-child(1) { animation-delay: -0.32s; }
.rk-ai-typing span:nth-child(2) { animation-delay: -0.16s; }
.rk-ai-typing span:nth-child(3) { animation-delay: 0; }

@keyframes rk-typing-dot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
    40% { transform: scale(1); opacity: 1; }
}

/* ==========================================
   ФОРМА ВВОДА
   ========================================== */

#rk-ai-form {
    display: flex;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #eee;
    gap: 12px;
    flex-shrink: 0;
}

#rk-ai-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    padding: 12px 20px;
    font-size: 14px;
    font-family: "Roboto", Arial, sans-serif;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#rk-ai-input:focus {
    border-color: #F64909;
    box-shadow: 0 0 0 3px rgba(246, 73, 9, 0.1);
}

#rk-ai-input::placeholder {
    color: #999;
}

#rk-ai-send {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #F64909 0%, #dc3200 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: transform 0.2s, box-shadow 0.2s;
    flex-shrink: 0;
}

#rk-ai-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(246, 73, 9, 0.3);
}

#rk-ai-send:active {
    transform: scale(0.95);
}

/* ==========================================
   МОБИЛЬНАЯ АДАПТАЦИЯ
   ========================================== */

@media (max-width: 480px) {
    #rk-ai-chat {
        width: 100%;
        height: 100%;
        max-height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }

    #rk-ai-chat-header {
        position: sticky;
        top: 0;
        z-index: 10;
    }

    #rk-ai-form {
        position: sticky;
        bottom: 0;
        z-index: 10;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    #rk-ai-float-btn {
        bottom: 16px;
        right: 16px;
    }

    #rk-ai-float-btn::after {
        display: none;
    }

    .rk-ai-quick-reply-btn {
        padding: 8px 14px;
        font-size: 12px;
    }
}

/* Фикс для iOS клавиатуры */
@supports (-webkit-touch-callout: none) {
    #rk-ai-chat {
        height: -webkit-fill-available;
    }
}


/* =============================================
   СТИЛИ ДЛЯ КНОПОК HANDOFF (Telegram, Позвонить)
   Добавить в rk-ai-widget.css или style.css
   ============================================= */

/* Контейнер для кнопок контактов */
.contact-buttons {
    display: flex;
    gap: 10px;
    margin: 12px 0;
    flex-wrap: wrap;
}

/* Общие стили для кнопок контактов */
.contact-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
}

/* Кнопка Telegram */
.contact-btn.tg-btn {
    background: linear-gradient(135deg, #0088cc 0%, #0077b5 100%);
    color: white;
}

.contact-btn.tg-btn:hover {
    background: linear-gradient(135deg, #0099dd 0%, #0088cc 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 136, 204, 0.3);
}

/* Кнопка MAX */
.contact-btn.max-btn {
    background: linear-gradient(135deg, #7B2CF4 0%, #5B0FCC 100%);
    color: white;
}

.contact-btn.max-btn:hover {
    background: linear-gradient(135deg, #8F3FFF 0%, #7B2CF4 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(123, 44, 244, 0.3);
}

/* Кнопка Позвонить */
.contact-btn.phone-btn {
    background: linear-gradient(135deg, #4CAF50 0%, #43A047 100%);
    color: white;
}

.contact-btn.phone-btn:hover {
    background: linear-gradient(135deg, #5CBF60 0%, #4CAF50 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

/* Подсказка про имя и телефон */
.contact-hint {
    font-size: 13px;
    color: #666;
    margin-top: 8px;
    padding: 8px 12px;
    background: #f5f5f5;
    border-radius: 8px;
    border-left: 3px solid #F64909;
}

.contact-hint strong {
    color: #F64909;
}

/* Адаптация под мобильные */
@media (max-width: 480px) {
    .contact-buttons {
        flex-direction: column;
    }
    
    .contact-btn {
        width: 100%;
        justify-content: center;
    }
}