/* =====================================================
   SURPIN - TIENDA Y CATEGORÍAS (DEFINITIVO - SIN DUPLICADOS)
   ===================================================== */

/* 1. Estilos generales */
body.woocommerce-shop,
body.post-type-archive-product,
body.tax-product_cat {
  background-color: #F5F7FA !important;
}

/* Contenedor principal */
body.woocommerce-shop main.wp-block-group,
body.post-type-archive-product main.wp-block-group,
body.tax-product_cat main,
body.tax-product_cat .wp-block-columns {
  max-width: 1400px !important;
  margin: 0 auto !important;
  padding: 20px 24px 80px 24px !important; 
  box-sizing: border-box !important;
  width: 100% !important;
}

/* ANULAR EL FLEX DEL MAIN (lo que empujaba el botón fuera) */
body.woocommerce-shop main.wp-block-group,
body.post-type-archive-product main.wp-block-group,
body.tax-product_cat main {
    flex: none !important;
    min-height: auto !important;
}

/* =====================================================
   2. ESTRUCTURA DE LA PÁGINA (PC)
   ===================================================== */
body.tax-product_cat .wp-block-columns,
body.woocommerce-shop .wp-block-columns {
  display: flex !important;
  flex-wrap: nowrap !important;
  gap: 30px !important; 
  align-items: flex-start !important;
}

body.tax-product_cat .wp-block-column:first-child,
body.woocommerce-shop .wp-block-column:first-child {
  width: 260px !important;
  flex: 0 0 260px !important;
  margin: 0 !important;
  z-index: 10 !important;
}

body.tax-product_cat .wp-block-column:last-child,
body.woocommerce-shop .wp-block-column:last-child {
  flex: 1 !important;
  width: calc(100% - 300px) !important;
}

/* =====================================================
   3. OCULTAR TÍTULOS Y BARRAS
   ===================================================== */
body.tax-product_cat h1.wp-block-query-title,
body.tax-product_cat .header-media-inner-post {
  display: none !important;
}

.woocommerce-result-count,
.woocommerce-ordering,
.wc-sort-label {
  display: none !important;
}

body.tax-product_cat .wp-product-sidebar-column h2.wp-block-heading,
body.woocommerce-shop .wp-product-sidebar-column h2.wp-block-heading,
body.tax-product_cat .wp-block-column:first-child h2,
body.woocommerce-shop .wp-block-column:first-child h2 {
    display: none !important;
}

.surpin-titulo-custom {
  margin-top: 0 !important;
  margin-bottom: 25px !important;
  padding: 0 !important;
  width: 100% !important;
}

/* =====================================================
   4. EL GRID DE PRODUCTOS Y TARJETAS
   ===================================================== */
.wc-block-product-template__responsive {
  display: grid !important;
  grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  gap: 30px 20px !important;
  padding: 0 !important;
  margin: 0 0 40px 0 !important;
  list-style: none !important;
  width: 100% !important;
  align-items: start !important; /* Evita que las tarjetas se estiren verticalmente */
}

/* LA TARJETA (Flex column para que el botón quede dentro) */
.wc-block-product-template__responsive li.wc-block-product {
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  background: #ffffff !important;
  border: 1px solid #E5EAF3 !important;
  border-radius: 16px !important;
  padding: 20px 15px !important;
  margin: 0 !important;
  text-align: center !important;
  box-shadow: 0 4px 20px rgba(10, 31, 68, 0.04) !important;
  box-sizing: border-box !important;
  height: 100% !important;
}

.wc-block-product-template__responsive li.wc-block-product:hover {
  transform: translateY(-5px) !important;
  box-shadow: 0 12px 25px rgba(10, 31, 68, 0.12) !important;
  border-color: #E63946 !important;
}

/* IMAGEN */
.wc-block-product-template__responsive li.wc-block-product .wc-block-components-product-image {
  width: 100% !important;
  max-width: 140px !important;
  height: 140px !important;
  margin: 0 auto 15px auto !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important;
  flex-shrink: 0 !important;
}

.wc-block-product-template__responsive li.wc-block-product .wc-block-components-product-image img {
  width: 100% !important;
  height: 100% !important;
  object-fit: contain !important;
  display: block !important;
  border-radius: 8px !important;
}

/* TÍTULO */
.wc-block-product-template__responsive li.wc-block-product .wp-block-post-title {
  font-family: 'Oswald', sans-serif !important;
  font-size: 15px !important;
  color: #0A1F44 !important;
  font-weight: 600 !important;
  line-height: 1.3 !important;
  margin: 0 0 5px 0 !important;
  padding: 0 !important;
  text-align: center !important;
  min-height: 40px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 100% !important;
}

.wc-block-product-template__responsive li.wc-block-product .wp-block-post-title a {
  color: #0A1F44 !important;
  text-decoration: none !important;
}

/* PRECIO (Empuja el botón hacia abajo dentro de la tarjeta) */
.wc-block-product-template__responsive li.wc-block-product .wp-block-woocommerce-product-price {
  margin-top: auto !important; 
  margin-bottom: 15px !important;
  width: 100% !important;
}

.wc-block-product-template__responsive li.wc-block-product .wc-block-components-product-price,
.wc-block-product-template__responsive li.wc-block-product .woocommerce-Price-amount {
  color: #E63946 !important;
  font-weight: 700 !important;
  font-size: 16px !important;
  font-family: 'Oswald', sans-serif !important;
  display: block !important;
  text-align: center !important;
}

/* =====================================================
   5. BOTÓN AÑADIR (CENTRADO, ESTÁTICO Y DENTRO DE LA TARJETA)
   ===================================================== */

/* El contenedor del botón: ancho completo y centrado */
.wc-block-product-template__responsive li.wc-block-product .wp-block-woocommerce-product-button {
  display: block !important;
  width: 100% !important;
  text-align: center !important;
  margin: 0 !important;
  padding: 0 !important;
  visibility: visible !important;
  opacity: 1 !important;
  position: static !important;
}

/* El botón: centrado, estático y con el diseño azul */
.wc-block-product-template__responsive li.wc-block-product .wp-block-button__link {
  display: inline-block !important;
  width: 140px !important;
  max-width: 140px !important;
  margin: 0 auto !important;
  padding: 10px 0 !important;
  background: #0A1F44 !important;
  color: #ffffff !important;
  border-radius: 6px !important;
  font-family: 'Nunito Sans', sans-serif !important;
  font-weight: 600 !important;
  text-transform: uppercase !important;
  font-size: 10px !important;
  border: none !important;
  text-align: center !important;
  visibility: visible !important;
  opacity: 1 !important;
  transform: none !important; /* Sin efecto de subir */
  transition: background-color 0.3s ease !important;
}

/* Hover: Solo cambia color, NO se mueve */
.wc-block-product-template__responsive li.wc-block-product .wp-block-button__link:hover {
  background: #E63946 !important;
  transform: none !important; 
}

/* Forzar el texto "AÑADIR AL CARRITO" */
.wc-block-product-template__responsive li.wc-block-product .wp-block-button__link span {
  display: none !important;
}

.wc-block-product-template__responsive li.wc-block-product .wp-block-button__link::before {
  content: 'AÑADIR AL CARRITO' !important;
  display: block !important;
  font-family: 'Nunito Sans', sans-serif !important;
  font-size: 10px !important;
  font-weight: 600 !important;
  color: #ffffff !important;
  text-align: center !important;
  width: 100% !important;
}

.added_to_cart.wc-forward {
  display: none !important;
}

/* =====================================================
   6. DISEÑO RESPONSIVE (MÓVIL)
   ===================================================== */
@media (max-width: 1024px) {
  body.tax-product_cat .wp-block-columns,
  body.woocommerce-shop .wp-block-columns {
    flex-direction: column !important; 
    gap: 20px !important;
  }
  body.tax-product_cat .wp-block-column:first-child,
  body.woocommerce-shop .wp-block-column:first-child {
    width: 100% !important;
    flex: 0 0 100% !important;
  }
  body.tax-product_cat .wp-block-column:last-child,
  body.woocommerce-shop .wp-block-column:last-child {
    width: 100% !important;
  }
}

@media (max-width: 768px) {
  body.tax-product_cat .wp-block-columns,
  body.woocommerce-shop .wp-block-columns {
    display: flex !important;
    flex-direction: column !important; 
    gap: 10px !important;
    padding: 10px 8px 40px 8px !important; 
  }

  body.tax-product_cat .wp-block-column:first-child,
  body.woocommerce-shop .wp-block-column:first-child {
    width: 100% !important;
    display: block !important;
    margin-bottom: 0 !important; 
    padding: 0 !important;
  }

  .surpin-titulo-custom {
    margin-top: 15px !important;
    margin-bottom: 15px !important;
    text-align: left !important;
  }

  .wc-block-product-template__responsive {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 10px !important; 
  }

  .wc-block-product-template__responsive li.wc-block-product {
    padding: 12px 8px !important;
    border-radius: 12px !important;
  }

  .wc-block-product-template__responsive li.wc-block-product .wc-block-components-product-image {
    max-width: 120px !important; 
    height: 120px !important;
    margin-bottom: 10px !important;
  }

  .wc-block-product-template__responsive li.wc-block-product .wp-block-post-title {
    font-size: 13px !important;
    min-height: 36px !important;
  }

  .wc-block-product-template__responsive li.wc-block-product .wc-block-components-product-price {
    font-size: 14px !important;
  }

  .wc-block-product-template__responsive li.wc-block-product .wp-block-button__link {
    width: 100% !important;
    max-width: 100% !important;
    padding: 8px 0 !important;
    font-size: 9px !important;
  }
  
  .wc-block-product-template__responsive li.wc-block-product .wp-block-button__link::before {
    font-size: 9px !important;
  }

  /* Botón de filtros en móvil */
  body.tax-product_cat .wc-block-product-filters__open-overlay,
  body.woocommerce-shop .wc-block-product-filters__open-overlay {
    display: inline-flex !important;
    background: #ffffff !important;
    border: 1px solid #E5EAF3 !important;
    padding: 8px 15px !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #0A1F44 !important;
    margin: 0 !important;
    pointer-events: auto !important;
  }
}

/* =====================================================
   7. CAMBIAR EL TEXTO DEL BOTÓN A "FILTROS"
   ===================================================== */
.wc-block-product-filters__open-overlay span {
    display: none !important;
}

.wc-block-product-filters__open-overlay::after {
    content: 'FILTROS' !important;
    display: inline-block !important;
    font-family: 'Nunito Sans', sans-serif !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    color: #0A1F44 !important;
    margin-left: 8px !important;
}

/* =====================================================
   ANULAR EL POSICIONAMIENTO ABSOLUTO DEL BOTÓN
   ===================================================== */

/* Forzamos al contenedor del botón a ser un bloque normal (sin position absolute) */
.wp-block-woocommerce-product-collection .wc-block-product-template li .wp-block-button.wc-block-components-product-button.wp-block-woocommerce-product-button,
.wp-block-woocommerce-product-collection .wc-block-product-template li .block-editor-block-list__block.wp-block-woocommerce-product-button {
    position: static !important; /* Anula position: absolute */
    transform: none !important;
    opacity: 1 !important;
    visibility: visible !important;
    left: auto !important;
    top: auto !important;
    margin: 10px 0 0 0 !important;
    display: block !important;
    text-align: center !important;
    width: 100% !important;
}

/* El botón se comporta como bloque en línea y se centra */
.wp-block-woocommerce-product-collection .wc-block-product-template li .wp-block-button__link {
    display: inline-block !important;
    margin: 0 auto !important;
    width: 140px !important;
    max-width: 140px !important;
    padding: 10px 0 !important;
    background: #0A1F44 !important;
    color: #ffffff !important;
    border-radius: 6px !important;
    font-family: 'Nunito Sans', sans-serif !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    font-size: 10px !important;
    border: none !important;
    text-align: center !important;
    transform: none !important;
}

/* =====================================================
   OCULTAR EL TÍTULO CUANDO EL PANEL DE FILTROS ESTÁ ABIERTO
   ===================================================== */

/* Cuando el body tiene la clase que indica que el filtro está abierto, ocultamos el título */
body:has(.wc-block-product-filters.is-overlay-opened) .surpin-titulo-custom {
    display: none !important;
}

/* También ocultamos el título original de Gutenberg por si acaso */
body:has(.wc-block-product-filters.is-overlay-opened) h1.wp-block-query-title {
    display: none !important;
}

/* =====================================================
   REDUCIR EL ESPACIO SUPERIOR EN TIENDA Y CATEGORÍAS
   ===================================================== */

/* 1. En PC y tablet, reducimos el padding superior del main */
body.woocommerce-shop main.wp-block-group,
body.post-type-archive-product main.wp-block-group,
body.tax-product_cat main {
    padding-top: 10px !important;
    margin-top: 0 !important;
}

/* 2. En móvil, lo reducimos aún más para que el título quede pegado al menú */
@media (max-width: 768px) {
    body.woocommerce-shop main.wp-block-group,
    body.post-type-archive-product main.wp-block-group,
    body.tax-product_cat main,
    body.tax-product_cat .wp-block-columns {
        padding-top: 5px !important;
    }
}

/* 3. Ajustamos el margen del título para que no deje hueco extra */
.surpin-titulo-custom {
    margin-top: 0 !important;
    padding-top: 0 !important;
}
/* Ocultar el mensaje feo por defecto de WooCommerce (Bloques) */
.wp-block-woocommerce-product-collection-no-results,
.wc-block-product-template__no-results {
    display: none !important;
}
