/* =============================================================
   AI-помощник PopMe — стили виджета
   Файл: assets/css/ai-assistant.css
   ============================================================= */

/* ── Кнопка-триггер ──────────────────────────────────────────── */
.ai-assistant-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0);   }
    40%       { transform: translateY(-10px); }
    60%       { transform: translateY(-5px);  }
}

.ai-assistant-trigger {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.45);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    padding: 0;
}

.ai-assistant-trigger:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(124, 58, 237, 0.55);
}

.ai-assistant-trigger.open {
    transform: scale(0.92);
}

.ai-assistant-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: block;
}

/* Красная точка-бейдж */
.ai-assistant-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
    font-size: 0;
    display: block;
}

/* ── Окно чата ───────────────────────────────────────────────── */
.ai-assistant-chat {
    position: absolute;
    bottom: 72px;
    right: 0;
    width: 360px;
    max-width: calc(100vw - 32px);
    background: #ffffff;
    border-radius: 20px;
    box-shadow:
        0 8px 40px rgba(0, 0, 0, 0.14),
        0 2px 8px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(12px) scale(0.97);
    pointer-events: none;
    transition:
        opacity 0.22s ease,
        transform 0.22s ease;
    max-height: calc(100vh - 120px);
}

.ai-assistant-chat.active {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ── Шапка ───────────────────────────────────────────────────── */
.ai-assistant-header {
    background: linear-gradient(135deg, #5b21b6 0%, #7c3aed 60%, #9461fb 100%);
    padding: 16px 14px 16px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ai-assistant-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ai-assistant-header-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid rgba(255, 255, 255, 0.35);
}

.ai-assistant-header-avatar svg {
    width: 100%;
    height: 100%;
    display: block;
}

.ai-assistant-header-name {
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ai-assistant-header-status {
    color: rgba(255, 255, 255, 0.85);
    font-size: 12px;
    margin-top: 2px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.ai-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    flex-shrink: 0;
    box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.3);
}

.ai-assistant-close {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #ffffff;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    flex-shrink: 0;
    transition: background 0.15s ease;
    padding: 0;
}

.ai-assistant-close:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* ── Область сообщений ───────────────────────────────────────── */
.ai-assistant-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 180px;
    max-height: 320px;
    scroll-behavior: smooth;
}

.ai-assistant-messages::-webkit-scrollbar {
    width: 4px;
}
.ai-assistant-messages::-webkit-scrollbar-thumb {
    background: #e2d9f3;
    border-radius: 4px;
}

/* Строка сообщения */
.ai-message {
    display: flex;
    max-width: 88%;
}

.ai-message--assistant {
    align-self: flex-start;
}

.ai-message--user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

/* Пузырь */
.ai-bubble {
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.55;
    word-break: break-word;
}

.ai-message--assistant .ai-bubble {
    background: #f3f0fd;
    color: #1e1b2e;
    border-bottom-left-radius: 5px;
}

.ai-message--user .ai-bubble {
    background: linear-gradient(135deg, #7c3aed, #5b21b6);
    color: #ffffff;
    border-bottom-right-radius: 5px;
}

/* ── Индикатор печати ────────────────────────────────────────── */
.ai-typing .ai-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 12px 16px;
}

@keyframes dotBounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40%            { transform: translateY(-6px); opacity: 1; }
}

.ai-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #7c3aed;
    display: inline-block;
    animation: dotBounce 1.2s ease infinite;
}
.ai-dot:nth-child(2) { animation-delay: 0.15s; }
.ai-dot:nth-child(3) { animation-delay: 0.30s; }

/* ── Быстрые ответы ──────────────────────────────────────────── */
.ai-assistant-quick {
    padding: 6px 14px 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    flex-shrink: 0;
    border-top: 1px solid #f3f0fd;
}

.ai-quick-btn {
    background: #f3f0fd;
    color: #5b21b6;
    border: 1px solid #ddd6fe;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    white-space: nowrap;
    line-height: 1.4;
}

.ai-quick-btn:hover {
    background: #7c3aed;
    color: #ffffff;
    border-color: #7c3aed;
}

/* ── Поле ввода ──────────────────────────────────────────────── */
.ai-assistant-input-wrap {
    padding: 10px 14px 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    border-top: 1px solid #f0eafd;
}

.ai-assistant-input {
    flex: 1;
    border: 1.5px solid #e2d9f3;
    border-radius: 24px;
    padding: 9px 16px;
    font-size: 14px;
    color: #1e1b2e;
    background: #fafafa;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    line-height: 1.4;
}

.ai-assistant-input::placeholder {
    color: #a78bca;
}

.ai-assistant-input:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
    background: #ffffff;
}

.ai-assistant-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-assistant-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed, #5b21b6);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    flex-shrink: 0;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 2px 10px rgba(124, 58, 237, 0.35);
    padding: 0;
}

.ai-assistant-send:hover:not(:disabled) {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(124, 58, 237, 0.50);
}

.ai-assistant-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.ai-assistant-send svg {
    width: 17px;
    height: 17px;
}

/* ── Мобильная адаптация ─────────────────────────────────────── */
@media (max-width: 480px) {
    .ai-assistant-widget {
        bottom: 16px;
        right: 14px;
    }

    .ai-assistant-chat {
        width: calc(100vw - 28px);
        right: 0;
        bottom: 68px;
        border-radius: 16px;
    }

    .ai-assistant-messages {
        max-height: 260px;
    }

    .ai-assistant-trigger {
        width: 54px;
        height: 54px;
    }
}
