/* ==========================================================================
   Webamax Consent — Frontend Styles
   Mobile-first. Position variants as classes. DSGVO-konforme Button-Parität.
   ========================================================================== */

:root {
    --wbx-color-bg: #ffffff;
    --wbx-color-fg: #1a1a1a;
    --wbx-color-muted: #595959;
    --wbx-color-border: #e5e5e5;
    --wbx-color-primary: #111827;
    --wbx-color-primary-contrast: #ffffff;
    --wbx-color-secondary: #f3f4f6;
    --wbx-color-accent: #d63638;
    --wbx-placeholder-bg: #0f172a;
    --wbx-placeholder-fg: #f8fafc;
    --wbx-radius: 10px;
    --wbx-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
    --wbx-z-banner: 99998;
    --wbx-z-modal: 99999;
    --wbx-z-badge: 99997;
    --wbx-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --wbx-gap: 0.75rem;
    --wbx-pad: 1rem;
}

.wbx-banner,
.wbx-modal,
.wbx-badge,
.wbx-placeholder {
    font-family: var(--wbx-font);
    color: var(--wbx-color-fg);
    box-sizing: border-box;
    -webkit-font-smoothing: antialiased;
}

.wbx-banner *,
.wbx-modal *,
.wbx-placeholder * {
    box-sizing: border-box;
}

html.wbx-modal-open { overflow: hidden; }

/* ==========================================================================
   Banner — mobile-first: immer als Box mit max-width, auf Desktop je Position
   ========================================================================== */

.wbx-banner {
    position: fixed;
    z-index: var(--wbx-z-banner);
    background: var(--wbx-color-bg);
    color: var(--wbx-color-fg);
    box-shadow: var(--wbx-shadow);
    border-radius: var(--wbx-radius);
    padding: 1rem 1.1rem;
    margin: 0.75rem;
    /* Default für mobile: zentriert unten, mit Abstand */
    left: 0;
    right: 0;
    bottom: 0;
    max-width: 640px;
    margin-left: auto;
    margin-right: auto;
}

.wbx-banner[hidden] { display: none; }

.wbx-banner__inner {
    display: flex;
    align-items: stretch;
    gap: var(--wbx-gap);
    flex-direction: column;
}

.wbx-banner__text { flex: 1 1 auto; }
.wbx-banner__title { margin: 0 0 0.35rem; font-size: 1.05rem; font-weight: 600; }
.wbx-banner__text p { margin: 0; font-size: 0.9rem; line-height: 1.55; color: var(--wbx-color-muted); }
.wbx-banner__text a { color: inherit; text-decoration: underline; }

.wbx-banner__actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.wbx-banner__actions .wbx-btn--ghost {
    grid-column: span 2;
}

/* Desktop: breitere Leiste, Buttons rechts */
@media (min-width: 720px) {
    .wbx-banner {
        padding: 1.1rem 1.4rem;
    }
    .wbx-banner__inner {
        flex-direction: row;
        align-items: center;
        gap: 1.5rem;
    }
    .wbx-banner__actions {
        display: flex;
        gap: 0.5rem;
        flex-wrap: wrap;
        flex: 0 0 auto;
    }
    .wbx-banner__actions .wbx-btn--ghost { grid-column: auto; }
}

/* ---------- Position-Varianten ---------- */

/* bottom (full width) */
.wbx-banner--pos-bottom {
    max-width: none;
    margin: 0;
    border-radius: 0;
    border-top: 1px solid var(--wbx-color-border);
}

@media (max-width: 719px) {
    .wbx-banner--pos-bottom {
        max-width: 640px;
        margin: 0.75rem;
        margin-left: auto;
        margin-right: auto;
        border-radius: var(--wbx-radius);
        border-top: none;
    }
}

/* top (full width) */
.wbx-banner--pos-top {
    max-width: none;
    margin: 0;
    border-radius: 0;
    bottom: auto;
    top: 0;
    border-bottom: 1px solid var(--wbx-color-border);
}

@media (max-width: 719px) {
    .wbx-banner--pos-top {
        max-width: 640px;
        margin: 0.75rem;
        margin-left: auto;
        margin-right: auto;
        border-radius: var(--wbx-radius);
        border-bottom: none;
    }
}

/* Box Ecke unten links */
@media (min-width: 720px) {
    .wbx-banner--pos-bottom-left {
        left: 0;
        right: auto;
        max-width: 440px;
        margin: 1rem;
    }
    .wbx-banner--pos-bottom-left .wbx-banner__inner { flex-direction: column; align-items: stretch; }
    .wbx-banner--pos-bottom-left .wbx-banner__actions { display: grid; grid-template-columns: 1fr 1fr; }
    .wbx-banner--pos-bottom-left .wbx-banner__actions .wbx-btn--ghost { grid-column: span 2; }
}

/* Box Ecke unten rechts */
@media (min-width: 720px) {
    .wbx-banner--pos-bottom-right {
        right: 0;
        left: auto;
        max-width: 440px;
        margin: 1rem;
    }
    .wbx-banner--pos-bottom-right .wbx-banner__inner { flex-direction: column; align-items: stretch; }
    .wbx-banner--pos-bottom-right .wbx-banner__actions { display: grid; grid-template-columns: 1fr 1fr; }
    .wbx-banner--pos-bottom-right .wbx-banner__actions .wbx-btn--ghost { grid-column: span 2; }
}

/* ==========================================================================
   Buttons — gleichwertige Optik für Accept/Reject (DSGVO / DSK 2022)
   ========================================================================== */

.wbx-btn {
    font: inherit;
    font-size: 0.92rem;
    font-weight: 500;
    padding: 0.7rem 1.1rem;
    min-height: 44px; /* Touch-Target */
    border-radius: var(--wbx-radius);
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.05s ease;
    line-height: 1.2;
    text-align: center;
    white-space: nowrap;
}
.wbx-btn:active { transform: translateY(1px); }
.wbx-btn:focus-visible { outline: 2px solid var(--wbx-color-primary); outline-offset: 2px; }
.wbx-btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* Primary & Secondary: gleiche Größe, gleicher Kontrast-Rahmen, kein "dark pattern" */
.wbx-btn--primary {
    background: var(--wbx-color-primary);
    color: var(--wbx-color-primary-contrast);
    border-color: var(--wbx-color-primary);
}
.wbx-btn--primary:hover { filter: brightness(1.1); }

.wbx-btn--secondary {
    background: var(--wbx-color-bg);
    color: var(--wbx-color-fg);
    border-color: var(--wbx-color-fg);
}
.wbx-btn--secondary:hover { background: var(--wbx-color-secondary); }

.wbx-btn--ghost {
    background: transparent;
    color: var(--wbx-color-fg);
    border-color: transparent;
    text-decoration: underline;
    font-weight: 400;
    padding: 0.55rem 0.6rem;
    min-height: 40px;
}
.wbx-btn--ghost:hover { background: var(--wbx-color-secondary); }

/* ==========================================================================
   Modal
   ========================================================================== */

.wbx-modal {
    position: fixed;
    inset: 0;
    z-index: var(--wbx-z-modal);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}
.wbx-modal[hidden] { display: none; }

.wbx-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.wbx-modal__dialog {
    position: relative;
    background: var(--wbx-color-bg);
    border-radius: var(--wbx-radius) var(--wbx-radius) 0 0;
    max-width: 720px;
    width: 100%;
    max-height: 92vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--wbx-shadow);
    overflow: hidden;
    animation: wbx-slide-up 0.2s ease-out;
}

@keyframes wbx-slide-up {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

/* Tablet/Desktop: zentrierter Dialog statt Bottom-Sheet */
@media (min-width: 720px) {
    .wbx-modal { align-items: center; padding: 1rem; }
    .wbx-modal__dialog { border-radius: var(--wbx-radius); max-height: calc(100vh - 2rem); }
    @keyframes wbx-slide-up { from { transform: scale(0.97); opacity: 0; } to { transform: scale(1); opacity: 1; } }
}

.wbx-modal__header {
    padding: 1.1rem 1.3rem;
    border-bottom: 1px solid var(--wbx-color-border);
}
.wbx-modal__header h2 { margin: 0; font-size: 1.1rem; }

.wbx-modal__body {
    padding: 1rem 1.3rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.wbx-modal__body > p { margin: 0 0 1rem; color: var(--wbx-color-muted); font-size: 0.9rem; }

.wbx-modal__footer {
    padding: 1rem 1.3rem;
    border-top: 1px solid var(--wbx-color-border);
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

@media (min-width: 540px) {
    .wbx-modal__footer {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        gap: 1rem;
        flex-wrap: wrap;
    }
}

.wbx-modal__links { display: flex; gap: 1rem; font-size: 0.85rem; }
.wbx-modal__links a { color: var(--wbx-color-muted); }

.wbx-modal__actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    width: 100%;
}
.wbx-modal__actions .wbx-btn {
    flex: 1 1 130px;
    min-width: 0;
}

@media (min-width: 540px) {
    .wbx-modal__actions { width: auto; }
    .wbx-modal__actions .wbx-btn { flex: 0 1 auto; }
}

/* ==========================================================================
   Kategorie / Service Liste
   ========================================================================== */

.wbx-category {
    border: 1px solid var(--wbx-color-border);
    border-radius: var(--wbx-radius);
    margin-bottom: 0.75rem;
    padding: 0.9rem 1rem;
}
.wbx-category__header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    justify-content: space-between;
}
.wbx-category__title { margin: 0 0 0.2rem; font-size: 0.95rem; }
.wbx-category__desc { margin: 0; font-size: 0.82rem; color: var(--wbx-color-muted); }

.wbx-services {
    list-style: none;
    padding: 0;
    margin: 0.75rem 0 0;
    border-top: 1px dashed var(--wbx-color-border);
}
.wbx-service { padding: 0.5rem 0; border-bottom: 1px dashed var(--wbx-color-border); }
.wbx-service:last-child { border-bottom: none; }

/* Zeile mit aufklappbaren Details (links) + Toggle (rechts) */
.wbx-service__row {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}
.wbx-service__disclose {
    flex: 1 1 auto;
    min-width: 0;
}
.wbx-toggle--service {
    flex: 0 0 auto;
    margin-top: 0.15rem;
}

.wbx-service summary {
    cursor: pointer;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0;
}
.wbx-service__tag {
    background: #fff3cd;
    color: #856404;
    padding: 0 0.4rem;
    border-radius: 3px;
    font-size: 0.72rem;
}
.wbx-service__details {
    margin: 0.5rem 0 0;
    font-size: 0.82rem;
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.25rem 0.75rem;
}
.wbx-service__details dt { font-weight: 600; color: var(--wbx-color-muted); }
.wbx-service__details dd { margin: 0; word-break: break-word; }
.wbx-service__details code { font-size: 0.78rem; }

/* Verarbeitete-Daten-Liste */
.wbx-service__data-list {
    margin: 0;
    padding-left: 1.1rem;
    font-size: 0.82rem;
}
.wbx-service__data-list li { margin-bottom: 0.15rem; }

/* Cookie-Karten (Borlabs-Style): je Cookie eine umrandete Box mit Name,
   Beschreibung, Host, Lebensdauer, Zweck, Typ in einem Key-Value-Grid. */
.wbx-service__cookies-wrap {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.wbx-cookie {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--wbx-color-border);
    padding: 0.75rem 0.9rem;
    border-radius: calc(var(--wbx-radius) / 2);
}
.wbx-cookie__details {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.2rem 0.75rem;
    font-size: 0.8rem;
    margin: 0;
}
.wbx-cookie__details dt { font-weight: 600; color: var(--wbx-color-muted); }
.wbx-cookie__details dd { margin: 0; word-break: break-word; }
.wbx-cookie__details code { font-size: 0.78rem; background: rgba(0, 0, 0, 0.06); padding: 0.05rem 0.3rem; border-radius: 3px; }

/* Widerrufsrechts-Hinweis */
.wbx-modal__legal-notice {
    padding: 0.9rem 1.3rem;
    background: rgba(0, 0, 0, 0.03);
    border-top: 1px solid var(--wbx-color-border);
    font-size: 0.82rem;
    color: var(--wbx-color-muted);
    line-height: 1.5;
}
.wbx-modal__legal-notice p { margin: 0; }
.wbx-modal__legal-notice strong { color: var(--wbx-color-fg); }
.wbx-modal__legal-notice a { color: inherit; text-decoration: underline; }

/* ==========================================================================
   Toggle
   ========================================================================== */

.wbx-toggle {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
    flex: none;
}
.wbx-toggle input { opacity: 0; width: 0; height: 0; }
.wbx-toggle__slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #cbd5e1;
    border-radius: 26px;
    transition: background 0.2s;
}
.wbx-toggle__slider::before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.wbx-toggle input:checked + .wbx-toggle__slider { background: var(--wbx-color-primary); }
.wbx-toggle input:checked + .wbx-toggle__slider::before { transform: translateX(20px); }
.wbx-toggle input:disabled + .wbx-toggle__slider { opacity: 0.6; cursor: not-allowed; }
/* BFSG/WCAG 2.1 SC 2.4.7: klar sichtbare Focus-Indikatoren, min. 3:1 Kontrast */
.wbx-toggle input:focus-visible + .wbx-toggle__slider {
    outline: 3px solid var(--wbx-color-primary);
    outline-offset: 3px;
}
.wbx-service summary:focus-visible,
.wbx-service__disclose summary:focus-visible {
    outline: 3px solid var(--wbx-color-primary);
    outline-offset: 2px;
    border-radius: 3px;
}

/* ==========================================================================
   Reopen-Badge
   ========================================================================== */

.wbx-badge {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    z-index: var(--wbx-z-badge);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--wbx-color-primary);
    color: var(--wbx-color-primary-contrast);
    border: none;
    cursor: pointer;
    box-shadow: var(--wbx-shadow);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Badge-Icon als CSS mask — theme-unabhängig, weil das SVG nie direkt
   im DOM liegt und der Theme-CSS-Selektor `svg` nicht greifen kann. */
.wbx-badge__icon {
    display: block;
    width: 22px;
    height: 22px;
    background-color: currentColor;
    -webkit-mask: url('../icons/cookie.svg') no-repeat center / contain;
            mask: url('../icons/cookie.svg') no-repeat center / contain;
}
.wbx-badge[hidden] { display: none; }
.wbx-badge:hover { transform: scale(1.05); }
.wbx-badge:focus-visible { outline: 2px solid var(--wbx-color-primary); outline-offset: 3px; }

.wbx-badge--pos-bottom-right { left: auto; right: 1rem; }

/* ==========================================================================
   Placeholder — blockierter Embed
   Grid + place-items:center ist robuster als flex (Themes können display
   überschreiben, aber grid-auto-Verhalten bleibt stabil).
   ========================================================================== */

.wbx-placeholder {
    position: relative;
    display: grid !important;
    place-items: center;
    border-radius: var(--wbx-radius);
    overflow: hidden;
    min-height: 220px;
    width: 100%;
    aspect-ratio: 16 / 9;
    background-color: var(--wbx-placeholder-bg);
    color: var(--wbx-placeholder-fg);
    isolation: isolate;
    box-sizing: border-box;
}

.wbx-placeholder[data-wbx-thumb] {
    background-image: var(--wbx-thumb);
    background-size: cover;
    background-position: center;
}

/* Blur-Layer: nutzt dieselbe CSS-Var (background-image:inherit ist
   nicht zuverlässig quer durch Browser). */
.wbx-placeholder[data-wbx-thumb]::before {
    content: "";
    position: absolute;
    inset: -12px;
    background-image: var(--wbx-thumb);
    background-size: cover;
    background-position: center;
    filter: blur(14px) brightness(0.55);
    z-index: -2;
}

/* Dunkles Overlay für Textkontrast (auf dem Blur-Thumbnail).
   Semi-transparentes Schwarz damit's auch auf hellen placeholder_bg-Werten
   funktioniert, solange ein Thumbnail drunter liegt. */
.wbx-placeholder[data-wbx-thumb]::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.6), rgba(0, 0, 0, 0.8));
    z-index: -1;
}

.wbx-placeholder__inner {
    max-width: min(90%, 520px);
    margin: 0 auto !important;
    padding: 1.75rem 1.5rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

.wbx-placeholder__icon {
    display: inline-flex;
    width: 48px;
    height: 48px;
    margin: 0 0 0.3rem;
    opacity: 0.9;
}
.wbx-placeholder__icon svg {
    width: 100%;
    height: 100%;
}

.wbx-placeholder__title {
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.3;
}
.wbx-placeholder__title strong { font-weight: 700; }

.wbx-placeholder__text {
    margin: 0 0 1.1rem;
    font-size: 0.88rem;
    line-height: 1.55;
    color: var(--wbx-placeholder-fg);
    opacity: 0.88;
}
.wbx-placeholder__third-country {
    display: block;
    margin-top: 0.5rem;
    color: #fca5a5;
    font-size: 0.8rem;
}

.wbx-placeholder__actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
}
/* Primary-Button: Text/Bg-Farben invertiert zur Placeholder-Farbe — funktioniert
   sowohl für dunkle als auch helle Placeholder-Themes. */
.wbx-placeholder__actions .wbx-btn--primary {
    background: var(--wbx-placeholder-fg);
    color: var(--wbx-placeholder-bg);
    border-color: var(--wbx-placeholder-fg);
}
.wbx-placeholder__actions .wbx-btn--ghost {
    color: var(--wbx-placeholder-fg);
    border-color: var(--wbx-placeholder-fg);
    opacity: 0.8;
    text-decoration: none;
}
.wbx-placeholder__actions .wbx-btn--ghost:hover { opacity: 1; }

.wbx-placeholder__legal {
    margin: 0.9rem 0 0;
    font-size: 0.78rem;
}
.wbx-placeholder__legal a {
    color: #93c5fd;
    text-decoration: underline;
}

/* Mobile: mehr Luft innen und außen, damit der Content nicht an den Rändern klebt */
@media (max-width: 720px) {
    .wbx-placeholder {
        min-height: 200px;
    }
    .wbx-placeholder__inner {
        max-width: 88%;
        padding: 1.75rem 1.25rem;
    }
}

@media (max-width: 480px) {
    .wbx-placeholder__inner {
        max-width: 90%;
        padding: 1.5rem 1.1rem;
    }
    .wbx-placeholder__title { font-size: 0.98rem; }
    .wbx-placeholder__text { font-size: 0.82rem; margin-bottom: 0.9rem; }
}

/* ==========================================================================
   Toast (Error-Nachricht bei fehlgeschlagenem REST)
   ========================================================================== */

.wbx-toast {
    position: fixed;
    bottom: 1.25rem;
    left: 50%;
    transform: translate(-50%, 20px);
    z-index: 100000;
    background: var(--wbx-color-accent);
    color: #ffffff;
    padding: 0.75rem 1.1rem;
    border-radius: var(--wbx-radius);
    font-family: var(--wbx-font);
    font-size: 0.9rem;
    box-shadow: var(--wbx-shadow);
    opacity: 0;
    transition: opacity 0.25s ease, transform 0.25s ease;
    max-width: 90vw;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}
.wbx-toast--visible {
    opacity: 1;
    transform: translate(-50%, 0);
}
.wbx-toast__retry {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.6);
    padding: 0.35rem 0.7rem;
    border-radius: calc(var(--wbx-radius) / 2);
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
    white-space: nowrap;
}
.wbx-toast__retry:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   Reduced motion
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .wbx-btn,
    .wbx-toggle__slider,
    .wbx-toggle__slider::before,
    .wbx-badge,
    .wbx-modal__dialog {
        transition: none;
        animation: none;
    }
}
