/**
 * AMBOSS Business Services GmbH - Cookie Consent System
 * Stylesheet für modales & zukunftssicheres Consent-Management
 * Konform mit WCAG 2.2, DSGVO und TDDDG
 */

:root {
  --amboss-primary: #0024B8;
  --amboss-primary-hover: #001a85;
  --amboss-accent: #0055FF;
  --amboss-text: #1e293b;
  --amboss-text-muted: #64748b;
  --amboss-bg: #ffffff;
  --amboss-card-bg: #f8fafc;
  --amboss-border: #e2e8f0;
  --amboss-radius: 12px;
  --amboss-shadow: 0 20px 40px -10px rgba(0, 36, 184, 0.15), 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Backdrop */
.amboss-consent-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 99998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.amboss-consent-backdrop.is-visible {
  opacity: 1;
  visibility: visible;
}

/* Modal / Floating Container */
.amboss-consent-modal {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  width: calc(100% - 32px);
  max-width: 680px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--amboss-bg);
  border-radius: var(--amboss-radius);
  box-shadow: var(--amboss-shadow);
  border: 1px solid var(--amboss-border);
  z-index: 99999;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--amboss-text);
  padding: 24px;
  box-sizing: border-box;
  opacity: 0;
  visibility: hidden;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease, visibility 0.3s ease;
}

.amboss-consent-modal.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Header */
.amboss-consent-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.amboss-consent-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(0, 36, 184, 0.08);
  color: var(--amboss-primary);
  font-size: 1.25rem;
}

.amboss-consent-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--amboss-primary);
  line-height: 1.3;
}

/* Content */
.amboss-consent-body {
  font-size: 0.925rem;
  line-height: 1.55;
  color: #334155;
  margin-bottom: 20px;
}

.amboss-consent-body p {
  margin: 0 0 10px 0;
}

.amboss-consent-body a {
  color: var(--amboss-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-weight: 500;
}

.amboss-consent-body a:hover {
  color: var(--amboss-primary-hover);
}

/* Detail Categories Accordion */
.amboss-consent-details {
  border-top: 1px solid var(--amboss-border);
  padding-top: 16px;
  margin-bottom: 20px;
  display: none;
}

.amboss-consent-details.is-open {
  display: block;
  animation: ambossFadeIn 0.25s ease-out;
}

@keyframes ambossFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.amboss-category-card {
  background: var(--amboss-card-bg);
  border: 1px solid var(--amboss-border);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
}

.amboss-category-card:last-child {
  margin-bottom: 0;
}

.amboss-category-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.amboss-category-info {
  display: flex;
  flex-direction: column;
}

.amboss-category-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--amboss-text);
  display: flex;
  align-items: center;
  gap: 8px;
}

.amboss-category-desc {
  font-size: 0.825rem;
  color: var(--amboss-text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

.amboss-badge-required {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #e2e8f0;
  color: #475569;
  padding: 2px 7px;
  border-radius: 4px;
}

/* Custom Toggle Switch */
.amboss-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.amboss-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.amboss-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: 0.25s;
  border-radius: 24px;
}

.amboss-toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.25s;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.amboss-toggle input:checked + .amboss-toggle-slider {
  background-color: var(--amboss-primary);
}

.amboss-toggle input:focus-visible + .amboss-toggle-slider {
  outline: 2px solid var(--amboss-accent);
  outline-offset: 2px;
}

.amboss-toggle input:checked + .amboss-toggle-slider:before {
  transform: translateX(20px);
}

.amboss-toggle input:disabled + .amboss-toggle-slider {
  cursor: not-allowed;
  opacity: 0.7;
}

/* Actions Buttons */
.amboss-consent-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.amboss-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
  text-decoration: none;
  font-family: inherit;
  box-sizing: border-box;
}

.amboss-btn:focus-visible {
  outline: 2px solid var(--amboss-accent);
  outline-offset: 2px;
}

.amboss-btn-primary {
  background-color: var(--amboss-primary);
  color: #ffffff;
  border-color: var(--amboss-primary);
}

.amboss-btn-primary:hover {
  background-color: var(--amboss-primary-hover);
  border-color: var(--amboss-primary-hover);
  color: #ffffff;
}

.amboss-btn-secondary {
  background-color: #f1f5f9;
  color: #334155;
  border-color: #cbd5e1;
}

.amboss-btn-secondary:hover {
  background-color: #e2e8f0;
  color: #0f172a;
}

.amboss-btn-link {
  background: transparent;
  color: var(--amboss-primary);
  padding: 10px 12px;
  font-size: 0.875rem;
}

.amboss-btn-link:hover {
  text-decoration: underline;
}

/* Footer & Legal links */
.amboss-consent-footer-links {
  display: flex;
  gap: 16px;
  margin-top: 14px;
  font-size: 0.8rem;
  color: var(--amboss-text-muted);
}

.amboss-consent-footer-links a {
  color: var(--amboss-text-muted);
  text-decoration: none;
}

.amboss-consent-footer-links a:hover {
  color: var(--amboss-primary);
  text-decoration: underline;
}

/* Mobile Adjustments */
@media (max-width: 640px) {
  .amboss-consent-modal {
    bottom: 16px;
    width: calc(100% - 24px);
    padding: 18px 16px;
  }
  
  .amboss-consent-actions {
    flex-direction: column-reverse;
    width: 100%;
  }

  .amboss-btn {
    width: 100%;
  }
  
  .amboss-btn-link {
    width: auto;
    text-align: center;
    margin-bottom: 4px;
  }

  .amboss-consent-footer-links {
    justify-content: center;
  }
}

/* Firefox & Compact Viewport Optimization (Laptops mit Windows 125%/150% Skalierung & Firefox Toolbars) */
@media (max-height: 760px) {
  .amboss-consent-modal {
    bottom: 20px;
    top: auto;
    height: auto;
    max-height: calc(100vh - 24px);
    max-height: calc(100dvh - 24px);
    padding: 16px 20px 14px;
  }
  .amboss-consent-header {
    margin-bottom: 8px;
  }
  .amboss-consent-header h2,
  .amboss-consent-title {
    font-size: 1.05rem;
  }
  .amboss-consent-body {
    margin-bottom: 12px;
  }
  .amboss-consent-body p {
    font-size: 0.85rem;
    margin-bottom: 8px;
  }
  .amboss-consent-actions {
    margin-top: 8px;
    padding-top: 8px;
  }
}

@media (max-height: 600px) {
  .amboss-consent-modal {
    bottom: 16px;
    top: auto;
    height: auto;
    max-height: calc(100vh - 16px);
    max-height: calc(100dvh - 16px);
    padding: 12px 16px;
  }
  .amboss-consent-body {
    margin-bottom: 8px;
  }
  .amboss-consent-body p {
    font-size: 0.82rem;
    line-height: 1.4;
    margin-bottom: 6px;
  }
  .amboss-btn {
    padding: 8px 14px;
    font-size: 0.85rem;
  }
}


/* Auto-hide Floating Chat Widget while Cookie Consent is active */
body.amboss-consent-open #ga-chat-widget,
body:has(.amboss-consent-modal.is-visible) #ga-chat-widget,
body:has(.amboss-consent-backdrop.is-visible) #ga-chat-widget {
  opacity: 0 !important;
  visibility: hidden !important;
  pointer-events: none !important;
  transform: translateY(20px) scale(0.9) !important;
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease !important;
}
