/* Stone & Water - KI Produktberater | storefront widget */
.staw-advisor {
    --staw-advisor-accent: #4f46e5;
    --staw-advisor-x: 24px;
    --staw-advisor-y: 24px;
    --staw-advisor-radius: 12px;
    --staw-advisor-bg: #ffffff;
    --staw-advisor-text: #1f2330;
    --staw-advisor-muted: #6b7280;
    --staw-advisor-border: #e5e7eb;
    position: fixed;
    z-index: 2147483647;
    font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.45;
    color: var(--staw-advisor-text);
}

/* horizontal anchor */
.staw-advisor-h-right { right: var(--staw-advisor-x); }
.staw-advisor-h-left { left: var(--staw-advisor-x); }
.staw-advisor-h-center { left: 50%; }

/* vertical anchor */
.staw-advisor-v-bottom { bottom: var(--staw-advisor-y); }
.staw-advisor-v-top { top: var(--staw-advisor-y); }
.staw-advisor-v-middle { top: 50%; }

/* combined transforms */
.staw-advisor-h-center.staw-advisor-v-bottom,
.staw-advisor-h-center.staw-advisor-v-top { transform: translateX(-50%); }
.staw-advisor-v-middle.staw-advisor-h-right,
.staw-advisor-v-middle.staw-advisor-h-left { transform: translateY(-50%); }
.staw-advisor-v-middle.staw-advisor-h-center { transform: translate(-50%, -50%); }

.staw-advisor-launcher {
    position: relative;
    width: 60px;
    height: 56px;
    border-radius: 22px;
    border: none;
    background: var(--staw-advisor-bg);
    box-shadow: 0 10px 30px rgba(17, 24, 39, .30), 0 3px 8px rgba(17, 24, 39, .20);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: transform .15s ease, box-shadow .15s ease;
}
.staw-advisor-launcher::after {
    content: "";
    position: absolute;
    bottom: -6px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 12px solid var(--staw-advisor-bg);
    filter: drop-shadow(0 4px 3px rgba(17, 24, 39, .16));
}
.staw-advisor-h-right .staw-advisor-launcher::after { right: 13px; }
.staw-advisor-h-left .staw-advisor-launcher::after { left: 13px; }
.staw-advisor-h-center .staw-advisor-launcher::after { left: 50%; transform: translateX(-50%); }
.staw-advisor-launcher:hover { transform: translateY(-2px); box-shadow: 0 14px 38px rgba(17, 24, 39, .34), 0 4px 10px rgba(17, 24, 39, .24); }
.staw-advisor-launcher:focus-visible { outline: 3px solid var(--staw-advisor-accent); outline-offset: 3px; }
.staw-advisor-launcher-icon { width: 34px; height: 34px; object-fit: contain; }
.staw-advisor.staw-advisor-open .staw-advisor-launcher { display: none; }

.staw-advisor-panel {
    position: absolute;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 48px);
    max-height: calc(100dvh - 48px);
    background: var(--staw-advisor-bg);
    border: 1px solid var(--staw-advisor-border);
    border-radius: var(--staw-advisor-radius);
    box-shadow: 0 12px 40px rgba(17, 24, 39, .22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.staw-advisor-v-bottom .staw-advisor-panel { bottom: 0; top: auto; }
.staw-advisor-v-top .staw-advisor-panel { top: 0; bottom: auto; }
.staw-advisor-v-middle .staw-advisor-panel { top: 0; bottom: auto; }
.staw-advisor-h-right .staw-advisor-panel { right: 0; left: auto; }
.staw-advisor-h-left .staw-advisor-panel { left: 0; right: auto; }
.staw-advisor-h-center .staw-advisor-panel { left: 50%; transform: translateX(-50%); }

.staw-advisor-header {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--staw-advisor-border);
}
.staw-advisor-header-logo { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; }
.staw-advisor-header-title { font-weight: 600; font-size: 15px; flex: 1; }
.staw-advisor-header-close {
    display: inline-flex; align-items: center; justify-content: center; height: 28px;
    border: none; background: transparent; font-size: 26px; line-height: 1;
    color: var(--staw-advisor-muted); cursor: pointer; padding: 0 4px;
}
.staw-advisor-header-close:hover { color: var(--staw-advisor-text); }
.staw-advisor-header-restart svg, .staw-advisor-header-close svg { display: block; width: 18px; height: 18px; }

.staw-advisor-messages {
    flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px;
    display: flex; flex-direction: column; gap: 12px; background: #f9fafb;
}

.staw-advisor-msg { max-width: 85%; padding: 10px 13px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.staw-advisor-msg-bot { align-self: flex-start; background: #ffffff; border: 1px solid var(--staw-advisor-border); border-bottom-left-radius: 4px; }
.staw-advisor-msg-user { align-self: flex-end; background: var(--staw-advisor-accent); color: #ffffff; border-bottom-right-radius: 4px; }

.staw-advisor-typing { display: inline-flex; gap: 4px; align-items: center; }
.staw-advisor-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--staw-advisor-muted); animation: staw-advisor-blink 1.2s infinite both; }
.staw-advisor-typing span:nth-child(2) { animation-delay: .2s; }
.staw-advisor-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes staw-advisor-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.staw-advisor-cards { display: flex; flex-direction: column; gap: 10px; align-self: flex-start; width: 85%; }
.staw-advisor-card { display: flex; gap: 10px; border: 1px solid var(--staw-advisor-border); border-radius: 10px; padding: 8px; background: #ffffff; text-decoration: none; color: var(--staw-advisor-text); }
.staw-advisor-card-media { width: 56px; height: 56px; flex: 0 0 56px; border-radius: 8px; overflow: hidden; background: #f3f4f6; }
.staw-advisor-card-media img { width: 100%; height: 100%; object-fit: cover; }
.staw-advisor-card-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.staw-advisor-card-name { font-weight: 600; font-size: 13px; line-height: 1.3; }
.staw-advisor-card-manufacturer { font-size: 11px; color: var(--staw-advisor-muted); }
.staw-advisor-card-price { font-weight: 600; font-size: 13px; color: var(--staw-advisor-accent); }
.staw-advisor-card-listprice { font-size: 12px; color: #9ca3af; text-decoration: line-through; margin-left: 6px; }
.staw-advisor-card-actions { display: flex; gap: 6px; margin-top: 4px; }
.staw-advisor-card-link, .staw-advisor-card-cart { font-size: 11px; border-radius: 6px; padding: 4px 8px; cursor: pointer; border: 1px solid var(--staw-advisor-accent); text-decoration: none; line-height: 1.4; }
.staw-advisor-card-link { color: var(--staw-advisor-accent); background: #ffffff; }
.staw-advisor-card-cart { color: #ffffff; background: var(--staw-advisor-accent); }

.staw-advisor-form { display: flex; flex: 0 0 auto; align-items: flex-end; gap: 8px; padding: 12px; border-top: 1px solid var(--staw-advisor-border); }
.staw-advisor-input { flex: 1; resize: none; border: 1.5px solid var(--staw-advisor-border); border-radius: 10px; padding: 9px 11px; font: inherit; max-height: 120px; outline: none; }
.staw-advisor-input:focus { border-color: var(--staw-advisor-accent); }
.staw-advisor-send { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 10px; border: none; background: var(--staw-advisor-accent); color: #ffffff; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.staw-advisor-send:disabled { opacity: .5; cursor: not-allowed; }


.staw-advisor-visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 600px), (max-height: 560px) {
    /* Make the open widget a full-screen sheet. Neutralise the container's
       anchor offsets and any center/middle transform (a transformed ancestor
       would otherwise break a fixed/full-screen child). */
    .staw-advisor.staw-advisor-open {
        top: 0; left: 0; right: 0; bottom: 0;
        height: 100vh;
        height: 100dvh;
        transform: none;
    }
    .staw-advisor.staw-advisor-open .staw-advisor-panel {
        position: absolute;
        top: 0; left: 0; right: 0; bottom: 0;
        width: 100%; max-width: 100%;
        height: 100%; max-height: none;
        transform: none;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }
    /* Respect notch / home-indicator safe areas. */
    .staw-advisor.staw-advisor-open .staw-advisor-header {
        padding-top: calc(14px + env(safe-area-inset-top));
    }
    .staw-advisor.staw-advisor-open .staw-advisor-form {
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
    /* Bigger, zoom-free typing on iOS (font-size < 16px triggers auto-zoom). */
    .staw-advisor-input { font-size: 16px; }
    .staw-advisor-send { width: 44px; height: 44px; }
    .staw-advisor-messages { padding: 14px; }

    /* Keep the closed launcher clear of the home indicator / rounded corners. */
    .staw-advisor-v-bottom { bottom: calc(var(--staw-advisor-y) + env(safe-area-inset-bottom)); }
    .staw-advisor-h-right { right: calc(var(--staw-advisor-x) + env(safe-area-inset-right)); }
    .staw-advisor-h-left { left: calc(var(--staw-advisor-x) + env(safe-area-inset-left)); }
}

/* Full-screen sheet on phones / short viewports / in-app browsers. The
   .staw-advisor-sheet class is set by JS (viewport-based) so it is reliable even
   when a "desktop site" mode or in-app browser misreports the screen size. The
   container's size/offset are additionally driven inline by JS via visualViewport
   so the input stays just above the on-screen keyboard. */
.staw-advisor-sheet .staw-advisor-input { font-size: 16px; }
.staw-advisor-sheet .staw-advisor-send { width: 44px; height: 44px; }
.staw-advisor-sheet.staw-advisor-open {
    top: 0; left: 0; right: 0; bottom: 0;
    height: 100vh;
    height: 100dvh;
    transform: none;
}
.staw-advisor-sheet.staw-advisor-open .staw-advisor-panel {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; max-width: 100%;
    height: 100%; max-height: none;
    transform: none;
    border: none;
    border-radius: 0;
    box-shadow: none;
}
.staw-advisor-sheet.staw-advisor-open .staw-advisor-header { padding-top: calc(14px + env(safe-area-inset-top)); }
.staw-advisor-sheet.staw-advisor-open .staw-advisor-form { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }

/* cards hint + clickable cards */
.staw-advisor-cards-hint { align-self: flex-start; font-size: 12px; color: var(--staw-advisor-muted); margin-bottom: -4px; }
.staw-advisor-card { cursor: pointer; transition: border-color .12s ease, box-shadow .12s ease; }
.staw-advisor-card:hover, .staw-advisor-card:focus-visible { border-color: var(--staw-advisor-accent); box-shadow: 0 2px 10px rgba(17,24,39,.08); outline: none; }
.staw-advisor-card-more { font-size: 11px; color: var(--staw-advisor-accent); font-weight: 600; margin-top: 2px; }

/* page-level quickview overlay */
.staw-advisor-noscroll { overflow: hidden !important; }
.staw-advisor-panel-lock { overflow: hidden !important; }
.staw-advisor-quickview {
    position: fixed; inset: 0; z-index: 2147483647;
    display: flex; align-items: center; justify-content: center;
    --staw-advisor-accent: #4f46e5;
    font-family: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.staw-advisor-quickview[hidden] { display: none; }
.staw-advisor-quickview-backdrop { position: absolute; inset: 0; background: rgba(17,24,39,.55); }
.staw-advisor-quickview-dialog {
    position: relative;
    width: min(760px, calc(100vw - 32px));
    max-height: calc(100vh - 48px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 24px 64px rgba(17,24,39,.35);
    display: flex;
    overflow: hidden;
}
.staw-advisor-quickview-close {
    position: absolute; top: 10px; right: 12px; z-index: 2;
    border: none; background: rgba(255,255,255,.92); border-radius: 50%;
    width: 34px; height: 34px; font-size: 24px; line-height: 1; cursor: pointer; color: #1f2330;
    box-shadow: 0 2px 8px rgba(17,24,39,.15);
}
.staw-advisor-quickview-media { flex: 0 0 44%; background: #f3f4f6; display: flex; align-items: center; justify-content: center; padding: 18px; }
.staw-advisor-quickview-media img { max-width: 100%; max-height: 440px; object-fit: contain; }
.staw-advisor-quickview-info { flex: 1; min-width: 0; padding: 24px 26px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; color: #1f2330; }
.staw-advisor-quickview-manufacturer { font-size: 13px; color: #6b7280; }
.staw-advisor-quickview-name { margin: 0; font-size: 21px; font-weight: 700; line-height: 1.25; }
.staw-advisor-quickview-priceline { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-top: 2px; }
.staw-advisor-quickview-price { font-size: 22px; font-weight: 700; color: var(--staw-advisor-accent); }
.staw-advisor-quickview-listprice { font-size: 14px; color: #6b7280; text-decoration: line-through; }
.staw-advisor-quickview-rating { font-size: 13px; color: #f59e0b; }
.staw-advisor-quickview-section { margin-top: 8px; }
.staw-advisor-quickview-section h4 { margin: 0 0 5px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: #6b7280; font-weight: 600; }
.staw-advisor-quickview-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.staw-advisor-quickview-chips li { font-size: 12px; background: #f3f4f6; border-radius: 999px; padding: 4px 11px; }
.staw-advisor-quickview-specs { font-size: 12px; color: #6b7280; margin: 8px 0 0; }
.staw-advisor-quickview-desc { font-size: 14px; line-height: 1.55; margin: 8px 0 0; }
.staw-advisor-quickview-actions { display: flex; gap: 10px; margin-top: 18px; }
.staw-advisor-quickview-link, .staw-advisor-quickview-cart {
    flex: 1; min-width: 0; text-align: center; font-size: 14px; border-radius: 10px; padding: 11px 12px; cursor: pointer;
    border: 1.5px solid var(--staw-advisor-accent); text-decoration: none; line-height: 1.3;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.staw-advisor-quickview-link { color: var(--staw-advisor-accent); background: #fff; }
.staw-advisor-quickview-cart { color: #fff; background: var(--staw-advisor-accent); }

@media (max-width: 640px) {
    .staw-advisor-quickview { padding: 12px; }
    .staw-advisor-quickview-dialog {
        flex-direction: column;
        width: 100%;
        max-height: 100vh;
        max-height: 100dvh;
    }
    .staw-advisor-quickview-media { flex: 0 0 auto; max-height: 38vh; max-height: 38dvh; }
    .staw-advisor-quickview-media img { max-height: 34vh; max-height: 34dvh; }
    .staw-advisor-quickview-info { padding: 18px 18px calc(22px + env(safe-area-inset-bottom)); }
    .staw-advisor-quickview-actions { position: sticky; bottom: 0; background: #fff; padding-top: 12px; margin-top: 14px; }
}

/* starter quick-replies */
.staw-advisor-starters { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 6px; }
.staw-advisor-starter {
    border: 1px solid var(--staw-advisor-border); background: #fff; color: var(--staw-advisor-text);
    border-radius: 999px; padding: 7px 12px; font-size: 13px; cursor: pointer; line-height: 1.2;
    transition: border-color .12s ease, background .12s ease;
}
.staw-advisor-starter:hover { border-color: var(--staw-advisor-accent); background: #f5f5ff; }

/* inline system notes (cart confirmation / errors) */
.staw-advisor-note {
    align-self: center; max-width: 92%; text-align: center; font-size: 12px; color: #6b7280;
    background: #f3f4f6; border-radius: 10px; padding: 7px 12px; margin: 2px 0;
}
.staw-advisor-note-success { color: #166534; background: #ecfdf3; }
.staw-advisor-note-link { color: var(--staw-advisor-accent); text-decoration: none; font-weight: 600; white-space: nowrap; }
.staw-advisor-note-link:hover { text-decoration: underline; }

/* restart button */
.staw-advisor-header-restart {
    display: inline-flex; align-items: center; justify-content: center; height: 28px;
    border: none; background: transparent; font-size: 18px; line-height: 1;
    color: var(--staw-advisor-muted); cursor: pointer; padding: 0 2px;
}
.staw-advisor-header-restart:hover { color: var(--staw-advisor-text); }

/* consent gate */
.staw-advisor-consent {
    background: #f8f8ff; border: 1px solid var(--staw-advisor-border); border-radius: 12px;
    padding: 14px 16px; margin: 4px 0; display: flex; flex-direction: column; gap: 10px;
}
.staw-advisor-consent-text { margin: 0; font-size: 13px; line-height: 1.5; color: var(--staw-advisor-text); }
.staw-advisor-consent-btn {
    align-self: flex-start; border: none; background: var(--staw-advisor-accent); color: #fff;
    border-radius: 8px; padding: 8px 16px; font-size: 13px; cursor: pointer;
}
.staw-advisor-consent-btn:hover { filter: brightness(1.05); }
.staw-advisor-consent-notice { font-size: 11px; }

/* proactive launcher pulse */
@keyframes staw-advisor-pulse {
    0% { box-shadow: 0 0 0 0 rgba(79, 70, 229, .45); }
    70% { box-shadow: 0 0 0 16px rgba(79, 70, 229, 0); }
    100% { box-shadow: 0 0 0 0 rgba(79, 70, 229, 0); }
}
.staw-advisor-launcher.staw-advisor-pulse::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    z-index: -1;
    pointer-events: none;
    animation: staw-advisor-pulse 2.2s ease-out infinite;
}
@media (prefers-reduced-motion: reduce) {
    .staw-advisor-launcher.staw-advisor-pulse::before { animation: none; }
}

/* quickview variant configurator */
.staw-advisor-quickview-config { display: flex; flex-direction: column; gap: 10px; margin: 6px 0 14px; }
.staw-advisor-config-group { display: flex; flex-direction: column; gap: 4px; }
.staw-advisor-config-label { font-size: 12px; font-weight: 600; color: var(--staw-advisor-muted); }
.staw-advisor-config-select {
    border: 1px solid var(--staw-advisor-border); border-radius: 8px; padding: 8px 10px;
    font-size: 13px; background: #fff; color: var(--staw-advisor-text); width: 100%;
}
.staw-advisor-config-select:focus { outline: 2px solid var(--staw-advisor-accent); outline-offset: 1px; }
