/* ==========================================================================
   ELIXIR Bio-Intelligence — floating chat widget (WordPress embed)
   Self-contained, namespaced (.elx-*), no external dependencies.
   ========================================================================== */

#elx-chat-root {
    /* Brand colour is overridden from window.ElixirChatConfig.colors.primary */
    --elx-primary: #16a34a;
    --elx-primary-dark: #15803d;
    --elx-ink: #0f172a;
    --elx-muted: #64748b;
    --elx-line: #e2e8f0;
    --elx-bg: #f6faf7;

    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 999999;
    font-family: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--elx-ink);
    -webkit-font-smoothing: antialiased;
    box-sizing: border-box;
}
#elx-chat-root *,
#elx-chat-root *::before,
#elx-chat-root *::after { box-sizing: border-box; }

/* ---------- Floating bubble ---------- */
.elx-bubble {
    width: 60px;
    height: 60px;
    border: none;
    border-radius: 9999px;
    background: linear-gradient(135deg, var(--elx-primary), var(--elx-primary-dark));
    color: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
    margin-left: auto;
    box-shadow: 0 14px 34px -10px rgba(22, 163, 74, 0.6);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.elx-bubble:hover { transform: translateY(-2px) scale(1.05); }
.elx-bubble:active { transform: scale(0.96); }
.elx-bubble svg { width: 26px; height: 26px; }
.elx-bubble .elx-icon-close { display: none; }
#elx-chat-root.elx-open .elx-bubble .elx-icon-open { display: none; }
#elx-chat-root.elx-open .elx-bubble .elx-icon-close { display: block; }

/* ---------- Chat window ---------- */
.elx-window {
    position: absolute;
    right: 0;
    bottom: 74px;
    width: 370px;
    max-width: calc(100vw - 40px);
    height: 540px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 22px;
    box-shadow: 0 24px 70px -20px rgba(16, 24, 40, 0.35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(14px) scale(0.96);
    transform-origin: bottom right;
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
}
#elx-chat-root.elx-open .elx-window {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* ---------- Header ---------- */
.elx-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: linear-gradient(135deg, var(--elx-primary), var(--elx-primary-dark));
    color: #fff;
}
.elx-avatar {
    width: 36px; height: 36px;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.2);
    display: grid; place-items: center;
    flex-shrink: 0;
}
.elx-avatar svg { width: 20px; height: 20px; }
.elx-htext { min-width: 0; flex: 1; }
.elx-htitle { font-weight: 600; font-size: 14px; line-height: 1.2; }
.elx-hstatus { font-size: 11px; opacity: 0.85; display: flex; align-items: center; gap: 5px; }
.elx-dot { width: 6px; height: 6px; border-radius: 9999px; background: #fff; }
.elx-close {
    background: transparent; border: none; color: rgba(255, 255, 255, 0.85);
    cursor: pointer; width: 30px; height: 30px; border-radius: 8px;
    display: grid; place-items: center;
}
.elx-close:hover { background: rgba(255, 255, 255, 0.15); }
.elx-close svg { width: 18px; height: 18px; }

/* ---------- Body / messages ---------- */
.elx-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--elx-bg);
    scroll-behavior: smooth;
}
.elx-empty { text-align: center; padding: 24px 8px; }
.elx-empty-icon {
    width: 56px; height: 56px; margin: 0 auto 12px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--elx-primary), var(--elx-primary-dark));
    color: #fff; display: grid; place-items: center;
}
.elx-empty-icon svg { width: 28px; height: 28px; }
.elx-empty h4 { margin: 0 0 4px; font-size: 16px; color: var(--elx-ink); }
.elx-empty p { margin: 0; font-size: 13px; color: var(--elx-muted); }

.elx-msg { display: flex; margin-bottom: 12px; }
.elx-msg-user { justify-content: flex-end; }
.elx-bubble-msg {
    max-width: 80%;
    padding: 9px 13px;
    border-radius: 16px;
    font-size: 13.5px;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.elx-msg-user .elx-bubble-msg {
    background: var(--elx-primary);
    color: #fff;
    border-bottom-right-radius: 5px;
}
.elx-msg-bot .elx-bubble-msg {
    background: #fff;
    color: #334155;
    border: 1px solid var(--elx-line);
    border-bottom-left-radius: 5px;
}

/* ---------- Typing indicator ---------- */
.elx-typing { display: flex; gap: 4px; padding: 12px 14px; background: #fff; border: 1px solid var(--elx-line); border-radius: 16px; border-bottom-left-radius: 5px; width: fit-content; }
.elx-typing span {
    width: 6px; height: 6px; border-radius: 9999px; background: var(--elx-primary);
    opacity: 0.6; animation: elx-bounce 1.2s infinite ease-in-out;
}
.elx-typing span:nth-child(2) { animation-delay: 0.15s; }
.elx-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes elx-bounce { 0%, 60%, 100% { transform: translateY(0); } 30% { transform: translateY(-5px); } }

/* ---------- Product cards (matched via ProductCatalog::search()) ---------- */
.elx-products { display: flex; flex-direction: column; gap: 6px; margin: 4px 0 12px; }
.elx-product {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    text-decoration: none;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid var(--elx-line);
    background: #fff;
    transition: border-color 0.15s, transform 0.15s;
}
.elx-product:hover { border-color: var(--elx-primary); transform: translateY(-1px); }
.elx-product-name { font-size: 13px; font-weight: 600; color: var(--elx-ink); }
.elx-product-price { font-size: 12px; font-weight: 600; color: var(--elx-primary); white-space: nowrap; }

/* ---------- Action buttons ---------- */
.elx-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.elx-action {
    text-decoration: none;
    font-size: 12px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 9999px;
    cursor: pointer;
    border: 1px solid var(--elx-line);
    background: #fff;
    color: #475569;
    transition: border-color 0.15s, color 0.15s;
}
.elx-action:hover { border-color: var(--elx-primary); color: var(--elx-primary); }
.elx-action-primary {
    background: var(--elx-primary);
    border-color: var(--elx-primary);
    color: #fff;
}
.elx-action-primary:hover { background: var(--elx-primary-dark); border-color: var(--elx-primary-dark); color: #fff; }

/* ---------- Footer / input ---------- */
.elx-footer {
    border-top: 1px solid var(--elx-line);
    background: #fff;
    padding: 10px 12px;
}
.elx-inputwrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: #f1f5f9;
    border: 1px solid transparent;
    border-radius: 16px;
    padding: 6px 6px 6px 12px;
    transition: border-color 0.15s, background 0.15s;
}
.elx-inputwrap:focus-within { background: #fff; border-color: var(--elx-primary); }
.elx-input {
    flex: 1;
    border: none;
    outline: none;
    resize: none;
    background: transparent;
    font-family: inherit;
    font-size: 13.5px;
    color: var(--elx-ink);
    max-height: 96px;
    padding: 5px 0;
    line-height: 1.4;
}
.elx-send {
    width: 34px; height: 34px;
    border: none; border-radius: 9999px;
    background: var(--elx-primary);
    color: #fff; cursor: pointer;
    display: grid; place-items: center;
    flex-shrink: 0;
    transition: background 0.15s, opacity 0.15s;
}
.elx-send:hover { background: var(--elx-primary-dark); }
.elx-send:disabled { opacity: 0.4; cursor: default; }
.elx-send svg { width: 16px; height: 16px; }
.elx-legal { margin: 6px 2px 0; font-size: 10px; text-align: center; color: #94a3b8; }
