/* Fallback para browsers sem suporte a :has() */
@supports not selector(:has(*)) {
  .simple-carousel-slide::before {
    animation: spin 1s linear infinite, fadeOut 0.3s ease-in-out 2s forwards;
  }
}

/* Contador de imagens */
.carousel-counter {
  position: absolute;
  bottom: 10px;
  right: 15px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  z-index: 10;
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.counter-current {
  font-weight: 600;
}

.counter-separator {
  margin: 0 3px;
  opacity: 0.8;
}

.counter-total {
  opacity: 0.9;
}

/* Container principal responsivo */
.simple-carousel-container {
  width: 100%;
  max-width: 600px;
  height: 500px;
  aspect-ratio: 16/9;
  overflow: hidden;
  position: relative;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Trilha que contém os slides */
.simple-carousel-track {
  display: flex;
  height: 100%;
  width: 100%;
  transition: transform 0.5s ease-in-out;
}

/* Estilo para cada slide */
.simple-carousel-slide {
  flex: 0 0 100%;
  min-width: 100%;
  height: 100%;
  position: relative;
  background: #f0f0f0; /* Cor de fundo enquanto carrega */
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Loading spinner para cada slide */
.simple-carousel-slide::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border: 3px solid #ddd;
  border-top: 3px solid #666;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 2;
}

/* Animação do spinner */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Fade-in das imagens */
@keyframes fadeIn {
  0% { 
    opacity: 0; 
  }
  100% { 
    opacity: 1; 
  }
}

/* Imagens responsivas com fade-in e centralização perfeita */
.simple-carousel-image {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center center;
  display: block;
  position: relative;
  z-index: 3;
  margin: 0 auto;
  /* Aplicar fade-in quando a imagem carrega */
  animation: fadeIn 0.6s ease-in-out;
  animation-fill-mode: backwards;
  animation-delay: 0.2s;
}

/* Alternativa: Usar transition para browsers que suportam */
.simple-carousel-image {
  opacity: 0;
  transition: opacity 0.6s ease-in-out 0.2s;
}

/* Quando a imagem carrega, ela fica visível */
.simple-carousel-image:not([src=""]) {
  opacity: 1;
}

/* Efeito adicional: esconder spinner quando imagem aparece */
.simple-carousel-image:not([src=""]) + .simple-carousel-slide::before,
.simple-carousel-slide:has(.simple-carousel-image:not([src=""]))::before {
  animation: fadeOut 0.3s ease-in-out forwards;
  animation-delay: 0.8s;
}

@keyframes fadeOut {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* Fallback para browsers sem suporte a :has() */
@supports not selector(:has(*)) {
  .simple-carousel-slide::before {
    animation: spin 1s linear infinite, fadeOut 0.3s ease-in-out 2s forwards;
  }
}

/* Media Queries para ajustes específicos */
@media (max-width: 599px) {
  .simple-carousel-container {
    max-width: 100%;
    height: 400px;
    aspect-ratio: 16/9;
  }
  
  .simple-carousel-slide::before {
    width: 25px;
    height: 25px;
    margin: -12.5px 0 0 -12.5px;
    border-width: 2px;
  }
  
  .carousel-counter {
    bottom: 8px;
    right: 10px;
    font-size: 12px;
    padding: 4px 10px;
  }
}

@media (max-width: 267px) {
  .simple-carousel-container {
    aspect-ratio: 4/3;
    height: 120px;
    margin-bottom: 0 !important;
  }
  
  .simple-carousel-slide::before {
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border-width: 2px;
  }
  
  .carousel-counter {
    bottom: 6px;
    right: 8px;
    font-size: 11px;
    padding: 3px 8px;
  }
}