/*!
 * Amplione Consent v1.0 — Styles
 *
 * WCAG 2.2 AA:
 * - Touch-Targets min 44x44px
 * - Contrast >= 4.5:1
 * - Focus-Outlines sichtbar (2px, 4.5:1 Kontrast)
 * - prefers-reduced-motion respektiert
 * - Keine Farbe-als-einziger-Informationstraeger
 */

/* CSS-Variablen (ueberschreibbar via data-config) */
.amp-banner, .amp-settings-overlay, .amp-float-btn {
  --amp-primary: #f14610;
  --amp-primary-hover: #d13d0d;
  --amp-bg: #ffffff;
  --amp-text: #1e293b;
  --amp-text-muted: #64748b;
  --amp-border: #e2e8f0;
  --amp-radius: 12px;
  --amp-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  --amp-focus-ring: 0 0 0 3px rgba(241, 70, 16, 0.35);

  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--amp-text);
  box-sizing: border-box;
}

.amp-banner *, .amp-banner *::before, .amp-banner *::after,
.amp-settings-overlay *, .amp-settings-overlay *::before, .amp-settings-overlay *::after {
  box-sizing: border-box;
}

/* ───────────────────────── Layer 1: Banner ───────────────────────── */

.amp-banner {
  position: fixed;
  z-index: 2147483600;
  background: var(--amp-bg);
  border-radius: var(--amp-radius) var(--amp-radius) 0 0;
  box-shadow: var(--amp-shadow);
  border-top: 1px solid var(--amp-border);
  padding: 24px;
  max-width: 760px;
  animation: amp-slide-up 280ms cubic-bezier(0.2, 0.9, 0.3, 1);
}

.amp-banner.amp-position-bottom-bar {
  bottom: 16px;
  left: 16px;
  right: 16px;
  margin: 0 auto;
  border-radius: var(--amp-radius);
}

.amp-banner.amp-position-bottom-sheet {
  bottom: 0;
  left: 0;
  right: 0;
  max-width: none;
  border-radius: var(--amp-radius) var(--amp-radius) 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}

.amp-banner.amp-position-center-modal {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: var(--amp-radius);
}

.amp-banner-inner {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.amp-banner-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--amp-text);
  letter-spacing: -0.01em;
}

.amp-banner-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--amp-text-muted);
}

.amp-gpc-notice {
  margin: 0;
  padding: 10px 12px;
  background: #f0fdf4;
  border-left: 3px solid #16a34a;
  border-radius: 6px;
  font-size: 13px;
  color: #15803d;
}

.amp-banner-links {
  margin: 0;
  font-size: 13px;
  color: var(--amp-text-muted);
}
.amp-banner-links a {
  color: var(--amp-text-muted);
  text-decoration: underline;
}
.amp-banner-links a:hover { color: var(--amp-text); }
.amp-banner-links a:focus-visible { outline: none; box-shadow: var(--amp-focus-ring); border-radius: 2px; }

.amp-btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.amp-btn {
  flex: 1;
  min-width: 130px;
  min-height: 44px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  border-radius: calc(var(--amp-radius) / 2);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, box-shadow 0.15s, border-color 0.15s;
  text-align: center;
  line-height: 1.3;
}

.amp-btn-primary {
  background: var(--amp-primary);
  color: #ffffff;
  border-color: var(--amp-primary);
}
.amp-btn-primary:hover { background: var(--amp-primary-hover); border-color: var(--amp-primary-hover); }
.amp-btn-primary:focus-visible { outline: none; box-shadow: var(--amp-focus-ring); }

.amp-btn-secondary {
  background: transparent;
  color: var(--amp-text);
  border-color: var(--amp-border);
}
.amp-btn-secondary:hover { background: #f8fafc; border-color: #cbd5e1; }
.amp-btn-secondary:focus-visible { outline: none; box-shadow: var(--amp-focus-ring); }

.amp-branding {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--amp-border);
  font-size: 11px;
  color: var(--amp-text-muted);
  text-align: center;
}
.amp-branding a {
  color: var(--amp-text-muted);
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 0.15s;
}
.amp-branding a:hover { opacity: 1; text-decoration: underline; }
.amp-branding a:focus-visible { outline: none; box-shadow: var(--amp-focus-ring); border-radius: 2px; }

/* ───────────────────────── Layer 2: Settings Modal ───────────────────────── */

.amp-settings-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 2147483610;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: amp-fade-in 200ms;
}

.amp-settings-modal {
  background: var(--amp-bg);
  border-radius: var(--amp-radius);
  max-width: 720px;
  width: 100%;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  box-shadow: var(--amp-shadow);
  display: flex;
  flex-direction: column;
  animation: amp-scale-up 240ms cubic-bezier(0.2, 0.9, 0.3, 1);
}

.amp-settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--amp-border);
  position: sticky;
  top: 0;
  background: var(--amp-bg);
  z-index: 1;
}
.amp-settings-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--amp-text);
}

.amp-close {
  background: none;
  border: none;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: var(--amp-text-muted);
  padding: 4px 12px;
  min-height: 44px;
  min-width: 44px;
  border-radius: 8px;
  transition: background 0.15s;
}
.amp-close:hover { background: #f8fafc; color: var(--amp-text); }
.amp-close:focus-visible { outline: none; box-shadow: var(--amp-focus-ring); }

.amp-settings-intro {
  padding: 16px 24px 0;
  margin: 0;
  font-size: 14px;
  color: var(--amp-text-muted);
}

/* Category */
.amp-category {
  padding: 16px 24px;
  border-bottom: 1px solid var(--amp-border);
}
.amp-category:last-of-type { border-bottom: none; }

.amp-category-header { margin-bottom: 6px; }

.amp-category-label {
  display: block;
  cursor: pointer;
}
.amp-category-name-row {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}
.amp-category-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--amp-text);
}
.amp-category-desc {
  margin: 4px 0 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--amp-text-muted);
}

/* Toggle-Switch */
.amp-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.amp-toggle input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 44px;
  height: 24px;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}
.amp-toggle input[type="checkbox"]:disabled {
  cursor: not-allowed;
}
.amp-toggle-slider {
  width: 44px;
  height: 24px;
  background: #cbd5e1;
  border-radius: 12px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.amp-toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
.amp-toggle input[type="checkbox"]:checked + .amp-toggle-slider {
  background: var(--amp-primary);
}
.amp-toggle input[type="checkbox"]:checked + .amp-toggle-slider::after {
  transform: translateX(20px);
}
.amp-toggle input[type="checkbox"]:focus-visible + .amp-toggle-slider {
  box-shadow: var(--amp-focus-ring);
}
.amp-toggle-locked .amp-toggle-slider { opacity: 0.6; cursor: not-allowed; }

.amp-always-on {
  font-size: 11px;
  font-weight: 600;
  color: var(--amp-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Cookies-Tabelle */
.amp-cookies-details {
  margin-top: 12px;
  font-size: 13px;
}
.amp-cookies-details summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--amp-primary);
  padding: 6px 0;
  min-height: 30px;
  user-select: none;
}
.amp-cookies-details summary:focus-visible {
  outline: none;
  box-shadow: var(--amp-focus-ring);
  border-radius: 4px;
}
.amp-cookies-table {
  width: 100%;
  margin-top: 8px;
  border-collapse: collapse;
  font-size: 12px;
}
.amp-cookies-table th,
.amp-cookies-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--amp-border);
  vertical-align: top;
}
.amp-cookies-table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--amp-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
}
.amp-cookies-table td {
  color: var(--amp-text);
  word-break: break-word;
}

/* Settings Actions */
.amp-settings-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 16px 24px;
  border-top: 1px solid var(--amp-border);
  position: sticky;
  bottom: 0;
  background: var(--amp-bg);
}

/* ───────────────────────── Floating Button ───────────────────────── */

.amp-float-btn {
  position: fixed;
  bottom: 16px;
  left: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--amp-bg);
  color: var(--amp-primary);
  border: 1px solid var(--amp-border);
  cursor: pointer;
  z-index: 2147483590;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  transition: transform 0.15s, box-shadow 0.15s;
  opacity: 0.85;
  padding: 0;
}
.amp-float-btn:hover {
  opacity: 1;
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}
.amp-float-btn:focus-visible {
  outline: none;
  box-shadow: var(--amp-focus-ring), 0 4px 12px rgba(0, 0, 0, 0.1);
  opacity: 1;
}

/* ───────────────────────── Animations ───────────────────────── */

@keyframes amp-slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
.amp-banner.amp-position-bottom-bar { animation-name: amp-slide-up; }
.amp-banner.amp-position-center-modal { animation-name: amp-scale-up; }

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

@keyframes amp-scale-up {
  from { opacity: 0; transform: scale(0.95) translate(-50%, -48%); }
  to { opacity: 1; transform: scale(1) translate(-50%, -50%); }
}
.amp-settings-modal { animation-name: amp-settings-pop; }
@keyframes amp-settings-pop {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .amp-banner, .amp-settings-overlay, .amp-settings-modal, .amp-float-btn,
  .amp-toggle-slider, .amp-toggle-slider::after,
  .amp-btn, .amp-close {
    animation: none !important;
    transition: none !important;
  }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .amp-banner, .amp-settings-overlay, .amp-float-btn {
    --amp-bg: #1e293b;
    --amp-text: #f1f5f9;
    --amp-text-muted: #94a3b8;
    --amp-border: #334155;
    --amp-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  }
  .amp-cookies-table th { background: #0f172a; }
  .amp-btn-secondary:hover { background: #334155; }
  .amp-close:hover { background: #334155; }
  .amp-toggle-slider { background: #475569; }
  .amp-gpc-notice { background: rgba(22, 163, 74, 0.15); color: #86efac; }
}

/* Mobile Anpassungen */
@media (max-width: 480px) {
  .amp-banner { padding: 20px 16px; }
  .amp-banner.amp-position-bottom-bar { left: 8px; right: 8px; bottom: 8px; }
  .amp-btn-row { flex-direction: column; }
  .amp-btn { width: 100%; flex: initial; }
  .amp-settings-header { padding: 16px 18px 12px; }
  .amp-category { padding: 14px 18px; }
  .amp-settings-actions { padding: 12px 18px; flex-direction: column; }
  .amp-settings-actions .amp-btn { width: 100%; flex: initial; }
}
