/*
 * Ecope — Aviso de cookies como modal centrado.
 * Se apoya en el marcado de GDPR Cookie Compliance (Moove) 5.0.x: no cambia su
 * lógica, solo su presentación. Lo encola functions.php (ecope_cookie_modal_assets).
 * Sin textos propios: los pone el plugin por idioma (WPML ES/EN).
 *
 * Capas (z-index): fondo 9980 < tarjeta 9985 < panel de Ajustes del plugin
 * (<dialog> en la capa superior del navegador; 9990/9992 si cae al modo antiguo).
 * El JS (ecope-cookie-modal.js) pone html.ecope-cc-open mientras la barra está visible.
 */

/* Gotcha Moove: el plugin oculta la barra con bottom:-400px; como aquí se fija la
   posición con !important, hay que ocultarla de forma explícita. */
#moove_gdpr_cookie_info_bar.moove-gdpr-info-bar-hidden {
  display: none !important;
}

/* Tarjeta centrada (siempre que la barra se vea, aunque falle el JS).
   Sustituye la posición de esquina gdpr_infobar_postion_bottom_left. */
html body #moove_gdpr_cookie_info_bar,
html body #moove_gdpr_cookie_info_bar.gdpr_infobar_postion_bottom_left {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;
  transform: translate(-50%, -50%) !important;
  width: min(520px, calc(100% - 32px)) !important;
  max-width: none !important;
  min-height: 0 !important;
  max-height: calc(100vh - 32px) !important;
  max-height: calc(100dvh - 32px) !important;
  overflow-y: auto !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 16px !important;
  background-color: #fff !important;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45) !important;
  z-index: 9985 !important;
  transition: none !important;
  outline: none;
}

html body #moove_gdpr_cookie_info_bar .moove-gdpr-info-bar-container {
  display: block !important;
  padding: 28px 24px 20px !important;
}

html body #moove_gdpr_cookie_info_bar .moove-gdpr-info-bar-container .moove-gdpr-info-bar-content {
  display: block !important;
  padding: 0 !important;
  text-align: left !important;
}

html body #moove_gdpr_cookie_info_bar .moove-gdpr-info-bar-container .moove-gdpr-info-bar-content .moove-gdpr-cookie-notice {
  margin: 0 0 20px !important;
  padding: 0 !important;
}

html body #moove_gdpr_cookie_info_bar .moove-gdpr-info-bar-container .moove-gdpr-info-bar-content .moove-gdpr-cookie-notice p {
  font-size: 15px !important;
  line-height: 1.55 !important;
  margin: 0 0 8px !important;
  color: #202020 !important;
}

/* Aceptar y Rechazar: mismo estilo, mismo tamaño, mismo peso (color del plugin, #122d48). */
html body #moove_gdpr_cookie_info_bar .moove-gdpr-info-bar-container .moove-gdpr-info-bar-content .moove-gdpr-button-holder {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 12px !important;
  padding: 0 !important;
  margin: 0 !important;
}

html body #moove_gdpr_cookie_info_bar .moove-gdpr-info-bar-container .moove-gdpr-info-bar-content .moove-gdpr-button-holder button.mgbutton.moove-gdpr-infobar-allow-all,
html body #moove_gdpr_cookie_info_bar .moove-gdpr-info-bar-container .moove-gdpr-info-bar-content .moove-gdpr-button-holder button.mgbutton.moove-gdpr-infobar-reject-btn {
  flex: 1 1 0 !important;
  order: 1 !important;
  min-width: 140px !important;
  min-height: 46px !important;
  margin: 0 !important;
  padding: 12px 20px !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  line-height: 20px !important;
  text-align: center !important;
  white-space: nowrap !important;
  color: #fff !important;
  background-color: #122d48 !important;
  box-shadow: none !important;
  opacity: 1 !important;
  border: 0 !important;
  border-radius: 8px !important;
}

html body #moove_gdpr_cookie_info_bar .moove-gdpr-button-holder button.mgbutton.moove-gdpr-infobar-allow-all:hover,
html body #moove_gdpr_cookie_info_bar .moove-gdpr-button-holder button.mgbutton.moove-gdpr-infobar-reject-btn:hover {
  background-color: #0b1d30 !important;
}

/* Ajustes: enlace terciario debajo, no un tercer botón del mismo peso que compita
   con Aceptar/Rechazar. Sigue siendo fácil de pulsar (44 px de alto). */
html body #moove_gdpr_cookie_info_bar .moove-gdpr-info-bar-container .moove-gdpr-info-bar-content .moove-gdpr-button-holder button.mgbutton.moove-gdpr-infobar-settings-btn {
  flex: 1 1 100% !important;
  order: 2 !important;
  min-height: 44px !important;
  margin: 0 !important;
  padding: 8px 12px !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  line-height: 20px !important;
  text-align: center !important;
  text-decoration: underline !important;
  text-underline-offset: 3px !important;
  color: #122d48 !important;
  background: transparent !important;
  box-shadow: none !important;
  opacity: 1 !important;
  border: 0 !important;
  border-radius: 8px !important;
}

html body #moove_gdpr_cookie_info_bar .moove-gdpr-info-bar-container .moove-gdpr-info-bar-content .moove-gdpr-button-holder button.mgbutton.moove-gdpr-infobar-settings-btn:hover {
  color: #0b1d30 !important;
  background: rgba(18, 45, 72, 0.06) !important;
}

html body #moove_gdpr_cookie_info_bar button.mgbutton:focus-visible {
  outline: 2px solid #122d48 !important;
  outline-offset: 2px !important;
}

/* Sin "X" de cierre: hay que elegir. (El JS además neutraliza su clic.) */
html body #moove_gdpr_cookie_info_bar .moove-gdpr-infobar-close-btn {
  display: none !important;
}

/* Fondo oscuro a pantalla completa, sin manejadores: no cierra al pulsar. */
#ecope-cc-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9980;
  background: rgba(8, 20, 33, 0.62);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

html.ecope-cc-open #ecope-cc-overlay {
  display: block;
}

/* Bloquear el scroll de la página mientras se decide. */
html.ecope-cc-open,
html.ecope-cc-open body {
  overflow: hidden !important;
}

/* Flotantes medidos en ecope.es (19-oct-2026, Playwright) que quedarían por encima
   del fondo: Buttonizer (grupo z 99999 con visibility:hidden, pero su botón visible es
   un hijo con visibility:visible y z 9999), su backdrop (99998), "volver arriba" de
   Happy Addons (span fijo z 9999 DENTRO de .ha-scroll-to-top-wrap, no hijo del body)
   y su cursor personalizado .mf-cursor (99999). Además .ecope-cc-hidden-float la pone
   el JS a cualquier otro hijo del body fijo y por encima de la tarjeta, aunque llegue
   tarde. opacity + pointer-events + visibility en hijos: un hijo con
   visibility:visible no puede reabrirse.
   Lo mismo con el panel de Ajustes del plugin abierto (desde la tarjeta o desde el
   engranaje): el plugin marca html.gdpr_lightbox-active y body.moove_gdpr_overflow
   (medido en ecope.es, 19-oct-2026; las quita al cerrar) y su panel (z 9990) queda
   por debajo de Buttonizer (z 9999), que en 375 px se le montaba encima. */
:is(html.ecope-cc-open, html.gdpr_lightbox-active, body.moove_gdpr_overflow) body > .buttonizer,
:is(html.ecope-cc-open, html.gdpr_lightbox-active, body.moove_gdpr_overflow) body > [class*="buttonizer-group"],
:is(html.ecope-cc-open, html.gdpr_lightbox-active, body.moove_gdpr_overflow) #buttonizer-backdrop,
:is(html.ecope-cc-open, html.gdpr_lightbox-active, body.moove_gdpr_overflow) .ha-scroll-to-top-wrap,
:is(html.ecope-cc-open, html.gdpr_lightbox-active, body.moove_gdpr_overflow) .ha-scroll-to-top-button,
:is(html.ecope-cc-open, html.gdpr_lightbox-active, body.moove_gdpr_overflow) .mf-cursor,
:is(html.ecope-cc-open, html.gdpr_lightbox-active, body.moove_gdpr_overflow) .ecope-cc-hidden-float {
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

:is(html.ecope-cc-open, html.gdpr_lightbox-active, body.moove_gdpr_overflow) body > .buttonizer *,
:is(html.ecope-cc-open, html.gdpr_lightbox-active, body.moove_gdpr_overflow) .ha-scroll-to-top-wrap *,
:is(html.ecope-cc-open, html.gdpr_lightbox-active, body.moove_gdpr_overflow) .ecope-cc-hidden-float * {
  visibility: hidden !important;
}

/* Red de seguridad: la tarjeta nunca hereda ese ocultado. */
html.ecope-cc-open #moove_gdpr_cookie_info_bar:not(.moove-gdpr-info-bar-hidden) {
  visibility: visible !important;
}

@media (max-width: 420px) {
  html body #moove_gdpr_cookie_info_bar .moove-gdpr-info-bar-container {
    padding: 22px 18px 14px !important;
  }
  html body #moove_gdpr_cookie_info_bar .moove-gdpr-info-bar-container .moove-gdpr-info-bar-content .moove-gdpr-button-holder button.mgbutton.moove-gdpr-infobar-allow-all,
  html body #moove_gdpr_cookie_info_bar .moove-gdpr-info-bar-container .moove-gdpr-info-bar-content .moove-gdpr-button-holder button.mgbutton.moove-gdpr-infobar-reject-btn {
    flex-basis: 100% !important;
  }
}

@media (prefers-reduced-motion: no-preference) {
  html.ecope-cc-open #ecope-cc-overlay {
    animation: ecope-cc-fade 0.2s ease-out;
  }
}

@keyframes ecope-cc-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
