/* ============================================================
   Alliance AI — chat widget
   Injected by chat-widget.js; no markup lives in any HTML file.
   Tokens come from styles.css, which every page carrying this
   widget already loads. Deliberately no :root block here.
   ============================================================ */

.aai-chat-launcher {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 60px;
    height: 60px;
    border-radius: 999px;
    border: none;
    background: var(--primary-ink);
    color: var(--on-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    z-index: 9998;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.aai-chat-launcher:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22); }
.aai-chat-launcher:focus-visible { outline: 2px solid var(--primary-ink); outline-offset: 3px; }
.aai-chat-launcher svg { display: block; }
.aai-chat-launcher .aai-icon-close { display: none; }
.aai-chat-launcher[aria-expanded="true"] .aai-icon-open { display: none; }
.aai-chat-launcher[aria-expanded="true"] .aai-icon-close { display: block; }

/* A bare dot, carrying no text. --primary is a decorative fill only; the
   moment a digit sits on it the pair is 3.04:1 and fails AA. It is also an
   engagement nudge on a timer, not a real unread count — a "1" would claim a
   message nobody sent. */
.aai-chat-unread {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 12px;
    height: 12px;
    border-radius: 999px;
    background: var(--primary);
    border: 2px solid var(--bg-card);
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.aai-chat-unread.is-visible { opacity: 1; transform: scale(1); }

.aai-chat-panel {
    position: fixed;
    bottom: 100px;
    right: 28px;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(12px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}
.aai-chat-panel.is-open { opacity: 1; visibility: visible; transform: translateY(0); }

.aai-chat-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.aai-chat-avatar {
    width: 32px; height: 32px; border-radius: 999px; flex-shrink: 0;
    background: var(--primary-ink); color: var(--on-primary);
    display: flex; align-items: center; justify-content: center;
}
.aai-chat-title { font-weight: 600; font-size: 0.9rem; color: var(--text-strong); line-height: 1.2; }
.aai-chat-status { font-size: 0.75rem; color: var(--text-subtle); }
.aai-chat-min {
    margin-left: auto; background: none; border: none; cursor: pointer;
    color: var(--text-subtle); padding: 4px; border-radius: 6px; line-height: 0;
}
.aai-chat-min:hover { color: var(--text-strong); }

.aai-chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Radius stays inside the documented four-value scale: 8px controls,
   6px chips. The tail corner uses the chip value rather than inventing a
   fifth number. */
.aai-msg { max-width: 84%; padding: 9px 13px; font-size: 0.875rem; line-height: 1.55; word-break: break-word; }
.aai-msg-bot {
    align-self: flex-start;
    background: var(--bg-card-hover);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px 8px 8px 6px;
}
.aai-msg-user {
    align-self: flex-end;
    background: var(--primary-ink);
    color: var(--on-primary);
    border-radius: 8px 8px 6px 8px;
}
.aai-msg-error { align-self: flex-start; border-color: var(--primary); }
.aai-msg a { color: inherit; text-decoration: underline; }

.aai-typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px;
    background: var(--bg-card-hover); border: 1px solid var(--border); border-radius: 8px 8px 8px 6px; }
.aai-typing span { width: 7px; height: 7px; border-radius: 999px; background: var(--primary-ink);
    animation: aai-typing 1.2s infinite; }
.aai-typing span:nth-child(2) { animation-delay: 0.2s; }
.aai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aai-typing {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

.aai-chat-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); flex-shrink: 0; }
.aai-chat-input {
    flex: 1; min-width: 0; padding: 9px 12px; font: inherit; font-size: 0.875rem;
    color: var(--text-strong); background: var(--bg); border: 1px solid var(--border);
    border-radius: 8px; outline: none;
}
.aai-chat-input:focus { border-color: var(--primary-ink); }
.aai-chat-send {
    width: 38px; height: 38px; flex-shrink: 0; border: none; border-radius: 8px;
    background: var(--primary-ink); color: var(--on-primary); cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.aai-chat-send:disabled { opacity: 0.5; cursor: default; }

@media (max-width: 640px) {
    .aai-chat-panel { right: 12px; left: 12px; width: auto; bottom: 88px; max-height: calc(100vh - 120px); }
    .aai-chat-launcher { bottom: 20px; right: 20px; width: 54px; height: 54px; }
}

@media (prefers-reduced-motion: reduce) {
    .aai-chat-launcher, .aai-chat-panel { transition: none; }
    .aai-typing span { animation: none; }
}
