/* ── Root ──────────────────────────────────────────────────── */
#aic-chat-root {
    position: fixed;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
#aic-chat-root.aic-bottom-right { bottom: 24px; right: 24px; }
#aic-chat-root.aic-bottom-left  { bottom: 24px; left:  24px; }

/* ── Launcher: bubble + label side by side ─────────────────── */
#aic-launcher {
    display: flex;
    align-items: center;
    gap: 0;
    cursor: pointer;
    position: relative;
}

/* Toggle bubble */
#aic-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(0,0,0,.28);
    transition: transform .2s ease, box-shadow .2s ease;
    flex-shrink: 0;
    position: relative;
    z-index: 2;
    padding: 0;
}
#aic-toggle:hover { transform: scale(1.08); box-shadow: 0 6px 22px rgba(0,0,0,.32); }

/* "AI Chatbot" label pill — sits to the LEFT of the bubble */
#aic-launcher-label {
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 7px 14px 7px 16px;
    border-radius: 24px 0 0 24px;
    margin-right: -10px;           /* tucks behind the bubble */
    box-shadow: 0 4px 12px rgba(0,0,0,.18);
    white-space: nowrap;
    transition: opacity .2s, transform .2s;
    letter-spacing: 0.02em;
}

/* Hide label when chat is open */
#aic-launcher.aic-open #aic-launcher-label {
    opacity: 0;
    pointer-events: none;
    transform: translateX(8px);
}

/* Bottom-left: flip label to the right */
.aic-bottom-left #aic-launcher { flex-direction: row-reverse; }
.aic-bottom-left #aic-launcher-label {
    border-radius: 0 24px 24px 0;
    margin-right: 0;
    margin-left: -10px;
}

/* ── Chat window ───────────────────────────────────────────── */
#aic-window {
    position: absolute;
    bottom: 72px;
    width: 340px;
    max-height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity .2s ease, transform .2s ease;
    font-size: 14px;
}
#aic-window.aic-hidden { opacity: 0; pointer-events: none; transform: translateY(12px); }

.aic-bottom-right #aic-window { right: 0; }
.aic-bottom-left  #aic-window { left:  0; }

/* ── Header ────────────────────────────────────────────────── */
#aic-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    color: #fff;
    flex-shrink: 0;
}

#aic-header-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255,255,255,.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#aic-header-text {
    flex: 1;
    min-width: 0;
}

#aic-header-name {
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#aic-header-status {
    font-size: 11px;
    opacity: 0.75;
    margin-top: 1px;
    display: flex;
    align-items: center;
    gap: 4px;
}
#aic-header-status::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #4ade80;
    flex-shrink: 0;
}

#aic-close {
    background: none;
    border: none;
    cursor: pointer;
    color: rgba(255,255,255,.8);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    border-radius: 50%;
    transition: background .15s;
}
#aic-close:hover { background: rgba(255,255,255,.15); color: #fff; }

/* ── Messages ──────────────────────────────────────────────── */
#aic-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.aic-msg {
    max-width: 82%;
    padding: 9px 13px;
    border-radius: 14px;
    line-height: 1.5;
    word-break: break-word;
    font-size: 13.5px;
}
.aic-msg a { text-decoration: underline; }

.aic-msg--bot {
    background: #f1f3f4;
    color: #202124;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
}
.aic-msg--user {
    color: #fff;
    border-bottom-right-radius: 4px;
    align-self: flex-end;
}
.aic-msg--bot a  { color: #1a73e8; }
.aic-msg--user a { color: rgba(255,255,255,.9); }
.aic-msg strong  { font-weight: 600; }

/* Typing dots */
.aic-typing {
    display: flex;
    gap: 5px;
    padding: 10px 14px;
    align-self: flex-start;
    background: #f1f3f4;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.aic-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #bbb;
    animation: aic-bounce .9s infinite;
}
.aic-dot:nth-child(2) { animation-delay: .15s; }
.aic-dot:nth-child(3) { animation-delay: .3s;  }
@keyframes aic-bounce {
    0%,60%,100% { transform: translateY(0); }
    30%          { transform: translateY(-6px); }
}

/* ── Input bar ─────────────────────────────────────────────── */
#aic-input-bar {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid #eee;
    flex-shrink: 0;
}

#aic-input {
    flex: 1;
    border: 1px solid #ddd;
    border-radius: 20px;
    padding: 8px 14px;
    font-size: 13px;
    outline: none;
    resize: none;
    font-family: inherit;
    line-height: 1.4;
    max-height: 80px;
    transition: border-color .15s;
}
#aic-input:focus { border-color: #aaa; }

#aic-send {
    width: 36px; height: 36px;
    border: none; border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    margin-top: 1px;
    transition: opacity .15s, transform .1s;
}
#aic-send:hover    { opacity: .88; transform: scale(1.05); }
#aic-send:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* ── Footer ────────────────────────────────────────────────── */
#aic-footer {
    text-align: center;
    font-size: 11px;
    color: #bbb;
    padding: 4px 0 8px;
}

/* ── Admin spin ────────────────────────────────────────────── */
@keyframes aic-spin { to { transform: rotate(360deg); } }
.aic-spin { animation: aic-spin .8s linear infinite; display: inline-block; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 400px) {
    #aic-window { width: calc(100vw - 32px); }
    #aic-launcher-label { display: none; }
    #aic-chat-root.aic-bottom-right { right: 12px; }
    #aic-chat-root.aic-bottom-left  { left:  12px; }
}
