/* ── Banner ─────────────────────────────────────────── */
#dan-cookie-consent-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  background-color: var(--dan-cookie-bg, #fff);
  color: var(--dan-cookie-text, #333);
  padding: 12px 20px 16px;
  box-shadow: 0 -2px 10px rgba(0,0,0,.15);
  /* Scala z-index condivisa tra i plugin dan-*: 1.000 locale/sticky · 10.000 UI
     flottante persistente · 100.000 popup modali (dan-custom-popups) · 110.000
     overlay sopra un popup modale (dan-ratings) · 500.000 cookie consent (qui,
     sempre in cima: requisito legale, deve vincere su qualunque altro overlay). */
  z-index: 500000;
  font-family: sans-serif;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

#dan-cookie-consent-banner p {
  margin: 0 0 10px 0;
  line-height: 1.5;
  font-size: 12px;
  max-width: 680px;
}

#dan-cookie-consent-banner p a {
  color: inherit;
  text-decoration: underline;
  opacity: .75;
}

.dan-cookie-consent-actions {
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

#dan-cookie-consent-banner:not(.dcc-theme-style) .button {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: opacity .2s;
}

#dan-cookie-consent-banner:not(.dcc-theme-style) #dan-cookie-accept-all {
  background-color: var(--dan-cookie-btn-bg, #007cba);
  color: var(--dan-cookie-btn-text, #fff);
}

#dan-cookie-consent-banner:not(.dcc-theme-style) #dan-cookie-reject-all {
  background-color: var(--dan-cookie-btn-accent-bg, #f0f0f1);
  color: var(--dan-cookie-btn-accent-text, #333);
}

#dan-cookie-consent-banner:not(.dcc-theme-style) #dan-cookie-customize {
  background-color: var(--dan-cookie-btn-accent-bg, #f0f0f1);
  color: var(--dan-cookie-btn-accent-text, #333);
}

#dan-cookie-consent-banner:not(.dcc-theme-style) .button:hover { opacity: .85; }

@media (max-width: 600px) {
  .dan-cookie-consent-actions { flex-direction: column; width: 100%; }
  .dan-cookie-consent-actions .button { text-align: center; }
}

/* Riquadro centrato (opzione "Larghezza Banner"): largo quanto il contenuto, staccato dal fondo */
#dan-cookie-consent-banner.dcc-compact {
  left: 50%;
  bottom: 16px;
  width: max-content;
  max-width: calc(100% - 32px);
  box-sizing: border-box;
  transform: translateX(-50%);
  padding: 14px 20px;
  box-shadow: 0 4px 24px rgba(0,0,0,.18);
}
#dan-cookie-consent-banner.dcc-compact:not(.dcc-theme-style) { border-radius: 12px; }
#dan-cookie-consent-banner.dcc-compact .dan-cookie-consent-actions { display: flex; justify-content: center; }

/* ── Overlay ─────────────────────────────────────────── */
#dan-cookie-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 499999; /* appena sotto banner/dialog (500.000): vedi scala z-index dan-* */
}

/* ── Preferences dialog ──────────────────────────────── */
#dan-cookie-consent-preferences {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  max-height: 85vh;
  background: #fff;
  z-index: 500000; /* stesso livello del banner (mai visibili insieme): vedi scala z-index dan-* */
  border-radius: 16px 16px 0 0;
  box-shadow: 0 -4px 28px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
  font-family: sans-serif;
  font-size: 14px;
  color: #333;
}

/* Header */
.dcc-pref-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
  flex-shrink: 0;
}

.dcc-pref-header__title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* Il titolo è un h3: dimensioni e margini propri, altrimenti eredita quelli (grandi) dei titoli del tema.
   Con "Stile dal tema" resta solo il carattere/colore dei titoli del tema. */
#dan-cookie-consent-preferences #dcc-pref-title {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
  font-weight: 700;
  letter-spacing: normal;
  text-transform: none;
  white-space: nowrap;
}
#dan-cookie-consent-preferences:not(.dcc-theme-style) #dcc-pref-title {
  font-family: inherit;
  color: #222;
}

.dcc-site-logo {
  height: auto;
  width: auto;
  max-width: 50px;
  object-fit: contain;
  display: block;
  flex-shrink: 0;
}

.dcc-pref-header strong {
  font-size: 15px;
  font-weight: 700;
  color: #222;
}

#dan-cookie-close-preferences {
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: #999;
  padding: 0 2px;
  transition: color .15s;
}

#dan-cookie-close-preferences:hover { color: #333; }

/* Body */
.dcc-pref-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 20px;
}

.dcc-pref-intro {
  font-size: 12px;
  color: #888;
  margin: 0 0 14px;
  line-height: 1.5;
}

.dcc-pref-intro a { color: inherit; text-decoration: underline; }

/* Category cards */
.cookie-category {
  background: #f7f8f9;
  border: 1px solid #eee;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
}

.cookie-category__row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cookie-category__label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  flex: 1;
}

.cookie-category__label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  cursor: pointer;
  accent-color: var(--dan-cookie-btn-bg, #007cba);
}

.cookie-category__label input[type="checkbox"]:disabled {
  cursor: default;
  opacity: .6;
}

.cookie-badge {
  font-size: 11px;
  color: #777;
  white-space: nowrap;
  font-weight: 400;
}

.cookie-category .description {
  font-size: 12px;
  color: #666;
  margin: 7px 0 0;
  line-height: 1.5;
}

/* Footer */
.dcc-pref-footer {
  padding: 12px 20px;
  border-top: 1px solid #eee;
  flex-shrink: 0;
}

#dan-cookie-save-preferences { width: 100%; }

#dan-cookie-consent-preferences:not(.dcc-theme-style) #dan-cookie-save-preferences {
  background-color: var(--dan-cookie-btn-bg, #007cba);
  color: var(--dan-cookie-btn-text, #fff);
  padding: 11px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  border: none;
  transition: opacity .2s;
}

#dan-cookie-consent-preferences:not(.dcc-theme-style) #dan-cookie-save-preferences:hover { opacity: .88; }

/* Desktop: centered dialog */
@media (min-width: 640px) {
  #dan-cookie-consent-preferences {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    bottom: auto;
    width: 90%;
    max-width: 520px;
    border-radius: 14px;
    max-height: 82vh;
  }
}

/* ── Details (script list) ───────────────────────────── */
.dan-cookie-details {
  margin-top: 8px;
  font-size: 11px;
}

.dan-cookie-details summary {
  cursor: pointer;
  color: #333;
  font-weight: 600;
  outline: none;
  list-style: none;
}

.dan-cookie-details summary::before {
  content: '▸ ';
}

.dan-cookie-details[open] summary::before {
  content: '▾ ';
}

.dan-cookie-details ul {
  margin: 0 0 0 25px;
  padding: 0;
  list-style: disc;
  color: #666;
}

.dan-cookie-details li { margin-bottom: 3px; }

/* ── Trigger button ──────────────────────────────────── */
#dan-cookie-trigger {
  position: fixed;
  bottom: 70px;
  width: 44px;
  height: 44px;
  background-color: var(--dan-cookie-trigger-bg, #007cba);
  color: var(--dan-cookie-trigger-text, #fff);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
  z-index: 10000; /* livello UI flottante persistente: vedi scala z-index dan-* */
  transition: transform .2s, opacity .2s;
}

#dan-cookie-trigger:hover { transform: scale(1.1); opacity: .9; }

#dan-cookie-trigger svg,
#dan-cookie-trigger img {
  width: 24px;
  height: 24px;
  pointer-events: none;
}

/* ── Stile dal tema (opzione "Stile dal tema") ───────────
   I pulsanti hanno la classe .wp-element-button: forma, carattere e colori arrivano da
   theme.json (styles.elements.button). Qui solo i colori di sito e i pulsanti secondari. */
#dan-cookie-consent-banner.dcc-theme-style,
#dan-cookie-consent-preferences.dcc-theme-style {
  font-family: inherit;
  background-color: var(--dan-cookie-bg);
  color: var(--dan-cookie-text);
}

#dan-cookie-consent-banner.dcc-theme-style .button { cursor: pointer; white-space: nowrap; }

/* Rifiuta / Personalizza: versione a contorno del pulsante del tema */
#dan-cookie-consent-banner.dcc-theme-style #dan-cookie-reject-all,
#dan-cookie-consent-banner.dcc-theme-style #dan-cookie-customize {
  background-color: transparent;
  color: var(--dan-cookie-text);
}
#dan-cookie-consent-banner.dcc-theme-style #dan-cookie-reject-all:hover,
#dan-cookie-consent-banner.dcc-theme-style #dan-cookie-customize:hover {
  background-color: var(--dan-cookie-btn-bg);
  color: var(--dan-cookie-btn-text);
}

/* Pannello preferenze: grigi derivati dal colore del testo, così va bene anche su sfondi scuri */
.dcc-theme-style .dcc-pref-header,
.dcc-theme-style .dcc-pref-footer { border-color: color-mix(in srgb, currentColor 12%, transparent); }
.dcc-theme-style .cookie-category { background: color-mix(in srgb, currentColor 5%, transparent); }
.dcc-theme-style .dcc-pref-header strong,
.dcc-theme-style .dan-cookie-details summary { color: inherit; }
.dcc-theme-style .dcc-pref-intro,
.dcc-theme-style .cookie-badge,
.dcc-theme-style .cookie-category .description,
.dcc-theme-style .dan-cookie-details ul { color: inherit; opacity: .75; }
.dcc-theme-style #dan-cookie-close-preferences { color: inherit; opacity: .6; }
.dcc-theme-style #dan-cookie-close-preferences:hover { opacity: 1; }

/* ── Cookie Policy (shortcode [dan_cookie_policy]) ───── */
.dan-cookie-policy__table {
  display: block;            /* scorre in orizzontale su schermi stretti */
  overflow-x: auto;
  border-collapse: collapse;
  width: 100%;
  margin: .5em 0 1.5em;
  font-size: .9em;
}
.dan-cookie-policy__table th,
.dan-cookie-policy__table td {
  border: 1px solid color-mix(in srgb, currentColor 20%, transparent);
  padding: .4em .6em;
  text-align: left;
  vertical-align: top;
}
.dan-cookie-policy__table th { background: color-mix(in srgb, currentColor 6%, transparent); }
