/* Ocultar calificaciones por estrellas en el grid */
.waeg-grid .star-rating,
.waeg-grid .woocommerce-product-rating {
  display: none !important;
}

/* Grid responsivo con cards de 357x492 */
.waeg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, 357px);
  gap: 24px;
  align-items: stretch;
  justify-content: center;
}

/* Desktop grande - 3 columnas */
@media (min-width: 1200px) {
  .waeg-grid {
    grid-template-columns: repeat(3, 357px);
    justify-content: space-between;
  }
}

/* Tablet - 2 columnas */
@media (max-width: 1199px) and (min-width: 768px) {
  .waeg-grid {
    grid-template-columns: repeat(2, 357px);
    justify-content: space-around;
  }
}

/* Mobile - 1 columna centrada */
@media (max-width: 767px) {
  .waeg-grid {
    grid-template-columns: 1fr;
    justify-content: center;
  }
  
  .waeg-grid .product,
  .waeg-grid li.product {
    width: 100% !important;
    max-width: 357px !important;
    margin: 0 auto !important;
  }
}

/* ======================================
   PRODUCTOS DE WOOCOMMERCE - DISEÑO UNIFICADO
   ====================================== */

/* Resetear estilos de WooCommerce que puedan interferir */
.waeg-grid ul.products,
.waeg-grid .products {
  list-style: none !important;
  padding: 0 !important;
  margin: 0 !important;
}

.waeg-grid ul.products li,
.waeg-grid .products .product {
  margin: 0 !important;
  padding: 0 !important;
  list-style: none !important;
}

/* Estructura de la card - TAMAÑO EXACTO 357x492 */
.waeg-grid .product,
.waeg-grid li.product,
.waeg-grid .type-product {
  display: flex !important;
  flex-direction: column !important;
  width: 357px !important;
  max-width: 357px !important;
  height: 492px !important;
  min-height: 492px !important;
  max-height: 492px !important;
  background: #fff !important;
  border: 1px solid #eee !important;
  border-radius: 8px !important;
  overflow: hidden !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02) !important;
  transition: box-shadow 0.3s ease !important;
  position: relative !important;
  margin: 0 !important;
  padding: 0 !important;
}

.waeg-grid .product:hover,
.waeg-grid li.product:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08) !important;
}

/* Contenedor del link principal - FLEX PARA DISTRIBUCIÓN */
.waeg-grid .product a.woocommerce-loop-product__link,
.waeg-grid .product a.woocommerce-LoopProduct-link,
.waeg-grid .product > a:first-child {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 1 auto !important;
  text-decoration: none !important;
  color: inherit !important;
  min-height: 0 !important;
}

/* IMAGEN - AJUSTADA PARA 492px DE ALTURA TOTAL */
.waeg-grid .product a img,
.waeg-grid .product img,
.waeg-grid .product .attachment-woocommerce_thumbnail {
  width: 100% !important;
  height: 280px !important;
  max-height: 280px !important;
  object-fit: contain !important;
  object-position: center !important;
  padding: 20px !important;
  background: #fafafa !important;
  display: block !important;
  margin: 0 !important;
  flex-shrink: 0 !important;
}

/* Área de contenido - FLEX PARA EMPUJAR BOTÓN AL FONDO */
.waeg-grid .product .woocommerce-loop-product__link {
  display: flex !important;
  flex-direction: column !important;
  flex: 1 !important;
}

/* TÍTULO - AJUSTADO PARA CARD DE 492px */
.waeg-grid .product .woocommerce-loop-product__title,
.waeg-grid .product h2.woocommerce-loop-product__title,
.waeg-grid .product h3.woocommerce-loop-product__title,
.waeg-grid .product h2,
.waeg-grid .product h3 {
  font-size: 16px !important;
  line-height: 1.5 !important;
  margin: 16px !important;
  padding: 0 !important;
  font-weight: 500 !important;
  color: #333 !important;
  height: 48px !important;
  max-height: 48px !important;
  min-height: 48px !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  flex-shrink: 0 !important;
}

/* PRECIO - AJUSTADO PARA CARD DE 492px */
.waeg-grid .product .price,
.waeg-grid .product span.price {
  font-size: 18px !important;
  font-weight: 600 !important;
  color: #333 !important;
  margin: 0 16px 16px 16px !important;
  padding: 0 !important;
  height: 28px !important;
  min-height: 28px !important;
  display: block !important;
  flex-shrink: 0 !important;
}

.waeg-grid .product .price del {
  opacity: 0.5 !important;
  font-weight: 400 !important;
  margin-right: 8px !important;
}

.waeg-grid .product .price ins {
  text-decoration: none !important;
  color: #0073aa !important;
  font-weight: 600 !important;
}

/* Espaciador flexible para empujar el botón al fondo */
.waeg-grid .product .woocommerce-loop-product__link::after {
  content: '' !important;
  flex: 1 1 auto !important;
  min-height: 0 !important;
}

/* BOTÓN - AJUSTADO PARA CARD DE 492px */
.waeg-grid .product .button,
.waeg-grid .product .add_to_cart_button,
.waeg-grid .product a.button {
  display: block !important;
  width: calc(100% - 32px) !important;
  margin: 0 16px 16px 16px !important;
  padding: 12px 20px !important;
  text-align: center !important;
  background: #0073aa !important;
  color: white !important;
  border: none !important;
  border-radius: 8px !important;
  font-weight: 600 !important;
  font-size: 15px !important;
  cursor: pointer !important;
  transition: all 0.3s ease !important;
  text-decoration: none !important;
  margin-top: auto !important;
  flex-shrink: 0 !important;
  height: 48px !important;
  line-height: 24px !important;
}

.waeg-grid .product .button:hover,
.waeg-grid .product .add_to_cart_button:hover {
  background: #005177 !important;
  transform: translateY(-2px) !important;
  box-shadow: 0 4px 8px rgba(0, 115, 170, 0.3) !important;
}

.waeg-grid .product .button:disabled,
.waeg-grid .product .button.loading {
  background: #ccc !important;
  cursor: not-allowed !important;
  transform: none !important;
}

/* Badge de "En oferta" */
.waeg-grid .product .onsale {
  position: absolute !important;
  top: 12px !important;
  left: 12px !important;
  background: #dc3545 !important;
  color: white !important;
  padding: 4px 10px !important;
  border-radius: 4px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  z-index: 2 !important;
  margin: 0 !important;
}

/* Ocultar elementos innecesarios que puedan descuadrar */
.waeg-grid .product .woocommerce-loop-category__title,
.waeg-grid .product .product-category {
  display: none !important;
}

/* Remover márgenes/paddings de listas */
.waeg-grid .product * {
  box-sizing: border-box !important;
}

/* Asegurar que elementos adicionales no rompan el layout */
.waeg-grid .product .woocommerce-placeholder,
.waeg-grid .product .placeholder {
  height: 220px !important;
  background: #f5f5f5 !important;
}

/* Si hay productos sin imagen */
.waeg-grid .product:not(:has(img)) a:first-child::before {
  content: '' !important;
  display: block !important;
  height: 220px !important;
  background: #f5f5f5 !important;
  flex-shrink: 0 !important;
}

/* Forzar estructura incluso si faltan elementos */
.waeg-grid .product {
  grid-template-rows: none !important;
}

/* Card (mantener para compatibilidad con custom templates) */
.waeg-product {
  background: #fff;
  border: 1px solid #eee;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.02);
}

.waeg-product .waeg-product-link {
  color: inherit;
  text-decoration: none;
  display: block;
  flex: 1 1 auto;
}

.waeg-thumb {
  padding: 12px;
  display:flex;
  align-items:center;
  justify-content:center;
  height: 220px;
  background: #fafafa;
}

.waeg-thumb img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  display:block;
}

/* Info */
.waeg-info {
  padding: 12px;
}

.waeg-title {
  font-size: 16px;
  margin: 0 0 8px 0;
  line-height: 1.2;
}

.waeg-price {
  font-weight: 600;
}

/* Acciones */
.waeg-actions {
  padding: 10px;
  border-top: 1px solid #f1f1f1;
  display:flex;
  gap:8px;
  justify-content: center;
  align-items:center;
}

.waeg-add-to-cart,
.waeg-view {
  display:inline-block;
  padding:8px 12px;
  border-radius:6px;
  text-decoration:none;
  border:1px solid #ddd;
  background:#fff;
  font-size:14px;
}

/* Controles */
.waeg-controls {
  margin-bottom: 20px;
  display:flex;
  flex-direction:column;
  gap:10px;
}

#waeg-search {
  padding:8px 12px;
  font-size:14px;
  max-width:420px;
  border:1px solid #ddd;
  border-radius:8px;
}

.waeg-filters {
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.waeg-filter-btn {
  background:#f5f5f5;
  border:none;
  padding:6px 10px;
  border-radius:6px;
  cursor:pointer;
}

.waeg-filter-btn.active {
  background:#333;
  color:#fff;
}

/* No results */
.waeg-no-results {
  grid-column: 1 / -1;
  padding: 30px;
  text-align: center;
  color:#666;
}

/* Botones de añadir al carrito */
.waeg-add-to-cart {
  background: #0073aa;
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s ease;
}

.waeg-add-to-cart:hover {
  background: #005177;
}

.waeg-add-to-cart:disabled {
  background: #ccc;
  cursor: not-allowed;
}

/* Notificaciones */
.waeg-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 6px;
  color: white;
  font-size: 14px;
  font-weight: 500;
  z-index: 9999;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: slideInFromRight 0.3s ease-out;
}

.waeg-notification-success {
  background: #28a745;
}

.waeg-notification-error {
  background: #dc3545;
}

@keyframes slideInFromRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ======================================
   BOTÓN FLOTANTE DEL CARRITO
   ====================================== */
.waeg-cart-float {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  background: #0073aa;
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 115, 170, 0.4);
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  padding: 0;
}

.waeg-cart-float:hover {
  background: #005177;
  transform: scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 115, 170, 0.5);
}

.waeg-cart-float:active {
  transform: scale(0.95);
}

#waeg-cart-count {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #dc3545;
  color: white;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  border: 2px solid white;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

/* ======================================
   OFFCANVAS DEL CARRITO
   ====================================== */
.waeg-cart-offcanvas {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 9999;
  pointer-events: none;
  transition: opacity 0.3s ease;
  opacity: 0;
}

.waeg-cart-offcanvas.active {
  pointer-events: auto;
  opacity: 1;
}

.waeg-cart-offcanvas-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  cursor: pointer;
}

.waeg-cart-offcanvas-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 420px;
  background: white;
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
  padding: 24px;
}

.waeg-cart-offcanvas.active .waeg-cart-offcanvas-panel {
  transform: translateX(0);
}

.waeg-cart-offcanvas-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: #666;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.waeg-cart-offcanvas-close:hover {
  background: #f5f5f5;
  color: #333;
}

.waeg-cart-offcanvas h2 {
  margin: 0 0 20px 0;
  font-size: 24px;
  font-weight: 600;
  color: #333;
  padding-right: 40px;
}

.waeg-cart-offcanvas h3 {
  margin: 20px 0 12px 0;
  font-size: 18px;
  font-weight: 600;
  color: #333;
}

.waeg-cart-offcanvas hr {
  border: none;
  border-top: 1px solid #e5e5e5;
  margin: 20px 0;
}

/* ======================================
   CONTENIDO DEL CARRITO
   ====================================== */
.waeg-cart-items {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 16px;
}

.waeg-cart-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.waeg-cart-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: #f9f9f9;
  border-radius: 8px;
  margin-bottom: 12px;
  align-items: center;
}

.waeg-cart-item .waeg-cart-thumb {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
  background: white;
  padding: 4px;
  flex-shrink: 0;
}

.waeg-cart-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.waeg-cart-item-name {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  line-height: 1.3;
}

.waeg-cart-item-qty {
  font-size: 13px;
  color: #666;
}

.waeg-cart-item-price {
  font-size: 15px;
  font-weight: 600;
  color: #0073aa;
}

.waeg-cart-total {
  padding: 16px;
  background: #f5f5f5;
  border-radius: 8px;
  margin: 16px 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
}

.waeg-cart-total strong {
  color: #333;
}

.waeg-cart-goto {
  display: block;
  width: 100%;
  padding: 12px 16px;
  text-align: center;
  background: #0073aa;
  color: white;
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  font-size: 15px;
  margin-bottom: 12px;
  transition: all 0.3s ease;
  border: none;
}

.waeg-cart-goto:hover {
  background: #005177;
  color: white;
}

.waeg-cart-checkout {
  background: #28a745;
}

.waeg-cart-checkout:hover {
  background: #218838;
}

.waeg-cart-empty,
.waeg-cart-error {
  padding: 32px 16px;
  text-align: center;
  color: #666;
  font-size: 15px;
  background: #f9f9f9;
  border-radius: 8px;
}

.waeg-cart-error {
  background: #fff3cd;
  color: #856404;
}

/* Bloqueo de scroll cuando el offcanvas está abierto */
body.waeg-cart-offcanvas-open {
  overflow: hidden;
}

/* ======================================
   RESPONSIVE
   ====================================== */
@media (max-width: 480px) {
  .waeg-cart-offcanvas-panel {
    max-width: 100%;
  }
  
  .waeg-cart-float {
    width: 56px;
    height: 56px;
    bottom: 16px;
    right: 16px;
    font-size: 22px;
  }
  
  #waeg-cart-count {
    width: 22px;
    height: 22px;
    font-size: 11px;
  }
}
