/* ==========================================================================
   Avico Cookie Consent — Frontend Banner Styles
   Two-state design: compact bar → expanded panel
   ========================================================================== */

/* --------------------------------------------------------------------------
   CSS Custom Properties
   -------------------------------------------------------------------------- */
:root {
  --avico-primary:  #1a1a2e;
  --avico-accent:   #c8102e;
  --avico-bg:       #ffffff;
  --avico-text:     #222222;
  --avico-btn-text: #ffffff;
  --avico-border:   #e2e6ea;
  --avico-radius:   10px;
  --avico-speed:    0.28s;
  --avico-ease:     cubic-bezier(0.4, 0, 0.2, 1);
  --avico-bar-h:    64px;
  --avico-shadow:   0 -4px 24px rgba(0,0,0,0.12);
}

/* --------------------------------------------------------------------------
   Overlay (only used when panel is open + center layout)
   -------------------------------------------------------------------------- */
.avico-cc-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 99997;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--avico-speed) var(--avico-ease);
}

.avico-cc-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}

/* --------------------------------------------------------------------------
   Banner wrapper — sits at the bottom of the viewport
   -------------------------------------------------------------------------- */
.avico-cc-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 99998;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.5;
  /* Hidden state */
  transform: translateY(100%);
  opacity: 0;
  pointer-events: none;
  transition: transform var(--avico-speed) var(--avico-ease),
              opacity var(--avico-speed) var(--avico-ease);
}

.avico-cc-banner.is-visible {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* --------------------------------------------------------------------------
   Compact Bar — always rendered, sits at the bottom of the banner wrapper
   -------------------------------------------------------------------------- */
.avico-cc-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--avico-primary);
  color: #fff;
  padding: 0 20px;
  min-height: var(--avico-bar-h);
  box-shadow: var(--avico-shadow);
}

.avico-cc-bar-text {
  flex: 1;
  margin: 0;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.88);
  display: flex;
  align-items: center;
  gap: 7px;
  line-height: 1.4;
}

.avico-cc-cookie-icon {
  flex-shrink: 0;
  opacity: 0.75;
  position: relative;
  top: -1px;
}

.avico-cc-privacy-link {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: underline;
  white-space: nowrap;
  font-size: 12px;
  margin-left: 4px;
  transition: color var(--avico-speed);
}

.avico-cc-privacy-link:hover {
  color: #fff;
}

.avico-cc-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Expanded Panel — slides up from above the bar
   max-height is set dynamically by JS (scrollHeight) for smooth animation.
   -------------------------------------------------------------------------- */
.avico-cc-panel {
  background: var(--avico-bg);
  color: var(--avico-text);
  border-top: 3px solid var(--avico-accent);
  box-shadow: 0 -8px 40px rgba(0,0,0,0.15);
  /* Collapsed by default */
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--avico-speed) var(--avico-ease);
  /* No display:none so scrollHeight is readable by JS */
}

/* Panel header */
.avico-cc-panel-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 24px 0;
}

.avico-cc-logo {
  height: 32px;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.avico-cc-title {
  flex: 1;
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--avico-text);
  line-height: 1.25;
}

.avico-cc-close-panel {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: none;
  border: 1px solid var(--avico-border);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  line-height: 1;
  transition: background var(--avico-speed), color var(--avico-speed);
  white-space: nowrap;
  font-family: inherit;
}

.avico-cc-close-panel:hover {
  background: #f5f5f5;
  color: #333;
}

/* Panel body */
.avico-cc-panel-body {
  padding: 16px 24px;
  max-height: 55vh;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.avico-cc-description {
  margin: 0 0 18px;
  font-size: 13.5px;
  color: #555;
  line-height: 1.6;
}

/* Category list */
.avico-cc-categories {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.avico-cc-category {
  border: 1px solid var(--avico-border);
  border-radius: 8px;
  overflow: hidden;
}

.avico-cc-cat-row {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 14px;
  background: #fafbfc;
}

.avico-cc-cat-row.is-locked {
  opacity: 0.85;
}

.avico-cc-cat-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.avico-cc-cat-name {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--avico-text);
}

.avico-cc-cat-desc {
  font-size: 12px;
  color: #777;
  line-height: 1.45;
}

.avico-cc-cat-control {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding-top: 2px;
}

/* Toggle switch */
.avico-cc-switch-label {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  gap: 8px;
}

.avico-cc-checkbox {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.avico-cc-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  background: #ccc;
  border-radius: 12px;
  flex-shrink: 0;
  transition: background var(--avico-speed) var(--avico-ease);
}

.avico-cc-switch::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.22);
  transition: transform var(--avico-speed) var(--avico-ease);
}

.avico-cc-checkbox:checked ~ .avico-cc-switch {
  background: var(--avico-accent);
}

.avico-cc-checkbox:checked ~ .avico-cc-switch::after {
  transform: translateX(18px);
}

.avico-cc-checkbox:focus-visible ~ .avico-cc-switch {
  outline: 2px solid var(--avico-accent);
  outline-offset: 2px;
}

.avico-cc-switch-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
}

.avico-cc-always-on {
  font-size: 11.5px;
  font-weight: 600;
  color: #4caf50;
  background: #e8f5e9;
  padding: 3px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

/* Panel actions */
.avico-cc-panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 24px 18px;
  border-top: 1px solid var(--avico-border);
  justify-content: flex-end;
  background: #fafbfc;
}

/* --------------------------------------------------------------------------
   Buttons (shared across bar and panel)
   -------------------------------------------------------------------------- */
.avico-cc-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  transition: background var(--avico-speed), color var(--avico-speed),
              border-color var(--avico-speed), transform 0.1s;
}

.avico-cc-btn:active {
  transform: scale(0.96);
}

/* ── Settings (bar, looks like a ghost) ── */
.avico-cc-btn--settings {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.85);
  border-color: rgba(255,255,255,0.2);
  font-size: 12.5px;
  padding: 7px 12px;
}

.avico-cc-btn--settings:hover {
  background: rgba(255,255,255,0.18);
  color: #fff;
  border-color: rgba(255,255,255,0.35);
}

.avico-cc-btn--settings.is-open {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

/* ── Ghost (Ablehnen in bar) ── */
.avico-cc-btn--ghost {
  background: transparent;
  color: rgba(255,255,255,0.78);
  border-color: transparent;
  font-size: 12.5px;
  padding: 7px 10px;
}

.avico-cc-btn--ghost:hover {
  color: #fff;
  background: rgba(255,255,255,0.08);
}

/* Ghost in panel context (after panel opens, bar stays so same class) */
.avico-cc-panel-actions .avico-cc-btn--ghost {
  color: #666;
  border-color: var(--avico-border);
}

.avico-cc-panel-actions .avico-cc-btn--ghost:hover {
  color: #333;
  background: #f0f0f0;
}

/* ── Outline (Nur notwendige in bar) ── */
.avico-cc-btn--outline {
  background: transparent;
  color: rgba(255,255,255,0.88);
  border-color: rgba(255,255,255,0.3);
  font-size: 12.5px;
  padding: 7px 13px;
}

.avico-cc-btn--outline:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
  border-color: rgba(255,255,255,0.5);
}

.avico-cc-panel-actions .avico-cc-btn--outline {
  color: var(--avico-primary);
  border-color: var(--avico-primary);
}

.avico-cc-panel-actions .avico-cc-btn--outline:hover {
  background: var(--avico-primary);
  color: #fff;
}

/* ── Secondary (Auswahl speichern in panel) ── */
.avico-cc-btn--secondary {
  background: transparent;
  color: var(--avico-primary);
  border-color: var(--avico-primary);
}

.avico-cc-btn--secondary:hover {
  background: var(--avico-primary);
  color: #fff;
}

/* ── Primary (Akzeptieren) ── */
.avico-cc-btn--primary {
  background: var(--avico-accent);
  color: var(--avico-btn-text);
  border-color: var(--avico-accent);
}

.avico-cc-btn--primary:hover {
  filter: brightness(1.08);
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
  .avico-cc-bar {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px;
    gap: 10px;
    min-height: auto;
  }

  .avico-cc-bar-text {
    font-size: 12.5px;
  }

  .avico-cc-bar-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 7px;
  }

  /* Akzeptieren spans full width */
  .avico-cc-btn--primary {
    grid-column: 1 / -1;
  }

  /* Settings button spans full width */
  .avico-cc-btn--settings {
    grid-column: 1 / -1;
  }
}

@media (max-width: 480px) {
  .avico-cc-panel-header {
    padding: 14px 16px 0;
  }

  .avico-cc-panel-body {
    padding: 14px 16px;
  }

  .avico-cc-panel-actions {
    flex-direction: column;
    padding: 12px 16px 14px;
  }

  .avico-cc-panel-actions .avico-cc-btn {
    width: 100%;
    justify-content: center;
  }
}

/* --------------------------------------------------------------------------
   Reduced motion
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .avico-cc-banner,
  .avico-cc-overlay,
  .avico-cc-panel,
  .avico-cc-switch,
  .avico-cc-switch::after {
    transition: none;
  }
}

/* --------------------------------------------------------------------------
   High contrast
   -------------------------------------------------------------------------- */
@media (forced-colors: active) {
  .avico-cc-switch {
    border: 2px solid ButtonText;
  }
  .avico-cc-checkbox:checked ~ .avico-cc-switch {
    background: Highlight;
  }
}
