/* AI Assistant Styles
 *
 * Every rule below is scoped to #aia-chat-fab, the single wrapper that
 * contains the whole widget. That is not cosmetic: an ID gives each rule a
 * specificity of (1,1,0), which outranks the button and input rules a page
 * builder's global kit emits at (0,2,0) - e.g. Elementor's
 * `.elementor-kit-8 button`. Without it a host theme restyles the chips,
 * send button and close button, and the widget arrives looking nothing
 * like this file. Do not un-scope a rule to simplify it, and do not reach
 * for !important instead; the ID is what makes !important unnecessary.
 */

/* Brand palette. The plugin re-emits this whole block on :root from the
   colour settings (see palette_css() in ai-assistant.php), so these values
   are only the fallback for a stylesheet loaded on its own. */
:root {
    --aia-chat-primary:  #2F5FD0;
    --aia-chat-primary-dk: #1A3472;
    --aia-chat-accent:   #5B8AF5;
    --aia-chat-accent-lt:#C7D8FC;
    /* rgb triples so the shadows and hairlines below can follow the brand
       colours at their own alphas instead of hardcoding them */
    --aia-chat-primary-rgb: 47,95,208;
    --aia-chat-accent-rgb:  91,138,245;
    --aia-chat-bg:       #F4F5F8;
    --aia-chat-white:    #ffffff;
    --aia-chat-border:   rgba(91,138,245,0.28);
    /* Body-text tones: neutral on purpose, not tinted toward the brand
       colour, so they keep their contrast whatever primary is set to. */
    --aia-chat-ink:      #0A1E44;
    --aia-chat-muted:    #5C6679;

    /* Corner radii. Every rounded corner in this file goes through one of
       these, so a host site can restyle the widget's shape from a single
       :root block of its own instead of fighting the ID-scoped rules below
       with !important. A later :root wins on source order alone. */
    --aia-chat-radius-panel:    22px;  /* chat window                    */
    --aia-chat-radius-card:     12px;  /* hint bubble                    */
    --aia-chat-radius-bubble:   16px;  /* messages and typing indicator  */
    --aia-chat-radius-launcher: 50%;   /* toggle and WhatsApp button     */
    --aia-chat-radius-pill:     999px; /* toggle once it carries a label */
    --aia-chat-radius-control:  50%;   /* send button                    */
    --aia-chat-radius-field:    100px; /* text input                     */
    --aia-chat-radius-chip:     100px; /* quick-reply chips              */
    --aia-chat-radius-close:    8px;   /* close button                   */
}

/* Reset
   Themes and page builders style bare `button`, `input` and `a` globally:
   padding, uppercase, letter-spacing, borrowed brand colours, square
   corners. Those declarations land on this widget's controls too. This block
   returns them to a known state before the widget's own rules run. It sits at
   (1,0,1); every rule after it is at (1,1,0) or higher, so source order never
   matters - the widget's own values always win.
   Deliberately not reset: `outline`, so keyboard focus stays visible. */
#aia-chat-fab,
#aia-chat-fab *,
#aia-chat-fab *::before,
#aia-chat-fab *::after {
    box-sizing: border-box;
}
#aia-chat-fab button,
#aia-chat-fab input,
#aia-chat-fab a {
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: none;
    box-shadow: none;
    color: inherit;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 100%;
    font-weight: 400;
    font-style: normal;
    line-height: normal;
    letter-spacing: normal;
    word-spacing: normal;
    text-transform: none;
    text-decoration: none;
    text-shadow: none;
    text-align: inherit;
    min-width: 0;
    min-height: 0;
    max-width: none;
    width: auto;
    height: auto;
    transition: none;
    transform: none;
    -webkit-appearance: none;
    appearance: none;
}
#aia-chat-fab button { cursor: pointer; }
#aia-chat-fab svg { max-width: none; vertical-align: middle; }
/* Themes also style bare `p`, `li` and headings — a body line-height of 2 or a
   24px paragraph margin turns a chat bubble into a wall. Inheriting instead
   lets the bubble's own typography reach the text the model returns. */
#aia-chat-fab p,
#aia-chat-fab h4,
#aia-chat-fab ul,
#aia-chat-fab li {
    margin: 0;
    padding: 0;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    letter-spacing: inherit;
    text-transform: none;
}

/* FAB Container */
#aia-chat-fab {
    position: fixed;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    bottom: 28px;
    right: 28px;
    /* Set on the wrapper as well as on the individual elements so nothing
       inside the widget silently inherits a display face, uppercasing or
       tracking from the host theme's body rules. */
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    text-transform: none;
    letter-spacing: normal;
}
#aia-chat-fab.position-left { right: auto; left: 28px; align-items: flex-start; }

/* Hint bubble */
#aia-chat-fab .aia-chat-hint {
    background: var(--aia-chat-white);
    border: 1.5px solid var(--aia-chat-primary);
    border-radius: var(--aia-chat-radius-card);
    padding: 10px 16px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--aia-chat-ink);
    white-space: nowrap;
    box-shadow: 0 8px 28px rgba(var(--aia-chat-primary-rgb),0.2);
    animation: aiaBubbleIn 0.5s ease 2s both;
    position: relative;
    font-family: system-ui, sans-serif;
}
#aia-chat-fab .aia-chat-hint::after {
    content: '';
    position: absolute;
    bottom: -7px;
    right: 18px;
    width: 12px; height: 12px;
    background: var(--aia-chat-white);
    border-right: 1.5px solid var(--aia-chat-primary);
    border-bottom: 1.5px solid var(--aia-chat-primary);
    transform: rotate(45deg);
}
@keyframes aiaBubbleIn {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* FAB Toggle Button.
   Default is a 52px circle. When a launcher label is configured the button
   becomes a pill carrying a spark dot and that label; it collapses back to a
   circle while the panel is open. */
#aia-chat-fab .aia-chat-toggle {
    width: 52px; height: 52px;
    border-radius: var(--aia-chat-radius-launcher);
    background: linear-gradient(135deg, var(--aia-chat-primary-dk), var(--aia-chat-primary));
    border: none;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 1.6rem;
    box-shadow: 0 6px 24px rgba(var(--aia-chat-primary-rgb),0.45),
                0 0 0 3px rgba(var(--aia-chat-accent-rgb),0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}
#aia-chat-fab .aia-chat-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 32px rgba(var(--aia-chat-primary-rgb),0.55),
                0 0 0 4px rgba(var(--aia-chat-accent-rgb),0.45);
}
#aia-chat-fab .aia-chat-badge {
    position: absolute;
    top: -3px; right: -3px;
    width: 18px; height: 18px;
    border-radius: 50%;
    background: var(--aia-chat-accent);
    border: 2px solid var(--aia-chat-bg);
    animation: aiaPulse 2s infinite;
}
@keyframes aiaPulse {
    0%,100% { transform: scale(1); opacity: 1; }
    50%      { transform: scale(0.65); opacity: 0.7; }
}

/* Pill variant */
#aia-chat-fab .aia-chat-toggle.has-label { width: auto; padding: 0 22px; gap: 10px; border-radius: var(--aia-chat-radius-pill); }
#aia-chat-fab .aia-chat-toggle.has-label .aia-chat-toggle-glyph { display: none; }
#aia-chat-fab .aia-chat-spark {
    flex: 0 0 auto;
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--aia-chat-accent);
    box-shadow: 0 0 0 4px rgba(var(--aia-chat-accent-rgb), 0.25);
}
#aia-chat-fab .aia-chat-label {
    color: #fff; font-size: 0.95rem; font-weight: 600;
    letter-spacing: -0.01em; white-space: nowrap; line-height: 1;
    font-family: system-ui, sans-serif;
}
#aia-chat-fab .aia-chat-toggle.has-label.is-open { width: 52px; padding: 0; gap: 0; }
#aia-chat-fab .aia-chat-toggle.is-open .aia-chat-spark,
#aia-chat-fab .aia-chat-toggle.is-open .aia-chat-label { display: none; }

/* Launcher row: WhatsApp (optional) sits beside the toggle, centres aligned,
   so the site does not have to guess the pill's width to position it. */
#aia-chat-fab .aia-chat-launchers { display: flex; align-items: center; gap: 12px; }
#aia-chat-fab.position-left .aia-chat-launchers { flex-direction: row-reverse; }
#aia-chat-fab .aia-chat-wa {
    flex: 0 0 auto;
    width: 52px; height: 52px; border-radius: var(--aia-chat-radius-launcher);
    background: #1EBE5D;
    display: flex; align-items: center; justify-content: center;
    text-decoration: none;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 6px 20px rgba(30,190,93,0.35);
}
#aia-chat-fab .aia-chat-wa:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(30,190,93,0.45); }
#aia-chat-fab .aia-chat-wa svg { width: 27px; height: 27px; fill: #fff; }

/* Chat Window */
#aia-chat-fab .aia-chat-window {
    position: fixed;
    bottom: 104px;
    right: 28px;
    width: 380px;
    height: 560px;
    background: var(--aia-chat-white);
    border: 1.5px solid rgba(var(--aia-chat-primary-rgb),0.2);
    border-radius: var(--aia-chat-radius-panel);
    box-shadow: 0 32px 80px rgba(var(--aia-chat-primary-rgb),0.22),
                0 0 0 1px rgba(var(--aia-chat-accent-rgb),0.15);
    z-index: 99998;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.85) translateY(24px);
    opacity: 0;
    pointer-events: none;
    transform-origin: bottom right;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#aia-chat-fab .aia-chat-window.is-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}
#aia-chat-fab.position-left .aia-chat-window {
    right: auto;
    left: 28px;
    transform-origin: bottom left;
}

/* Header */
#aia-chat-fab .aia-chat-header {
    background: linear-gradient(135deg, var(--aia-chat-primary-dk), var(--aia-chat-primary));
    padding: 18px 20px;
    display: flex; align-items: center; gap: 12px;
    flex-shrink: 0;
    border-bottom: 2px solid rgba(var(--aia-chat-accent-rgb),0.3);
}
#aia-chat-fab .aia-chat-avatar {
    width: 42px; height: 42px; border-radius: 50%;
    background: rgba(var(--aia-chat-accent-rgb),0.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.15rem; flex-shrink: 0; position: relative;
}
#aia-chat-fab .aia-chat-avatar-ring {
    position: absolute; bottom: 1px; right: 1px;
    width: 11px; height: 11px; border-radius: 50%;
    background: var(--aia-chat-accent);
    border: 2px solid var(--aia-chat-primary-dk);
}
#aia-chat-fab .aia-chat-name { font-weight: 700; font-size: 0.92rem; color: #fff; font-family: system-ui, sans-serif; }
#aia-chat-fab .aia-chat-status { font-size: 0.7rem; color: var(--aia-chat-accent-lt); font-family: system-ui, sans-serif; }
#aia-chat-fab .aia-chat-close {
    margin-left: auto;
    background: rgba(255,255,255,0.1);
    border: none; color: rgba(255,255,255,0.8);
    cursor: pointer; font-size: 1rem;
    width: 30px; height: 30px; border-radius: var(--aia-chat-radius-close);
    display: flex; align-items: center; justify-content: center;
    transition: background 0.2s;
}
#aia-chat-fab .aia-chat-close:hover { background: rgba(255,255,255,0.22); }

/* Messages */
#aia-chat-fab .aia-chat-messages {
    flex: 1; overflow-y: auto; padding: 20px;
    display: flex; flex-direction: column; gap: 14px;
    background: var(--aia-chat-bg);
    scrollbar-width: thin;
    scrollbar-color: var(--aia-chat-border) transparent;
}
#aia-chat-fab .aia-chat-msg {
    max-width: 86%;
    animation: aiaMsgIn 0.28s ease;
    font-family: system-ui, sans-serif;
}
@keyframes aiaMsgIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}
#aia-chat-fab .aia-chat-msg.bot { align-self: flex-start; }
#aia-chat-fab .aia-chat-msg.user { align-self: flex-end; }

#aia-chat-fab .aia-chat-msg-label {
    font-size: 0.67rem; font-weight: 600;
    color: var(--aia-chat-muted); margin-bottom: 5px;
    display: flex; align-items: center; gap: 6px;
}
#aia-chat-fab .aia-chat-ai-pill {
    background: rgba(var(--aia-chat-primary-rgb),0.1);
    color: var(--aia-chat-primary);
    padding: 1px 7px; border-radius: 4px;
    font-size: 0.6rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.06em;
}
#aia-chat-fab .aia-chat-bubble {
    padding: 12px 16px;
    border-radius: var(--aia-chat-radius-bubble);
    font-size: 0.84rem;
    line-height: 1.65;
}
#aia-chat-fab .aia-chat-msg.bot  .aia-chat-bubble {
    background: var(--aia-chat-white);
    border: 1.5px solid var(--aia-chat-border);
    border-bottom-left-radius: 4px;
    color: var(--aia-chat-ink);
}
#aia-chat-fab .aia-chat-msg.user .aia-chat-bubble {
    background: linear-gradient(135deg, var(--aia-chat-primary-dk), var(--aia-chat-primary));
    color: #fff;
    border-bottom-right-radius: 4px;
    font-weight: 500;
}

/* Quick chips */
#aia-chat-fab .aia-chat-chips {
    display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px;
}
#aia-chat-fab .aia-chat-chip {
    padding: 5px 13px; border-radius: var(--aia-chat-radius-chip);
    border: 1.5px solid rgba(var(--aia-chat-primary-rgb),0.22);
    font-size: 0.72rem; color: var(--aia-chat-primary);
    cursor: pointer; font-weight: 600;
    background: var(--aia-chat-white);
    transition: background 0.2s, color 0.2s;
    font-family: system-ui, sans-serif;
}
#aia-chat-fab .aia-chat-chip:hover {
    background: var(--aia-chat-primary);
    color: #fff;
    border-color: var(--aia-chat-primary);
}

/* Typing indicator */
#aia-chat-fab .aia-chat-typing {
    background: var(--aia-chat-white);
    border: 1.5px solid var(--aia-chat-border);
    border-radius: var(--aia-chat-radius-bubble); border-bottom-left-radius: 4px;
    padding: 12px 18px;
    display: flex; align-items: center; gap: 5px;
}
#aia-chat-fab .aia-chat-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--aia-chat-primary);
    animation: aiaBounce 1.3s infinite ease-in-out;
}
#aia-chat-fab .aia-chat-dot:nth-child(2) { animation-delay: 0.2s; }
#aia-chat-fab .aia-chat-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes aiaBounce {
    0%,60%,100% { transform: translateY(0); opacity: 0.4; }
    30%          { transform: translateY(-7px); opacity: 1; }
}

/* Input row */
#aia-chat-fab .aia-chat-input-row {
    padding: 14px 16px;
    background: var(--aia-chat-white);
    border-top: 1.5px solid var(--aia-chat-border);
    display: flex; gap: 10px; align-items: center;
    flex-shrink: 0;
}
#aia-chat-fab .aia-chat-input {
    flex: 1;
    background: var(--aia-chat-bg);
    border: 1.5px solid var(--aia-chat-border);
    border-radius: var(--aia-chat-radius-field);
    padding: 11px 18px;
    color: var(--aia-chat-ink);
    font-family: system-ui, sans-serif;
    font-size: 0.83rem;
    outline: none;
    transition: border-color 0.2s;
}
#aia-chat-fab .aia-chat-input::placeholder { color: var(--aia-chat-muted); }
#aia-chat-fab .aia-chat-input:focus { border-color: var(--aia-chat-primary); }
#aia-chat-fab .aia-chat-send {
    width: 42px; height: 42px; border-radius: var(--aia-chat-radius-control);
    background: linear-gradient(135deg, var(--aia-chat-primary-dk), var(--aia-chat-primary));
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    color: #fff; flex-shrink: 0; font-size: 1rem;
    box-shadow: 0 4px 14px rgba(var(--aia-chat-primary-rgb),0.35);
    transition: transform 0.15s, box-shadow 0.15s;
}
#aia-chat-fab .aia-chat-send:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(var(--aia-chat-primary-rgb),0.45); }
#aia-chat-fab .aia-chat-send:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

/* Screen reader only */
#aia-chat-fab .sr-only {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Mobile */
@media (max-width: 480px) {
    #aia-chat-fab .aia-chat-window {
        width: calc(100vw - 24px);
        height: 70vh;
        right: 12px; bottom: 90px;
    }
}
