/* ============================================================
   AI Visibility Scanner — Front-End Chat Widget
   ============================================================ */

#aivs-chat-root {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Bubble ─────────────────────────────────────────────── */
#aivs-bubble {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,.25);
    transition: transform .2s ease, box-shadow .2s ease;
    position: relative;
    color: #fff;
    margin-left: auto;
}
#aivs-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0,0,0,.3);
}
#aivs-bubble:active { transform: scale(.96); }

#aivs-unread-dot {
    position: absolute;
    top: 3px; right: 3px;
    width: 12px; height: 12px;
    background: #EF4444;
    border-radius: 50%;
    border: 2px solid #fff;
    display: none;
    animation: aivs-pulse 2s infinite;
}
@keyframes aivs-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50%       { transform: scale(1.2); opacity: .7; }
}

/* ── Panel ─────────────────────────────────────────────── */
#aivs-chat-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 360px;
    max-height: 560px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(.92) translateY(12px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s ease, transform .22s ease;
    transform-origin: bottom right;
}
#aivs-chat-panel.aivs-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* ── Header ─────────────────────────────────────────────── */
#aivs-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    color: #fff;
    flex-shrink: 0;
}
#aivs-chat-header-info { display: flex; align-items: center; gap: 10px; }
#aivs-chat-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 15px; color: #fff;
    flex-shrink: 0;
}
#aivs-chat-agent-name { font-weight: 700; font-size: 14px; line-height: 1.2; }
#aivs-chat-status { font-size: 11px; opacity: .85; display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.aivs-status-dot {
    width: 7px; height: 7px; background: #4ADE80;
    border-radius: 50%; display: inline-block;
    animation: aivs-blink 3s infinite;
}
@keyframes aivs-blink {
    0%, 90%, 100% { opacity: 1; }
    95%            { opacity: .3; }
}
#aivs-chat-close {
    background: rgba(255,255,255,.15); border: none;
    width: 28px; height: 28px; border-radius: 50%;
    cursor: pointer; color: #fff;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
}
#aivs-chat-close:hover { background: rgba(255,255,255,.3); }

/* ── Messages ───────────────────────────────────────────── */
#aivs-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px 14px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}
#aivs-chat-messages::-webkit-scrollbar { width: 4px; }
#aivs-chat-messages::-webkit-scrollbar-track { background: transparent; }
#aivs-chat-messages::-webkit-scrollbar-thumb { background: #E2E8F0; border-radius: 2px; }

.aivs-msg { display: flex; flex-direction: column; max-width: 85%; animation: aivs-msg-in .18s ease; }
@keyframes aivs-msg-in { from { opacity:0; transform:translateY(6px); } to { opacity:1; transform:translateY(0); } }

.aivs-msg--agent { align-self: flex-start; align-items: flex-start; }
.aivs-msg--user  { align-self: flex-end;   align-items: flex-end; }

.aivs-msg-bubble {
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.55;
    word-break: break-word;
}
.aivs-msg--agent .aivs-msg-bubble {
    background: #F1F5F9;
    color: #1E293B;
    border-bottom-left-radius: 4px;
}
.aivs-msg--user .aivs-msg-bubble {
    background: var(--aivs-bubble-color, #2563EB);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.aivs-msg-time {
    font-size: 10px;
    color: #94A3B8;
    margin-top: 3px;
    padding: 0 3px;
}

/* Typing indicator */
.aivs-typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 10px 14px;
    background: #F1F5F9;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
    width: fit-content;
}
.aivs-typing-dot {
    width: 7px; height: 7px;
    background: #94A3B8;
    border-radius: 50%;
    animation: aivs-typing .9s infinite;
}
.aivs-typing-dot:nth-child(2) { animation-delay: .15s; }
.aivs-typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes aivs-typing {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-5px); }
}

/* ── Suggestions ────────────────────────────────────────── */
#aivs-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 14px 10px;
}
.aivs-suggestion-btn {
    background: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 20px;
    padding: 5px 12px;
    font-size: 12px;
    color: #475569;
    cursor: pointer;
    transition: all .15s;
    font-family: inherit;
    text-align: left;
    line-height: 1.4;
}
.aivs-suggestion-btn:hover {
    background: #EFF6FF;
    border-color: #BFDBFE;
    color: #1D4ED8;
}

/* ── Input ──────────────────────────────────────────────── */
#aivs-chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #F1F5F9;
    background: #fff;
    flex-shrink: 0;
}
#aivs-chat-input {
    flex: 1;
    border: 1px solid #E2E8F0;
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    outline: none;
    line-height: 1.45;
    max-height: 100px;
    overflow-y: auto;
    transition: border-color .15s;
    color: #1E293B;
}
#aivs-chat-input:focus { border-color: var(--aivs-bubble-color, #2563EB); }
#aivs-chat-input::placeholder { color: #94A3B8; }
#aivs-chat-send {
    width: 36px; height: 36px;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: opacity .15s, transform .12s;
}
#aivs-chat-send:hover  { opacity: .88; }
#aivs-chat-send:active { transform: scale(.94); }
#aivs-chat-send:disabled { opacity: .45; cursor: not-allowed; }

/* ── Footer ─────────────────────────────────────────────── */
#aivs-chat-footer {
    text-align: center;
    font-size: 10px;
    color: #CBD5E1;
    padding: 6px 0 8px;
    background: #fff;
    flex-shrink: 0;
}

/* ── Error message ──────────────────────────────────────── */
.aivs-msg--error .aivs-msg-bubble {
    background: #FEF2F2;
    color: #DC2626;
    border: 1px solid #FEE2E2;
}

/* ── Mobile ─────────────────────────────────────────────── */
@media (max-width: 480px) {
    #aivs-chat-root { bottom: 16px; right: 16px; }
    #aivs-chat-panel { width: calc(100vw - 32px); right: 0; bottom: 66px; max-height: 70vh; }
}
