/* AI Chat Widget Styles */
#ai-chat-widget {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 9999;
    font-family: 'Inter', sans-serif;
}

/* Кнопка открытия */
#ai-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--accent, #38BDF8);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(56, 189, 248, 0.4);
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
}

#ai-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(56, 189, 248, 0.6);
}

#ai-chat-toggle svg {
    width: 28px;
    height: 28px;
    stroke: #0f172a;
}

.ai-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    border: 2px solid var(--bg-card, #1e293b);
}

/* Окно чата */
#ai-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: var(--bg-card, #1e293b);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    transition: opacity 0.3s, transform 0.3s;
}

#ai-chat-window.hidden {
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
}

/* Шапка чата */
.ai-chat-header {
    padding: 15px 20px;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid rgba(255,255,255,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-chat-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-avatar {
    width: 36px;
    height: 36px;
    background: var(--accent, #38BDF8);
    color: #0f172a;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 12px;
}

.ai-name {
    color: #fff;
    font-size: 14px;
    font-weight: 600;
}

.ai-status {
    color: #4ade80;
    font-size: 11px;
}

#ai-chat-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

#ai-chat-close:hover {
    color: #fff;
}

/* Сообщения */
#ai-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.5;
    word-wrap: break-word;
}

.ai-message-bot {
    background: rgba(255,255,255,0.05);
    color: #cbd5e1;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.ai-message-user {
    background: var(--accent, #38BDF8);
    color: #0f172a;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    font-weight: 500;
}

/* Индикатор печати */
.ai-typing span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    margin: 0 2px;
    animation: typing 1.4s infinite ease-in-out both;
}

.ai-typing span:nth-child(1) { animation-delay: -0.32s; }
.ai-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Поле ввода */
.ai-chat-input-area {
    padding: 15px;
    background: rgba(0,0,0,0.2);
    border-top: 1px solid rgba(255,255,255,0.05);
    display: flex;
    gap: 10px;
}

#ai-chat-input {
    flex: 1;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 20px;
    padding: 10px 16px;
    color: #fff;
    font-size: 13px;
    outline: none;
    transition: border-color 0.3s;
}

#ai-chat-input:focus {
    border-color: var(--accent, #38BDF8);
}

#ai-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent, #38BDF8);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

#ai-chat-send:hover {
    transform: scale(1.1);
}

#ai-chat-send svg {
    width: 18px;
    height: 18px;
    stroke: #0f172a;
}

/* Мобильная адаптация */
@media (max-width: 480px) {
    #ai-chat-window {
        width: calc(100vw - 40px);
        height: 60vh;
        right: -10px;
    }
    
    #ai-chat-widget {
        right: 20px;
        bottom: 20px;
    }
}
.ai-avatar-img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: #0f172a; /* Цвет фона на случай долгой загрузки */
    border: 2px solid rgba(56, 189, 248, 0.2); /* Легкое свечение вокруг */
}
/* Автоматическая подсветка email в сообщениях бота */
.ai-message-bot a,
.ai-message-bot span.email-highlight {
    color: #38BDF8 !important; /* Ваш акцентный голубой */
    font-weight: 700 !important;
    text-decoration: none;
    border-bottom: 1px dashed rgba(56, 189, 248, 0.5);
    transition: all 0.2s;
}

.ai-message-bot a:hover,
.ai-message-bot span.email-highlight:hover {
    color: #7dd3fc !important;
    border-bottom-style: solid;
}

/* Стили для жирного текста от Markdown (если ИИ использует **) */
.ai-message-bot strong {
    color: #38BDF8;
    font-weight: 700;
}
/* Компактная панель приветствия */
#ai-chat-compact {
    position: fixed;
    bottom: 30px;
    right: 100px; /* Слева от основной кнопки */
    background: var(--bg-card, #1e293b);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 30px;
    padding: 8px 16px 8px 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    z-index: 9998;
    animation: slideInRight 0.5s ease-out;
    max-width: 300px;
}

#ai-chat-compact.hidden {
    display: none;
}

.compact-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.compact-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(56, 189, 248, 0.5);
}

.compact-text {
    color: #cbd5e1;
    font-size: 13px;
    line-height: 1.3;
}

.compact-text strong {
    color: #fff;
    font-weight: 600;
}

#ai-chat-expand {
    background: var(--accent, #38BDF8);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    flex-shrink: 0;
}

#ai-chat-expand:hover {
    transform: scale(1.1);
}

#ai-chat-expand svg {
    width: 16px;
    height: 16px;
    stroke: #0f172a;
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Адаптация для мобильных */
@media (max-width: 480px) {
    #ai-chat-compact {
        right: 20px;
        bottom: 90px; /* Над основной кнопкой */
        max-width: calc(100vw - 40px);
    }
}