/* Spotitap chatbot widget — namespaced spcb- + a scoped reset so the host theme
   (Woostify / WooCommerce) cannot leak its input/button styles into the widget.
   Palette lives in CSS variables on .spcb-root — change those to re-theme. */

.spcb-root {
    --ink: #111827;            /* header + bubble (dark navy) */
    --ink-2: #1f2937;          /* gradient top / body text */
    --accent: #4f46e5;         /* indigo accent */
    --accent-strong: #4338ca;  /* hover / pressed */
    --accent-tint: #eef0fe;    /* icon squares, soft fills */
    --accent-tint-2: #e0e7ff;  /* hover tint */
    --accent-ink: #3730a3;     /* text on tint */
    --line: #eceef1;           /* hairline borders */
    --muted: #8a93a3;          /* secondary text */
    --field: #d8dce3;          /* input borders */
    position: fixed; bottom: 22px; right: 22px; z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px; line-height: 1.5; color: var(--ink-2);
    -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility;
}
.spcb-root *, .spcb-root *::before, .spcb-root *::after { box-sizing: border-box; }
.spcb-root button {
    font-family: inherit; cursor: pointer; padding: 0; margin: 0;
    line-height: 1.4; -webkit-appearance: none; appearance: none;
    text-transform: none; letter-spacing: normal; box-shadow: none;
}
.spcb-back, .spcb-close, .spcb-topic-row, .spcb-article-row, .spcb-footer button {
    background: transparent; border: none;
}
.spcb-root input, .spcb-root textarea { font-family: inherit; }
.spcb-panel input.spcb-field,
.spcb-panel textarea.spcb-field,
.spcb-panel .spcb-search input {
    font-size: 14px !important; line-height: 1.4 !important;
    min-height: 0 !important; height: auto !important;
    box-shadow: none !important; letter-spacing: normal !important;
}
/* The host theme decorates bare <input> with its own search-form chrome (border,
   fill, radius) which leaked a nested box into our search field. Force it flat. */
.spcb-panel .spcb-search input {
    border: none !important; background: transparent !important;
    border-radius: 0 !important; padding: 0 !important;
}

/* Move the theme's scroll-to-top button above our bubble so they don't overlap. */
#scroll-to-top { bottom: 94px !important; }

/* ── bubble (dark navy) ──────────────────────────────────────────────────── */
.spcb-bubble {
    width: 58px; height: 58px; border-radius: 50%; background: var(--ink); color: #fff;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 24px rgba(17,24,39,.34);
    transition: transform .15s ease, box-shadow .15s ease;
}
.spcb-bubble:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 30px rgba(17,24,39,.42); }
.spcb-bubble:active { transform: scale(.97); }

/* ── panel ───────────────────────────────────────────────────────────────── */
.spcb-panel {
    position: absolute; bottom: 74px; right: 0; width: 384px; max-width: calc(100vw - 32px);
    height: 604px; max-height: calc(100vh - 120px); background: #fff; border-radius: 18px;
    box-shadow: 0 20px 64px rgba(16,24,40,.24); display: none; flex-direction: column;
    overflow: hidden; opacity: 0; transform: translateY(8px);
    transition: opacity .18s ease, transform .18s ease;
}
.spcb-root.spcb-open .spcb-panel { display: flex; opacity: 1; transform: translateY(0); }

/* ── header ──────────────────────────────────────────────────────────────── */
.spcb-header {
    background: var(--ink); color: #fff;
    padding: 16px; display: flex; flex-direction: column; flex-shrink: 0;
}
.spcb-header-top { display: flex; align-items: center; gap: 13px; }
.spcb-header--home { padding-bottom: 18px; }
.spcb-hgreet { font-size: 15.5px; font-weight: 500; line-height: 1.4; margin-top: 12px; }
.spcb-avatar {
    width: 40px; height: 40px; border-radius: 12px; background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.spcb-htitle { font-weight: 500; font-size: 15px; letter-spacing: -.01em; }
.spcb-hsub { font-size: 12px; color: #b8c0cf; display: flex; align-items: center; gap: 6px; margin-top: 3px; }
.spcb-hsub::before {
    content: ""; width: 7px; height: 7px; border-radius: 50%; background: #34d399;
    box-shadow: 0 0 0 3px rgba(52,211,153,.22);
}
.spcb-back, .spcb-close {
    color: rgba(255,255,255,.85); background: rgba(255,255,255,.12);
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 9px; transition: background .12s, color .12s; flex-shrink: 0;
}
.spcb-back:hover, .spcb-close:hover { background: rgba(255,255,255,.22); color: #fff; }
/* Specificity must beat the `.spcb-root button { margin: 0 }` reset, otherwise
   the auto-margin is ignored and the close button never reaches the right edge. */
.spcb-header-top .spcb-close { margin-left: auto; }

/* ── body / scrollbar ────────────────────────────────────────────────────── */
.spcb-body { flex: 1; overflow-y: auto; padding: 20px 16px; }
.spcb-body::-webkit-scrollbar { width: 8px; }
.spcb-body::-webkit-scrollbar-thumb { background: #dbe1e3; border-radius: 4px; }
.spcb-body::-webkit-scrollbar-thumb:hover { background: #c6ced1; }
.spcb-greet { font-size: 15px; color: var(--ink-2); margin: 0 0 16px; line-height: 1.5; }

/* ── search ──────────────────────────────────────────────────────────────── */
.spcb-search {
    display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid #e8eaee;
    border-radius: 13px; padding: 0 14px; height: 48px; margin-bottom: 0;
    transition: border-color .12s, background .12s, box-shadow .12s;
}
.spcb-search:focus-within { background: #fff; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.spcb-search svg { color: var(--muted); flex-shrink: 0; }
.spcb-search input { border: none; outline: none; flex: 1; background: transparent; color: var(--ink-2); padding: 0; }
.spcb-search input::placeholder { color: var(--muted); }
/* Home search sits just below the header with a clean gap (no overlap), lifted
   slightly with a soft shadow so it reads as the primary action. */
.spcb-search--float {
    margin-top: -4px; background: #fff; border-color: #e8eaee;
    box-shadow: 0 6px 16px rgba(16,24,40,.08); position: relative; z-index: 1;
}

/* ── section labels ──────────────────────────────────────────────────────── */
.spcb-section-label {
    font-size: 11px; font-weight: 500; letter-spacing: .07em; text-transform: uppercase;
    color: var(--muted); margin: 18px 4px 8px;
}
.spcb-section-label.spcb-mt { margin-top: 22px; }

/* ── popular questions list ──────────────────────────────────────────────── */
.spcb-poplist { margin-bottom: 0; }

/* ── topic / article rows ────────────────────────────────────────────────── */
.spcb-topic-row, .spcb-article-row {
    display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
    padding: 11px 10px; border-radius: 11px; font-size: 13.5px; color: var(--ink-2); transition: background .12s;
}
.spcb-topic-row:hover, .spcb-article-row:hover { background: var(--accent-tint); }
/* Topic rows carry a 38px icon square, so give them extra vertical rhythm. */
.spcb-topic-row { padding-top: 13px; padding-bottom: 13px; }
.spcb-topic-row > span:not(.spcb-chevron), .spcb-article-row > span:not(.spcb-chevron) { flex: 1; }
/* Each suggestion is one uniform single-line row — long questions truncate with
   an ellipsis (min-width:0 lets the flex item shrink so the ellipsis triggers). */
.spcb-article-row > span:not(.spcb-chevron) {
    min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* Topic label cell: name on top, article count below. */
.spcb-topic-cell { display: flex; flex-direction: column; gap: 1px; }
.spcb-topic-name { font-size: 13.5px; color: var(--ink-2); }
.spcb-topic-count { font-size: 12px; color: var(--muted); }
/* Topic leading icon: tinted rounded square. */
.spcb-topic-row > svg {
    color: var(--accent); background: var(--accent-tint); border-radius: 10px; padding: 8px;
    width: 38px; height: 38px; flex-shrink: 0;
}
.spcb-topic-row:hover > svg { background: var(--accent-tint-2); }
.spcb-article-row > svg { color: var(--accent); flex-shrink: 0; }
.spcb-chevron { display: inline-flex; color: #c2cace; flex-shrink: 0; }
.spcb-search-results { margin-top: 4px; }

/* ── answer ──────────────────────────────────────────────────────────────── */
.spcb-answer { font-size: 14px; color: #374151; line-height: 1.65; }
.spcb-answer p { margin: 0 0 10px; }
.spcb-answer p:last-child { margin-bottom: 0; }
.spcb-answer h1, .spcb-answer h2, .spcb-answer h3 { font-size: 15px; font-weight: 600; margin: 14px 0 6px; color: var(--ink-2); }
.spcb-answer a { color: var(--accent); text-decoration: underline; }
.spcb-answer ul, .spcb-answer ol { margin: 0 0 10px; padding-left: 20px; }

/* ── feedback ────────────────────────────────────────────────────────────── */
.spcb-feedback { margin-top: 22px; background: var(--accent-tint); border: 1px solid var(--accent-tint-2); border-radius: 12px; padding: 14px; }
.spcb-feedback-q { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 0 0 11px; }
.spcb-feedback-actions { display: flex; gap: 8px; }
/* White pills so they stand out against the tinted feedback box (which is itself
   accent-tint — a tinted pill there would vanish). */
.spcb-fbtn {
    flex: 1; font-size: 13.5px; font-weight: 500; padding: 10px 0; border-radius: 10px;
    border: 1px solid var(--accent-tint-2); color: var(--accent-ink); background: #fff;
    transition: border-color .12s, color .12s;
}
.spcb-fbtn:hover { border-color: var(--accent); color: var(--accent); }
.spcb-feedback-thanks { font-size: 13px; font-weight: 500; color: var(--accent-ink); margin: 0; }

/* ── buttons ─────────────────────────────────────────────────────────────── */
.spcb-btn {
    font-size: 13.5px; font-weight: 500; padding: 11px 16px; border-radius: 11px;
    border: 1px solid var(--accent); color: var(--accent); background: #fff;
    display: inline-flex; align-items: center; justify-content: center; gap: 7px; transition: background .12s, border-color .12s;
}
.spcb-btn:hover { background: var(--accent-tint); }
.spcb-btn--primary { background: var(--accent); color: #fff; }
.spcb-btn--primary:hover { background: var(--accent-strong); }
.spcb-btn--block { display: flex; width: 100%; margin-bottom: 12px; }
.spcb-btn[disabled] { opacity: .6; cursor: default; }
.spcb-btn svg, .spcb-footer button svg { flex-shrink: 0; }

/* ── footer ──────────────────────────────────────────────────────────────── */
.spcb-footer { border-top: 1px solid var(--line); padding: 10px 14px; flex-shrink: 0; background: #fff; }
.spcb-footer button {
    background: var(--accent-tint); color: var(--accent-ink); font-weight: 500; font-size: 13.5px;
    width: 100%; height: 46px; border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    transition: background .12s;
}
.spcb-footer button:hover { background: var(--accent-tint-2); }

/* ── empty state (prod-safe: KB returned nothing) ────────────────────────── */
.spcb-empty { text-align: center; padding: 26px 16px 10px; }
.spcb-empty svg { color: var(--accent); background: var(--accent-tint); border-radius: 14px; padding: 11px; width: 48px; height: 48px; }
.spcb-empty p { font-size: 13.5px; color: var(--muted); line-height: 1.5; margin: 14px auto 0; max-width: 240px; }

/* ── escalation fields ───────────────────────────────────────────────────── */
.spcb-field {
    width: 100%; margin-bottom: 11px; padding: 11px 13px; border: 1px solid var(--field); border-radius: 11px;
    color: var(--ink-2); background: #fff; outline: none; transition: border-color .12s, box-shadow .12s;
}
.spcb-field::placeholder { color: var(--muted); }
.spcb-field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
textarea.spcb-field { resize: vertical; min-height: 92px; }

/* ── note + "ou" divider ─────────────────────────────────────────────────── */
.spcb-note { font-size: 12px; color: var(--muted); margin: 8px 0; text-align: center; }
.spcb-or { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: var(--muted); font-size: 12px; }
.spcb-or::before, .spcb-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ── two-way chat thread ─────────────────────────────────────────────────── */
.spcb-thread { display: flex; flex-direction: column; gap: 10px; }
.spcb-msg { display: flex; max-width: 100%; }
.spcb-msg--visitor { justify-content: flex-end; }
.spcb-msg--agent { justify-content: flex-start; }
.spcb-bubble-msg {
    max-width: 78%; padding: 9px 13px; border-radius: 16px; font-size: 13.5px; line-height: 1.45;
    white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
}
.spcb-msg--visitor .spcb-bubble-msg { background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.spcb-msg--agent .spcb-bubble-msg { background: #f1f3f5; color: var(--ink-2); border-bottom-left-radius: 5px; }

.spcb-composer { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: #fff; flex-shrink: 0; }
.spcb-composer-input {
    flex: 1; resize: none; min-height: 42px; max-height: 110px; overflow-y: auto;
    padding: 11px 13px; border: 1px solid var(--field); border-radius: 12px; outline: none;
    font-size: 14px; line-height: 1.4; color: var(--ink-2); background: #fff;
    transition: border-color .12s, box-shadow .12s;
}
.spcb-composer-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.spcb-composer-send {
    width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background .12s;
}
.spcb-composer-send:hover { background: var(--accent-strong); }
.spcb-composer-send[disabled] { opacity: .6; cursor: default; }

/* ── responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 430px) {
    .spcb-root { bottom: 16px; right: 16px; }
    .spcb-panel { width: calc(100vw - 24px); height: calc(100vh - 92px); }
    #scroll-to-top { bottom: 86px !important; }
}
