/* ================================================================
   AI Chat Assistant — Chat Widget Styles
   ================================================================ */

:root {
    --aca-primary:      #0d6efd;
    --aca-primary-dark: #0b5ed7;
    --aca-primary-rgb:  13, 110, 253;
    --aca-radius:       18px;
    --aca-shadow:       0 8px 32px rgba(0,0,0,0.18);
    --aca-font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --aca-z:            999999;
}

/* ── Floating Bubble Button ── */
#aca-bubble {
    position: fixed;
    bottom: 28px;
    right: 28px;
    z-index: var(--aca-z);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--aca-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(var(--aca-primary-rgb), 0.5);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}

#aca-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 28px rgba(var(--aca-primary-rgb), 0.65);
}

#aca-bubble:active {
    transform: scale(0.95);
}

#aca-bubble svg {
    width: 28px;
    height: 28px;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

#aca-bubble .aca-icon-chat  { position: absolute; }
#aca-bubble .aca-icon-close { position: absolute; opacity: 0; transform: rotate(-90deg); }

#aca-bubble.aca-open .aca-icon-chat  { opacity: 0; transform: rotate(90deg); }
#aca-bubble.aca-open .aca-icon-close { opacity: 1; transform: rotate(0deg); }

/* Pulse ring animation */
#aca-bubble::before {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--aca-primary);
    opacity: 0.3;
    animation: aca-pulse 2.5s ease-out infinite;
}

@keyframes aca-pulse {
    0%   { transform: scale(1);   opacity: 0.3; }
    70%  { transform: scale(1.6); opacity: 0; }
    100% { transform: scale(1.6); opacity: 0; }
}

/* ── Chat Window ── */
#aca-window {
    position: fixed;
    bottom: 102px;
    right: 28px;
    z-index: var(--aca-z);
    width: 370px;
    height: 520px;
    border-radius: var(--aca-radius);
    background: #fff;
    box-shadow: var(--aca-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--aca-font);

    /* Hidden by default */
    opacity: 0;
    transform: translateY(20px) scale(0.97);
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

#aca-window.aca-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: all;
}

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

.aca-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.aca-header-info { flex: 1; }

#aca-clear-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}
#aca-clear-btn:hover { background: rgba(255,255,255,0.28); }
#aca-clear-btn svg { width: 16px; height: 16px; }

.aca-header-title {
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    margin: 0;
    line-height: 1.2;
}

.aca-header-status {
    color: rgba(255,255,255,0.8);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 5px;
    margin-top: 2px;
}

.aca-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
    animation: aca-blink 2s ease-in-out infinite;
}

@keyframes aca-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.4; }
}

/* ── Messages Area ── */
#aca-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8f9fb;
    scroll-behavior: smooth;
}

#aca-messages::-webkit-scrollbar { width: 4px; }
#aca-messages::-webkit-scrollbar-track { background: transparent; }
#aca-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* ── Message Bubbles ── */
.aca-msg {
    display: flex;
    flex-direction: column;
    max-width: 82%;
    animation: aca-fadein 0.2s ease;
}

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

.aca-msg.aca-user {
    align-self: flex-end;
    align-items: flex-end;
}

.aca-msg.aca-bot {
    align-self: flex-start;
    align-items: flex-start;
}

.aca-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
    white-space: pre-wrap;
}

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

.aca-msg.aca-bot .aca-bubble {
    background: #fff;
    color: #1a1a2e;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.aca-msg.aca-bot.aca-error .aca-bubble {
    background: #fff3f3;
    color: #c0392b;
    border: 1px solid #ffc9c9;
}

.aca-msg-label {
    font-size: 11px;
    color: #9ca3af;
    margin-bottom: 4px;
    padding: 0 4px;
}

/* ── Typing Indicator ── */
#aca-typing {
    display: none;
    align-self: flex-start;
    align-items: flex-start;
    flex-direction: column;
}

#aca-typing.aca-visible {
    display: flex;
}

.aca-typing-bubble {
    background: #fff;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: 12px 16px;
    display: flex;
    gap: 5px;
    align-items: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.aca-dot {
    width: 7px;
    height: 7px;
    background: #9ca3af;
    border-radius: 50%;
    animation: aca-bounce 1.2s ease-in-out infinite;
}
.aca-dot:nth-child(1) { animation-delay: 0s; }
.aca-dot:nth-child(2) { animation-delay: 0.2s; }
.aca-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* ── Input Area ── */
#aca-input-area {
    padding: 12px 14px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: #fff;
    flex-shrink: 0;
}

#aca-input {
    flex: 1;
    border: 1.5px solid #e5e7eb;
    border-radius: 22px;
    padding: 10px 16px;
    font-size: 14px;
    font-family: var(--aca-font);
    outline: none;
    resize: none;
    max-height: 100px;
    overflow-y: auto;
    line-height: 1.4;
    color: #1a1a2e;
    background: #f8f9fb;
    transition: border-color 0.2s;
}

#aca-input:focus {
    border-color: var(--aca-primary);
    background: #fff;
}

#aca-input::placeholder { color: #adb5bd; }

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

#aca-send:hover  { background: var(--aca-primary-dark); transform: scale(1.05); }
#aca-send:active { transform: scale(0.95); }
#aca-send:disabled { background: #d1d5db; cursor: not-allowed; transform: none; }

#aca-send svg { width: 18px; height: 18px; }

/* ── Mobile Responsive ── */
@media (max-width: 480px) {
    #aca-window {
        width: calc(100vw - 20px);
        height: calc(100vh - 110px);
        bottom: 90px;
        right: 10px;
        left: 10px;
    }
    #aca-bubble { bottom: 18px; right: 18px; }
}
