/* ==========================================================================
Loading Animation - Billetterie Moderne
========================================================================== */

.app-loading {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #000000 0%, #1a0033 50%, #000000 100%);
  z-index: 9999;
  overflow: hidden;

  /* Background animé */
  &::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 30% 50%, rgba(124, 58, 237, 0.3), transparent 50%),
                radial-gradient(circle at 70% 80%, rgba(236, 72, 153, 0.2), transparent 50%);
    animation: drift 20s ease-in-out infinite;
  }

  &::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
      linear-gradient(45deg, transparent 48%, rgba(124, 58, 237, 0.03) 49%, rgba(124, 58, 237, 0.03) 51%, transparent 52%),
      linear-gradient(-45deg, transparent 48%, rgba(236, 72, 153, 0.03) 49%, rgba(236, 72, 153, 0.03) 51%, transparent 52%);
    background-size: 100px 100px;
    animation: grid-scroll 20s linear infinite;
  }
}

@keyframes drift {
  0%, 100% { 
    transform: translate(0, 0) rotate(0deg); 
  }
  33% { 
    transform: translate(30px, -30px) rotate(5deg); 
  }
  66% { 
    transform: translate(-20px, 20px) rotate(-5deg); 
  }
}

@keyframes grid-scroll {
  0% { 
    background-position: 0 0, 0 0; 
  }
  100% { 
    background-position: 100px 100px, -100px -100px; 
  }
}

.app-loading-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
}

.app-loading-logo {
  width: 100px;
  height: 100px;
  background: linear-gradient(135deg, #7c3aed, #ec4899);
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 20px 60px rgba(124, 58, 237, 0.6);
  animation: logo-pulse 2s ease-in-out infinite;
  
  svg {
    width: 50px;
    height: 50px;
    color: white;
  }
}

@keyframes logo-pulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 20px 60px rgba(124, 58, 237, 0.6);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 25px 80px rgba(124, 58, 237, 0.8);
  }
}

/* Animation principale - Tickets qui défilent */
.ticket-loader {
  position: relative;
  width: 300px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ticket {
  position: absolute;
  width: 80px;
  height: 50px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.8), rgba(236, 72, 153, 0.8));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(124, 58, 237, 0.4);
  
  &::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    bottom: 0;
    width: 2px;
    background: repeating-linear-gradient(
      to bottom,
      white 0px,
      white 4px,
      transparent 4px,
      transparent 8px
    );
  }

  &::after {
    content: '';
    width: 30px;
    height: 30px;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2'%3E%3Cpath d='M21 8v13H3V8M1 3h22v5H1z'/%3E%3Cpath d='M10 12L8 21M14 12l2 9'/%3E%3C/svg%3E") no-repeat center;
    background-size: contain;
  }
}

.ticket:nth-child(1) {
  animation: ticket-slide 2s ease-in-out infinite;
  animation-delay: 0s;
}

.ticket:nth-child(2) {
  animation: ticket-slide 2s ease-in-out infinite;
  animation-delay: 0.4s;
  opacity: 0;
}

.ticket:nth-child(3) {
  animation: ticket-slide 2s ease-in-out infinite;
  animation-delay: 0.8s;
  opacity: 0;
}

@keyframes ticket-slide {
  0% {
    transform: translateX(-150px) rotate(-10deg);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  50% {
    transform: translateX(0) rotate(0deg);
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateX(150px) rotate(10deg);
    opacity: 0;
  }
}

/* Texte de chargement */
.app-loading p {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: 1.2rem;
  font-weight: 600;
  color: #ffffff;
  text-align: center;
  animation: text-fade 2s ease-in-out infinite;
}

@keyframes text-fade {
  0%, 100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

/* Loader alternatif - Cercle de tickets */
.ticket-circle-loader {
  position: relative;
  width: 120px;
  height: 120px;
  
  .ticket-mini {
    position: absolute;
    width: 20px;
    height: 30px;
    background: linear-gradient(135deg, #7c3aed, #ec4899);
    border-radius: 4px;
    top: 50%;
    left: 50%;
    transform-origin: center;
    
    &::before {
      content: '';
      position: absolute;
      left: 50%;
      transform: translateX(-50%);
      top: 2px;
      bottom: 2px;
      width: 1px;
      background: repeating-linear-gradient(
        to bottom,
        white 0px,
        white 2px,
        transparent 2px,
        transparent 4px
      );
    }
  }
  
  @for $i from 1 through 8 {
    .ticket-mini:nth-child(#{$i}) {
      transform: rotate(#{($i - 1) * 45}deg) translateY(-50px);
      animation: ticket-fade 1.6s ease-in-out infinite;
      animation-delay: #{($i - 1) * 0.2}s;
    }
  }
}

@keyframes ticket-fade {
  0%, 100% {
    opacity: 0.2;
    transform: rotate(0deg) translateY(-50px) scale(0.8);
  }
  50% {
    opacity: 1;
    transform: rotate(0deg) translateY(-50px) scale(1);
  }
}

/* Loader simple - Barre de progression */
.progress-loader {
  width: 200px;
  height: 6px;
  background: rgba(124, 58, 237, 0.2);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
  
  &::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 50%;
    height: 100%;
    background: linear-gradient(90deg, transparent, #7c3aed, #ec4899, transparent);
    animation: progress-slide 1.5s ease-in-out infinite;
  }
}

@keyframes progress-slide {
  0% {
    left: -100%;
  }
  100% {
    left: 200%;
  }
}

/* Loader dots */
.dot-loader {
  display: flex;
  gap: 12px;
  
  .dot {
    width: 16px;
    height: 16px;
    background: linear-gradient(135deg, #7c3aed, #ec4899);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
    animation: dot-bounce 1.4s ease-in-out infinite;
    
    &:nth-child(1) {
      animation-delay: 0s;
    }
    &:nth-child(2) {
      animation-delay: 0.2s;
    }
    &:nth-child(3) {
      animation-delay: 0.4s;
    }
  }
}

@keyframes dot-bounce {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1.2);
    opacity: 1;
  }
}

/* Layout avec loader choisi */
.loading-with-tickets {
  .app-loading-content {
    gap: 3rem;
  }
}

.loading-with-circle {
  .app-loading-content {
    gap: 2.5rem;
  }
}

.loading-with-progress {
  .app-loading-content {
    gap: 2rem;
  }
  
  .app-loading p {
    order: -1;
  }
}

.loading-with-dots {
  .app-loading-content {
    gap: 2rem;
  }
}

/* Responsive */
@media (max-width: 576px) {
  .ticket-loader {
    width: 200px;
    
    .ticket {
      width: 60px;
      height: 40px;
      
      &::after {
        width: 24px;
        height: 24px;
      }
    }
  }
  
  .app-loading-logo {
    width: 80px;
    height: 80px;
    
    svg {
      width: 40px;
      height: 40px;
    }
  }
  
  .app-loading p {
    font-size: 1rem;
    padding: 0 1rem;
  }
}