/**
 * CMP - Frontend CSS (iubenda-like bottom full-width)
 * Target: come screenshot: pannello bianco full-width in basso, logo sopra, testo centrale,
 * pulsanti in basso: "Scopri di più" a sinistra e "Rifiuta/Accetta" a destra. [file:76]
 */

/* Lock scroll quando overlay attivo */
html.cmp-no-scroll,
body.cmp-no-scroll {
  overflow: hidden !important;
}

/* Overlay */
#cmp-cookie-overlay {
  display: none;
  position: fixed !important;
  inset: 0 !important;
  background: rgb(0 0 0 / 46%) !important;
  z-index: calc(var(--cmp-z, 2147483647) - 1) !important;
}

/**
 * Wrapper banner: full-width bottom, “sheet”
 * (iubenda usa un wrapper fixed a tutta pagina e poi allinea il contenuto; qui teniamo la sheet bottom) [page:0]
 */
#cmp-cookie-banner {
  display: none;
  position: fixed !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;

  z-index: var(--cmp-z, 2147483647) !important;
  background: var(--cmp-bg, #ffffff) !important;
  color: var(--cmp-text, #111111) !important;

  box-shadow: 0 -10px 48px rgba(0, 0, 0, 0.22);
  border-top: 2px solid rgba(0, 115, 230, 0.15);

  /* rende la sheet “piena” fino al bordo inferiore */
  padding: 0 !important;

  /* Anti-blocco mobile: se il contenuto supera la viewport, il banner
     scrolla internamente invece di rendere i pulsanti irraggiungibili
     (la pagina resta con lo scroll bloccato via .cmp-no-scroll).
     dvh tiene conto della toolbar dinamica dei browser mobile. */
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/**
 * Container: max-width tipo 992px su desktop, centrato,
 * ma con background già sul wrapper (full width) come nello screenshot. [file:76]
 */
#cmp-cookie-banner .cmp-banner-container {
  box-sizing: border-box;
  max-width: 992px;
  margin: 0 auto;
  padding: 34px 28px 26px 28px;
  position: relative;
  /* Per posizionamento logo assoluto */

  /* layout verticale: contenuto sopra, barra pulsanti sotto */
  display: flex;
  flex-direction: column;
  gap: 18px;

  font-family: inherit !important;
}

/* Logo in alto a destra (stile Iubenda) */
#cmp-cookie-banner .cmp-logo {
  position: absolute;
  top: 20px;
  right: 28px;
  z-index: 10;
}

#cmp-cookie-banner .cmp-logo img {
  max-width: 140px;
  max-height: 42px;
  width: auto;
  height: auto;
  display: block;
}

/* Riga contenuto: solo testo (logo è assoluto) */
#cmp-cookie-banner .cmp-banner-left {
  padding-top: 20px;
  display: block;
  /* Spazio per logo a destra */
  min-width: 0;
}

/* Titolo + testo */
#cmp-cookie-banner .cmp-content {
  width: 100%;
  min-width: 0;
}

#cmp-cookie-banner .cmp-title {
  margin: 0 0 12px 0 !important;
  font-size: 19px !important;
  font-weight: 800 !important;
  line-height: 1.3 !important;
  color: var(--cmp-text, #111111) !important;
}

#cmp-cookie-banner .cmp-text {
  margin: 0 !important;
  font-size: 14.5px;
  line-height: 1.65;
  text-align: justify;
  color: var(--cmp-text, rgba(0, 0, 0, 0.82));
}

#cmp-cookie-banner .cmp-privacy-inline {
  color: rgba(0, 0, 0, 0.7);
  text-decoration: underline;
  font-weight: 600;
}

/**
 * Footer pulsanti: allineamento “come iubenda opt-group”
 * (custom a sinistra + consent a destra) [page:0]
 */
#cmp-cookie-banner .cmp-banner-right {
  margin-top: 6px;
}

#cmp-cookie-banner .cmp-actions-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* sinistra vs destra */
  gap: 18px;
}

#cmp-cookie-banner .cmp-actions-main {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
}

/* Base button */
#cmp-cookie-banner .cmp-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  line-height: 1;
  text-transform: uppercase;

  border-radius: 999px;
  padding: 12px 26px;

  transition:
    transform 0.12s ease,
    box-shadow 0.12s ease,
    opacity 0.12s ease;
  white-space: nowrap;
}

/* Scopri di più (Personalizza): Link testuale discreto */
#cmp-cookie-banner .cmp-btn-link {
  background: transparent !important;
  color: var(--cmp-primary-bg, #0073e6) !important;
  border: none !important;
  box-shadow: none !important;
  padding: 14px 24px;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  font-weight: 600;
  text-transform: none; /* Rende più amichevole */
}

#cmp-cookie-banner .cmp-btn-link:hover {
  filter: brightness(0.85);
  text-decoration-thickness: 2px;
  transform: none;
  opacity: 1;
}

/* Pulsante Accetta: colore configurabile (100.5.0: prima hardcodato nel CSS).
   Il gradiente blu fisso è stato sostituito dal colore amministrato. */
#cmp-cookie-banner .cmp-btn-primary {
  background: var(--cmp-primary-bg, #0073e6) !important;
  color: var(--cmp-primary-text, #ffffff) !important;
  border: 3px solid rgba(255, 255, 255, 0.25) !important;
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.2),
    0 0 0 4px rgba(0, 0, 0, 0.06);
  padding: 16px 42px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

#cmp-cookie-banner .cmp-btn-primary:hover {
  opacity: 1;
  transform: translateY(-2px);
  box-shadow:
    0 6px 20px rgba(0, 0, 0, 0.25),
    0 0 0 4px rgba(0, 0, 0, 0.08);
}

/* Pulsante Rifiuta: secondario — trasparente+outline se --cmp-secondary-bg è
   vuoto, oppure colore pieno amministrato quando valorizzato. */
#cmp-cookie-banner .cmp-btn-secondary {
  background: var(--cmp-secondary-bg, transparent) !important;
  color: var(--cmp-secondary-text, #666666) !important;
  border: 2px solid var(--cmp-secondary-bg, #d0d0d0) !important;
  box-shadow: none !important;
  padding: 14px 36px;
  font-weight: 600;
}

#cmp-cookie-banner .cmp-btn-secondary:hover {
  background: var(--cmp-secondary-bg, #f5f5f5) !important;
  border-color: var(--cmp-secondary-bg, #999999) !important;
  color: var(--cmp-secondary-text, #333333) !important;
  filter: brightness(0.92);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08) !important;
}

/* 100.5.0: anche i pulsanti della modale "Impostazioni privacy" usano i colori
   amministrati (prima .cmp-btn-primary/secondary era scoped solo al banner). */
#cmp-settings-modal .cmp-btn-primary {
  background: var(--cmp-primary-bg, #0073e6) !important;
  color: var(--cmp-primary-text, #ffffff) !important;
  border: 0 !important;
}

#cmp-settings-modal .cmp-btn-secondary {
  background: var(--cmp-secondary-bg, #ffffff) !important;
  color: var(--cmp-secondary-text, #666666) !important;
  border: 1px solid var(--cmp-secondary-bg, #d0d0d0) !important;
}

/* Focus accessibile */
#cmp-cookie-banner .cmp-btn:focus {
  outline: 3px solid rgba(0, 115, 206, 0.35);
  outline-offset: 2px;
}

/* Responsive */
@media (max-width: 991px) {
  #cmp-cookie-banner .cmp-banner-container {
    max-width: 100%;
    padding: 22px 16px 18px 16px;
  }

  #cmp-cookie-banner .cmp-logo {
    position: static;
    margin-bottom: 12px;
  }

  #cmp-cookie-banner .cmp-banner-left {
    padding-right: 0;
  }

  #cmp-cookie-banner .cmp-actions-bottom {
    flex-direction: column;
    align-items: stretch;
  }

  #cmp-cookie-banner .cmp-actions-main {
    width: 100%;
    flex-direction: column;
  }

  #cmp-cookie-banner .cmp-btn {
    width: 100%;
    text-align: center;
  }

  #cmp-cookie-banner .cmp-btn-link {
    padding: 14px 24px;
  }
}

/* Override temi che mettono sticky/footer sopra tutto */
body.woodmart-theme #cmp-cookie-banner,
body.martfury-theme #cmp-cookie-banner,
body[class*="woodmart"] #cmp-cookie-banner,
body[class*="martfury"] #cmp-cookie-banner {
  z-index: 99999999 !important;
}

body.woodmart-theme #cmp-cookie-overlay,
body.martfury-theme #cmp-cookie-overlay,
body[class*="woodmart"] #cmp-cookie-overlay,
body[class*="martfury"] #cmp-cookie-overlay {
  z-index: 99999998 !important;
}

@media print {
  #cmp-cookie-overlay,
  #cmp-cookie-banner {
    display: none !important;
  }
}

/* =========================================
   RESTORED MODAL STYLES (Previously Missing)
   ========================================= */
#cmp-settings-modal {
  display: none;
  position: fixed !important;
  inset: 0 !important;
  z-index: calc(var(--cmp-z, 2147483647) + 1) !important;
  background: var(--cmp-overlay, rgba(0, 0, 0, 0.85)) !important;
  backdrop-filter: blur(5px);
}

.cmp-modal-card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(720px, calc(100vw - 32px));
  max-height: 90vh;
  overflow: hidden;
  border-radius: 10px;
  background: var(--cmp-bg, #fff);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

.cmp-modal-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.cmp-modal-logo {
  max-width: 120px;
  max-height: 40px;
  display: block;
}

.cmp-modal-title {
  font-size: 18px;
  font-weight: 800;
  flex: 1;
}

.cmp-x {
  background: transparent;
  border: 0;
  font-size: 28px;
  line-height: 28px;
  cursor: pointer;
  color: rgba(0, 0, 0, 0.6);
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s;
}

.cmp-x:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #000;
}

.cmp-modal-body {
  padding: 16px 20px;
  overflow: auto;
  max-height: calc(90vh - 140px);
}

.cmp-modal-foot {
  padding: 14px 20px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  gap: 10px;
}

.cmp-modal-foot .cmp-btn {
  width: auto;
  flex: 1;
}

/* Categorie cookie */
.cmp-cat {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.02);
  margin-bottom: 10px;
}

.cmp-cat-locked {
  opacity: 0.9;
}

.cmp-cat-left {
  flex: 1;
  min-width: 0;
}

.cmp-cat-name {
  font-weight: 800;
  margin-bottom: 4px;
}

.cmp-cat-desc {
  font-size: 13px;
  opacity: 0.75;
}

/* Switch toggle */
.cmp-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}

.cmp-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.cmp-slider {
  position: absolute;
  inset: 0;
  background: #d0d0d0;
  border-radius: 26px;
  transition: 0.2s;
  cursor: pointer;
}

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

.cmp-switch input:checked + .cmp-slider {
  background: #0ccf489e;
}

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

.cmp-switch input:disabled + .cmp-slider {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Cookie list accordion */
.cmp-cookie-list {
  margin-top: 10px;
}

.cmp-cookie-accordion {
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.02);
  font-size: 13px;
}

.cmp-cookie-accordion summary {
  cursor: pointer;
  font-weight: 600;
  user-select: none;
  list-style: none;
}

.cmp-cookie-accordion summary::-webkit-details-marker {
  display: none;
}

.cmp-cookie-accordion[open] summary {
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.cmp-cookie-table {
  width: 100%;
  font-size: 12px;
  border-collapse: collapse;
}

.cmp-cookie-table th {
  text-align: left;
  font-weight: 600;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.03);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.cmp-cookie-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  vertical-align: top;
}

.cmp-cookie-table code {
  font-size: 11px;
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 4px;
  border-radius: 2px;
}

/* ── Modale "Personalizza" responsive (mobile) ───────────────────────────── */
@media (max-width: 600px) {
  .cmp-modal-card {
    width: calc(100vw - 20px);
    max-height: 92vh;
  }

  .cmp-modal-head,
  .cmp-modal-body,
  .cmp-modal-foot {
    padding-left: 14px;
    padding-right: 14px;
  }

  .cmp-modal-body {
    max-height: calc(92vh - 150px);
  }

  /* Bottoni footer impilati e a piena larghezza */
  .cmp-modal-foot {
    flex-direction: column;
  }

  .cmp-modal-foot .cmp-btn {
    width: 100%;
  }

  /* Tabella cookie a 4 colonne → card impilate leggibili su mobile.
     Ogni cella mostra la sua etichetta via data-label (niente scroll orizzontale). */
  .cmp-cookie-table thead {
    display: none;
  }

  .cmp-cookie-table,
  .cmp-cookie-table tbody,
  .cmp-cookie-table tr,
  .cmp-cookie-table td {
    display: block;
    width: 100%;
  }

  .cmp-cookie-table tr {
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 6px;
    padding: 6px 10px;
    margin-bottom: 8px;
  }

  .cmp-cookie-table td {
    border: 0;
    padding: 4px 0;
    display: flex;
    gap: 8px;
    word-break: break-word;
  }

  .cmp-cookie-table td::before {
    content: attr(data-label);
    flex: 0 0 64px;
    font-weight: 700;
    opacity: 0.7;
  }
}
