* {
  box-sizing: border-box;
}

#carousel {
  position: relative;
  width: 100%;
  max-width: 900px;
  margin: 20px auto;
  overflow: hidden;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  background: #000;
}

/* Agregar aspect ratio para consistencia */
#carousel::before {
  content: '';
  display: block;
  padding-top: 56.25%; /* Ratio 16:9 */
}

.carousel-track {
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.carousel-track picture {
  display: contents;
}

.index-image-representative {
  width: 100%;
  height: 100%;
  flex-shrink: 0;
  object-fit: cover;
  object-position: center;
  opacity: 0.95;
  transition: opacity 0.3s ease;
}

#carousel:hover .index-image-representative {
  opacity: 1;
}

/* Overlay gradient para mejor legibilidad de controles */
#carousel::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0.1) 0%,
    rgba(0, 0, 0, 0) 20%,
    rgba(0, 0, 0, 0) 80%,
    rgba(0, 0, 0, 0.3) 100%
  );
  pointer-events: none;
  z-index: 1;
}

/* Botones mejorados */
.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.9);
  color: #1e3c72;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 16px 20px;
  border-radius: 50%;
  z-index: 10;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  opacity: 0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  width: 50px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#carousel:hover .carousel-btn {
  opacity: 1;
}

.carousel-btn:hover {
  background: white;
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  color: #ff6b35;
}

.carousel-btn:active {
  transform: translateY(-50%) scale(0.95);
}

.carousel-btn.prev {
  left: 20px;
}

.carousel-btn.next {
  right: 20px;
}

/* Indicadores mejorados */
.carousel-indicators {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 2;
  background: rgba(0, 0, 0, 0.3);
  padding: 10px 16px;
  border-radius: 25px;
  backdrop-filter: blur(10px);
}

.carousel-indicators button {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
  position: relative;
}

.carousel-indicators button:hover {
  background: rgba(255, 255, 255, 0.8);
  transform: scale(1.2);
}

.carousel-indicators button.active {
  background: #ff6b35;
  border-color: white;
  width: 32px;
  border-radius: 25px;
}

/* Efecto de pulso en el indicador activo */
.carousel-indicators button.active::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  border-radius: 25px;
  border: 2px solid #ff6b35;
  animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
  0% {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.5);
    opacity: 0;
  }
}

/* Loading skeleton para mejor UX */
.carousel-track.loading .index-image-representative {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Responsive mejorado */
@media (max-width: 768px) {
  #carousel {
    max-width: 100%;
    border-radius: 12px;
    margin: 15px auto;
  }

  .carousel-btn {
    padding: 12px 16px;
    font-size: 18px;
    width: 44px;
    height: 44px;
    opacity: 0.8;
  }

  .carousel-btn.prev {
    left: 10px;
  }

  .carousel-btn.next {
    right: 10px;
  }

  .carousel-indicators {
    bottom: 15px;
    padding: 8px 12px;
    gap: 8px;
  }

  .carousel-indicators button {
    width: 10px;
    height: 10px;
  }

  .carousel-indicators button.active {
    width: 24px;
  }
}

@media (max-width: 480px) {
  .carousel-btn {
    width: 38px;
    height: 38px;
    font-size: 16px;
  }

  .carousel-indicators {
    padding: 6px 10px;
    gap: 6px;
  }

  .carousel-indicators button {
    width: 8px;
    height: 8px;
  }

  .carousel-indicators button.active {
    width: 20px;
  }
}

/* Accesibilidad */
.carousel-btn:focus,
.carousel-indicators button:focus {
  outline: 3px solid #ff6b35;
  outline-offset: 2px;
}

/* Pausar animación cuando el usuario prefiere reducir movimiento */
@media (prefers-reduced-motion: reduce) {
  .carousel-track {
    transition: none;
  }
  
  .carousel-btn,
  .carousel-indicators button {
    transition: none;
  }
  
  @keyframes pulse {
    0%, 100% {
      transform: translate(-50%, -50%) scale(1);
      opacity: 0;
    }
  }
}