/* =========================================================================
 * cb_cookieconsent - Banner de consentimiento (RGPD / AEPD 2023)
 * Mobile-first. Todo namespaced bajo #cb-cookieconsent / #cb-revoke.
 * Los colores se reciben por CSS custom properties (--cb-*) desde la config.
 * Por defecto oculto: el JS revela el banner (evita el flash a recurrentes).
 * ========================================================================= */

#cb-cookieconsent {
  --cb-bg: #ffffff;
  --cb-text: #1d2530;
  --cb-accept: #2fb344;
  --cb-reject: #414b56;
  --cb-config: #206bc4;
  position: fixed;
  z-index: 2147483000;
  left: 0;
  right: 0;
  color: var(--cb-text);
  font-size: 14px;
  line-height: 1.5;
  box-sizing: border-box;
}

#cb-cookieconsent[hidden] { display: none; }
#cb-cookieconsent *, #cb-cookieconsent *::before, #cb-cookieconsent *::after { box-sizing: border-box; }

/* --- Overlay (solo en modo popup) --- */
#cb-cookieconsent .cb-overlay { display: none; }
#cb-cookieconsent.cb-pos-popup .cb-overlay {
  display: block;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: -1;
}

/* --- Caja del banner --- */
#cb-cookieconsent .cb-box {
  background: var(--cb-bg);
  color: var(--cb-text);
  box-shadow: 0 -2px 18px rgba(0, 0, 0, .18);
  padding: 18px;
}
#cb-cookieconsent .cb-content {
  max-width: 1180px;
  margin: 0 auto;
}
#cb-cookieconsent .cb-text { margin-bottom: 14px; }
#cb-cookieconsent .cb-text p { margin: 0 0 8px; color: var(--cb-text); }
#cb-cookieconsent .cb-text a { color: var(--cb-config); text-decoration: underline; }

/* --- Botones: rechazar TAN visible como aceptar (AEPD: sin atenuar) --- */
#cb-cookieconsent .cb-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#cb-cookieconsent .cb-btn {
  display: inline-block;
  width: 100%;
  padding: 11px 18px;
  border: 0;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  color: #fff;
  cursor: pointer;
  text-align: center;
  transition: filter .15s ease;
}
#cb-cookieconsent .cb-btn:hover { filter: brightness(1.08); }
#cb-cookieconsent .cb-btn-accept { background: var(--cb-accept); }
#cb-cookieconsent .cb-btn-reject { background: var(--cb-reject); }
#cb-cookieconsent .cb-btn-config { background: var(--cb-config); }

#cb-cookieconsent .cb-policy-link {
  display: inline-block;
  margin-top: 12px;
  color: var(--cb-config);
  text-decoration: underline;
  font-size: 13px;
}

/* --- Panel granular --- */
#cb-cookieconsent .cb-panel-title { margin: 0 0 14px; font-size: 18px; color: var(--cb-text); }
#cb-cookieconsent .cb-category { padding: 12px 0; border-top: 1px solid rgba(0, 0, 0, .08); }
#cb-cookieconsent .cb-category-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
#cb-cookieconsent .cb-category-name { font-weight: 600; }
#cb-cookieconsent .cb-category-desc { margin: 6px 0 0; font-size: 13px; opacity: .8; }

/* Interruptores */
#cb-cookieconsent .cb-switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: 0 0 auto; }
#cb-cookieconsent .cb-switch input { opacity: 0; width: 0; height: 0; }
#cb-cookieconsent .cb-slider {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 26px;
  transition: background .2s ease;
}
#cb-cookieconsent .cb-slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform .2s ease;
}
#cb-cookieconsent .cb-switch input:checked + .cb-slider { background: var(--cb-accept); }
#cb-cookieconsent .cb-switch input:checked + .cb-slider::before { transform: translateX(20px); }
#cb-cookieconsent .cb-switch-locked .cb-slider { opacity: .7; cursor: not-allowed; }

/* --- Posiciones --- */
#cb-cookieconsent.cb-pos-bottom { bottom: 0; }
#cb-cookieconsent.cb-pos-top { top: 0; }
#cb-cookieconsent.cb-pos-top .cb-box { box-shadow: 0 2px 18px rgba(0, 0, 0, .18); }

#cb-cookieconsent.cb-pos-popup {
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#cb-cookieconsent.cb-pos-popup .cb-box {
  max-width: 560px;
  width: 100%;
  border-radius: 10px;
  max-height: 90vh;
  overflow-y: auto;
}

/* --- Animación de entrada/salida --- */
#cb-cookieconsent .cb-box {
  opacity: 0;
  transition: opacity .28s ease, transform .28s ease;
}
#cb-cookieconsent.cb-pos-bottom .cb-box { transform: translateY(100%); }
#cb-cookieconsent.cb-pos-top .cb-box { transform: translateY(-100%); }
#cb-cookieconsent.cb-pos-popup .cb-box { transform: scale(.94); }

#cb-cookieconsent.cb-visible .cb-box {
  opacity: 1;
  transform: none;
}

/* --- Enlace flotante de revocación --- */
#cb-revoke {
  position: fixed;
  left: 16px;
  bottom: 16px;
  z-index: 2147482000;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border: 0;
  border-radius: 30px;
  background: #1d2530;
  color: #fff;
  font-size: 13px;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
}
#cb-revoke[hidden] { display: none; }
#cb-revoke .cb-revoke-icon { font-size: 16px; line-height: 1; }

/* --- Escritorio --- */
@media (min-width: 768px) {
  #cb-cookieconsent.cb-pos-bottom .cb-content,
  #cb-cookieconsent.cb-pos-top .cb-content {
    display: flex;
    align-items: center;
    gap: 22px;
  }
  #cb-cookieconsent.cb-pos-bottom .cb-text,
  #cb-cookieconsent.cb-pos-top .cb-text { margin-bottom: 0; flex: 1; }
  #cb-cookieconsent .cb-actions { flex-direction: row; flex: 0 0 auto; }
  #cb-cookieconsent .cb-btn { width: auto; }
  #cb-cookieconsent.cb-pos-popup .cb-actions { flex-wrap: wrap; }
}

/* --- Respeto a usuarios que reducen el movimiento --- */
@media (prefers-reduced-motion: reduce) {
  #cb-cookieconsent .cb-box { transition: none; transform: none; }
}
