/* ============================================================
   Devotion Consent Manager — Frontend CSS
   Prefix: devotion-  (Frontend, kein Admin-Overlap)
   CSS-Tokens: --wpdcm-* (werden via wp_add_inline_style gesetzt)
   ============================================================ */

/* ── Tokens (Fallbacks) ──────────────────────────────────── */
:root {
    --wpdcm-primary:      #1d4ed8;
    --wpdcm-secondary:    #6b7280;
    --wpdcm-text:         #111827;
    --wpdcm-text-muted:   #6b7280;
    --wpdcm-bg:           #ffffff;
    --wpdcm-bg-hover:     #f9fafb;
    --wpdcm-border:       #e5e7eb;
    --wpdcm-radius:       14px;
    --wpdcm-shadow:       0 8px 32px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.06);
    --wpdcm-font:         system-ui, -apple-system, sans-serif;
    --wpdcm-accent:       #1d4ed8;
    --wpdcm-toggle-on:    var(--wpdcm-primary);
    --wpdcm-toggle-off:   #d1d5db;
}

/* ── Freeze / Overlay ────────────────────────────────────── */
/*
 * z-index Hinweis:
 * Overlay: 99998, Banner: 99999, Floating Icon: 99997
 * Elemente auf der Website mit z-index >= 99999 können den Overlay überlappen.
 * Falls das passiert: eigenen z-index des Elements reduzieren oder
 * --wpdcm-overlay-z und --wpdcm-banner-z als CSS-Variablen überschreiben.
 */
.devotion-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 99998;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
}

.devotion-overlay.is-visible {
    opacity: 1;
    pointer-events: auto;
}

body.devotion-frozen {
    overflow: hidden;
}

/* ── Banner ──────────────────────────────────────────────── */
.devotion-banner {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(680px, 75vw);
    max-height: 85vh;
    overflow-y: auto;
    background: var(--wpdcm-bg);
    border-radius: var(--wpdcm-radius);
    box-shadow: var(--wpdcm-shadow);
    z-index: 99999;
    font-family: var(--wpdcm-font);
    font-size: 14px;
    color: var(--wpdcm-text);
    display: flex;
    flex-direction: column;
}

.devotion-banner[aria-hidden="true"],
.devotion-banner[hidden] {
    display: none;
}

/* ── Header ──────────────────────────────────────────────── */
.devotion-banner__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--wpdcm-border);
}

.devotion-banner__brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.devotion-banner__logo {
    height: 28px;
    width: auto;
    object-fit: contain;
}

.devotion-banner__logo-icon {
    width: 28px;
    height: 28px;
    background: var(--wpdcm-primary);
    color: #fff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.devotion-banner__site-name {
    font-weight: 700;
    font-size: 15px;
    color: var(--wpdcm-text);
}

.devotion-banner__badge {
    font-size: 11px;
    color: var(--wpdcm-text-muted);
    opacity: .6;
}

/* ── Tabs ────────────────────────────────────────────────── */
.devotion-banner__tabs {
    display: flex;
    gap: 2px;
    padding: 8px 12px 0;
    border-bottom: 1px solid var(--wpdcm-border);
}

.devotion-tab {
    flex: 1;
    padding: 8px 4px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 13px;
    font-weight: 500;
    color: var(--wpdcm-text-muted);
    cursor: pointer;
    transition: color .15s, border-color .15s;
    margin-bottom: -1px;
}

.devotion-tab:hover { color: var(--wpdcm-text); }

.devotion-tab.is-active {
    color: var(--wpdcm-primary);
    border-bottom-color: var(--wpdcm-primary);
}

/* ── Panel ───────────────────────────────────────────────── */
.devotion-panel {
    padding: 18px 20px;
    flex: 1;
    overflow-y: auto;
}

.devotion-panel[hidden] { display: none; }

.devotion-panel__title {
    font-size: 17px;
    font-weight: 700;
    margin: 0 0 10px;
    color: var(--wpdcm-text);
}

.devotion-panel__subtitle {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 8px;
}

.devotion-panel__intro {
    font-size: 13px;
    color: #374151;
    line-height: 1.6;
    margin: 0 0 8px;
}

.devotion-panel__notice {
    font-size: 11px;
    color: #92400e;
    background: #fef3c7;
    border-radius: 6px;
    padding: 6px 10px;
    margin: 0 0 12px;
    line-height: 1.4;
}

.devotion-panel__text {
    font-size: 13px;
    color: #374151;
    line-height: 1.6;
    margin: 0 0 14px;
}

/* ── Akkordeon ───────────────────────────────────────────── */
.devotion-accordion {
    border: 1px solid var(--wpdcm-border);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.devotion-accordion__trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 11px 14px;
    background: var(--wpdcm-bg-hover);
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--wpdcm-text);
    text-align: left;
}

.devotion-accordion__trigger:hover { background: #f3f4f6; }

.devotion-accordion__count {
    font-size: 12px;
    font-weight: 400;
    color: var(--wpdcm-text-muted);
}

.devotion-accordion__arrow {
    margin-left: auto;
    transition: transform .2s;
}

.devotion-accordion__trigger.is-open .devotion-accordion__arrow {
    transform: rotate(180deg);
}

.devotion-accordion__body {
    border-top: 1px solid var(--wpdcm-border);
    padding: 4px 0;
}

.devotion-accordion__body[hidden] { display: none; }

/* ── Kategorie-Zeile ─────────────────────────────────────── */
.devotion-category-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    gap: 12px;
}

.devotion-category-row + .devotion-category-row {
    border-top: 1px solid var(--wpdcm-border);
}

.devotion-category-info {
    flex: 1;
    min-width: 0;
}

.devotion-category-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--wpdcm-text);
    margin-bottom: 2px;
}

.devotion-category-desc {
    display: block;
    font-size: 11px;
    color: var(--wpdcm-text-muted);
    line-height: 1.4;
}

/* ── Toggle ──────────────────────────────────────────────── */
.devotion-toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex-shrink: 0;
}

.devotion-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.devotion-toggle__slider {
    position: absolute;
    inset: 0;
    background: var(--wpdcm-toggle-off);
    border-radius: 99px;
    cursor: pointer;
    transition: background .2s;
}

.devotion-toggle__slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.devotion-toggle input:checked + .devotion-toggle__slider {
    background: var(--wpdcm-toggle-on);
}

.devotion-toggle input:checked + .devotion-toggle__slider::before {
    transform: translateX(18px);
}

.devotion-toggle--locked .devotion-toggle__slider {
    opacity: .5;
    cursor: not-allowed;
}

/* ── Link-Button ─────────────────────────────────────────── */
.devotion-link-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    padding: 0;
    font-size: 12px;
    color: var(--wpdcm-primary);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.devotion-link-btn:hover { opacity: .8; }

/* ── Dienste (Tab 2) ─────────────────────────────────────── */
.devotion-service-category {
    border: 1px solid var(--wpdcm-border);
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
}

.devotion-service-category__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--wpdcm-bg-hover);
    gap: 12px;
}

.devotion-service-category__info {
    flex: 1;
    min-width: 0;
}

.devotion-service-category__info strong {
    display: block;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 2px;
}

.devotion-service-category__info span {
    font-size: 11px;
    color: var(--wpdcm-text-muted);
}

.devotion-service-category__controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.devotion-service-category__toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--wpdcm-text-muted);
    border-radius: 4px;
    transition: background .15s;
}

.devotion-service-category__toggle:hover { background: var(--wpdcm-border); }

.devotion-service-category__toggle .is-open {
    transform: rotate(180deg);
}

.devotion-service-list { padding: 8px 0; }
.devotion-service-list[hidden] { display: none; }

.devotion-service-item {
    padding: 10px 14px;
    border-top: 1px solid var(--wpdcm-border);
}

.devotion-service-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.devotion-service-table th {
    width: 110px;
    font-weight: 600;
    color: var(--wpdcm-text-muted);
    padding: 3px 0;
    vertical-align: top;
    text-align: left;
}

.devotion-service-table td {
    color: var(--wpdcm-text);
    padding: 3px 0;
}

.devotion-service-table a {
    color: var(--wpdcm-primary);
}

/* ── FAQ ─────────────────────────────────────────────────── */
.devotion-faq__item {
    border: 1px solid var(--wpdcm-border);
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
}

.devotion-faq__item summary {
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    background: var(--wpdcm-bg-hover);
    list-style: none;
    display: flex;
    justify-content: space-between;
}

.devotion-faq__item summary::-webkit-details-marker { display: none; }
.devotion-faq__item summary::after { content: '+'; }
.devotion-faq__item[open] summary::after { content: '−'; }

.devotion-faq__item p {
    padding: 10px 14px;
    font-size: 13px;
    color: #374151;
    margin: 0;
    line-height: 1.6;
    border-top: 1px solid var(--wpdcm-border);
}

/* ── Footer Buttons ──────────────────────────────────────── */
.devotion-banner__footer {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 20px 10px;
    border-top: 1px solid var(--wpdcm-border);
}

.devotion-btn {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: opacity .15s, transform .1s;
    font-family: var(--wpdcm-font);
}

.devotion-btn:active { transform: scale(.99); }

.devotion-btn--primary {
    background: var(--wpdcm-accent);
    color: #fff;
}

.devotion-btn--primary:hover { opacity: .9; }

.devotion-btn--secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid var(--wpdcm-border);
}

.devotion-btn--secondary:hover { background: #e5e7eb; }

.devotion-btn--settings {
    background: transparent;
    color: var(--wpdcm-primary);
    border: 1px solid var(--wpdcm-primary);
}

.devotion-btn--settings:hover { background: #eff6ff; }

/* ── Footer-Leiste ───────────────────────────────────────── */
.devotion-banner__bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    font-size: 11px;
    color: var(--wpdcm-text-muted);
    border-top: 1px solid var(--wpdcm-border);
}

.devotion-banner__bar nav {
    display: flex;
    gap: 12px;
}

/* Breakdance und andere Theme/Builder CSS Overrides verhindern */
#devotion-consent-banner a,
#devotion-consent-banner .devotion-banner__bar a,
#devotion-consent-banner .devotion-link-btn {
    color: var(--wpdcm-primary) !important;
    text-decoration: none !important;
}

#devotion-consent-banner .devotion-banner__bar a {
    color: var(--wpdcm-text-muted) !important;
}

#devotion-consent-banner a:hover,
#devotion-consent-banner .devotion-banner__bar a:hover {
    text-decoration: underline !important;
}

/* ── Floating Icon ───────────────────────────────────────── */
.devotion-floating-icon {
    position: fixed;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--wpdcm-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(0,0,0,.2);
    z-index: 99997;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s, transform .2s;
    transform: scale(.8);
}

.devotion-floating-icon.is-visible {
    opacity: 1;
    pointer-events: auto;
    transform: scale(1);
}

.devotion-floating-icon:hover { transform: scale(1.08); }
.devotion-floating-icon:active { transform: scale(.95); }

/* ── iFrame Platzhalter ──────────────────────────────────── */
.devotion-iframe-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border: 2px dashed var(--wpdcm-border);
    border-radius: 8px;
    min-height: 200px;
    padding: 24px;
}

.devotion-iframe-accept {
    padding: 10px 20px;
    background: var(--wpdcm-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.devotion-iframe-accept:hover { opacity: .9; }

/* ── Shortcode Button ────────────────────────────────────── */
.devotion-consent-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--wpdcm-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.devotion-consent-btn:hover { opacity: .9; }

/* ── Cookie-Tabelle (Shortcode) ──────────────────────────── */
.devotion-cookie-table-wrap { margin: 1.5em 0; }
.devotion-ct-category { font-size: 18px; font-weight: 700; margin: 1.5em 0 .4em; }
.devotion-ct-desc { font-size: 13px; color: #6b7280; margin-bottom: .8em; }
.devotion-ct-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.devotion-ct-table th {
    background: #f9fafb;
    padding: 8px 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 2px solid #e5e7eb;
}
.devotion-ct-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: top;
}

/* ── Compact Mode (Freeze-Ausnahmen: Impressum, Datenschutz etc.) ────── */
.devotion-banner--compact {
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    top: auto !important;
    transform: none !important;
    border-radius: var(--wpdcm-radius) var(--wpdcm-radius) 0 0 !important;
    max-height: 120px !important;
    overflow: hidden !important;
    flex-direction: row !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: 12px !important;
    padding: 14px 24px !important;
}

.devotion-banner--compact .devotion-banner__header,
.devotion-banner--compact .devotion-banner__tabs,
.devotion-banner--compact .devotion-panel:not(.is-active),
.devotion-banner--compact .devotion-banner__bar {
    display: none !important;
}

.devotion-banner--compact .devotion-panel.is-active {
    padding: 0 !important;
    flex: 1 !important;
    min-width: 200px !important;
    overflow: visible !important;
}

.devotion-banner--compact .devotion-panel__title {
    font-size: 14px !important;
    margin: 0 !important;
}

.devotion-banner--compact .devotion-panel__intro {
    font-size: 12px !important;
    margin: 2px 0 0 !important;
    color: #6b7280 !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
}

.devotion-banner--compact .devotion-accordion,
.devotion-banner--compact .devotion-link-btn {
    display: none !important;
}

.devotion-banner--compact .devotion-banner__footer {
    border: none !important;
    padding: 0 !important;
    display: flex !important;
    flex-direction: row !important;
    gap: 8px !important;
    flex-wrap: wrap !important;
    flex-shrink: 0 !important;
}

.devotion-banner--compact .devotion-btn {
    width: auto !important;
    padding: 9px 18px !important;
    font-size: 13px !important;
}

/* Mobile: Stack bei kleinem Viewport */
@media (max-width: 600px) {
    .devotion-banner--compact {
        flex-direction: column !important;
        align-items: flex-start !important;
        padding: 12px 16px !important;
    }
    .devotion-banner--compact .devotion-banner__footer {
        width: 100% !important;
    }
    .devotion-banner--compact .devotion-btn {
        flex: 1 !important;
    }
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 600px) {
    .devotion-banner:not(.devotion-banner--compact) {
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        transform: none;
        width: 100%;
        border-radius: var(--wpdcm-radius) var(--wpdcm-radius) 0 0;
        max-height: 85vh;
    }
}
