/* Contenedor principal del carrusel */
.category-carousel-container {
  /* max-width: 1200px; */
  margin: 0 0 30px 0;
  /* padding: 0 20px; */
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Wrapper del grid que contiene las 2 filas */
.category-grid-wrapper {
  flex: 1;
  overflow: hidden;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.02);
  padding: 15px;
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.05);
  position: relative;
}

/* Gradientes de difuminado en los extremos */
.category-grid-wrapper::before,
.category-grid-wrapper::after {
  content: '';
  position: absolute;
  top: 15px;
  bottom: 15px;
  width: 30px;
  z-index: 5;
  pointer-events: none;
}

.category-grid-wrapper::before {
  left: 15px;
  background: linear-gradient(to right, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.5), transparent);
}

.category-grid-wrapper::after {
  right: 15px;
  background: linear-gradient(to left, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.5), transparent);
}

/* Grid principal - 2 filas con scroll horizontal */
.category-grid {
  display: grid;
  grid-template-rows: repeat(2, 1fr);
  grid-auto-flow: column;
  gap: 16px;
  padding: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
  /* Optimizaciones para touch por defecto */
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
}

.category-grid::-webkit-scrollbar {
  display: none; /* Chrome, Safari and Opera */
}

/* Botones de navegación - Más modernos y profesionales */
.carousel-nav {
  position: static;
  background: rgba(255, 255, 255, 0.9);
  color: rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(0, 0, 0, 0.1);
  width: 42px;
  height: 42px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 500;
  z-index: 10;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  flex-shrink: 0;
  backdrop-filter: blur(10px);
}

.carousel-nav:hover {
  background: rgba(255, 255, 255, 0.95);
  color: rgba(0, 0, 0, 0.8);
  border-color: rgba(0, 0, 0, 0.15);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  transform: translateY(-1px);
}

.carousel-nav:active {
  transform: translateY(0) scale(0.98);
}

/* Indicadores de posición - Más cercanos y modernos */
.carousel-indicators {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
}

.carousel-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: none;
  position: relative;
}

.carousel-indicator.active {
  background: rgba(0, 0, 0, 0.8);
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.3);
  transform: scale(1.2);
}

.carousel-indicator:hover {
  background: rgba(0, 0, 0, 0.6);
  transform: scale(1.1);
}

/* Items de categoría - Sin fondo, más limpio y profesional */
.category-item {
  background: transparent;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  width: 220px;
  height: 64px;
  backdrop-filter: blur(5px);
  scroll-snap-align: start;
}

.category-item a {
  text-decoration: none;
  color: inherit;
  display: grid;
  grid-template-columns: 64px 1fr;
  height: 100%;
  width: 100%;
  align-items: center;
}

.category-item a:hover {
  text-decoration: none;
}

.category-image {
  background: rgb(0 0 0 / 4%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 12px;
  border-radius: 12px;
  margin: 4px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.category-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.category-text {
  padding: 0 16px;
  display: flex;
  align-items: center;
}

.category-title {
  color: rgba(0, 0, 0, 0.85);
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  letter-spacing: 0.3px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Efectos hover más sutiles y profesionales */
.category-item:hover {
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.02);
}

.category-item:hover .category-title {
  color: #007cba;
  transition: color 0.3s ease;
}

.category-item:hover .category-image {
  background: rgba(0, 124, 186, 0.1);
  border-color: rgba(0, 124, 186, 0.2);
}

/* Animación de entrada mejorada */
@keyframes categorySlideIn {
  from {
    opacity: 0;
    transform: translateX(-15px) translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateX(0) translateY(0);
  }
}

.category-item {
  animation: categorySlideIn 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.category-item:nth-child(even) {
  animation-delay: 0.15s;
}

/* Responsive para tablets */
@media (max-width: 768px) {
  .category-carousel-container {
    padding: 0 10px;
    gap: 6px;
  }

  /* Reducir padding en tablets también */
  .category-grid-wrapper {
    padding: 12px;
  }

  .category-grid {
    gap: 14px;
    padding: 6px;
    /* Mejorar el touch scrolling */
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  .category-item {
    width: 180px;
    height: 56px;
    scroll-snap-align: start;
    box-shadow: none;
    border: 1px solid rgba(0, 0, 0, 0.1);
  }

  .category-item a {
    grid-template-columns: 56px 1fr;
  }

  .category-text {
    padding: 0 12px;
  }

  .category-title {
    font-size: 13px;
  }

  /* Ocultar navegación en tablets */
  .carousel-nav {
    display: none !important;
  }

  .carousel-indicators {
    display: none !important;
  }

  /* Ocultar gradientes de blur en tablets */
  .category-grid-wrapper::before,
  .category-grid-wrapper::after {
    display: none;
  }
}

/* Responsive para móviles */
@media (max-width: 480px) {
  .category-carousel-container {
    padding: 0 5px;
    gap: 4px;
  }

  /* Reducir padding del wrapper en móvil */
  .category-grid-wrapper {
    padding: 8px;
  }

  .category-grid {
    gap: 12px;
    padding: 4px;
    /* Optimizar para touch */
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  .category-item {
    width: 150px;
    height: 48px;
    scroll-snap-align: start;
    /* Evitar selección de texto durante el drag */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    box-shadow: none;
    border: 1px solid rgba(0, 0, 0, 0.1);
  }

  .category-item a {
    grid-template-columns: 48px 1fr;
  }

  .category-image {
    padding: 5px;
  }

  .category-text {
    padding: 0 10px;
  }

  .category-title {
    font-size: 12px;
  }

  /* Ocultar completamente la navegación en móviles */
  .carousel-nav {
    display: none !important;
  }

  .carousel-indicators {
    display: none !important;
  }

  /* Ocultar gradientes de blur en móviles */
  .category-grid-wrapper::before,
  .category-grid-wrapper::after {
    display: none;
  }
}

/* Muy pequeños */
@media (max-width: 360px) {
  /* Padding aún más reducido para pantallas muy pequeñas */
  .category-grid-wrapper {
    padding: 6px;
  }

  .category-grid {
    padding: 3px;
    /* Mantener optimizaciones touch */
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  .category-item {
    width: 130px;
    height: 44px;
    scroll-snap-align: start;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    box-shadow: none;
    border: 1px solid rgba(0, 0, 0, 0.1);
  }

  .category-item a {
    grid-template-columns: 44px 1fr;
  }

  .category-title {
    font-size: 11px;
  }

  /* Asegurar que la navegación esté oculta */
  .carousel-nav {
    display: none !important;
  }

  .carousel-indicators {
    display: none !important;
  }

  /* Ocultar gradientes de blur en pantallas muy pequeñas */
  .category-grid-wrapper::before,
  .category-grid-wrapper::after {
    display: none;
  }
}

/* Estados de carga y vacío */
.category-carousel-container:empty::after {
  content: "Cargando categorías...";
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.6);
  font-style: italic;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Mejoras de accesibilidad */
.carousel-nav:focus {
  outline: 2px solid rgba(255, 255, 255, 0.6);
  outline-offset: 2px;
}

.category-item:focus-within {
  outline: 2px solid rgba(255, 255, 255, 0.4);
  outline-offset: 2px;
  transform: translateY(-2px);
}

/* Smooth scrolling mejorado */
.category-grid {
  scroll-snap-type: x mandatory;
}

.category-item {
  scroll-snap-align: start;
}

/* Ocultar navegación cuando no es necesaria */
.carousel-nav[style*="display: none"] {
  display: none !important;
}

/* Optimizaciones específicas para dispositivos táctiles */
@media (hover: none) and (pointer: coarse) {
  /* Ocultar navegación en dispositivos táctiles */
  .carousel-nav,
  .carousel-indicators {
    display: none !important;
  }
  
  /* Mejorar el scroll táctil */
  .category-grid {
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }
  
  .category-item {
    scroll-snap-align: start;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    /* Mejorar la respuesta táctil */
    -webkit-tap-highlight-color: transparent;
  }
  
  /* Ajustar transiciones para mejor rendimiento en móvil */
  .category-item:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }

  .category-item {
    box-shadow: none;
    border: 1px solid rgba(0, 0, 0, 0.1);
  }
}
