/* =============================================================================
   AI GENERATION LOADER - CREATIVE ANIMATIONS
   ============================================================================= */

/* Main Loader Container */
.ai-loader-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ai-loader-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Loader Content Box */
.ai-loader-content {
  text-align: center;
  max-width: 400px;
  padding: 2rem;
  animation: loaderFadeIn 0.5s ease-out;
}

@keyframes loaderFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Creative Loader Animation */
.ai-creative-loader {
  width: 120px;
  height: 120px;
  margin: 0 auto 2rem;
  position: relative;
}

/* Neural Network Animation */
.neural-network {
  width: 100%;
  height: 100%;
  position: relative;
}

.neural-node {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--brand-color-dark);
  border-radius: 50%;
  box-shadow: 0 0 20px var(--brand-color-dark);
}

body.light-mode .neural-node {
  background: var(--brand-color-light);
  box-shadow: 0 0 20px var(--brand-color-light);
}

.neural-node:nth-child(1) { top: 0; left: 50%; transform: translateX(-50%); }
.neural-node:nth-child(2) { top: 25%; right: 0; }
.neural-node:nth-child(3) { bottom: 0; right: 25%; }
.neural-node:nth-child(4) { bottom: 0; left: 25%; }
.neural-node:nth-child(5) { top: 25%; left: 0; }
.neural-node:nth-child(6) { top: 50%; left: 50%; transform: translate(-50%, -50%); }

.neural-connection {
  position: absolute;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--brand-color-dark), transparent);
  transform-origin: left center;
  animation: pulseConnection 2s ease-in-out infinite;
}

body.light-mode .neural-connection {
  background: linear-gradient(90deg, transparent, var(--brand-color-light), transparent);
}

@keyframes pulseConnection {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* Rotating Brain Animation */
.ai-brain {
  width: 100px;
  height: 100px;
  margin: 0 auto;
  position: relative;
  animation: rotateBrain 4s linear infinite;
}

@keyframes rotateBrain {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.brain-hemisphere {
  position: absolute;
  width: 50%;
  height: 100%;
  background: var(--brand-color-dark);
  opacity: 0.8;
}

body.light-mode .brain-hemisphere {
  background: var(--brand-color-light);
}

.brain-left {
  left: 0;
  border-radius: 100% 0 0 100%;
  animation: brainPulseLeft 2s ease-in-out infinite;
}

.brain-right {
  right: 0;
  border-radius: 0 100% 100% 0;
  animation: brainPulseRight 2s ease-in-out infinite;
}

@keyframes brainPulseLeft {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1) translateX(-5px); }
}

@keyframes brainPulseRight {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1) translateX(5px); }
}

/* Magic Sparkles Animation */
.magic-sparkles {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}

.sparkle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: white;
  border-radius: 50%;
  animation: sparkleFloat 3s linear infinite;
}

@keyframes sparkleFloat {
  0% {
    transform: translateY(0) scale(0);
    opacity: 0;
  }
  10% {
    transform: translateY(-10px) scale(1);
    opacity: 1;
  }
  90% {
    transform: translateY(-90px) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(-100px) scale(0);
    opacity: 0;
  }
}

.sparkle:nth-child(1) { left: 20%; animation-delay: 0s; }
.sparkle:nth-child(2) { left: 40%; animation-delay: 0.5s; }
.sparkle:nth-child(3) { left: 60%; animation-delay: 1s; }
.sparkle:nth-child(4) { left: 80%; animation-delay: 1.5s; }
.sparkle:nth-child(5) { left: 30%; animation-delay: 2s; }
.sparkle:nth-child(6) { left: 70%; animation-delay: 2.5s; }

/* Dynamic Loading Messages */
.ai-loader-message {
  color: white;
  font-size: 1.2rem;
  font-weight: 500;
  margin-bottom: 1rem;
  min-height: 30px;
  animation: messageChange 0.5s ease-out;
}

body.light-mode .ai-loader-message {
  color: white; /* Keep white in overlay */
}

@keyframes messageChange {
  0% {
    opacity: 0;
    transform: translateY(-10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.ai-loader-submessage {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

/* Progress Bar */
.ai-progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 2rem;
}

.ai-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--brand-color-dark), var(--brand-color-light));
  border-radius: 2px;
  width: 0%;
  animation: progressAnimation 20s ease-out forwards;
}

body.light-mode .ai-progress-fill {
  background: linear-gradient(90deg, var(--brand-color-light), var(--brand-color-dark));
}

@keyframes progressAnimation {
  0% { width: 0%; }
  10% { width: 15%; }
  30% { width: 35%; }
  50% { width: 55%; }
  70% { width: 75%; }
  90% { width: 90%; }
  100% { width: 95%; }
}

/* Platform-specific loaders */
.loader-instagram .neural-node,
.loader-instagram .ai-progress-fill {
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
}

.loader-facebook .neural-node,
.loader-facebook .ai-progress-fill {
  background: #1877f2;
}

.loader-linkedin .neural-node,
.loader-linkedin .ai-progress-fill {
  background: #0a66c2;
}

.loader-x .neural-node,
.loader-x .ai-progress-fill {
  background: #000;
  box-shadow: 0 0 20px #ff0050;
}

/* Typing Animation for Messages */
.typing-dots {
  display: inline-flex;
  align-items: center;
  margin-left: 5px;
}

.typing-dot {
  width: 8px;
  height: 8px;
  margin: 0 2px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  animation: typingAnimation 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingAnimation {
  0%, 80%, 100% {
    transform: scale(0.8);
    opacity: 0.5;
  }
  40% {
    transform: scale(1.2);
    opacity: 1;
  }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .ai-loader-content {
    padding: 1.5rem;
    max-width: 90%;
  }
  
  .ai-creative-loader {
    width: 80px;
    height: 80px;
  }
  
  .ai-loader-message {
    font-size: 1rem;
  }
  
  .ai-loader-submessage {
    font-size: 0.8rem;
  }
}