/* ====================================================================
   AI Support Agent — Frontend Chat Widget
   Free / Lite version
   ==================================================================== */

#aisa-chatbot-root * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Bubble button ───────────────────────────────────────────────── */
.aisa-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--aisa-color, #2563EB);
    color: #fff;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    z-index: 999998;
    transition: transform .2s, box-shadow .2s;
}

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

.aisa-bubble--left  { left: 24px; right: auto; }

.aisa-bubble__badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    background: #EF4444;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Window ──────────────────────────────────────────────────────── */
.aisa-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    height: 580px;
    max-height: 80vh;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 8px 40px rgba(0,0,0,.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 999999;
    animation: aisaSlideUp .25s ease;
}

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

@keyframes aisaSlideUp {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

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

.aisa-header-bar__avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    overflow: hidden;
    flex-shrink: 0;
}

.aisa-header-bar__avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.aisa-header-bar__info { flex: 1; }
.aisa-header-bar__name { font-weight: 700; font-size: 15px; }
.aisa-header-bar__status { font-size: 12px; opacity: .8; }

.aisa-header-bar__close {
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s;
}

.aisa-header-bar__close:hover { background: rgba(255,255,255,.3); }

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

.aisa-messages::-webkit-scrollbar { width: 4px; }
.aisa-messages::-webkit-scrollbar-track { background: transparent; }
.aisa-messages::-webkit-scrollbar-thumb { background: #DDD; border-radius: 4px; }

/* ── Message bubbles ─────────────────────────────────────────────── */
.aisa-msg {
    display: flex;
    gap: 8px;
    max-width: 100%;
}

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

.aisa-msg__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #F3F4F6;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    overflow: hidden;
}

.aisa-msg__avatar img { width: 100%; height: 100%; object-fit: cover; }

.aisa-msg__bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.55;
    max-width: 260px;
    word-break: break-word;
}

.aisa-msg--bot  .aisa-msg__bubble { background: #F3F4F6; color: #111827; border-bottom-left-radius: 4px; }
.aisa-msg--user .aisa-msg__bubble { background: var(--aisa-color, #2563EB); color: #fff; border-bottom-right-radius: 4px; }

.aisa-msg__time { font-size: 11px; color: #9CA3AF; margin-top: 3px; text-align: right; }

/* ── Typing indicator ────────────────────────────────────────────── */
.aisa-typing { display: flex; gap: 5px; padding: 10px 14px; }
.aisa-typing span {
    width: 8px; height: 8px;
    background: #9CA3AF;
    border-radius: 50%;
    animation: aisaBounce 1.2s infinite;
}
.aisa-typing span:nth-child(2) { animation-delay: .2s; }
.aisa-typing span:nth-child(3) { animation-delay: .4s; }

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

/* ── Input bar ───────────────────────────────────────────────────── */
.aisa-inputbar {
    padding: 12px 16px;
    border-top: 1px solid #E5E7EB;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: #fff;
    flex-shrink: 0;
}

.aisa-inputbar__input {
    flex: 1;
    resize: none;
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 14px;
    max-height: 100px;
    color: #111;
    background: #F9FAFB;
    transition: border-color .15s;
    line-height: 1.4;
}

.aisa-inputbar__input:focus { outline: none; border-color: var(--aisa-color, #2563EB); background: #fff; }

.aisa-inputbar__send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--aisa-color, #2563EB);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: opacity .15s;
}

.aisa-inputbar__send:hover   { opacity: .9; }
.aisa-inputbar__send:disabled{ opacity: .5; cursor: not-allowed; }

/* ── Footer ──────────────────────────────────────────────────────── */
.aisa-footer {
    text-align: center;
    font-size: 11px;
    color: #9CA3AF;
    padding: 6px;
    border-top: 1px solid #F3F4F6;
    flex-shrink: 0;
    background: #fff;
}

/* ── RTL ─────────────────────────────────────────────────────────── */
[dir="rtl"] .aisa-bubble { right: auto; left: 24px; }
[dir="rtl"] .aisa-window { right: auto; left: 24px; }

/* ── Mobile ──────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .aisa-window {
        width: 100vw;
        height: 100%;
        max-height: 100%;
        bottom: 0;
        right: 0;
        left: 0;
        border-radius: 0;
    }
}
