/*
 * Ecotime — 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 (ecotime_cookie_modal_assets).
 *
 * Capas (z-index): fondo 9980 < tarjeta 9985 < panel de Ajustes del plugin 9990/9992.
 * El JS (ecotime-cookie-modal.js) pone html.eco-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). */
html body #moove_gdpr_cookie_info_bar {
  top: 50% !important;
  left: 50% !important;
  right: auto !important;
  bottom: auto !important;
  transform: translate(-50%, -50%) !important;
  width: min(520px, calc(100% - 32px)) !important;
  min-height: 0 !important;
  max-height: calc(100vh - 32px) !important;
  max-height: calc(100dvh - 32px) !important;
  overflow-y: auto !important;
  border: 0 !important;
  border-radius: 16px !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 24px !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-cookie-notice p {
  font-size: 15px !important;
  line-height: 1.55 !important;
  margin: 0 0 8px !important;
}

/* Aceptar y Rechazar: mismo estilo, mismo tamaño, mismo peso. */
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,
html body #moove_gdpr_cookie_info_bar .moove-gdpr-info-bar-container .moove-gdpr-info-bar-content .moove-gdpr-button-holder a.mgbutton {
  flex: 1 1 0 !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: #3f899d !important;
  box-shadow: none !important;
  opacity: 1 !important;
  border: 0 !important;
  border-radius: 150px !important;
}

html body #moove_gdpr_cookie_info_bar .moove-gdpr-button-holder button.mgbutton:hover,
html body #moove_gdpr_cookie_info_bar .moove-gdpr-button-holder a.mgbutton:hover {
  background-color: #357587 !important;
}

/* Sin "X" de cierre en la tarjeta: hay que elegir (el plugin no la pinta con la
   configuración actual; esto la mantiene oculta si alguien la activa). */
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. */
#eco-cc-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9980;
  background: rgba(10, 18, 22, 0.62);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

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

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

/* Flotantes con z-index altísimo que quedarían por encima del fondo
   (chatbot 2147483645, Buttonizer, selector de idioma): fuera mientras se decide.
   El chatbot NO cuelga de #eco-widget-root (vacío): pinta #eco-fab, #eco-popup y
   #eco-tooltip como hijos directos del body; el globo #eco-tooltip sale solo a los
   3 s de cargar y se va a los 8 s (setTimeout del widget).
   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 ecotime.es; las quita al cerrar) y su panel (z 9990/9992) quedaba por
   debajo del chatbot (z 2147483646), que tapaba texto.
   .eco-cc-hidden-float la pone el JS a cualquier otro hijo del body fijo y por
   encima de la tarjeta, aunque se inyecte tarde (iframe o host de shadow DOM). */
:is(html.eco-cc-open, html.gdpr_lightbox-active, body.moove_gdpr_overflow) #eco-widget-root,
:is(html.eco-cc-open, html.gdpr_lightbox-active, body.moove_gdpr_overflow) #eco-fab,
:is(html.eco-cc-open, html.gdpr_lightbox-active, body.moove_gdpr_overflow) #eco-popup,
:is(html.eco-cc-open, html.gdpr_lightbox-active, body.moove_gdpr_overflow) #eco-tooltip,
:is(html.eco-cc-open, html.gdpr_lightbox-active, body.moove_gdpr_overflow) .eco-cc-hidden-float,
:is(html.eco-cc-open, html.gdpr_lightbox-active, body.moove_gdpr_overflow) .gtranslate_wrapper,
:is(html.eco-cc-open, html.gdpr_lightbox-active, body.moove_gdpr_overflow) .gt_float_switcher,
html:is(.eco-cc-open, .gdpr_lightbox-active) body > [class*="buttonizer"],
body.moove_gdpr_overflow > [class*="buttonizer"],
html:is(.eco-cc-open, .gdpr_lightbox-active) body > [id*="buttonizer"],
body.moove_gdpr_overflow > [id*="buttonizer"] {
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* visibility la puede reabrir un hijo con visibility:visible: cortarlo también. */
:is(html.eco-cc-open, html.gdpr_lightbox-active, body.moove_gdpr_overflow) #eco-fab *,
:is(html.eco-cc-open, html.gdpr_lightbox-active, body.moove_gdpr_overflow) #eco-popup *,
:is(html.eco-cc-open, html.gdpr_lightbox-active, body.moove_gdpr_overflow) #eco-tooltip *,
:is(html.eco-cc-open, html.gdpr_lightbox-active, body.moove_gdpr_overflow) .eco-cc-hidden-float * {
  visibility: hidden !important;
}

/* Red de seguridad: la tarjeta nunca hereda ese ocultado. */
html.eco-cc-open #moove_gdpr_cookie_info_bar {
  visibility: visible !important;
}

/* Engranaje de reapertura: por encima del globo de GTranslate (abajo-izquierda). */
#moove_gdpr_save_popup_settings_button:not(.gdpr-floating-button-custom-position) {
  bottom: 76px;
  left: 20px;
}

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

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

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