/* ============================================================
   COOKIE BANNER - Stili principali
   Conforme: GDPR, Cookie Law italiana (D.Lgs. 196/2003 + GDPR 679/2016)
   ============================================================ */

/* --- Overlay di sfondo (opzionale, per il pannello preferenze) --- */
#cookie-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(3px);
  z-index: 9998;
}

/* --- Banner principale (barra inferiore) --- */
#cookie-banner {
  display: none; /* Nascosto di default, mostrato via JS */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  background: #1a1a2e;
  color: #e0e0e0;
  border-top: 1px solid rgba(99, 102, 241, 0.4);
  box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.4);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: 0.875rem;
  line-height: 1.6;
  animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);   opacity: 1; }
}

.cookie-banner__inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.cookie-banner__text {
  flex: 1;
  min-width: 260px;
}

.cookie-banner__text strong {
  display: block;
  color: #ffffff;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
}

.cookie-banner__text a {
  color: #818cf8;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.cookie-banner__text a:hover {
  color: #a5b4fc;
}

/* --- Gruppo pulsanti --- */
.cookie-banner__actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
  flex-shrink: 0;
}

.cookie-btn {
  padding: 0.55rem 1.1rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.2s ease;
  white-space: nowrap;
}

/* Accetta tutti - primario */
.cookie-btn--accept {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
}
.cookie-btn--accept:hover {
  background: linear-gradient(135deg, #4f46e5, #7c3aed);
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

/* Rifiuta tutti - secondario */
.cookie-btn--reject {
  background: transparent;
  color: #a0a0b8;
  border: 1px solid rgba(160, 160, 184, 0.35);
}
.cookie-btn--reject:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #d0d0e8;
  border-color: rgba(160, 160, 184, 0.6);
}

/* Personalizza - terziario */
.cookie-btn--customize {
  background: transparent;
  color: #818cf8;
  border: 1px solid rgba(99, 102, 241, 0.4);
}
.cookie-btn--customize:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.7);
}

/* ============================================================
   PANNELLO PREFERENZE (modale)
   ============================================================ */
#cookie-preferences {
  display: none;
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  width: min(560px, 94vw);
  background: #16213e;
  border: 1px solid rgba(99, 102, 241, 0.3);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  color: #e0e0e0;
  font-size: 0.875rem;
  animation: fadeScaleIn 0.3s ease-out;
}

@keyframes fadeScaleIn {
  from { opacity: 0; transform: translateX(-50%) scale(0.95); }
  to   { opacity: 1; transform: translateX(-50%) scale(1); }
}

.cookie-prefs__header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cookie-prefs__header h2 {
  margin: 0;
  font-size: 1rem;
  color: #fff;
  font-weight: 700;
}

.cookie-prefs__close {
  background: none;
  border: none;
  color: #a0a0b8;
  font-size: 1.4rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.2rem 0.4rem;
  border-radius: 6px;
  transition: color 0.2s, background 0.2s;
}
.cookie-prefs__close:hover { color: #fff; background: rgba(255,255,255,0.08); }

.cookie-prefs__body {
  padding: 1.25rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 55vh;
  overflow-y: auto;
}

/* Singola categoria di cookie */
.cookie-category {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 1rem 1.25rem;
}

.cookie-category__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.cookie-category__title {
  font-weight: 700;
  color: #fff;
  font-size: 0.9rem;
}

.cookie-category__badge {
  font-size: 0.7rem;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
}

.badge--required {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.cookie-category__desc {
  margin-top: 0.5rem;
  color: #a0a0b8;
  font-size: 0.8rem;
  line-height: 1.5;
}

/* Toggle switch */
.cookie-toggle {
  position: relative;
  flex-shrink: 0;
}

.cookie-toggle input[type="checkbox"] {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.cookie-toggle__slider {
  display: block;
  width: 42px;
  height: 24px;
  background: rgba(255,255,255,0.15);
  border-radius: 24px;
  cursor: pointer;
  transition: background 0.25s;
  position: relative;
}

.cookie-toggle__slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s;
}

.cookie-toggle input:checked + .cookie-toggle__slider {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}

.cookie-toggle input:checked + .cookie-toggle__slider::after {
  transform: translateX(18px);
}

.cookie-toggle input:disabled + .cookie-toggle__slider {
  cursor: not-allowed;
  opacity: 0.6;
}

/* Toggle sempre attivo per i necessari */
.cookie-toggle input:disabled:checked + .cookie-toggle__slider {
  background: linear-gradient(135deg, #10b981, #059669);
}

.cookie-prefs__footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

/* Responsive */
@media (max-width: 600px) {
  .cookie-banner__inner {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }
  .cookie-banner__actions {
    flex-direction: column;
  }
  .cookie-btn {
    width: 100%;
    text-align: center;
    padding: 0.7rem;
  }
  #cookie-preferences {
    bottom: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }
}
