/* Worn Out Vegan support chat widget. Scoped under #wov-chat / .wovc-*. */

#wov-chat {
    --wovc-accent: #111111;
    --wovc-accent-text: #ffffff;
    /* Width the page lost when a drawer hid the scrollbar; widget.js keeps it
       in sync. Added to `right` so the fab/panel don't slide outward. */
    --wovc-gutter: 0px;
    font-family: inherit;
    transition: opacity .18s ease, visibility 0s;
}

/* The theme's own overlays own the screen while they're up: cart drawer,
   search, mobile nav, filter sidebar (open-drawer/nav-open/open-sidebar on
   <html>) and tingle popups — quick view, newsletter (tingle-enabled on
   <body>). The widget fades out from under them instead of floating on top,
   and stops taking clicks/tab focus while it's away. */
html.open-drawer #wov-chat,
html.nav-open #wov-chat,
html.open-sidebar #wov-chat,
body.tingle-enabled #wov-chat {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .18s ease, visibility 0s linear .18s;
}

/* The widget shows/hides everything through the `hidden` attribute, and most
   of those elements are flex containers. An author `display` beats the UA's
   [hidden] rule, so hidden would otherwise do nothing (panel stuck open). */
#wov-chat [hidden] { display: none !important; }

/* ------------------------------------------------ floating button -- */

/* z-index sits above page content (the theme tops out around 20) but below
   its modal layers — mobile filter/sort sheets (998/999) and tingle popups
   (1000) — and below third-party popups, which all live in the 9000s+. */
.wovc-fab {
    position: fixed;
    right: calc(20px + var(--wovc-gutter, 0px));
    bottom: 20px;
    z-index: 900;
    width: 56px;
    height: 56px;
    border: none;
    border-radius: 50%;
    background: var(--wovc-accent);
    color: var(--wovc-accent-text);
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform .15s ease;
}

.wovc-fab:hover { transform: scale(1.06); }

/* Chat icon morphs into a cross while the panel is open: the two icons are
   stacked and swapped with a brief rotate+fade so the toggle feels snappy. */
.wovc-fab svg {
    width: 26px;
    height: 26px;
    position: absolute;
    transition: transform .18s ease, opacity .18s ease;
}

.wovc-fab .wovc-fab-icon--close { opacity: 0; transform: rotate(-90deg) scale(.5); }
.wovc-fab--open .wovc-fab-icon--chat { opacity: 0; transform: rotate(90deg) scale(.5); }
.wovc-fab--open .wovc-fab-icon--close { opacity: 1; transform: none; }

.wovc-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    background: #e11d48;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 20px;
    text-align: center;
}

/* ---------------------------------------------------------- panel -- */

.wovc-panel {
    position: fixed;
    right: calc(20px + var(--wovc-gutter, 0px));
    bottom: 90px;
    z-index: 901;
    width: 360px;
    max-width: calc(100vw - 40px);
    height: 704px;
    max-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    background: #fff;
    color: #111;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, .28);
    overflow: hidden;
}

.wovc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--wovc-accent);
    color: var(--wovc-accent-text);
}

.wovc-headtext { flex: 1; min-width: 0; }

.wovc-title { font-weight: 700; font-size: 15px; }
.wovc-sub { font-size: 12px; opacity: .75; margin-top: 2px; }

.wovc-back {
    border: none;
    background: none;
    color: inherit;
    cursor: pointer;
    padding: 2px;
    opacity: .85;
    display: flex;
    align-items: center;
}
.wovc-back:hover { opacity: 1; }
.wovc-back svg { width: 20px; height: 20px; }

/* Home (instant answers) view: the head doubles as a welcome header. */
.wovc-head--home { flex-wrap: wrap; padding: 20px 16px 8px; }
/* The strip the composer card overlaps into, when it's the one on show. */
.wovc-head--composer { padding-bottom: 34px; }
.wovc-head--home .wovc-title { font-size: 22px; }
.wovc-head--home .wovc-sub { font-size: 13px; opacity: .9; margin-top: 6px; }

.wovc-return {
    flex-basis: 100%;
    border: none;
    background: none;
    color: inherit;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    padding: 18px 0 10px;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.wovc-return:hover { opacity: .85; }

/* Home view's composer: a card straddling the header edge, so a first-time
   visitor can type without picking an instant answer. Sits between the head
   and the scrolling body, so the answers list scrolls underneath it. Mutually
   exclusive with "Return to chat" — it's hidden once a thread exists. */
.wovc-home-composer {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex: 0 0 auto;
    margin: -26px 16px 0;
    padding: 14px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}

/* Same defensive spelling-out as the input bar's textarea: themes style bare
   <textarea> globally (Glozin sets min-height: 15rem). */
.wovc-home-composer textarea {
    flex: 1;
    resize: none;
    border: none;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    min-height: 0;
    height: auto;
    max-height: 120px;
    box-sizing: border-box;
    background: transparent;
    padding: 0;
}

.wovc-home-composer button {
    border: none;
    background: none;
    color: #c7c7c7;
    cursor: pointer;
    padding: 0;
}
.wovc-home-composer button:not(:disabled) { color: var(--wovc-accent); }
.wovc-home-composer button svg { width: 22px; height: 22px; display: block; }

.wovc-close {
    border: none;
    background: none;
    color: inherit;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    opacity: .8;
}
.wovc-close:hover { opacity: 1; }

.wovc-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #f6f6f6;
    overscroll-behavior: contain;
}

/* The body hosts three switchable views (home / prechat / chat). */
.wovc-view {
    flex: 1 0 auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.wovc-view[hidden] { display: none; }

.wovc-intro {
    font-size: 13px;
    color: #555;
    text-align: center;
    margin: auto 12px;
}

/* -------------------------------------------- home: instant answers -- */

.wovc-ia-btn {
    border: 1px solid #111;
    border-radius: 10px;
    background: #fff;
    color: #111;
    font-family: inherit;
    font-size: 15px;
    text-align: left;
    padding: 14px 16px;
    cursor: pointer;
    transition: background .12s ease;
}
.wovc-ia-btn:hover { background: #f0f0f0; }

/* ----------------------------------------------- pre-chat form view -- */

.wovc-prechat-title {
    font-size: 18px;
    font-weight: 700;
    text-align: center;
    margin-top: 24px;
}

.wovc-prechat-sub {
    font-size: 13px;
    color: #555;
    text-align: center;
    margin: 0 12px 10px;
}

.wovc-consent {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 13px;
    line-height: 1.4;
    color: #111;
    cursor: pointer;
    margin: 2px 0 6px;
}

/* Keep the theme's/our own text-input styling off the checkboxes and pin
   their size, so the label hugs the box and centres on its first line. */
.wovc-consent input {
    appearance: auto;
    -webkit-appearance: auto;
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    margin: 1px 0 0;
    padding: 0;
    border-radius: 0;
    accent-color: var(--wovc-accent);
}

/* ------------------------------------------------------- messages -- */

.wovc-msg { max-width: 82%; display: flex; flex-direction: column; }
.wovc-msg--you { align-self: flex-end; align-items: flex-end; }
.wovc-msg--agent { align-self: flex-start; align-items: flex-start; }

.wovc-bubble {
    padding: 9px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.45;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

/* Links inside a bubble inherit the bubble's colour: the customer's own
   messages sit on the accent background, where a default blue would clash. */
.wovc-bubble a {
    color: inherit;
    text-decoration: underline;
}
.wovc-bubble a:hover { opacity: .8; }

.wovc-msg--you .wovc-bubble {
    background: var(--wovc-accent);
    color: var(--wovc-accent-text);
    border-bottom-right-radius: 4px;
}

.wovc-msg--agent .wovc-bubble {
    background: #fff;
    border: 1px solid #e5e5e5;
    border-bottom-left-radius: 4px;
}

/* Typing dots: instant answers "being typed" + agent composing a reply. */
.wovc-typing .wovc-bubble {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 13px;
}
.wovc-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #b3b3b3;
    animation: wovc-typing 1.2s infinite ease-in-out;
}
.wovc-dot:nth-child(2) { animation-delay: .15s; }
.wovc-dot:nth-child(3) { animation-delay: .3s; }
@keyframes wovc-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: .45; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.wovc-msg--failed .wovc-bubble { opacity: .5; }
.wovc-msg--failed::after {
    content: 'Not sent — try again';
    font-size: 11px;
    color: #e11d48;
    margin-top: 2px;
}

.wovc-time {
    font-size: 10px;
    color: #999;
    margin-top: 3px;
}

.wovc-att-img img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 10px;
    display: block;
    margin-top: 4px;
}

.wovc-att-file {
    display: inline-block;
    margin-top: 4px;
    font-size: 13px;
    color: var(--wovc-accent);
    text-decoration: underline;
}

/* ----------------------------------------------------- email form -- */

.wovc-emailform {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0 8px;
}

.wovc-emailform input:not([type="checkbox"]) {
    border: 1px solid #d4d4d4;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    background: #fff;
}

.wovc-emailform button {
    border: none;
    border-radius: 10px;
    padding: 11px;
    background: var(--wovc-accent);
    color: var(--wovc-accent-text);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.wovc-emailform button:disabled { opacity: .6; }

.wovc-error { font-size: 12px; color: #e11d48; }

/* ------------------------------------------------------ input bar -- */

.wovc-inputbar {
    display: flex;
    flex-direction: column;
    padding: 10px 12px;
    border-top: 1px solid #e5e5e5;
    background: #fff;
}

.wovc-inputrow {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.wovc-pending {
    display: flex;
    gap: 8px;
    padding-bottom: 8px;
}

.wovc-pending-chip {
    position: relative;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    overflow: visible;
}

.wovc-pending-chip img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid #e5e5e5;
    display: block;
}

.wovc-pending-chip button {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    border: none;
    border-radius: 50%;
    background: #111;
    color: #fff;
    font-size: 13px;
    line-height: 18px;
    text-align: center;
    padding: 0;
    cursor: pointer;
}

.wovc-attach { align-self: flex-end; }

/* min-height/box-sizing are spelled out because themes style bare <textarea>
   globally (Glozin sets min-height: 15rem), which would floor the one-row box
   at ~150px and defeat the JS auto-grow. */
.wovc-inputbar textarea {
    flex: 1;
    resize: none;
    border: none;
    outline: none;
    font-size: 14px;
    font-family: inherit;
    line-height: 1.4;
    min-height: 0;
    height: auto;
    max-height: 120px;
    box-sizing: border-box;
    background: transparent;
    padding: 6px 0;
}

.wovc-inputbar button {
    border: none;
    background: none;
    color: var(--wovc-accent);
    cursor: pointer;
    padding: 6px;
}

.wovc-inputbar button svg { width: 22px; height: 22px; }

.wovc-hint {
    font-size: 11px;
    color: #999;
    text-align: center;
    padding: 0 16px 10px;
    background: #fff;
}

/* ------------------------------------------------------ lightbox -- */

.wovc-lightbox {
    position: fixed;
    inset: 0;
    z-index: 902;
    background: rgba(0, 0, 0, .88);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    cursor: zoom-out;
}

.wovc-lightbox img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 12px;
}

.wovc-lightbox-close {
    position: absolute;
    top: calc(12px + env(safe-area-inset-top));
    right: 16px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    color: #fff;
    font-size: 22px;
    line-height: 36px;
    text-align: center;
    padding: 0;
    cursor: pointer;
}

/* -------------------------------------------------------- mobile -- */

@media (max-width: 749px) {
    /* True fullscreen: no sliver of page above, no radius fighting the
       device's screen corners, white panel background behind the home
       indicator via safe-area padding. */
    .wovc-panel {
        inset: 0;
        width: auto;
        max-width: none;
        height: 100dvh;
        max-height: none;
        border-radius: 0;
        padding-bottom: env(safe-area-inset-bottom);
    }

    /* While the fullscreen panel is open the page behind must not scroll
       (widget.js toggles this class on <html>). */
    html.wovc-chat-open, html.wovc-chat-open body {
        overflow: hidden;
    }

    /* 16px keeps iOS from auto-zooming the page when a field is focused. */
    .wovc-inputbar textarea,
    .wovc-home-composer textarea,
    .wovc-emailform input:not([type="checkbox"]) {
        font-size: 16px;
    }
}
