/* ═══════════════════════════════════════════
   AI Site Agent — Chat Widget v1.1
   ═══════════════════════════════════════════ */

:root {
    --aisa-primary: #2563eb;
    --aisa-primary-dark: #1d4ed8;
    --aisa-primary-light: #dbeafe;
    --aisa-bg: #ffffff;
    --aisa-surface: #f8fafc;
    --aisa-border: #e2e8f0;
    --aisa-text: #1e293b;
    --aisa-text-muted: #64748b;
    --aisa-radius: 16px;
    --aisa-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 4px 16px rgba(0, 0, 0, 0.08);
}

/* ─── Toggle Button ─── */
.aisa-toggle {
    position: fixed;
    bottom: 24px;
    z-index: 999998;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--aisa-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.aisa-toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.25);
}

.aisa-toggle.bottom-right { right: 24px; }
.aisa-toggle.bottom-left { left: 24px; }

.aisa-toggle svg {
    width: 28px;
    height: 28px;
    transition: transform 0.3s ease, opacity 0.2s ease;
}

.aisa-toggle .aisa-icon-close {
    position: absolute;
    transform: rotate(90deg) scale(0);
    opacity: 0;
}

.aisa-toggle.active .aisa-icon-chat {
    transform: rotate(-90deg) scale(0);
    opacity: 0;
}

.aisa-toggle.active .aisa-icon-close {
    transform: rotate(0deg) scale(1);
    opacity: 1;
}

.aisa-toggle .aisa-notif {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #ef4444;
    border-radius: 50%;
    border: 2px solid #fff;
    font-size: 10px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: aisa-pulse 2s infinite;
}

@keyframes aisa-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

/* ─── Chat Window ─── */
.aisa-window {
    position: fixed;
    bottom: 100px;
    z-index: 999999;
    width: 400px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 140px);
    background: var(--aisa-bg);
    border-radius: var(--aisa-radius);
    box-shadow: var(--aisa-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

.aisa-window.bottom-right { right: 24px; }
.aisa-window.bottom-left { left: 24px; }

/* ─── Header ─── */
.aisa-header {
    background: var(--aisa-primary);
    color: #fff;
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

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

.aisa-avatar svg {
    width: 22px;
    height: 22px;
}

.aisa-header-info { flex: 1; min-width: 0; }

.aisa-header-name {
    font-weight: 600;
    font-size: 15px;
    line-height: 1.2;
}

.aisa-header-status {
    font-size: 12px;
    opacity: 0.85;
    display: flex;
    align-items: center;
    gap: 5px;
}

.aisa-header-status::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
}

/* ─── Messages ─── */
.aisa-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.aisa-messages::-webkit-scrollbar { width: 5px; }
.aisa-messages::-webkit-scrollbar-track { background: transparent; }
.aisa-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

.aisa-msg {
    display: flex;
    gap: 8px;
    max-width: 88%;
    animation: aisa-fadeIn 0.3s ease;
}

@keyframes aisa-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.aisa-msg.bot { align-self: flex-start; }
.aisa-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.aisa-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--aisa-primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.aisa-msg-avatar svg { width: 16px; height: 16px; color: var(--aisa-primary); }

.aisa-msg.user .aisa-msg-avatar { background: #e2e8f0; }
.aisa-msg.user .aisa-msg-avatar svg { color: #64748b; }

.aisa-msg-bubble {
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
    color: var(--aisa-text);
}

.aisa-msg.bot .aisa-msg-bubble {
    background: var(--aisa-surface);
    border: 1px solid var(--aisa-border);
    border-bottom-left-radius: 4px;
}

.aisa-msg.user .aisa-msg-bubble {
    background: var(--aisa-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Typing */
.aisa-typing { display: flex; gap: 4px; padding: 4px 0; }

.aisa-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: aisa-bounce 1.4s infinite;
}

.aisa-typing span:nth-child(2) { animation-delay: 0.2s; }
.aisa-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes aisa-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* CTA Buttons */
.aisa-cta-buttons {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.aisa-contact-cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--aisa-primary);
    color: #fff !important;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none !important;
    transition: background 0.2s ease, transform 0.15s ease;
}

.aisa-contact-cta:hover {
    background: var(--aisa-primary-dark);
    transform: translateY(-1px);
}

.aisa-contact-cta svg { width: 14px; height: 14px; }

.aisa-call-cta {
    background: #16a34a;
}

.aisa-call-cta:hover {
    background: #15803d;
}

/* Input */
.aisa-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--aisa-border);
    background: var(--aisa-bg);
    display: flex;
    gap: 8px;
    align-items: flex-end;
    flex-shrink: 0;
}

.aisa-input-wrap { flex: 1; position: relative; }

.aisa-input {
    width: 100%;
    border: 1px solid var(--aisa-border);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 100px;
    line-height: 1.4;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.aisa-input:focus {
    border-color: var(--aisa-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.aisa-input::placeholder { color: #94a3b8; }

.aisa-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--aisa-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease, transform 0.15s ease;
}

.aisa-send-btn:hover { background: var(--aisa-primary-dark); transform: scale(1.05); }
.aisa-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.aisa-send-btn svg { width: 18px; height: 18px; }

/* Powered by */
.aisa-powered {
    text-align: center;
    padding: 6px;
    font-size: 10px;
    color: #94a3b8;
    background: var(--aisa-surface);
    border-top: 1px solid var(--aisa-border);
    flex-shrink: 0;
}

/* Mobile */
@media (max-width: 480px) {
    .aisa-window {
        width: calc(100vw - 16px);
        height: calc(100vh - 100px);
        max-height: calc(100vh - 100px);
        bottom: 88px;
        right: 8px !important;
        left: 8px !important;
        border-radius: 12px;
    }

    .aisa-toggle { bottom: 16px; }
    .aisa-toggle.bottom-right { right: 16px; }
    .aisa-toggle.bottom-left { left: 16px; }
}
