/* ChatBot frontend widget - floating bubble + chat panel.
 *
 * Rewritten 2026-11-04 to actually match the approved Desktop/Mobile
 * Widget boards on the "zilleali.com UI/UX Redesign" Claude Artifact
 * canvas (Artboard-5kxv.dc.html / ChatBotMobile.dc.html), after an
 * owner screenshot showed the live widget was a generic light theme
 * that never matched the approved dark design at all - this file's
 * first version was built without re-reading those boards closely
 * enough. Colors/fonts below are copied directly from that design:
 * dark panel #161616, thread background #0f0f0f, assistant bubbles
 * #1f1f1f, Syne for headings, DM Sans for body text, JetBrains Mono
 * for the source citation - all three fonts are already loaded
 * sitewide (see the main site CLAUDE.md's "Heading Font / Body Font /
 * Mono Font" table), so no separate @font-face/Google Fonts link is
 * needed here.
 *
 * Every selector is scoped under the #chatbot-root ID rather than bare
 * classes like .cbw-btn-primary - found 2026-11-04 via live browser
 * testing that this site's own combined stylesheets were overriding
 * bare-class widget rules at equal specificity. An ID selector reliably
 * wins over that regardless of load order.
 */

#chatbot-root {
    --cb-accent: #a502a8;
    position: fixed;
    z-index: 99998;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}
/* The site's own floating contact buttons (footer.php's
 * .hec-float-buttons - WhatsApp always visible, bottom:1.25em/right:1.25em,
 * collapsed stack height toggle(44px)+gap(12px)+WhatsApp(56px)=112px above
 * that) live in the same bottom-right corner. "right" position sits above
 * that stack instead of on top of it so the two never overlap. "left"
 * position has nothing to clear, so it keeps the normal 20px inset. */
#chatbot-root[data-position="right"] { right: 20px; bottom: 150px; }
#chatbot-root[data-position="left"] { left: 20px; bottom: 20px; }

#chatbot-root .cbw-bubble {
    position: relative;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--cb-accent);
    background: linear-gradient(135deg, var(--cb-accent), color-mix(in srgb, var(--cb-accent) 60%, black));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 6px 20px color-mix(in srgb, var(--cb-accent) 50%, transparent);
    color: #fff;
    transition: transform 0.15s ease;
}
#chatbot-root .cbw-bubble:hover { transform: scale(1.06); }
#chatbot-root .cbw-bubble svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; }
/* The design treats the round launcher and the open panel as mutually
 * exclusive (bubbleVisible = !open in Artboard-5kxv.dc.html) - the
 * launcher disappears entirely while the panel is open, relying on the
 * panel's own header close (X) button instead. Found 2026-11-04: an
 * earlier version kept the launcher visible (as a redundant close-X)
 * at its own elevated bottom:150px position while the panel sat at
 * its own independent bottom:24px (see below) - different positions
 * for each meant the still-visible launcher visually overlapped the
 * panel's own edge instead of the two ever lining up. Hiding it
 * outright while open is what the design actually specifies, and it
 * sidesteps that overlap by construction rather than by tuning more
 * coordinates to match. */
#chatbot-root.is-open .cbw-bubble { display: none; }
/* Small "online" notification dot on the closed bubble, matching the
 * design - its border is white rather than the design mockup's fixed
 * #0a0a0a (that color was specific to the mockup's own dark preview
 * background, not a real requirement; white reads correctly against
 * any real page background this widget can appear on). */
#chatbot-root .cbw-bubble-dot { position: absolute; top: -2px; right: -2px; width: 12px; height: 12px; border-radius: 50%; background: #22c55e; border: 2px solid #fff; }

/* The open panel is its OWN independent fixed-position box, not
 * stacked above the launcher bubble - matches the design exactly
 * (Artboard-5kxv.dc.html: "position:fixed; right:24px; bottom:24px").
 * Found 2026-11-04 via a location mismatch report: an earlier version
 * positioned this panel relative to #chatbot-root's own box (which
 * sits at the launcher's elevated bottom:150px, to clear the site's
 * WhatsApp button when CLOSED) - so the panel opened ~130px higher up
 * the screen than the approved design shows. Since the launcher is
 * hidden entirely while the panel is open (see .cbw-bubble rule
 * above), there's no WhatsApp-overlap concern for the panel itself to
 * account for - a plain 24px inset, independent of the launcher's own
 * position, is both what the design specifies and the simpler choice. */
#chatbot-root .cbw-panel {
    position: fixed;
    bottom: 24px;
    width: 384px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 48px);
    background: #161616;
    border: 1px solid #2a2a2a;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
#chatbot-root[data-position="right"] .cbw-panel { right: 24px; }
#chatbot-root[data-position="left"] .cbw-panel { left: 24px; }
#chatbot-root:not(.is-open) .cbw-panel { display: none; }

/* #cbw-content (widget.js's wrapper div around the body/quick-replies/
 * footer for whichever phase is active) needs flex:1 + min-height:0 to
 * be properly constrained to the panel's remaining height - without
 * min-height:0 a flex item's default min-height is auto (its content
 * size), so it never shrinks below its content and .cbw-panel's
 * overflow:hidden silently clips anything past that instead of
 * scrolling (the single most common flexbox-scrolling gotcha). */
#chatbot-root #cbw-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

#chatbot-root .cbw-head {
    background: var(--cb-accent);
    background: linear-gradient(135deg, var(--cb-accent), color-mix(in srgb, var(--cb-accent) 60%, black));
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
#chatbot-root .cbw-head__icon { width: 36px; height: 36px; border-radius: 50%; background: rgba(255,255,255,0.15); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
#chatbot-root .cbw-head__icon svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2; }
#chatbot-root .cbw-head__text { flex: 1; min-width: 0; }
#chatbot-root .cbw-head__title { font-family: 'Syne', 'DM Sans', sans-serif; font-weight: 700; font-size: 14px; line-height: 1.3; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chatbot-root .cbw-head__sub { font-size: 11px; color: rgba(255,255,255,0.8); display: flex; align-items: center; gap: 5px; margin-top: 2px; }
#chatbot-root .cbw-head__dot { width: 6px; height: 6px; border-radius: 50%; background: #4ade80; display: inline-block; flex-shrink: 0; }
/* Header close (X) - hides the panel without clearing the
 * conversation, a second way to close alongside clicking the bubble
 * itself. "End Chat" (clears the conversation, with a confirmation) is
 * a separate action, now a text link in the footer - see .cbw-end-link
 * below. Previously these two were conflated into one header button
 * that actually did the "end chat" behavior; the design keeps them
 * distinct. */
#chatbot-root .cbw-head__close { width: 28px; height: 28px; border-radius: 50%; border: none; background: rgba(255,255,255,0.12); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; }
#chatbot-root .cbw-head__close:hover { background: rgba(255,255,255,0.22); }
#chatbot-root .cbw-head__close svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 2.5; }

#chatbot-root .cbw-body { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; background: #0f0f0f; }

#chatbot-root .cbw-msg { display: flex; gap: 8px; max-width: 92%; }
#chatbot-root .cbw-msg--user { justify-content: flex-end; max-width: 85%; margin-left: auto; }
#chatbot-root .cbw-msg--assistant { justify-content: flex-start; }
#chatbot-root .cbw-msg-avatar { width: 26px; height: 26px; border-radius: 50%; background: var(--cb-accent); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-family: 'Syne', sans-serif; font-weight: 700; font-size: 11px; color: #fff; }
#chatbot-root .cbw-bubble-text { max-width: 100%; font-size: 13.5px; line-height: 1.5; padding: 12px 14px; border-radius: 14px; white-space: pre-wrap; }
#chatbot-root .cbw-msg--user .cbw-bubble-text { background: var(--cb-accent); color: #fff; border-radius: 14px 4px 14px 14px; }
#chatbot-root .cbw-msg--assistant .cbw-bubble-text { background: #1f1f1f; color: #FAFAFA; border: 1px solid #2a2a2a; border-radius: 4px 14px 14px 14px; }
#chatbot-root .cbw-source { display: inline-block; margin-top: 6px; margin-left: 2px; font-size: 11px; font-family: 'JetBrains Mono', monospace; color: #D34DD6; text-decoration: none; }
#chatbot-root .cbw-source:hover { color: #E8521A; }

#chatbot-root .cbw-typing { display: flex; gap: 4px; padding: 12px 14px; background: #1f1f1f; border: 1px solid #2a2a2a; border-radius: 4px 14px 14px 14px; width: fit-content; }
#chatbot-root .cbw-typing span { width: 6px; height: 6px; border-radius: 50%; background: #6b6b6b; animation: cbw-bounce 1.2s infinite ease-in-out; }
#chatbot-root .cbw-typing span:nth-child(2) { animation-delay: 0.15s; }
#chatbot-root .cbw-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes cbw-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

#chatbot-root .cbw-quick-replies { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 14px; flex-shrink: 0; }
#chatbot-root .cbw-quick-reply { font-family: 'DM Sans', sans-serif; font-size: 12px; font-weight: 600; color: #D34DD6; background: #1a1a1a; border: 1px solid #333; border-radius: 20px; padding: 7px 13px; cursor: pointer; transition: all 0.15s ease; }
#chatbot-root .cbw-quick-reply:hover { background: #262626; border-color: var(--cb-accent); }

#chatbot-root .cbw-footer { flex-shrink: 0; padding: 12px 14px; border-top: 1px solid #2a2a2a; background: #161616; }
#chatbot-root .cbw-footer-row { display: flex; align-items: center; gap: 8px; background: #0f0f0f; border: 1px solid #2a2a2a; border-radius: 24px; padding: 6px 6px 6px 16px; }
#chatbot-root .cbw-input { flex: 1; min-width: 0; background: none; border: none; outline: none; font-family: 'DM Sans', sans-serif; font-size: 13.5px; color: #FAFAFA; resize: none; max-height: 80px; }
#chatbot-root .cbw-input::placeholder { color: #6b6b6b; opacity: 1; }
#chatbot-root .cbw-send { width: 32px; height: 32px; border-radius: 50%; background: var(--cb-accent); border: none; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background 0.15s ease; }
#chatbot-root .cbw-send:hover { background: color-mix(in srgb, var(--cb-accent) 85%, black); }
#chatbot-root .cbw-send:disabled { opacity: 0.5; cursor: default; }
#chatbot-root .cbw-send svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.5; }
#chatbot-root .cbw-footer-meta { display: flex; justify-content: space-between; margin-top: 8px; padding: 0 4px; }
#chatbot-root .cbw-ai-note { font-size: 10.5px; color: #6b6b6b; font-family: 'DM Sans', sans-serif; }
#chatbot-root .cbw-end-link { font-family: 'DM Sans', sans-serif; font-size: 10.5px; color: #D34DD6; background: none; border: none; padding: 0; cursor: pointer; text-decoration: underline; }
#chatbot-root .cbw-end-link:hover { color: #E8521A; }

/* Lead capture + booking forms */
#chatbot-root .cbw-capture,
#chatbot-root .cbw-booking { padding: 20px 18px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; background: #0f0f0f; }
#chatbot-root .cbw-capture h4,
#chatbot-root .cbw-booking h4 { margin: 0 0 4px; font-family: 'Syne', sans-serif; font-weight: 700; font-size: 15px; color: #FAFAFA; }
#chatbot-root .cbw-capture p,
#chatbot-root .cbw-booking p { margin: 0; font-size: 12.5px; color: #9CA3AF; line-height: 1.5; }
#chatbot-root .cbw-booking-back { display: flex; align-items: center; gap: 5px; align-self: flex-start; background: none; border: none; padding: 0; cursor: pointer; font-size: 11.5px; color: #9CA3AF; font-family: 'DM Sans', sans-serif; }
#chatbot-root .cbw-booking-back svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.5; }
#chatbot-root .cbw-field-group { display: flex; flex-direction: column; gap: 5px; }
#chatbot-root .cbw-field-group label { font-size: 11.5px; color: #9CA3AF; }
#chatbot-root .cbw-field-group input,
#chatbot-root .cbw-field-group select,
#chatbot-root .cbw-field-group textarea { font-family: 'DM Sans', sans-serif; font-size: 13.5px; padding: 10px 12px; background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 8px; color: #FAFAFA; }
#chatbot-root .cbw-field-group input::placeholder,
#chatbot-root .cbw-field-group textarea::placeholder { color: #6b6b6b; opacity: 1; }
#chatbot-root .cbw-field-group input:focus,
#chatbot-root .cbw-field-group select:focus,
#chatbot-root .cbw-field-group textarea:focus { outline: none; border-color: var(--cb-accent); }
#chatbot-root .cbw-capture-actions { display: flex; gap: 8px; margin-top: 4px; }
#chatbot-root .cbw-btn-primary { flex: 1; width: 100%; box-sizing: border-box; font-family: 'DM Sans', sans-serif; background: var(--cb-accent); background: linear-gradient(135deg, var(--cb-accent), #E8521A); color: #fff; border: none; border-radius: 10px; padding: 12px; font-size: 13.5px; font-weight: 600; cursor: pointer; transition: filter 0.15s ease; margin-top: 4px; }
#chatbot-root .cbw-btn-primary:hover { filter: brightness(1.08); }
#chatbot-root .cbw-btn-primary:disabled { opacity: 0.6; cursor: default; filter: none; }
#chatbot-root .cbw-btn-secondary { font-family: 'DM Sans', sans-serif; background: #262626; color: #FAFAFA; border: none; border-radius: 8px; padding: 10px 14px; font-size: 13px; font-weight: 600; cursor: pointer; }
#chatbot-root .cbw-error-text { font-size: 11.5px; color: #f87171; }
#chatbot-root .cbw-field-note { font-size: 10.5px; color: #9CA3AF; }
#chatbot-root .cbw-fine-print { font-size: 10.5px; color: #6b6b6b; text-align: center; }
#chatbot-root .cbw-combobox { position: relative; }
#chatbot-root .cbw-combobox-list { position: absolute; top: 100%; left: 0; right: 0; background: #1f1f1f; border: 1px solid #333; border-radius: 8px; max-height: 140px; overflow-y: auto; z-index: 10; box-shadow: 0 6px 16px rgba(0,0,0,0.4); }
#chatbot-root .cbw-combobox-list[hidden] { display: none; }
#chatbot-root .cbw-combobox-item { padding: 9px 12px; font-size: 12.5px; color: #FAFAFA; font-family: 'DM Sans', sans-serif; cursor: pointer; }
#chatbot-root .cbw-combobox-item:hover { background: #262626; }

#chatbot-root .cbw-booking-done { padding: 32px 22px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 14px; background: #0f0f0f; }
#chatbot-root .cbw-booking-done-icon { width: 48px; height: 48px; border-radius: 50%; background: rgba(34,197,94,0.15); display: flex; align-items: center; justify-content: center; }
#chatbot-root .cbw-booking-done-icon svg { width: 24px; height: 24px; fill: none; stroke: #4ade80; stroke-width: 2.5; }
#chatbot-root .cbw-booking-done h4 { margin: 0; }
#chatbot-root .cbw-booking-done p { max-width: 260px; }
#chatbot-root .cbw-booking-done .cbw-end-link { font-size: 13px; }

#chatbot-root .cbw-declined-note { font-size: 11px; color: #9ca3af; text-align: center; padding: 2px 0; }

/* Custom "End Chat" confirmation dialog - replaces window.confirm(),
 * which renders as the browser's own unstyled native alert chrome
 * with no way to apply any of this site's design to it - a native
 * confirm() can never be restyled by CSS no matter what, so the only
 * fix is to not use one at all. */
#chatbot-root .cbw-confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
#chatbot-root .cbw-confirm-box {
    width: min(300px, 100%);
    background: #161616;
    border: 1px solid #2a2a2a;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    padding: 20px;
    text-align: center;
}
#chatbot-root .cbw-confirm-text { margin: 0 0 16px; font-family: 'DM Sans', sans-serif; font-size: 13.5px; color: #FAFAFA; line-height: 1.5; }
#chatbot-root .cbw-confirm-actions { display: flex; gap: 8px; }

/* Mobile: full-screen takeover */
@media (max-width: 480px) {
    #chatbot-root .cbw-panel {
        position: fixed;
        inset: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border-radius: 0;
    }
    /* max-height: none here specifically (not just on the bare
     * .cbw-panel rule above) is required, not decoration - these two
     * selectors match the position-qualified desktop max-height rules
     * above at EQUAL specificity (ID + attribute + class on both
     * sides), so without restating it here at equal specificity, CSS
     * specificity (which ignores media-query nesting) would let those
     * desktop rules win over the mobile full-screen override below,
     * breaking it on narrow viewports regardless of source order. */
    #chatbot-root[data-position="right"] .cbw-panel,
    #chatbot-root[data-position="left"] .cbw-panel { left: 0; right: 0; max-height: none; }

    /* footer.css's own mobile breakpoint (max-width: 575px) shrinks the
     * floating buttons to 50px/40px and tightens their inset to 1em -
     * collapsed stack height becomes 40+12+50=102px above a 16px inset,
     * so the bubble only needs to clear ~130px here, not the desktop
     * 150px. */
    #chatbot-root[data-position="right"] { right: 16px; bottom: 130px; }
}

#chatbot-root [hidden] { display: none !important; }
