/* ── AI Chat Widget — NE00GEN Evangelion theme ─────────────────── */

/* ── Floating Action Button ─────────────────────────────────────── */
.ai-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9900;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    background: linear-gradient(135deg, var(--purple-mid) 0%, var(--pink-neon) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px var(--pink-glow), 0 2px 8px rgba(0, 0, 0, 0.45);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    padding: 0;
}

.ai-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(255, 20, 147, 0.45), 0 2px 12px rgba(0, 0, 0, 0.5);
}

.ai-fab:active { transform: scale(0.96); }

/* Icon toggle: chat <-> close */
.ai-fab-icon {
    position: absolute;
    transition: opacity 0.2s ease, transform 0.25s ease;
}
.ai-fab-icon--close {
    opacity: 0;
    transform: rotate(-90deg) scale(0.7);
}
.ai-fab--open .ai-fab-icon--chat {
    opacity: 0;
    transform: rotate(90deg) scale(0.7);
}
.ai-fab--open .ai-fab-icon--close {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* ── Chat Panel ──────────────────────────────────────────────────── */
.ai-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    z-index: 9899;
    width: 340px;
    height: 480px;
    background: var(--bg-card);
    border: 1px solid rgba(157, 78, 221, 0.25);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow:
        0 8px 40px rgba(0, 0, 0, 0.65),
        0 0 0 1px rgba(157, 78, 221, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    /* hidden by default */
    opacity: 0;
    transform: translateY(16px) scale(0.96);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.ai-panel--open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

/* ── Header ──────────────────────────────────────────────────────── */
.ai-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 14px;
    background: linear-gradient(90deg, var(--purple-deep) 0%, rgba(74, 45, 138, 0.85) 100%);
    border-bottom: 1px solid rgba(157, 78, 221, 0.3);
    flex-shrink: 0;
}

.ai-header-title {
    font-family: var(--font-display);
    font-size: 0.72rem;
    letter-spacing: 0.06em;
    color: var(--text-primary);
    text-shadow: 0 0 12px var(--purple-glow);
}

.ai-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 3px 5px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}
.ai-close:hover {
    color: var(--pink-neon);
    background: rgba(255, 20, 147, 0.12);
}

/* ── Messages area ───────────────────────────────────────────────── */
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--purple-deep) transparent;
}
.ai-messages::-webkit-scrollbar { width: 4px; }
.ai-messages::-webkit-scrollbar-thumb {
    background: var(--purple-deep);
    border-radius: 2px;
}

/* ── Message bubbles ─────────────────────────────────────────────── */
.ai-msg {
    max-width: 88%;
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 0.855rem;
    line-height: 1.55;
    word-break: break-word;
    white-space: pre-wrap;
    animation: ai-pop 0.2s ease;
}

@keyframes ai-pop {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0)  scale(1);    }
}

.ai-msg--user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--purple-mid), var(--purple-deep));
    color: var(--text-primary);
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(45, 27, 105, 0.4);
}

.ai-msg--assistant {
    align-self: flex-start;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

/* ── Typing indicator ────────────────────────────────────────────── */
.ai-typing {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px 14px;
    min-height: 42px;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}

.ai-typing span {
    display: block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--purple-light);
    animation: ai-bounce 1.3s ease-in-out infinite;
    flex-shrink: 0;
}
.ai-typing span:nth-child(2) { animation-delay: 0.18s; }
.ai-typing span:nth-child(3) { animation-delay: 0.36s; }

@keyframes ai-bounce {
    0%, 55%, 100% { transform: translateY(0);   opacity: 0.45; }
    27%            { transform: translateY(-7px); opacity: 1;    }
}

/* ── Footer / Input ──────────────────────────────────────────────── */
.ai-footer {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 10px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.ai-input {
    flex: 1;
    min-width: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.855rem;
    padding: 8px 11px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.ai-input:focus {
    border-color: var(--purple-light);
    box-shadow: 0 0 0 2px var(--purple-glow);
}
.ai-input::placeholder { color: var(--text-muted); }

.ai-send {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    background: var(--pink-neon);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.15s, opacity 0.2s;
}
.ai-send:hover:not(:disabled) { background: var(--purple-light); }
.ai-send:active:not(:disabled) { transform: scale(0.91); }
.ai-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Mobile ──────────────────────────────────────────────────────── */
@media (max-width: 500px) {
    .ai-panel {
        bottom: 0;
        right: 0;
        left: 0;
        width: 100%;
        height: 72vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        border-bottom: none;
    }

    .ai-fab {
        bottom: 16px;
        right: 16px;
    }

    /* Панель на мобильном упирается в низ экрана (bottom:0) — тем же
       местом, где висит FAB. Прячем FAB, пока чат открыт: закрыть чат
       можно через ✕ в шапке, дублирующий круглый FAB поверх поля
       ввода/кнопки "Отправить" не нужен. */
    .ai-fab--open {
        display: none;
    }
}
