/*
 * Stili della CMP condivisa cirelli.eu (banner, pannello preferenze,
 * pulsante discreto, toast). Palette brand del Hub, font di sistema:
 * nessuna dipendenza da font/librerie esterne, valido in Next.js e
 * negli HTML standalone (TAC del Controllo, La Bussola).
 */
#cirelli-consent-banner,
#cirelli-consent-overlay,
.cc-discrete-trigger,
.cc-toast {
  --cc-avorio: #f6f2ea;
  --cc-antracite: #262521;
  --cc-antracite-soft: #322f27;
  --cc-petrolio: #17332f;
  --cc-rame: #b5652d;
  --cc-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  box-sizing: border-box;
  font-family: var(--cc-font);
}
#cirelli-consent-banner *,
#cirelli-consent-overlay *,
.cc-discrete-trigger,
.cc-toast {
  box-sizing: border-box;
}

/* ---------------------------------------------------------------- Banner */

.cc-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2147483000;
  display: none;
  background: var(--cc-antracite);
  color: var(--cc-avorio);
  border-top: 1px solid rgba(246, 242, 234, 0.12);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.22);
}
.cc-banner.cc-banner--visible {
  display: block;
  animation: cc-slide-up 0.25s ease-out;
}
.cc-banner__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
}
.cc-banner__text {
  flex: 1 1 320px;
  min-width: 0;
}
.cc-banner__title {
  margin: 0 0 0.3rem;
  font-size: 0.95rem;
  font-weight: 600;
}
.cc-banner__desc {
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.5;
  color: rgba(246, 242, 234, 0.78);
}
.cc-banner__link {
  color: var(--cc-avorio);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.cc-banner__actions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

/* ------------------------------------------------------------- Pulsanti */

.cc-btn {
  font-family: var(--cc-font);
  font-size: 0.85rem;
  font-weight: 600;
  line-height: 1;
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
}
/* Accetta e Rifiuta: stessa forma piena, stesso peso, pari dignità
   visiva — cambia solo il colore, non il livello gerarchico. */
.cc-btn--primary {
  background: var(--cc-rame);
  color: var(--cc-avorio);
}
.cc-btn--primary:hover {
  background: #a15726;
}
.cc-btn--secondary {
  background: var(--cc-petrolio);
  color: var(--cc-avorio);
}
.cc-btn--secondary:hover {
  background: #0f2622;
}
.cc-btn--ghost {
  background: transparent;
  color: rgba(246, 242, 234, 0.78);
  border-color: transparent;
  text-decoration: underline;
  text-underline-offset: 2px;
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}
.cc-btn--ghost:hover {
  color: var(--cc-avorio);
}
.cc-btn:focus-visible,
.cc-toggle:focus-visible,
.cc-discrete-trigger:focus-visible,
.cc-modal__close:focus-visible {
  outline: 2px solid var(--cc-rame);
  outline-offset: 2px;
}

/* ------------------------------------------------------ Overlay/Modale */

.cc-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(23, 51, 47, 0.55);
}
.cc-overlay.cc-overlay--visible {
  display: flex;
  animation: cc-fade-in 0.2s ease-out;
}
.cc-modal {
  width: 100%;
  max-width: 640px;
  max-height: min(88vh, 720px);
  overflow-y: auto;
  background: var(--cc-avorio);
  color: var(--cc-antracite);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}
.cc-modal__header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.25rem;
  background: var(--cc-avorio);
  border-bottom: 1px solid rgba(38, 37, 33, 0.1);
}
.cc-modal__title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}
.cc-modal__close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--cc-antracite);
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
}
.cc-modal__close:hover {
  background: rgba(38, 37, 33, 0.08);
}
.cc-modal__body {
  padding: 1.1rem 1.25rem;
}
.cc-modal__intro {
  margin: 0 0 1.1rem;
  font-size: 0.88rem;
  line-height: 1.55;
  color: rgba(38, 37, 33, 0.75);
}
.cc-category {
  padding: 0.9rem 0;
  border-top: 1px solid rgba(38, 37, 33, 0.1);
}
.cc-category:first-of-type {
  border-top: none;
}
.cc-category__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.cc-category__name {
  font-size: 0.95rem;
  font-weight: 700;
}
.cc-category__desc {
  margin: 0.4rem 0 0.7rem;
  font-size: 0.82rem;
  line-height: 1.5;
  color: rgba(38, 37, 33, 0.72);
}

.cc-toggle {
  position: relative;
  width: 44px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 999px;
  border: none;
  background: rgba(38, 37, 33, 0.22);
  cursor: pointer;
  padding: 0;
}
.cc-toggle__dot {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--cc-avorio);
  transition: left 0.15s ease;
}
.cc-toggle.cc-toggle--on {
  background: var(--cc-rame);
}
.cc-toggle.cc-toggle--on .cc-toggle__dot {
  left: 21px;
}
.cc-toggle--locked {
  background: var(--cc-petrolio);
  cursor: default;
  opacity: 0.85;
}
.cc-toggle--locked .cc-toggle__dot {
  left: 21px;
}

.cc-table-wrap {
  overflow-x: auto;
  border: 1px solid rgba(38, 37, 33, 0.1);
  border-radius: 10px;
}
.cc-table {
  width: 100%;
  min-width: 560px;
  border-collapse: collapse;
  font-size: 0.78rem;
}
.cc-table th,
.cc-table td {
  text-align: left;
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid rgba(38, 37, 33, 0.08);
  vertical-align: top;
}
.cc-table thead th {
  background: rgba(38, 37, 33, 0.05);
  font-weight: 600;
  white-space: nowrap;
}
.cc-table tbody tr:last-child td {
  border-bottom: none;
}

.cc-modal__footer {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: flex-end;
  padding: 1rem 1.25rem;
  background: var(--cc-avorio);
  border-top: 1px solid rgba(38, 37, 33, 0.1);
}
.cc-modal__footer .cc-btn--ghost {
  color: rgba(38, 37, 33, 0.75);
}
.cc-modal__footer .cc-btn--ghost:hover {
  color: var(--cc-antracite);
}

/* ------------------------------------------------- Trigger discreto */

.cc-discrete-trigger {
  position: fixed;
  left: 1rem;
  bottom: 1rem;
  z-index: 2147482900;
  background: var(--cc-avorio);
  color: var(--cc-antracite);
  border: 1px solid rgba(38, 37, 33, 0.18);
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
}
.cc-discrete-trigger:hover {
  background: #efe9db;
}

/* --------------------------------------------------------------- Toast */

.cc-toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  transform: translate(-50%, 8px);
  z-index: 2147483200;
  background: var(--cc-antracite);
  color: var(--cc-avorio);
  padding: 0.7rem 1.1rem;
  border-radius: 999px;
  font-size: 0.82rem;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}
.cc-toast.cc-toast--visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes cc-slide-up {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}
@keyframes cc-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ------------------------------------------------------------ Mobile */

@media (max-width: 640px) {
  .cc-banner__inner {
    padding: 1rem;
  }
  .cc-banner__actions {
    width: 100%;
  }
  .cc-banner__actions .cc-btn {
    flex: 1 1 auto;
    text-align: center;
  }
  .cc-modal {
    max-height: 92vh;
    border-radius: 14px;
  }
  .cc-modal__footer {
    justify-content: stretch;
  }
  .cc-modal__footer .cc-btn {
    flex: 1 1 auto;
    text-align: center;
  }
  .cc-discrete-trigger {
    left: 0.75rem;
    bottom: 0.75rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.72rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cc-banner.cc-banner--visible,
  .cc-overlay.cc-overlay--visible {
    animation: none;
  }
  .cc-toast {
    transition: none;
  }
}
