/**
 * Top Categories Widget - Estilos
 * Categorías más buscadas con iconos circulares
 */

/* ========================================
   CONTENEDOR PRINCIPAL
   ======================================== */

.top-categories-widget {
  width: 100%;
  padding: 40px 20px;
  color: #fff;
}

/* Título */
.top-categories-title {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  color: #fff;
  margin: 0 0 40px 0;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ========================================
   GRID DE CATEGORÍAS
   ======================================== */

.top-categories-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 30px;
  max-width: 1200px;
  margin: 0 auto;
}

/* Item de categoría */
.category-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: #fff;
  transition: all 0.3s ease;
}

.category-item:hover {
  transform: translateY(-5px);
}

/* ========================================
   ICONO CIRCULAR
   ======================================== */

/* Contenedor circular para el icono
   - Mantiene aspect ratio 1:1
   - Overflow hidden para crop circular
   - Position relative para posicionamiento absoluto del icono
*/
.category-icon-wrapper {
  width: 150px;
  height: 150px;
  border-radius: var(--waeg-radius-full);
  border: 3px solid var(--waeg-danger);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--waeg-black);
  margin-bottom: 15px;
  transition: all var(--waeg-transition);
  overflow: hidden;
  position: relative;
}

.category-item:hover .category-icon-wrapper {
  border-color: #fff;
  transform: scale(1.05);
}

/* Icono de imagen */
.category-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  filter: brightness(0) invert(1); /* Icono blanco */
  transition: filter 0.3s ease;
  padding: 1%; /* AJUSTAR AQUÍ: 1% = 98% del contenedor */
  box-sizing: border-box;
}

/* Variante para SVG o iconos que necesitan más espacio */
.category-icon[src*=".svg"],
.category-icon[src*="icon"] {
  object-fit: contain;
  padding: 1%; /* SVG ocupan 98% */
}

/* Variante para PNG transparentes */
.category-icon[src*=".png"] {
  object-fit: contain;
  padding: 1%; /* PNG ocupan 98% */
}

/* Forzar aspect ratio 1:1 */
.category-icon-wrapper::before {
  content: '';
  display: block;
  padding-top: 100%;
}

.category-icon-wrapper > img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.category-item:hover .category-icon {
  filter: brightness(0) invert(1);
}

/* Clase opcional para iconos que ya son blancos o no necesitan filtro */
.category-icon.no-filter {
  filter: none !important;
}

.category-icon.no-filter:hover {
  filter: none !important;
}

/* Clase opcional para iconos que necesitan MÁS espacio */
.category-icon.large-padding {
  padding: 0% !important; /* 100% del contenedor */
}

/* Clase opcional para iconos que necesitan MENOS espacio */
.category-icon.small-padding {
  padding: 5% !important; /* 90% del contenedor */
}

/* Placeholder cuando no hay icono */
.category-icon-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  font-weight: 700;
  color: #e74c3c;
}

/* ========================================
   NOMBRE DE CATEGORÍA
   ======================================== */

.category-name {
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  line-height: 1.3;
  max-width: 120px;
  transition: color 0.3s ease;
}

.category-item:hover .category-name {
  color: #e74c3c;
}

/* ========================================
   RESPONSIVE
   ======================================== */

/* Tablet (4 columnas) */
@media (max-width: 991px) {
  .top-categories-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 25px;
  }
  
  .category-icon-wrapper {
    width: 110px;
    height: 110px;
  }
  
  .category-name {
    font-size: 12px;
  }
  
  .top-categories-title {
    font-size: 22px;
    margin-bottom: 35px;
  }
}

/* Tablet pequeño (slider horizontal) */
@media (max-width: 767px) {
  .top-categories-grid {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 20px;
    padding: 0 20px 20px 20px;
    grid-template-columns: none;
    position: relative;
  }
  
  /* Sin indicador visual de scroll */
  .top-categories-grid::after {
    display: none;
  }
  
  .category-item {
    flex: 0 0 auto;
    scroll-snap-align: start;
    min-width: 120px;
  }
  
  .category-icon-wrapper {
    width: 100px;
    height: 100px;
  }
  
  .category-name {
    font-size: 11px;
  }
  
  .top-categories-title {
    font-size: 20px;
    margin-bottom: 30px;
  }
  
  /* Ocultar scrollbar pero mantener funcionalidad */
  .top-categories-grid::-webkit-scrollbar {
    display: none;
  }
  
  .top-categories-grid {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
}

/* Mobile (2 filas x 3 columnas) */
@media (max-width: 480px) {
  .top-categories-widget {
    padding: 30px 15px;
    position: relative;
  }
  
  .top-categories-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 15px;
    padding: 0;
    max-height: none;
    overflow: visible;
  }
  
  /* Mostrar solo las primeras 6 categorías */
  .category-item:nth-child(n+7) {
    display: none;
  }
  
  .category-item {
    flex: none;
    scroll-snap-align: none;
    min-width: auto;
  }
  
  .category-icon-wrapper {
    width: 90px;
    height: 90px;
    border-width: 2px;
  }
  
  .category-name {
    font-size: 10px;
    max-width: 100px;
  }
  
  .top-categories-title {
    font-size: 18px;
    margin-bottom: 25px;
    letter-spacing: 1px;
    padding: 0;
  }
}

/* ========================================
   BOTÓN VER MÁS
   ======================================== */

.top-categories-more {
  display: none;
  text-align: center;
  margin-top: 30px;
}

.top-categories-more-btn {
  display: inline-block;
  padding: 12px 40px;
  background: #e74c3c;
  color: #fff;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-radius: 4px;
  transition: all 0.3s ease;
  border: 2px solid #e74c3c;
}

.top-categories-more-btn:hover {
  background: transparent;
  color: #e74c3c;
  transform: translateY(-2px);
}

/* Mostrar botón solo en mobile cuando hay más de 6 categorías */
@media (max-width: 480px) {
  .top-categories-more {
    display: block;
  }
}

/* ========================================
   VARIANTES DE COLUMNAS (via shortcode)
   ======================================== */

/* 2 columnas */
.top-categories-widget[data-columns="2"] .top-categories-grid {
  grid-template-columns: repeat(2, 1fr);
}

/* 3 columnas */
.top-categories-widget[data-columns="3"] .top-categories-grid {
  grid-template-columns: repeat(3, 1fr);
}

/* 4 columnas */
.top-categories-widget[data-columns="4"] .top-categories-grid {
  grid-template-columns: repeat(4, 1fr);
}

/* 6 columnas */
.top-categories-widget[data-columns="6"] .top-categories-grid {
  grid-template-columns: repeat(6, 1fr);
}

/* ========================================
   ANIMACIONES
   ======================================== */

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.category-item {
  animation: fadeInUp 0.5s ease-out;
  animation-fill-mode: both;
}

/* Delay escalonado para cada item */
.category-item:nth-child(1) { animation-delay: 0.1s; }
.category-item:nth-child(2) { animation-delay: 0.2s; }
.category-item:nth-child(3) { animation-delay: 0.3s; }
.category-item:nth-child(4) { animation-delay: 0.4s; }
.category-item:nth-child(5) { animation-delay: 0.5s; }
.category-item:nth-child(6) { animation-delay: 0.6s; }
.category-item:nth-child(7) { animation-delay: 0.7s; }
.category-item:nth-child(8) { animation-delay: 0.8s; }
.category-item:nth-child(9) { animation-delay: 0.9s; }
.category-item:nth-child(10) { animation-delay: 1s; }

/* ========================================
   EFECTOS ADICIONALES
   ======================================== */

/* Efecto ripple al hacer click */
.category-item:active .category-icon-wrapper {
  transform: scale(0.95);
}
