/* ✨ AI Consultant Chat Widget - ФИНАЛЬНАЯ ЧИСТАЯ ВЕРСИЯ */

/* 🎯 Базовый контейнер виджета */
.ai-chat-widget {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    z-index: 999999 !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif !important;
}

/* 🔘 Кнопка открытия чата */
.ai-chat-button {
    width: 64px !important;
    height: 64px !important;
    border-radius: 50% !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    border: none !important;
    color: white !important;
    font-size: 26px !important;
    cursor: pointer !important;
    box-shadow: 0 12px 48px rgba(102, 126, 234, 0.5) !important;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: relative !important;
    overflow: hidden !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* Индикатор онлайн статуса */
.ai-chat-button::after {
    content: '';
    position: absolute;
    bottom: 2px !important;
    right: 2px !important;
    width: 14px !important;
    height: 14px !important;
    background: #10b981 !important;
    border: 3px solid white !important;
    border-radius: 50%;
    animation: pulseOnline 2s infinite;
}

/* 🏢 Контейнер чата - ГЛУБОКИЙ ТЕМНО-ФИОЛЕТОВЫЙ ГРАДИЕНТ */
.ai-chat-container {
    position: absolute;
    bottom: 85px;
    right: 0;
    width: 420px;
    height: 700px;
    max-height: 85vh;
    /* Глубокий темно-фиолетовый градиент */
    background: linear-gradient(135deg, #1e1b4b 0%, #3f226a 50%, #6a2c7d 100%) !important;
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 10px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    transform-origin: bottom right;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.ai-chat-container.active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
    transform: scale(1) translateY(0);
}

/* 🎨 Шапка чата */
.ai-chat-header {
    flex-shrink: 0;
    padding: 20px 24px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: 24px 24px 0 0;
}

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

.ai-avatar-bot {
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 20px !important;
    background: linear-gradient(135deg, #7c3aed 0%, #22c55e 100%) !important;
    color: white !important;
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
}

.ai-header-text h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: white;
}

/* 📝 Поле ввода - СТИЛИЗОВАННОЕ СТЕКЛЯННОЕ */
.ai-chat-input-container {
    /* КРИТИЧНО: flex-shrink: 0 чтобы не сжималось */
    flex-shrink: 0 !important;
    padding: 16px 20px !important;
    background: linear-gradient(135deg, #1e1b4b 0%, #3f226a 100%) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 0 0 24px 24px !important;
    align-self: stretch !important;
    position: relative !important;
}

/* Стеклянный эффект для поля ввода */
.ai-input-wrapper {
    display: flex !important;
    gap: 10px !important;
    align-items: flex-end !important;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.05) 100%) !important;
    border-radius: 24px !important;
    padding: 8px !important;
    border: 1px solid rgba(124, 60, 237, 0.4) !important;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    backdrop-filter: blur(10px) !important;
    box-shadow: 
        inset 0 1px 0 rgba(255, 255, 255, 0.2),
        0 8px 32px rgba(124, 60, 237, 0.15) !important;
    position: relative !important;
}

/* Радиальный градиент для стеклянного эффекта */
.ai-input-wrapper::before {
    content: '';
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: radial-gradient(ellipse at top left, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0) 60%) !important;
    border-radius: 24px !important;
    pointer-events: none !important;
}

.ai-input-wrapper:focus-within {
    border-color: rgba(124, 60, 237, 0.9) !important;
    box-shadow: 
        inset 0 1px 0 rgba(255, 255, 255, 0.3),
        0 0 0 3px rgba(124, 60, 237, 0.25),
        0 12px 30px rgba(124, 60, 237, 0.35) !important;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.08) 100%) !important;
    transform: translateY(-2px) !important;
    border: 1px solid rgba(124, 60, 237, 0.8) !important;
}

.ai-chat-input {
    flex: 1 !important;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    color: white !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
    resize: none !important;
    padding: 12px 16px !important;
    font-family: inherit !important;
    letter-spacing: 0.3px !important;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2) !important;
}

.ai-chat-input::placeholder {
    color: rgba(255, 255, 255, 0.6) !important;
    font-weight: 300 !important;
    letter-spacing: 0.2px !important;
}

/* Кнопка отправки - премиум стиль */
.ai-send-btn {
    background: linear-gradient(135deg, #7c3aed 0%, #22c55e 100%) !important;
    color: white !important;
    border: none !important;
    border-radius: 14px !important;
    padding: 12px 18px !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    cursor: pointer !important;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1) !important;
    box-shadow: 
        0 8px 25px rgba(124, 60, 237, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.3) !important;
    position: relative !important;
    overflow: hidden !important;
}

.ai-send-btn::before {
    content: '';
    position: absolute !important;
    top: 0 !important;
    left: -100% !important;
    width: 100% !important;
    height: 100% !important;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent) !important;
    transition: left 0.6s !important;
}

.ai-send-btn:hover::before {
    left: 100% !important;
}

.ai-send-btn:hover {
    background: linear-gradient(135deg, #8b5cf6 0%, #22c55e 100%) !important;
    transform: translateY(-3px) scale(1.02) !important;
    box-shadow: 
        0 12px 35px rgba(124, 60, 237, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.4) !important;
}

.ai-send-btn:active {
    transform: translateY(0) scale(0.98) !important;
    box-shadow: 
        0 4px 15px rgba(124, 60, 237, 0.25),
        inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
}

/* 📝 Поле ввода и кнопки - ИСПРАВЛЕННЫЕ */
.ai-input-wrapper {
    display: flex !important;
    gap: 10px !important;
    align-items: flex-end !important;
    background: var(--bg-input-wrapper) !important;
    border-radius: 24px !important;
    padding: 4px !important;
    border: 2px solid transparent !important;
    transition: all 0.3s ease !important;
}

.ai-input-wrapper:focus-within {
    border-color: var(--accent-color) !important;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1) !important;
}

.ai-chat-input {
    flex: 1 !important;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    color: var(--text-primary) !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    resize: none !important;
    padding: 8px 12px !important;
    font-family: inherit !important;
}

.ai-chat-input::placeholder {
    color: var(--text-secondary) !important;
}

.ai-send-button {
    background: var(--accent-color) !important;
    color: white !important;
    border: none !important;
    border-radius: 12px !important;
    padding: 8px 16px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

.ai-send-button:hover {
    background: var(--accent-color) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3) !important;
}

.ai-send-button:active {
    transform: translateY(0) !important;
}

.ai-input-wrapper {
    display: flex !important;
    gap: 10px !important;
    align-items: flex-end !important;
    background: var(--bg-input-wrapper) !important;
    border-radius: 24px !important;
    padding: 4px !important;
    border: 2px solid transparent !important;
    transition: all 0.3s ease !important;
}

.ai-chat-input {
    flex: 1 !important;
    background: transparent !important;
    border: none !important;
    outline: none !important;
    color: var(--text-primary) !important;
    font-size: 14px !important;
    line-height: 1.5 !important;
    resize: none !important;
    padding: 8px 12px !important;
    font-family: inherit !important;
}

.ai-chat-input::placeholder {
    color: var(--text-secondary) !important;
}

.ai-send-button {
    background: var(--accent-color) !important;
    color: white !important;
    border: none !important;
    border-radius: 12px !important;
    padding: 8px 16px !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

.ai-send-button:hover {
    background: var(--accent-color) !important;
    transform: translateY(-2px) !important;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3) !important;
}

.ai-send-button:active {
    transform: translateY(0) !important;
}

.ai-chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    opacity: 0.9;
    margin-top: 4px;
}

.ai-status-dot {
    width: 6px;
    height: 6px;
    background: #10b981;
    border-radius: 50%;
}

/* 📱 Мобильная адаптация */
@media (max-width: 480px) {
    .ai-chat-container {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .ai-chat-messages {
        padding: 16px !important;
    }
    
    .ai-message-avatar {
        width: 28px !important;
        height: 28px !important;
        font-size: 14px !important;
    }
    
    .ai-chat-input {
        padding: 6px 10px !important;
        font-size: 16px !important;
    }
    
    .ai-send-button {
        padding: 6px 12px !important;
        font-size: 16px !important;
    }
}

/* 💬 Область сообщений */
.ai-chat-messages {
    flex: 1;
    min-height: 0;
    padding: 24px;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    background: transparent;
    position: relative;
}

/* 🎭 Сообщения - ОСНОВАЯ СТРУКТУРА */
.ai-message {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    animation: messageSlideIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    width: 100%;
}

/* Структура сообщений */
.ai-message-row {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

/* Аватары */
.ai-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 0;
    padding: 0;
    position: relative;
}

/* Аватар робота в сообщениях - контрастный */
.ai-message.assistant .ai-message-avatar {
    background: linear-gradient(135deg, #7c3aed 0%, #22c55e 100%) !important;
    color: white !important;
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
}

/* Аватар пользователя - контрастный */
.ai-message.user .ai-message-avatar {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%) !important;
    color: white !important;
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
}

/* Сообщения ассистента - СЛЕВА */
.ai-message.assistant {
    align-items: flex-start !important;
    justify-content: flex-start !important;
    text-align: left !important;
}

.ai-message.assistant .ai-message-row {
    justify-content: flex-start !important;
}

.ai-message.assistant .ai-message-content {
    text-align: left !important;
    align-self: flex-start !important;
    max-width: 85% !important;
    background: rgba(0, 0, 0, 0.3) !important;
    backdrop-filter: blur(10px) !important;
    color: #ffffff !important;
    border-bottom-left-radius: 6px !important;
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
}

/* Сообщения пользователя - СПРАВА */
.ai-message.user {
    align-items: flex-end !important;
    justify-content: flex-end !important;
    text-align: right !important;
}

.ai-message.user .ai-message-row {
    flex-direction: row-reverse !important;
    justify-content: flex-end !important;
}

.ai-message.user .ai-message-content {
    text-align: right !important;
    align-self: flex-end !important;
    max-width: 85% !important;
    background: linear-gradient(135deg, #8b5cf6 0%, #a78bfa 100%) !important;
    color: white !important;
    border-bottom-right-radius: 12px !important;
    border-top-left-radius: 12px !important;
    border-top-right-radius: 12px !important;
    box-shadow: 
        0 4px 15px rgba(139, 92, 246, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.2) !important;
    position: relative !important;
    padding: 14px 18px !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
}

/* Градиентный бордюр для сообщений пользователя */
.ai-message.user .ai-message-content::before {
    content: '';
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0) 40%) !important;
    border-radius: 12px !important;
    pointer-events: none !important;
    z-index: 1 !important;
}

.ai-message.user .ai-message-content * {
    position: relative !important;
    z-index: 2 !important;
}

/* Сообщения ассистента - СЛЕВА */
.ai-message.assistant {
    align-items: flex-start !important;
    justify-content: flex-start !important;
    text-align: left !important;
}

.ai-message.assistant .ai-message-row {
    justify-content: flex-start !important;
}

.ai-message.assistant .ai-message-content {
    text-align: left !important;
    align-self: flex-start !important;
    max-width: 85% !important;
    background: rgba(0, 0, 0, 0.3) !important;
    backdrop-filter: blur(10px) !important;
    color: #ffffff !important;
    border-bottom-left-radius: 12px !important;
    border-top-left-radius: 12px !important;
    border-top-right-radius: 12px !important;
    border: 1px solid rgba(255, 255, 255, 0.18) !important;
    box-shadow: 
        0 4px 15px rgba(0, 0, 0, 0.2),
        inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
    position: relative !important;
    padding: 14px 18px !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
}

/* Градиентный бордюр для сообщений ассистента */
.ai-message.assistant .ai-message-content::before {
    content: '';
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(255, 255, 255, 0.3) 60%) !important;
    border-radius: 12px !important;
    pointer-events: none !important;
    z-index: 1 !important;
}

.ai-message.assistant .ai-message-content * {
    position: relative !important;
    z-index: 2 !important;
}

.ai-message.user .ai-message-row {
    flex-direction: row-reverse !important;
    justify-content: flex-end !important;
}

.ai-message.user .ai-message-content {
    text-align: right !important;
    align-self: flex-end !important;
    max-width: 85% !important;
    background: linear-gradient(135deg, #7c3aed 0%, #22c55e 100%) !important;
    color: white !important;
    border-bottom-right-radius: 6px !important;
    box-shadow: 0 2px 8px rgba(124, 60, 237, 0.2) !important;
}

.ai-message.assistant .ai-message-row {
    justify-content: flex-start;
}

.ai-message.assistant .ai-message-content {
    text-align: left;
    align-self: flex-start;
    max-width: 85%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    color: #ffffff;
    border-bottom-left-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.18);
}

/* Сообщения пользователя - СПРАВА */
.ai-message.user {
    align-items: flex-end;
    justify-content: flex-end;
}

.ai-message.user .ai-message-row {
    flex-direction: row-reverse;
    justify-content: flex-end;
}

.ai-message.user .ai-message-content {
    text-align: right;
    align-self: flex-end;
    max-width: 85%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 6px;
    border: 1px solid rgba(102, 126, 234, 0.2);
}

/* Мобильная адаптация */
@media (max-width: 480px) {
    .ai-chat-container {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .ai-chat-messages {
        padding: 16px;
    }
    
    .ai-message-avatar {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
}

/* Анимации */
@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulseOnline {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Кнопки управления - улучшенные стили */
.ai-control-btn {
    background: linear-gradient(135deg, #7c3aed 0%, #22c55e 100%) !important;
    color: white !important;
    border: none !important;
    width: 36px !important;
    height: 36px !important;
    border-radius: 12px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 16px !important;
    box-shadow: 0 4px 15px rgba(124, 60, 237, 0.3) !important;
}

.ai-control-btn:hover {
    background: linear-gradient(135deg, #8b5cf6 0%, #22c55e 100%) !important;
    transform: scale(1.05) !important;
    box-shadow: 0 6px 20px rgba(124, 60, 237, 0.4) !important;
}

/* Скрытие кнопки смены темы */
.ai-theme-toggle {
    display: none !important;
}

/* Кнопка закрытия */
.ai-close-btn {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%) !important;
}

.ai-close-btn:hover {
    background: linear-gradient(135deg, #f87171 0%, #ef4444 100%) !important;
}
