/**
 * Adelstein Consent Dialog — Styles
 *
 * DSGVO-konform: Alle Buttons gleichwertig gestaltet (kein Dark Pattern).
 * Bottom-Bar-Layout mit Slide-up-Animation.
 * Theming über Custom Properties.
 *
 * @package Adelstein_Consent
 */

:root {
  /* Adelstein Editorial Theme — Gold-Akzente, warmes Papier */
  --ac-accent: #8b7335;
  --ac-accent-hover: #7a6530;
  --ac-contrast: #ffffff;
  --ac-bg: #f7f2eb;
  --ac-bg-secondary: #f2ede4;
  --ac-text: #1a1a1a;
  --ac-text-secondary: #6a6258;
  --ac-border: #e0dbd3;
  --ac-radius: 2px;
  --ac-shadow: 0 -1px 12px rgba(0, 0, 0, 0.1);
  --ac-font: "Source Serif 4", "Source Serif Fallback", Georgia, serif;
  --ac-font-display: "Playfair Display", "Playfair Fallback", Georgia, serif;
  --ac-font-size: 14px;
  --ac-z-index: 99999;
  --ac-max-width: 540px;
  --ac-overlay-bg: rgba(17, 17, 17, 0.35);
  --ac-toggle-width: 44px;
  --ac-toggle-height: 24px;
  --ac-toggle-bg: #d4b87c;
  --ac-toggle-bg-active: #8b7335;
  --ac-toggle-knob: #ffffff;
  --ac-focus-ring: 0 0 0 3px rgba(122, 101, 48, 0.3);
}

/* Dark Theme */
[data-theme="dark"] {
  --ac-accent: #c4a265;
  --ac-accent-hover: #d4b87c;
  --ac-contrast: #141210;
  --ac-bg: #1e1b17;
  --ac-bg-secondary: #1c1916;
  --ac-text: #e8e2d8;
  --ac-text-secondary: #978b7b;
  --ac-border: #2e2921;
  --ac-shadow: 0 -1px 16px rgba(0, 0, 0, 0.4);
  --ac-overlay-bg: rgba(10, 10, 10, 0.5);
  --ac-toggle-bg: #2e2921;
  --ac-toggle-bg-active: #c4a265;
  --ac-toggle-knob: #141210;
  --ac-focus-ring: 0 0 0 3px rgba(212, 184, 124, 0.3);
}

/* High Contrast Theme (BFSG) */
[data-theme="contrast"] {
  --ac-accent: #daa520;
  --ac-accent-hover: #ffd700;
  --ac-contrast: #000000;
  --ac-bg: #111111;
  --ac-bg-secondary: #000000;
  --ac-text: #ffffff;
  --ac-text-secondary: #cccccc;
  --ac-border: #444444;
  --ac-shadow: 0 0 0 1px #444;
  --ac-overlay-bg: rgba(0, 0, 0, 0.7);
  --ac-toggle-bg: #444444;
  --ac-toggle-bg-active: #ffd700;
  --ac-toggle-knob: #000000;
  --ac-focus-ring: 0 0 0 3px rgba(255, 215, 0, 0.5);
}

/* ================================================================
   Overlay — Bottom-aligned mit Backdrop-Blur
   ================================================================ */

.adelstein-consent-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: var(--ac-z-index);
  background: var(--ac-overlay-bg);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  font-family: var(--ac-font);
  font-size: var(--ac-font-size);
  line-height: 1.5;
  color: var(--ac-text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Slide-up Animation */
@keyframes ac-slide-up {
  from {
    transform: translateY(100%);
    opacity: 0.8;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes ac-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.adelstein-consent-overlay {
  animation: ac-fade-in 0.3s ease-out;
}

/* ================================================================
   Dialog-Box — Full-width Bottom Bar
   ================================================================ */

.adelstein-consent-box {
  background: var(--ac-bg);
  border-radius: 6px 6px 0 0;
  box-shadow: var(--ac-shadow);
  border-top: 2px solid var(--ac-accent);
  width: 100%;
  max-width: 100%;
  max-height: 40vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: ac-slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ================================================================
   Header
   ================================================================ */

.adelstein-consent-header {
  padding: 20px 32px 0;
  flex-shrink: 0;
}

.adelstein-consent-header h2 {
  margin: 0;
  font-family: var(--ac-font-display);
  font-size: 18px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ac-text);
}

/* ================================================================
   Body
   ================================================================ */

.adelstein-consent-body {
  padding: 12px 32px;
  overflow-y: auto;
  flex: 1 1 auto;
  -webkit-overflow-scrolling: touch;
}

.adelstein-consent-description {
  margin: 0 0 8px;
  color: var(--ac-text-secondary);
  font-size: 13px;
  line-height: 1.6;
  max-width: 80ch;
}

/* ================================================================
   Service-Gruppen (Detail-Ansicht)
   ================================================================ */

.adelstein-consent-group {
  border: 1px solid var(--ac-border);
  border-radius: var(--ac-radius);
  margin-bottom: 8px;
  overflow: hidden;
}

.adelstein-consent-group:last-child {
  margin-bottom: 0;
}

.adelstein-consent-group-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: var(--ac-bg-secondary);
  cursor: pointer;
  border: none;
  width: 100%;
  text-align: left;
  font: inherit;
  color: inherit;
  -webkit-appearance: none;
  appearance: none;
  min-height: 44px;
}

.adelstein-consent-group-header:focus-visible {
  outline: none;
  box-shadow: inset var(--ac-focus-ring);
}

.adelstein-consent-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.adelstein-consent-arrow svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.adelstein-consent-arrow--open {
  transform: rotate(90deg);
}

.adelstein-consent-group-info {
  flex: 1;
  min-width: 0;
}

.adelstein-consent-group-name {
  font-weight: 600;
  font-size: var(--ac-font-size);
  display: block;
}

.adelstein-consent-group-count {
  font-size: 12px;
  color: var(--ac-text-secondary);
  display: block;
  margin-top: 2px;
}

.adelstein-consent-group-toggle-wrapper {
  flex-shrink: 0;
}

/* ================================================================
   Toggle Switch (CSS-only, iOS-Stil)
   ================================================================ */

.adelstein-consent-toggle {
  position: relative;
  display: inline-block;
  width: var(--ac-toggle-width);
  height: var(--ac-toggle-height);
}

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

.adelstein-consent-toggle-track {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--ac-toggle-bg);
  border-radius: calc(var(--ac-toggle-height) / 2);
  transition: background-color 0.2s ease;
}

.adelstein-consent-toggle-track::after {
  content: "";
  position: absolute;
  width: calc(var(--ac-toggle-height) - 4px);
  height: calc(var(--ac-toggle-height) - 4px);
  left: 2px;
  bottom: 2px;
  background: var(--ac-toggle-knob);
  border-radius: 50%;
  transition: transform 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.adelstein-consent-toggle input:checked + .adelstein-consent-toggle-track {
  background: var(--ac-toggle-bg-active);
}

.adelstein-consent-toggle
  input:checked
  + .adelstein-consent-toggle-track::after {
  transform: translateX(calc(var(--ac-toggle-width) - var(--ac-toggle-height)));
}

.adelstein-consent-toggle
  input:focus-visible
  + .adelstein-consent-toggle-track {
  box-shadow: var(--ac-focus-ring);
}

/* Deaktiviert (essenziell — nicht änderbar) */
.adelstein-consent-toggle input:disabled + .adelstein-consent-toggle-track {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ================================================================
   Services innerhalb einer Gruppe
   ================================================================ */

.adelstein-consent-group-services {
  border-top: 1px solid var(--ac-border);
}

.adelstein-consent-service {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--ac-border);
}

.adelstein-consent-service:last-child {
  border-bottom: none;
}

.adelstein-consent-service-info {
  flex: 1;
  min-width: 0;
}

.adelstein-consent-service-name {
  font-weight: 500;
  font-size: var(--ac-font-size);
  display: block;
  margin-bottom: 2px;
}

.adelstein-consent-service-desc {
  font-size: 12px;
  color: var(--ac-text-secondary);
  line-height: 1.4;
  display: block;
  margin-bottom: 4px;
}

.adelstein-consent-service-cookie {
  font-size: 11px;
  color: var(--ac-text-secondary);
  display: block;
}

.adelstein-consent-service-cookie span {
  margin-right: 12px;
}

.adelstein-consent-service-toggle-wrapper {
  flex-shrink: 0;
  padding-top: 2px;
}

/* ================================================================
   Footer (Buttons) — Compact horizontal layout
   ================================================================ */

.adelstein-consent-footer {
  padding: 12px 32px;
  flex-shrink: 0;
  border-top: 1px solid var(--ac-border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.adelstein-consent-buttons {
  display: flex;
  gap: 10px;
}

/* DSGVO: Alle primären Buttons IDENTISCH gestaltet — kein Dark Pattern */
.adelstein-consent-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 22px;
  border: 2px solid var(--ac-accent);
  border-radius: 3px;
  font-family:
    "Inter",
    "Inter Fallback",
    -apple-system,
    BlinkMacSystemFont,
    sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  cursor: pointer;
  transition:
    background-color 0.15s ease,
    color 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease;
  min-height: 44px;
  min-width: 44px;
  text-decoration: none;
  white-space: nowrap;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.adelstein-consent-btn:focus-visible {
  outline: none;
  box-shadow: var(--ac-focus-ring);
}

/* Primärer Button (Alle akzeptieren + Nur Essentiell — DSGVO-gleichwertig) */
.adelstein-consent-btn--primary {
  background: var(--ac-accent);
  color: var(--ac-contrast);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12);
}

.adelstein-consent-btn--primary:hover {
  background: var(--ac-accent-hover);
  border-color: var(--ac-accent-hover);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
}

/* Outline-Button (Auswahl speichern — Detail-Ansicht) */
.adelstein-consent-btn--outline {
  background: transparent;
  color: var(--ac-accent);
}

.adelstein-consent-btn--outline:hover {
  background: var(--ac-bg-secondary);
}

/* ================================================================
   Einstellungen-Link — Inline neben Buttons
   ================================================================ */

.adelstein-consent-settings-link {
  color: var(--ac-text-secondary);
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 8px;
  font-family: var(--ac-font);
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.adelstein-consent-settings-link:hover {
  color: var(--ac-text);
}

.adelstein-consent-settings-link:focus-visible {
  outline: none;
  box-shadow: var(--ac-focus-ring);
  border-radius: 4px;
}

/* Zurück-Link in Detail-Ansicht */
.adelstein-consent-back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--ac-text-secondary);
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  padding: 4px 0;
  font-family: var(--ac-font);
  margin-bottom: 12px;
  min-height: 44px;
}

.adelstein-consent-back-link:hover {
  color: var(--ac-text);
}

.adelstein-consent-back-link:focus-visible {
  outline: none;
  box-shadow: var(--ac-focus-ring);
  border-radius: 4px;
}

/* ================================================================
   Links (Datenschutz, Impressum)
   ================================================================ */

.adelstein-consent-links {
  padding: 8px 32px 14px;
  display: flex;
  justify-content: flex-start;
  gap: 16px;
  flex-shrink: 0;
}

.adelstein-consent-links a {
  color: var(--ac-text-secondary);
  font-size: 12px;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.adelstein-consent-links a:hover {
  color: var(--ac-text);
}

.adelstein-consent-links a:focus-visible {
  outline: none;
  box-shadow: var(--ac-focus-ring);
  border-radius: 2px;
}

/* ================================================================
   Responsive (<600px): Kompaktere Abstände, Buttons stapeln
   ================================================================ */

@media (max-width: 599px) {
  .adelstein-consent-box {
    max-height: 55vh;
    border-radius: 6px 6px 0 0;
  }

  .adelstein-consent-header {
    padding: 16px 16px 0;
  }

  .adelstein-consent-body {
    padding: 10px 16px;
  }

  .adelstein-consent-footer {
    padding: 12px 16px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .adelstein-consent-buttons {
    flex-direction: column;
    gap: 8px;
  }

  .adelstein-consent-btn {
    width: 100%;
    justify-content: center;
  }

  .adelstein-consent-settings-link {
    justify-content: center;
    width: 100%;
  }

  .adelstein-consent-links {
    padding: 4px 16px 12px;
    justify-content: center;
  }
}

/* ================================================================
   Desktop (>900px): Horizontales Kompakt-Layout
   ================================================================ */

@media (min-width: 900px) {
  .adelstein-consent-box {
    max-height: 40vh;
  }

  .adelstein-consent-description {
    margin-bottom: 4px;
  }
}
