/* Finconext Consent Banner — self-built, Google Consent Mode v2.
   Optik angelehnt an Usercentrics-GDPR-Stil, ohne Branding.
   Variablen mit Fallbacks, damit Banner auf jeder Subdomain funktioniert. */

.fc-consent-root {
  /* Banner-Akzentfarbe ist immer Finconext-Marke (#143566) — unabhängig vom
     Advisor, dessen Markenfarbe (--agent-color) die Produktseite einfärbt. */
  --fc-accent: #143566;
  --fc-accent-contrast: #ffffff;
  --fc-surface: var(--surface, #ffffff);
  --fc-text: var(--text, #1d1d1f);
  --fc-text-muted: var(--text-muted, #515154);
  --fc-border: var(--border, #d2d2d7);
  --fc-overlay: rgba(0, 0, 0, 0.55);
  --fc-neutral-bg: #f5f5f7;
  --fc-neutral-bg-hover: #e8e8ed;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--fc-text);
}

.fc-consent-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483646;
  display: flex;
  opacity: 0;
  transition: opacity 200ms ease-out;
}
.fc-consent-overlay.is-visible { opacity: 1; }

/* Modal-Variante: zentriert mit abgedunkeltem Backdrop. */
.fc-consent-overlay--modal {
  background: var(--fc-overlay);
  align-items: center;
  justify-content: center;
  padding: 16px;
}

/* Corner-Variante: unten links, kein Backdrop, Seite bleibt bedienbar. */
.fc-consent-overlay--corner {
  background: transparent;
  pointer-events: none; /* Klicks fallen auf die Seite durch ... */
  align-items: flex-end;
  justify-content: flex-start;
  padding: 16px;
}
.fc-consent-overlay--corner .fc-consent-card {
  pointer-events: auto; /* ... außer auf der Karte selbst. */
  max-width: 420px;
}

.fc-consent-card {
  background: var(--fc-surface);
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 24px;
  transform: translateY(12px) scale(0.98);
  opacity: 0;
  transition: transform 200ms ease-out, opacity 200ms ease-out;
}
.fc-consent-overlay.is-visible .fc-consent-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Auf Mobil belegt auch die Corner-Variante fast die volle Breite. */
@media (max-width: 520px) {
  .fc-consent-overlay--corner {
    padding: 12px;
    align-items: flex-end;
    justify-content: stretch;
  }
  .fc-consent-overlay--corner .fc-consent-card {
    max-width: none;
  }
}

.fc-consent-card__title {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--fc-text);
}

.fc-consent-card__text {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--fc-text-muted);
}

.fc-consent-card__text a {
  color: var(--fc-accent);
  text-decoration: underline;
}


/* Buttons */
.fc-consent-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 16px;
}
.fc-consent-actions__settings {
  grid-column: 1 / -1;
}
.fc-consent-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  font-family: inherit;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.fc-consent-btn:focus-visible {
  outline: 2px solid var(--fc-accent);
  outline-offset: 2px;
}
.fc-consent-btn--primary {
  background: var(--fc-accent);
  color: var(--fc-accent-contrast);
}
.fc-consent-btn--primary:hover { filter: brightness(0.94); }
.fc-consent-btn--secondary {
  background: var(--fc-neutral-bg);
  color: var(--fc-text);
}
.fc-consent-btn--secondary:hover { background: var(--fc-neutral-bg-hover); }
.fc-consent-btn--ghost {
  background: transparent;
  color: var(--fc-text);
  border-color: var(--fc-border);
}
.fc-consent-btn--ghost:hover { background: var(--fc-neutral-bg); }

/* Settings list */
.fc-consent-categories {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--fc-border);
}
.fc-consent-category {
  padding: 14px 0;
  border-bottom: 1px solid var(--fc-border);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}
.fc-consent-category__name {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 600;
  color: var(--fc-text);
}
.fc-consent-category__desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--fc-text-muted);
}

/* iOS-style toggle */
.fc-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  flex: 0 0 44px;
}
.fc-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}
.fc-toggle__slider {
  position: absolute;
  inset: 0;
  background: #c7c7cc;
  border-radius: 999px;
  transition: background-color 160ms ease;
  cursor: pointer;
}
.fc-toggle__slider::before {
  content: "";
  position: absolute;
  width: 22px;
  height: 22px;
  left: 2px;
  top: 2px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  transition: transform 160ms ease;
}
.fc-toggle input:checked + .fc-toggle__slider { background: var(--fc-accent); }
.fc-toggle input:checked + .fc-toggle__slider::before { transform: translateX(18px); }
.fc-toggle input:focus-visible + .fc-toggle__slider {
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}
.fc-toggle input:disabled + .fc-toggle__slider { opacity: 0.7; cursor: not-allowed; }

/* Header for settings step */
.fc-consent-settings__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.fc-consent-settings__head .fc-consent-card__title {
  margin: 0;
  flex: 1;
}
.fc-consent-close {
  background: none;
  border: 0;
  padding: 4px 8px;
  margin: -4px -8px 0 0;
  font: inherit;
  font-size: 18px;
  line-height: 1;
  color: var(--fc-text-muted);
  cursor: pointer;
}
.fc-consent-close:hover { color: var(--fc-text); }
.fc-consent-close:focus-visible {
  outline: 2px solid var(--fc-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Inline legal links below the settings intro */
.fc-consent-settings__legal {
  margin: 4px 0 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
}
.fc-consent-settings__legal a {
  color: var(--fc-text);
  text-decoration: none;
}
.fc-consent-settings__legal a:hover { text-decoration: underline; }

/* Footer with legal links */
.fc-consent-footer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--fc-border);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 12px;
  color: var(--fc-text-muted);
}
.fc-consent-footer a {
  color: var(--fc-text-muted);
  text-decoration: underline;
}
.fc-consent-footer a:hover { color: var(--fc-text); }

/* Mobile */
@media (max-width: 520px) {
  .fc-consent-card { padding: 20px; }
  .fc-consent-actions,
  .fc-consent-actions--three {
    grid-template-columns: 1fr;
  }
  .fc-consent-actions__settings { grid-column: auto; }
  .fc-consent-btn { width: 100%; }
  .fc-consent-card__title { font-size: 18px; }
}

/* Tabs (Kategorien | Dienste) */
.fc-consent-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-bottom: 1px solid var(--fc-border);
  margin: 8px 0 12px;
}
.fc-consent-tab {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  padding: 10px 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--fc-text-muted);
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease;
}
.fc-consent-tab:hover { color: var(--fc-text); }
.fc-consent-tab.is-active {
  color: var(--fc-accent);
  border-bottom-color: var(--fc-accent);
  font-weight: 600;
}
.fc-consent-tab:focus-visible {
  outline: 2px solid var(--fc-accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Three-button action row */
.fc-consent-actions--three {
  grid-template-columns: 1fr 1fr 1fr;
}

/* Services list */
.fc-consent-services {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fc-consent-service {
  border: 1px solid var(--fc-border);
  border-radius: 8px;
  background: var(--fc-surface);
  overflow: hidden;
  transition: border-color 120ms ease;
}
.fc-consent-service.is-open { border-color: var(--fc-accent); }
.fc-consent-service__summary {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: none;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--fc-text);
}
.fc-consent-service__summary:hover { background: var(--fc-neutral-bg); }
.fc-consent-service__summary:focus-visible {
  outline: 2px solid var(--fc-accent);
  outline-offset: -2px;
}
.fc-consent-service__meta { min-width: 0; }
.fc-consent-service__name {
  margin: 0 0 2px;
  font-size: 14px;
  font-weight: 600;
  color: var(--fc-text);
}
.fc-consent-service__cat {
  margin: 0;
  font-size: 12px;
  color: var(--fc-text-muted);
}
.fc-consent-service__controls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}
.fc-consent-service__chev {
  font-size: 16px;
  line-height: 1;
  color: var(--fc-text-muted);
  transition: transform 160ms ease;
}
.fc-consent-service.is-open .fc-consent-service__chev {
  transform: rotate(180deg);
}
.fc-consent-service__details {
  padding: 0 14px 14px;
  border-top: 1px solid var(--fc-border);
  background: #fafafa;
}
.fc-consent-service__desc,
.fc-consent-service__provider {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--fc-text-muted);
}
.fc-consent-service__provider { font-size: 12px; }

/* Expandable categories (with sub-services inside) */
.fc-consent-cats {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.fc-consent-cat {
  border: 1px solid var(--fc-border);
  border-radius: 8px;
  background: var(--fc-surface);
  overflow: hidden;
  transition: border-color 120ms ease;
}
.fc-consent-cat.is-open { border-color: var(--fc-accent); }
.fc-consent-cat__summary {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: none;
  border: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: var(--fc-text);
}
.fc-consent-cat__summary:hover { background: var(--fc-neutral-bg); }
.fc-consent-cat__summary:focus-visible {
  outline: 2px solid var(--fc-accent);
  outline-offset: -2px;
}
.fc-consent-cat__meta { min-width: 0; flex: 1; }
.fc-consent-cat__name {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 700;
  color: var(--fc-text);
}
.fc-consent-cat__desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--fc-text-muted);
}
.fc-consent-cat__controls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
  padding-top: 2px;
}
.fc-consent-cat__chev {
  font-size: 16px;
  line-height: 1;
  color: var(--fc-text-muted);
  transition: transform 160ms ease;
}
.fc-consent-cat.is-open .fc-consent-cat__chev {
  transform: rotate(180deg);
}
.fc-consent-cat__details {
  border-top: 1px solid var(--fc-border);
  background: #fafafa;
  padding: 6px 14px 10px;
}
.fc-consent-cat__empty {
  margin: 10px 0 4px;
  font-size: 12px;
  color: var(--fc-text-muted);
}

/* Sub-services inside an expanded category */
.fc-consent-subservices {
  list-style: none;
  margin: 0;
  padding: 0;
}
.fc-consent-subservice {
  border-bottom: 1px solid var(--fc-border);
  padding: 10px 0;
}
.fc-consent-subservice:last-child { border-bottom: 0; }
.fc-consent-subservice__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.fc-consent-subservice__name {
  font-size: 14px;
  color: var(--fc-text);
}
.fc-consent-subservice__ctrls {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex: 0 0 auto;
}
.fc-consent-subservice__info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1px solid var(--fc-border);
  background: var(--fc-surface);
  color: var(--fc-text-muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.fc-consent-subservice__info:hover {
  color: var(--fc-text);
  border-color: var(--fc-text-muted);
}
.fc-consent-subservice__info[aria-expanded="true"] {
  color: var(--fc-accent);
  border-color: var(--fc-accent);
}
.fc-consent-subservice__desc {
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--fc-surface);
  border: 1px solid var(--fc-border);
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--fc-text-muted);
}
.fc-consent-subservice__desc p { margin: 0; }
.fc-consent-subservice__desc p + p { margin-top: 6px; }
.fc-consent-subservice__provider { font-style: italic; }

/* Small toggle variant (for sub-services) */
.fc-toggle--sm {
  width: 36px;
  height: 22px;
  flex-basis: 36px;
}
.fc-toggle--sm .fc-toggle__slider::before {
  width: 18px;
  height: 18px;
}
.fc-toggle--sm input:checked + .fc-toggle__slider::before {
  transform: translateX(14px);
}

/* Strukturierte Metadaten pro Dienst (Anbieter, Rechtsgrundlage, Speicherdauer, Drittland) */
.fc-consent-svc-meta {
  margin: 8px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: minmax(110px, max-content) 1fr;
  column-gap: 10px;
  row-gap: 4px;
  font-size: 12px;
  line-height: 1.45;
}
.fc-consent-svc-meta dt {
  color: var(--fc-text-muted);
  margin: 0;
}
.fc-consent-svc-meta dd {
  margin: 0;
  color: var(--fc-text);
}
@media (max-width: 520px) {
  .fc-consent-svc-meta {
    grid-template-columns: 1fr;
    row-gap: 2px;
  }
  .fc-consent-svc-meta dt {
    margin-top: 4px;
    font-weight: 600;
  }
}

/* Hide helper */
.fc-consent-hidden { display: none !important; }
