/* =========================================================================
   COOKIE BANNER + PREFERENCE MODAL
   GDPR / ePrivacy compliant cookie consent UI.
   File standalone: nessuna dipendenza da style.css.
   Tutte le classi sono prefissate con `cb-` per evitare collisioni.
   ========================================================================= */

:root {
  --cb-bg:           #ffffff;
  --cb-surface:      #fafaf7;
  --cb-text:         #1a1a1a;
  --cb-text-muted:   #5a5a5a;
  --cb-border:       rgba(0, 0, 0, 0.08);
  --cb-shadow:       0 24px 60px rgba(0, 0, 0, 0.18);
  --cb-radius:       16px;
  --cb-radius-sm:    10px;
  --cb-accent:       #ff7a1a;
  --cb-accent-text:  #1a0f08;
  --cb-accent-hover: #e86a0e;
  --cb-secondary:    #f0eeea;
  --cb-success:      #27a35a;
  --cb-overlay:      rgba(12, 8, 5, 0.55);
  --cb-z-banner:     2147483600;  /* sopra qualsiasi cosa */
  --cb-z-modal:      2147483601;
}

/* Schema scuro coerente con il sito Boomerang */
@media (prefers-color-scheme: dark) {
  :root {
    --cb-bg:        #1a1109;
    --cb-surface:   #221608;
    --cb-text:      #fff5e6;
    --cb-text-muted:#c8b8a4;
    --cb-border:    rgba(255, 234, 210, 0.14);
    --cb-secondary: rgba(255, 234, 210, 0.08);
    --cb-shadow:    0 24px 60px rgba(0, 0, 0, 0.55);
  }
}

/* =========================================================================
   BANNER PRINCIPALE
   ========================================================================= */
.cb-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: var(--cb-z-banner);
  max-width: 760px;
  margin: 0 auto;
  padding: 22px 26px;
  background: var(--cb-bg);
  color: var(--cb-text);
  border: 1px solid var(--cb-border);
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14.5px;
  line-height: 1.55;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.35s ease, transform 0.45s cubic-bezier(.2,.8,.2,1);
}

.cb-banner.cb-visible {
  opacity: 1;
  transform: translateY(0);
}

.cb-banner[hidden] {
  display: none !important;
}

.cb-banner-title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 700;
  color: var(--cb-text);
}

.cb-banner-text {
  margin: 0 0 16px;
  color: var(--cb-text-muted);
}

.cb-banner-text a {
  color: var(--cb-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cb-banner-text a:hover {
  color: var(--cb-accent-hover);
}

.cb-banner-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

/* =========================================================================
   PULSANTI
   ========================================================================= */
.cb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 600;
  font-size: 14px;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  background: var(--cb-secondary);
  color: var(--cb-text);
  transition: background 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.cb-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.cb-btn:focus-visible {
  outline: 3px solid var(--cb-accent);
  outline-offset: 2px;
}

.cb-btn-primary {
  background: var(--cb-accent);
  color: var(--cb-accent-text);
}

.cb-btn-primary:hover {
  background: var(--cb-accent-hover);
}

.cb-btn-secondary {
  background: transparent;
  border-color: var(--cb-border);
  color: var(--cb-text);
}

.cb-btn-link {
  background: transparent;
  color: var(--cb-text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  padding: 10px 12px;
}

.cb-btn-link:hover {
  color: var(--cb-text);
  background: transparent;
  box-shadow: none;
}

/* =========================================================================
   MODAL PREFERENZE
   ========================================================================= */
.cb-modal {
  position: fixed;
  inset: 0;
  z-index: var(--cb-z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--cb-overlay);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.cb-modal.cb-visible {
  opacity: 1;
  pointer-events: auto;
}

.cb-modal[hidden] {
  display: none !important;
}

.cb-modal-dialog {
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  background: var(--cb-bg);
  color: var(--cb-text);
  border: 1px solid var(--cb-border);
  border-radius: var(--cb-radius);
  box-shadow: var(--cb-shadow);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  transform: scale(0.96) translateY(20px);
  transition: transform 0.35s cubic-bezier(.2,.8,.2,1);
}

.cb-modal.cb-visible .cb-modal-dialog {
  transform: scale(1) translateY(0);
}

.cb-modal-header {
  position: relative;
  padding: 24px 28px 14px;
  border-bottom: 1px solid var(--cb-border);
}

.cb-modal-title {
  margin: 0 0 4px;
  font-size: 19px;
  font-weight: 700;
}

.cb-modal-subtitle {
  margin: 0;
  font-size: 14px;
  color: var(--cb-text-muted);
}

.cb-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  background: transparent;
  color: var(--cb-text-muted);
  font-size: 22px;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.cb-close:hover {
  background: var(--cb-secondary);
  color: var(--cb-text);
}

.cb-modal-body {
  padding: 18px 28px;
  overflow-y: auto;
  flex: 1;
}

.cb-category {
  padding: 16px 18px;
  margin-bottom: 12px;
  background: var(--cb-surface);
  border: 1px solid var(--cb-border);
  border-radius: var(--cb-radius-sm);
}

.cb-category-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cb-category-name {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.cb-category-desc {
  margin: 8px 0 0;
  font-size: 13.5px;
  color: var(--cb-text-muted);
}

.cb-category-locked {
  font-size: 12px;
  font-weight: 600;
  color: var(--cb-success);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Toggle switch accessibile */
.cb-switch {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 26px;
  flex-shrink: 0;
}

.cb-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.cb-slider {
  position: absolute;
  inset: 0;
  background: #c8c2bb;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.25s ease;
}

.cb-slider::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.25s cubic-bezier(.4,0,.2,1);
}

.cb-switch input:checked + .cb-slider {
  background: var(--cb-accent);
}

.cb-switch input:checked + .cb-slider::before {
  transform: translateX(20px);
}

.cb-switch input:focus-visible + .cb-slider {
  box-shadow: 0 0 0 3px rgba(255, 122, 26, 0.35);
}

.cb-switch input:disabled + .cb-slider {
  opacity: 0.7;
  cursor: not-allowed;
}

.cb-modal-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  padding: 18px 28px 22px;
  border-top: 1px solid var(--cb-border);
  background: var(--cb-surface);
  border-bottom-left-radius: var(--cb-radius);
  border-bottom-right-radius: var(--cb-radius);
}

/* =========================================================================
   BOTTONE FLOTTANTE PER RIAPRIRE LE PREFERENZE
   ========================================================================= */
.cb-fab {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: var(--cb-z-banner);
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--cb-bg);
  color: var(--cb-text);
  border: 1px solid var(--cb-border);
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  font-size: 20px;
  opacity: 0;
  transform: translateY(20px) scale(0.85);
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(.2,.8,.2,1), background 0.2s ease;
}

.cb-fab.cb-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.cb-fab:hover {
  background: var(--cb-accent);
  color: var(--cb-accent-text);
}

.cb-fab[hidden] {
  display: none !important;
}

/* =========================================================================
   RESPONSIVE
   ========================================================================= */
@media (max-width: 620px) {
  .cb-banner {
    left: 10px;
    right: 10px;
    bottom: 10px;
    padding: 18px 18px 16px;
  }

  .cb-banner-title { font-size: 16px; }
  .cb-banner-actions { justify-content: stretch; }
  .cb-banner-actions .cb-btn { flex: 1 1 calc(50% - 5px); }
  .cb-banner-actions .cb-btn-link { flex: 1 1 100%; order: 3; }

  .cb-modal-header,
  .cb-modal-body,
  .cb-modal-footer { padding-left: 20px; padding-right: 20px; }

  .cb-modal-footer .cb-btn { flex: 1 1 100%; }

  .cb-fab { left: 10px; bottom: 10px; }
}

/* =========================================================================
   PREFERS-REDUCED-MOTION
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  .cb-banner,
  .cb-modal,
  .cb-modal-dialog,
  .cb-fab,
  .cb-slider::before {
    transition: none !important;
  }
}
