/* AI Chatbot Pro — Frontend Widget */
:root {
    --aicp-c:       #2563eb;
    --aicp-c-dark:  #1d4ed8;
    --aicp-c-light: #eff6ff;
    --aicp-radius:  16px;
    --aicp-shadow:  0 8px 40px rgba(0,0,0,.18);
    --aicp-font:    -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Launcher button ──────────────────────────────────────────── */
#aicp-launcher {
    position: fixed;
    bottom: 24px; right: 24px;
    width: 58px; height: 58px;
    border-radius: 50%;
    background: var(--aicp-c);
    border: none; cursor: pointer;
    box-shadow: 0 4px 20px rgba(37,99,235,.45);
    display: flex; align-items: center; justify-content: center;
    z-index: 999998;
    transition: transform .2s, box-shadow .2s;
}
#aicp-launcher:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(37,99,235,.55); }
#aicp-launcher svg   { width: 26px; height: 26px; fill: #fff; transition: opacity .2s; }
#aicp-launcher .icon-close { display: none; }

#aicp-launcher.open .icon-chat  { display: none; }
#aicp-launcher.open .icon-close { display: block; }

.aicp-pos-left  #aicp-launcher,
.aicp-pos-left  #aicp-window { left: 24px; right: auto; }

/* Pulse ring */
#aicp-launcher::after {
    content: '';
    position: absolute; inset: -4px;
    border-radius: 50%;
    border: 3px solid var(--aicp-c);
    animation: aicp-pulse 2.5s ease-out infinite;
    opacity: 0;
}
@keyframes aicp-pulse {
    0%   { transform: scale(1); opacity: .6; }
    100% { transform: scale(1.6); opacity: 0; }
}

/* ── Chat window ──────────────────────────────────────────────── */
#aicp-window {
    position: fixed;
    bottom: 96px; right: 24px;
    width: 380px; height: 560px;
    background: #fff;
    border-radius: var(--aicp-radius);
    box-shadow: var(--aicp-shadow);
    display: flex; flex-direction: column;
    z-index: 999997;
    opacity: 0; pointer-events: none;
    transform: translateY(16px) scale(.97);
    transition: opacity .25s, transform .25s;
    font-family: var(--aicp-font);
    overflow: hidden;
}
#aicp-window.open {
    opacity: 1; pointer-events: all;
    transform: translateY(0) scale(1);
}

/* Header */
#aicp-header {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px;
    background: var(--aicp-c);
    color: #fff;
    border-radius: var(--aicp-radius) var(--aicp-radius) 0 0;
}
#aicp-avatar {
    width: 38px; height: 38px; border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0;
}
#aicp-title-wrap { flex: 1; }
#aicp-title { font-weight: 700; font-size: 15px; margin: 0; }
#aicp-status { font-size: 11px; opacity: .8; margin-top: 1px; }
.aicp-dot { display: inline-block; width: 7px; height: 7px; background: #4ade80; border-radius: 50%; margin-right: 4px; animation: aicp-blink 2s infinite; }
@keyframes aicp-blink { 0%,100%{opacity:1}50%{opacity:.4} }

/* GDPR banner */
#aicp-gdpr-banner {
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
    padding: 14px 16px;
    font-size: 13px; color: #78350f; line-height: 1.5;
}
#aicp-gdpr-banner a { color: var(--aicp-c); }
#aicp-gdpr-accept {
    margin-top: 10px; width: 100%;
    padding: 9px; border: none; border-radius: 8px;
    background: var(--aicp-c); color: #fff;
    font-weight: 600; font-size: 13px; cursor: pointer;
}
#aicp-gdpr-accept:hover { background: var(--aicp-c-dark); }

/* Messages area */
#aicp-messages {
    flex: 1; overflow-y: auto; padding: 16px;
    display: flex; flex-direction: column; gap: 12px;
    scroll-behavior: smooth;
}
#aicp-messages::-webkit-scrollbar { width: 4px; }
#aicp-messages::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 4px; }

/* Bubbles */
.aicp-bubble-wrap { display: flex; gap: 8px; max-width: 88%; }
.aicp-bubble-wrap.user  { flex-direction: row-reverse; align-self: flex-end; }
.aicp-bubble-wrap.bot   { align-self: flex-start; }

.aicp-bubble-avatar {
    width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
    background: var(--aicp-c-light); display: flex; align-items: center; justify-content: center;
    font-size: 13px; margin-top: 4px;
}
.aicp-bubble-wrap.user .aicp-bubble-avatar { background: #f1f5f9; }

.aicp-bubble {
    padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.6;
    max-width: 100%; word-break: break-word;
}
.aicp-bubble.user { background: var(--aicp-c); color: #fff; border-bottom-right-radius: 4px; }
.aicp-bubble.bot  { background: #f8fafc; color: #1e293b; border-bottom-left-radius: 4px; border: 1px solid #e2e8f0; }
.aicp-bubble a    { color: inherit; text-decoration: underline; }

/* Typing indicator */
.aicp-typing { display: flex; gap: 4px; padding: 12px 14px; }
.aicp-typing span {
    width: 7px; height: 7px; border-radius: 50%; background: #94a3b8;
    animation: aicp-bounce .9s infinite;
}
.aicp-typing span:nth-child(2) { animation-delay: .15s; }
.aicp-typing span:nth-child(3) { animation-delay: .30s; }
@keyframes aicp-bounce { 0%,80%,100%{transform:translateY(0)}40%{transform:translateY(-7px)} }

/* Rate limit badge */
#aicp-rate-badge {
    text-align: center; font-size: 11px; color: #94a3b8;
    padding: 2px 0; margin-top: -8px;
}

/* Input area */
#aicp-input-area {
    display: flex; gap: 8px; padding: 12px 14px;
    border-top: 1px solid #e2e8f0; background: #fff;
}
#aicp-input {
    flex: 1; padding: 10px 14px; border: 1.5px solid #e2e8f0;
    border-radius: 22px; font-size: 14px; font-family: var(--aicp-font);
    outline: none; resize: none; height: 42px; line-height: 1.4;
    transition: border .2s;
}
#aicp-input:focus { border-color: var(--aicp-c); }
#aicp-input:disabled { opacity: .5; }

#aicp-send {
    width: 42px; height: 42px; border-radius: 50%; border: none;
    background: var(--aicp-c); color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: background .2s, transform .15s;
}
#aicp-send:hover:not(:disabled) { background: var(--aicp-c-dark); transform: scale(1.05); }
#aicp-send:disabled { opacity: .4; cursor: not-allowed; }
#aicp-send svg { width: 18px; height: 18px; fill: #fff; }

/* Rate limit warning */
.aicp-rate-warning {
    font-size: 12px; color: #ef4444; text-align: center;
    padding: 8px 14px; background: #fef2f2; border-radius: 8px;
}

/* Powered by */
#aicp-footer {
    text-align: center; font-size: 10px; color: #cbd5e1;
    padding: 4px 0 8px; letter-spacing: .03em;
}

/* Mobile */
@media (max-width: 480px) {
    #aicp-window {
        width: calc(100vw - 24px);
        height: 65vh;
        bottom: 84px;
        right: 12px;
    }
    .aicp-pos-left #aicp-window,
    .aicp-pos-left #aicp-launcher { left: 12px; right: auto; }
}
