/* ShopAssistent - Chat-Fenster. Farbe aus dem Theme (--sa-farbe = sw-color-brand-primary), sonst neutral.
   Liegt unter Bootstrap-Offcanvas/Modals (z-index 1045+), damit Warenkorb und Cookie-Dialog darüber erscheinen. */
.sa-wurzel {
    --sa-farbe: #2b3136;
    --sa-text: #1f2328;
    --sa-grau: #6b7280;
    --sa-linie: #e5e7eb;
    --sa-flaeche: #f4f5f7;
    --sa-radius: 16px;
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom));
    z-index: 1040;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.45;
    color: var(--sa-text);
}
.sa-wurzel[hidden] { display: none; }
.sa-rechts { right: max(20px, env(safe-area-inset-right)); }
.sa-links { left: max(20px, env(safe-area-inset-left)); }
.sa-wurzel *, .sa-wurzel *::before, .sa-wurzel *::after { box-sizing: border-box; }

.sa-unsichtbar {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Knopf ---------- */
.sa-knopf {
    display: flex; align-items: center; gap: 10px;
    height: 56px; padding: 0 20px 0 16px;
    border: 0; border-radius: 28px;
    background: var(--sa-farbe); color: #fff;
    font: inherit; font-weight: 600;
    box-shadow: 0 6px 24px rgba(0, 0, 0, .22);
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease;
}
.sa-knopf:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(0, 0, 0, .26); }
.sa-knopf:focus-visible { outline: 3px solid rgba(0, 0, 0, .35); outline-offset: 3px; }
.sa-gesehen .sa-knopf { width: 56px; padding: 0; justify-content: center; }
.sa-gesehen .sa-knopf-text { display: none; }
.sa-offen .sa-knopf { width: 56px; padding: 0; justify-content: center; }
.sa-offen .sa-knopf-text { display: none; }

/* ---------- Fenster ---------- */
.sa-fenster {
    position: absolute; bottom: 72px;
    width: 390px; height: min(640px, calc(100vh - 120px));
    display: flex; flex-direction: column;
    background: #fff;
    border-radius: var(--sa-radius);
    box-shadow: 0 12px 48px rgba(0, 0, 0, .25);
    overflow: hidden;
    animation: sa-auf .18s ease-out;
}
.sa-fenster[hidden] { display: none; }
.sa-rechts .sa-fenster { right: 0; }
.sa-links .sa-fenster { left: 0; }
@keyframes sa-auf { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

.sa-kopf {
    position: relative;
    display: flex; align-items: center; gap: 10px;
    padding: 12px 10px 12px 14px;
    background: var(--sa-farbe); color: #fff;
}
.sa-avatar {
    flex: none; width: 36px; height: 36px; border-radius: 50%;
    display: grid; place-items: center;
    background: rgba(255, 255, 255, .22); font-weight: 700;
}
.sa-kopf-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sa-kopf-text strong { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sa-kopf-zeile { font-size: 12px; opacity: .85; }
.sa-menue-knopf, .sa-schliessen {
    flex: none; width: 36px; height: 36px; border: 0; border-radius: 50%;
    display: grid; place-items: center;
    background: transparent; color: inherit; cursor: pointer;
}
.sa-menue-knopf:hover, .sa-schliessen:hover { background: rgba(255, 255, 255, .18); }
.sa-menue {
    position: absolute; top: 54px; right: 10px; z-index: 2;
    min-width: 230px; padding: 6px;
    background: #fff; color: var(--sa-text);
    border-radius: 10px; box-shadow: 0 8px 28px rgba(0, 0, 0, .2);
}
.sa-menue[hidden] { display: none; }
.sa-menue button {
    display: block; width: 100%; padding: 10px 12px; border: 0; border-radius: 6px;
    background: none; font: inherit; text-align: left; cursor: pointer;
}
.sa-menue button:hover, .sa-menue button:focus-visible { background: var(--sa-flaeche); }

/* ---------- Verlauf ---------- */
.sa-verlauf {
    flex: 1; overflow-y: auto; overscroll-behavior: contain;
    padding: 16px 14px 8px;
    display: flex; flex-direction: column; gap: 10px;
    background: #fafafa;
}
.sa-nachricht { max-width: 88%; display: flex; flex-direction: column; gap: 6px; }
.sa-nachricht .sa-text { padding: 10px 13px; border-radius: 14px; overflow-wrap: anywhere; }
.sa-text:empty { display: none; }
.sa-text p { margin: 0 0 6px; }
.sa-text p:last-child { margin-bottom: 0; }
.sa-text ul, .sa-text ol { margin: 4px 0 6px; padding-left: 20px; }
.sa-text li { margin: 2px 0; }
.sa-text a { color: inherit; text-decoration: underline; font-weight: 600; }
.sa-kunde { align-self: flex-end; }
.sa-kunde .sa-text { background: var(--sa-farbe); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; }
.sa-assistent { align-self: flex-start; }
.sa-assistent .sa-text { background: #fff; border: 1px solid var(--sa-linie); border-bottom-left-radius: 4px; }
.sa-fehler .sa-text { background: #fff4f2; border-color: #f3c3bb; }
.sa-hinweis { margin: 0; padding: 0 4px; font-size: 12px; color: var(--sa-grau); }
.sa-systemhinweis { margin: 4px auto; font-size: 12px; color: var(--sa-grau); text-align: center; }

.sa-status { display: flex; align-items: center; gap: 8px; padding: 6px 4px; font-size: 13px; color: var(--sa-grau); }
.sa-status[hidden] { display: none; }
.sa-punkte { display: inline-flex; gap: 3px; }
.sa-punkte i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: sa-punkt 1s infinite ease-in-out; }
.sa-punkte i:nth-child(2) { animation-delay: .15s; }
.sa-punkte i:nth-child(3) { animation-delay: .3s; }
@keyframes sa-punkt { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.sa-nochmal {
    align-self: flex-start; padding: 6px 12px; border: 1px solid var(--sa-linie); border-radius: 16px;
    background: #fff; font: inherit; font-size: 13px; cursor: pointer;
}

.sa-bewertung { display: flex; align-items: center; gap: 2px; padding-left: 4px; }
.sa-daumen {
    width: 28px; height: 28px; border: 0; border-radius: 50%;
    display: grid; place-items: center;
    background: none; color: #a0a4ab; cursor: pointer;
}
.sa-daumen:hover { background: var(--sa-flaeche); color: var(--sa-text); }
.sa-daumen.sa-gewaehlt { color: var(--sa-farbe); }
.sa-danke { margin-left: 6px; font-size: 12px; color: var(--sa-grau); }

/* ---------- Produktkarten ---------- */
.sa-nachricht:has(.sa-karten) { max-width: 100%; }
.sa-karten {
    display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory;
    padding: 2px 2px 8px; margin: 0 -2px;
}
.sa-karte {
    flex: 0 0 168px; scroll-snap-align: start;
    display: flex; flex-direction: column;
    background: #fff; border: 1px solid var(--sa-linie); border-radius: 12px; overflow: hidden;
}
.sa-karte-bild { display: block; aspect-ratio: 1; background: #fff; }
.sa-karte-bild img { width: 100%; height: 100%; object-fit: contain; padding: 8px; }
.sa-ohne-bild { display: block; width: 100%; height: 100%; background: var(--sa-flaeche); }
.sa-karte-text { flex: 1; display: flex; flex-direction: column; gap: 2px; padding: 8px 10px 6px; font-size: 13px; }
.sa-marke { font-size: 11px; text-transform: uppercase; letter-spacing: .03em; color: var(--sa-grau); }
.sa-karte-name {
    color: var(--sa-text); font-weight: 600; text-decoration: none; line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.sa-karte-name:hover { text-decoration: underline; }
.sa-preis { margin-top: 4px; font-weight: 700; font-size: 15px; }
.sa-preis s { font-weight: 400; font-size: 12px; color: var(--sa-grau); }
.sa-grundpreis { font-size: 11px; color: var(--sa-grau); }
.sa-verfuegbar { font-size: 11px; display: flex; gap: 5px; align-items: baseline; }
.sa-verfuegbar::before { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: #3cb371; transform: translateY(-1px); }
.sa-verfuegbar.sa-knapp::before { background: #f0a020; }
.sa-verfuegbar.sa-aus::before { background: #d64545; }
.sa-karte-knopf {
    margin: 4px 10px 10px; padding: 8px 6px;
    border: 0; border-radius: 8px;
    background: var(--sa-farbe); color: #fff;
    font: inherit; font-size: 13px; font-weight: 600; text-align: center; text-decoration: none;
    cursor: pointer;
}
a.sa-karte-knopf { background: #fff; color: var(--sa-farbe); border: 1.5px solid var(--sa-farbe); }
.sa-karte-knopf:hover { filter: brightness(1.08); color: #fff; }
a.sa-karte-knopf:hover { background: var(--sa-farbe); }
.sa-karte-knopf.sa-ok { background: #3cb371; }
.sa-zum-warenkorb { margin: -4px 10px 10px; font-size: 12px; text-align: center; color: var(--sa-text); }

/* ---------- Vorschläge + Eingabe ---------- */
.sa-vorschlaege { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 8px; background: #fafafa; }
.sa-vorschlaege:empty { display: none; }
.sa-vorschlag {
    padding: 7px 12px; border: 1px solid var(--sa-farbe); border-radius: 18px;
    background: #fff; color: var(--sa-farbe); font: inherit; font-size: 13px; cursor: pointer;
}
.sa-vorschlag:hover { background: var(--sa-farbe); color: #fff; }

.sa-eingabe { display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--sa-linie); background: #fff; }
.sa-feld {
    flex: 1; resize: none; max-height: 120px; min-height: 42px;
    padding: 10px 12px; border: 1px solid var(--sa-linie); border-radius: 12px;
    font: inherit; color: inherit; background: var(--sa-flaeche); line-height: 1.35;
}
.sa-feld:focus { outline: none; border-color: var(--sa-farbe); background: #fff; }
.sa-senden {
    flex: none; width: 42px; height: 42px; border: 0; border-radius: 50%;
    display: grid; place-items: center;
    background: var(--sa-farbe); color: #fff; cursor: pointer;
}
.sa-senden:disabled { opacity: .35; cursor: default; }
.sa-fuss { margin: 0; padding: 0 12px 8px; font-size: 11px; color: var(--sa-grau); background: #fff; text-align: center; }
.sa-fuss a { color: inherit; }

/* ---------- Handy: Vollbild ---------- */
@media (max-width: 767.98px) {
    .sa-wurzel { bottom: max(14px, env(safe-area-inset-bottom)); }
    .sa-rechts { right: 14px; }
    .sa-links { left: 14px; }
    .sa-knopf { height: 52px; }
    .sa-gesehen .sa-knopf, .sa-offen .sa-knopf { width: 52px; }
    .sa-offen .sa-knopf { display: none; }
    .sa-fenster {
        position: fixed; inset: 0; width: auto; height: 100%; height: 100dvh;
        border-radius: 0; bottom: auto;
    }
    .sa-feld { font-size: 16px; } /* iOS zoomt sonst beim Tippen */
    html.sa-chat-offen, html.sa-chat-offen body { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
    .sa-fenster, .sa-punkte i { animation: none; }
    .sa-knopf { transition: none; }
}

@media print { .sa-wurzel { display: none !important; } }
