/*
 * Voiceflow chat widget — Retoura brand chrome.
 *
 * Uses the CSS custom properties defined by the Retoura template on :root
 * (templates/Retoura/themes/retoura/css/base.css, loaded on every page type)
 * with hard-coded fallbacks:
 *   --brand-rgb: 190, 211, 54   (#BED336 lime)
 *   --bod-b-rgb:  48,  54, 51   (#303633 dark charcoal)
 *   --lightborder: #E9ECEB
 *
 * z-index 99990 sits above all shop UI but below the consent banner/modal
 * (100000/100001) so the consent UI can never be blocked by the widget.
 */

.sua-customer-service-agent-hidden {
    display: none !important;
}

/* --- bubble ------------------------------------------------------------ */

#sua-customer-service-agent-bubble {
    position: fixed;
    right: 16px;
    bottom: 16px;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    background: rgba(var(--brand-rgb, 190, 211, 54), 1);
    color: rgba(var(--bod-b-rgb, 48, 54, 51), 1);
    box-shadow: 0 4px 14px rgba(var(--bod-b-rgb, 48, 54, 51), 0.3);
    z-index: 99990;
    transition: transform 0.15s ease;
    animation: sua-customer-service-agent-pulse 2.4s ease-out 3;
}

#sua-customer-service-agent-bubble:hover,
#sua-customer-service-agent-bubble:focus-visible {
    transform: scale(1.06);
}

@keyframes sua-customer-service-agent-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(var(--brand-rgb, 190, 211, 54), 0.45);
    }
    70% {
        box-shadow: 0 0 0 14px rgba(var(--brand-rgb, 190, 211, 54), 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(var(--brand-rgb, 190, 211, 54), 0);
    }
}

/* --- panel (shared chrome) ---------------------------------------------- */

#sua-customer-service-agent-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-radius: 12px;
    background: #fff;
    border: 1px solid var(--lightborder, #E9ECEB);
    box-shadow: 0 8px 30px rgba(var(--bod-b-rgb, 48, 54, 51), 0.35);
}

.sua-customer-service-agent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
    padding: 12px 16px;
    background: rgba(var(--bod-b-rgb, 48, 54, 51), 1);
    color: #fff;
}

/* our chrome header is redundant once the Voiceflow widget (with its own
   header) has rendered — the panel then closes via bubble, ESC, escape link
   or a click outside */
.sua-customer-service-agent-loaded .sua-customer-service-agent-header {
    display: none;
}

.sua-customer-service-agent-title {
    font-weight: 700;
    letter-spacing: 1px;
    font-size: 15px;
}

.sua-customer-service-agent-accent {
    color: rgba(var(--brand-rgb, 190, 211, 54), 1);
    letter-spacing: normal;
    font-weight: 600;
}

.sua-customer-service-agent-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #fff;
    cursor: pointer;
}

.sua-customer-service-agent-close:hover,
.sua-customer-service-agent-close:focus-visible {
    background: rgba(255, 255, 255, 0.15);
}

.sua-customer-service-agent-body {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
}

.sua-customer-service-agent-chat {
    width: 100%;
    height: 100%;
}

/* --- loading spinner (hidden once the chat bundle rendered) ------------- */

.sua-customer-service-agent-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 36px;
    height: 36px;
    margin: -18px 0 0 -18px;
    border: 3px solid var(--lightborder, #E9ECEB);
    border-top-color: rgba(var(--brand-rgb, 190, 211, 54), 1);
    border-radius: 50%;
    animation: sua-customer-service-agent-spin 0.9s linear infinite;
}

#sua-customer-service-agent-panel.sua-customer-service-agent-loaded .sua-customer-service-agent-spinner {
    display: none;
}

@keyframes sua-customer-service-agent-spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- consent placeholder / load-error card ------------------------------ */

/* display:flex on the class would defeat the hidden attribute (author styles
   beat the UA [hidden] rule), so re-assert it with higher specificity */
.sua-customer-service-agent-consent[hidden] {
    display: none;
}

.sua-customer-service-agent-consent {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 24px;
    text-align: center;
    background: #fff;
}

.sua-customer-service-agent-consent p {
    margin: 0;
    font-size: 14px;
    line-height: 1.55;
    color: rgba(var(--bod-b-rgb, 48, 54, 51), 0.75);
}

.sua-customer-service-agent-consent-btn {
    padding: 12px 24px;
    border: 0;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
    background: rgba(var(--brand-rgb, 190, 211, 54), 1);
    color: rgba(var(--bod-b-rgb, 48, 54, 51), 1);
    transition: transform 0.15s ease;
}

.sua-customer-service-agent-consent-btn:hover,
.sua-customer-service-agent-consent-btn:focus-visible {
    transform: translateY(-2px);
}

/* --- floating variant (bubble modes) ------------------------------------ */

#sua-customer-service-agent-panel.sua-customer-service-agent-floating {
    position: fixed;
    right: 16px;
    bottom: 88px;
    width: 380px;
    height: min(600px, calc(100vh - 120px));
    z-index: 98;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

#sua-customer-service-agent-panel.sua-customer-service-agent-floating.sua-customer-service-agent-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0);
}

@media (max-width: 575.98px) {
    #sua-customer-service-agent-panel.sua-customer-service-agent-floating {
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }
}

/* --- inline variant (contact-form overlay) ------------------------------ */

#sua-customer-service-agent-panel.sua-customer-service-agent-inline {
    display: none;
    height: min(600px, calc(100vh - 160px));
    min-height: 420px;
    margin-bottom: 8px;
}

#sua-customer-service-agent-panel.sua-customer-service-agent-inline.sua-customer-service-agent-open {
    display: flex;
}

/* while the overlay is open it replaces the whole contact content (#ct-fr
   direct children: form, admin-maintained intro with phone number / service
   hours, OPC zones) — only the page heading stays. One container-level rule
   instead of hiding individual siblings, so content edited in the admin
   backend later is covered automatically. */
.sua-customer-service-agent-overlay-open > :not(#sua-customer-service-agent-panel):not(.sua-customer-service-agent-escape):not(h1) {
    display: none;
}

.sua-customer-service-agent-overlay-open > .sua-customer-service-agent-escape {
    display: block;
}

.sua-customer-service-agent-escape {
    display: none;
    margin: 0 auto 24px;
    padding: 6px 12px;
    border: 0;
    background: none;
    font-size: 14px;
    text-decoration: underline;
    color: inherit;
    cursor: pointer;
}

/* --- reduced motion ------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
    #sua-customer-service-agent-bubble,
    .sua-customer-service-agent-consent-btn,
    #sua-customer-service-agent-panel.sua-customer-service-agent-floating {
        transition: none;
        animation: none;
    }
}
