/* =====================================================================
   CMP (Consent Management) — gemeinsame Basis-Styles fuer ALLE Tenants.
   Aus style.css herausgeloest (Single Source of Truth), damit Voll-Custom-
   Tenants (an/sr/tv/hb) das grosse Magazin-Bundle nicht nur fuers Cookie-
   Banner laden muessen. Tenant-spezifische Button-/Akzentfarben bleiben in
   style.css (Magazin-Tenants) bzw. den Theme-Dateien (Custom-Tenants).
   Die Design-Tokens liegen auf :root als DEFAULTS (Werte = Magazin-Standard).
   Wichtig: :root (statt .cmp-banner) -> Tenant-Themes, die einzelne Tokens
   auf body.site-X umdefinieren (z.B. ct --link Bronze, md --link Cyan),
   ueberschreiben diese Defaults korrekt per Vererbung (body ist naeher als
   :root). Voll-Custom-Tenants ohne eigene Tokens bekommen die Defaults.
   ===================================================================== */
:root {
  --white: #FFFFFF; --ink: #111111; --yellow: #FFDC00; --link: #B71C4C;
  --gray-100: #F5F3EB; --gray-200: #E6E3DA; --gray-300: #C8C4BA;
  --gray-400: #969288; --gray-500: #6E6A60; --gray-600: #504C42; --gray-700: #37342C;
  --radius-md: 16px; --radius-lg: 20px;
  --brand-border-thin: 2px solid var(--ink); --brand-border: 3px solid var(--ink);
  --brand-shadow-md: 4px 4px 0 var(--ink); --brand-shadow-lg: 6px 6px 0 var(--ink);
}

/* Skip-Link (globale a11y-Chrome aus main.php; Basis lag frueher in style.css,
   die die Voll-Custom-Tenants nicht mehr laden -> hier gemeinsam). Schrift erbt
   die Body-Font des Tenants. */
.skip-link {
  position: absolute; top: -100%; left: 0;
  background: var(--yellow); color: var(--ink);
  padding: 10px 20px; font-weight: 900; font-size: 14px;
  z-index: 10000; text-decoration: none;
}
.skip-link:focus { top: 0; }

/* ---------- Banner ---------- */
.cmp-banner {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 9999;
  background: var(--white); border-top: var(--brand-border);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.12);
  padding: 20px;
}
.cmp-banner__inner { max-width: 1200px; margin: 0 auto; display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.cmp-banner__content { flex: 1; min-width: 280px; }
.cmp-banner__title { font-weight: 900; font-size: 14px; letter-spacing: 1px; display: block; margin-bottom: 6px; }
.cmp-banner__text { font-size: 13px; line-height: 1.55; color: var(--gray-700); margin: 0 0 8px; }
.cmp-banner__links { font-size: 12px; }
.cmp-banner__links a { color: var(--link); text-decoration: underline; }
.cmp-banner__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.cmp-btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 10px 20px; border-radius: 50px; border: var(--brand-border-thin);
  font-family: inherit; font-weight: 700; font-size: 12px; letter-spacing: 1px;
  text-transform: uppercase; cursor: pointer; background: var(--white); color: var(--ink);
  transition: transform 0.1s ease;
}
.cmp-btn:hover { transform: translateY(-1px); }
.cmp-btn--primary { background: var(--ink); color: var(--yellow); }
.cmp-btn--ghost { background: transparent; }
/* Equal-Choice: Ablehnen + Alles akzeptieren gleichgestellt (DSK/CNIL). */
.cmp-btn--equal { background: var(--ink); color: var(--yellow); border-color: var(--ink); }
.cmp-btn--equal:hover { background: var(--ink); color: var(--yellow); }

/* Reduced-Motion: Transitions aus fuer User mit prefers-reduced-motion. */
@media (prefers-reduced-motion: reduce) {
  .cmp-btn, .cmp-banner, .cmp-modal__dialog { transition: none; }
  .cmp-btn:hover { transform: none; }
}

/* ---------- Modal ---------- */
.cmp-modal { position: fixed; inset: 0; z-index: 10000; }
.cmp-modal[hidden] { display: none; }
.cmp-modal__overlay { position: absolute; inset: 0; background: rgba(17,17,17,0.55); }
.cmp-modal__dialog {
  position: relative; max-width: 680px; width: calc(100% - 40px);
  max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); margin: 20px auto;
  background: var(--white); border: var(--brand-border);
  border-radius: var(--radius-lg); box-shadow: var(--brand-shadow-lg);
  display: flex; flex-direction: column; overflow: hidden;
}
.cmp-modal__close {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid rgba(128,128,128,0.45);
  background: rgba(128,128,128,0.16); color: inherit; cursor: pointer; font-weight: 900; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.cmp-modal__close:hover { background: rgba(128,128,128,0.28); }
.cmp-modal__header { padding: 24px 24px 0; border-bottom: 1px solid var(--gray-200); }
.cmp-modal__title { font-weight: 900; font-size: 22px; margin: 0 0 10px; }
.cmp-modal__intro { font-size: 13px; color: var(--gray-700); line-height: 1.5; margin: 0 0 10px; }
.cmp-modal__links { font-size: 12px; margin-bottom: 16px; }
.cmp-modal__links a { color: var(--link); text-decoration: underline; margin-right: 12px; }
.cmp-modal__tabs { display: flex; gap: 0; border-bottom: 0; margin: 0 -24px; padding: 0 24px; }
.cmp-tab {
  flex: 1; padding: 14px 8px; background: none; border: 0; border-bottom: 3px solid transparent;
  font-family: inherit; font-weight: 700; font-size: 14px; cursor: pointer; color: var(--gray-500);
}
.cmp-tab.is-active { color: var(--ink); border-bottom-color: var(--ink); }

.cmp-modal__body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.cmp-tabpanel { display: none; }
.cmp-tabpanel.is-active { display: block; }

.cmp-cat, .cmp-service {
  border: 2px solid var(--gray-200); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 10px; transition: border-color 0.15s;
}
.cmp-cat:hover, .cmp-service:hover { border-color: var(--gray-300); }
.cmp-cat__head, .cmp-service__head { display: flex; align-items: flex-start; gap: 16px; }
.cmp-cat__meta, .cmp-service__meta { flex: 1; min-width: 0; }
.cmp-cat__name, .cmp-service__name { font-weight: 900; font-size: 14px; display: block; margin-bottom: 4px; }
.cmp-cat__desc { font-size: 12px; color: var(--gray-700); line-height: 1.5; margin: 0; }
.cmp-service__cat { font-size: 11px; color: var(--gray-500); }
.cmp-cat__controls, .cmp-service__controls { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.cmp-cat__services { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--gray-200); display: flex; flex-direction: column; gap: 8px; }
.cmp-cat__services[hidden], .cmp-service__detail[hidden] { display: none !important; }
.cmp-cat-service { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }

.cmp-switch { position: relative; display: inline-block; width: 40px; height: 22px; cursor: pointer; }
.cmp-switch--sm { width: 34px; height: 20px; }
.cmp-switch input { position: absolute; opacity: 0; pointer-events: none; }
.cmp-switch__track {
  position: absolute; inset: 0; background: #8b9099; border-radius: 22px; transition: background 0.2s;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.22);
}
.cmp-switch__track::before {
  content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px;
  background: #fff; border-radius: 50%; transition: transform 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.45);
}
.cmp-switch--sm .cmp-switch__track::before { width: 16px; height: 16px; }
/* AN = klar erkennbares Gruen (statt --ink, das auf dunklen Themes mit weissem Knopf unsichtbar war) */
.cmp-switch input:checked ~ .cmp-switch__track { background: #1f9d57; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.18); }
.cmp-switch input:checked ~ .cmp-switch__track::before { transform: translateX(18px); }
.cmp-switch--sm input:checked ~ .cmp-switch__track::before { transform: translateX(14px); }
.cmp-switch.is-locked { opacity: 0.5; cursor: not-allowed; }

.cmp-expand {
  background: none; border: 0; font-size: 16px; font-weight: 900;
  cursor: pointer; color: var(--ink); padding: 4px 6px;
  transition: transform 0.2s;
}

.cmp-service__detail { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--gray-200); font-size: 13px; }
.cmp-kv { margin-bottom: 14px; }
.cmp-kv__k { font-weight: 700; font-size: 12px; color: var(--gray-700); margin-bottom: 4px; }
.cmp-kv__v { font-size: 13px; line-height: 1.5; }
.cmp-kv__chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cmp-chip {
  display: inline-block; padding: 4px 10px; border-radius: 6px;
  background: var(--gray-100); font-size: 11px; font-weight: 600; color: var(--gray-700);
}
.cmp-cookies { display: flex; flex-direction: column; gap: 8px; }
.cmp-cookie { padding: 10px 12px; border: 1px solid var(--gray-200); border-radius: 8px; background: var(--gray-100); }
.cmp-cookie__head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.cmp-cookie__head strong { font-size: 13px; font-family: ui-monospace, 'SFMono-Regular', Menlo, monospace; }
.cmp-cookie__type { font-size: 10px; font-weight: 700; letter-spacing: 0.8px; color: var(--gray-500); text-transform: uppercase; }
.cmp-cookie__purpose { font-size: 12px; line-height: 1.4; color: var(--gray-700); }
.cmp-cookie__duration { font-size: 11px; color: var(--gray-500); margin-top: 2px; }

.cmp-filter { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.cmp-filter__btn {
  padding: 6px 14px; border-radius: 50px; border: 2px solid var(--gray-200);
  background: var(--white); font-family: inherit; font-weight: 600; font-size: 12px;
  cursor: pointer; color: var(--gray-700); transition: all 0.15s;
}
.cmp-filter__btn.is-active { border-color: var(--ink); color: var(--ink); background: var(--gray-100); }

.cmp-modal__footer {
  padding: 16px 24px; padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: var(--gray-100); display: flex; flex-direction: column; gap: 10px;
  border-top: var(--brand-border-thin); flex-shrink: 0;
}
.cmp-modal__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.cmp-modal__actions .cmp-btn { flex: 1; min-width: 120px; }
.cmp-modal__meta { font-size: 11px; color: var(--gray-600); text-align: center; font-family: ui-monospace, monospace; word-break: break-all; }
.cmp-modal__meta code { background: rgba(128,128,128,0.18); color: inherit; padding: 2px 6px; border-radius: 4px; }

@media (max-width: 640px) {
  .cmp-banner__inner { flex-direction: column; align-items: stretch; }
  /* Mobile: Buttons stapeln, primaerer "Alles akzeptieren"-Button oben.
     HTML-Reihenfolge bleibt (fuer a11y/Tab-Order), CSS reverse'd nur visuell. */
  .cmp-banner__actions,
  .cmp-modal__actions { flex-direction: column-reverse; flex-wrap: nowrap; gap: 10px; }
  .cmp-banner__actions .cmp-btn,
  .cmp-modal__actions .cmp-btn { flex: 0 0 auto; width: 100%; min-width: 0; }
  .cmp-modal__dialog { margin: 0; width: 100%; max-height: 100vh; max-height: 100dvh; height: 100dvh; border-radius: 0; border-width: 0; box-shadow: none; }
}
