/* MDS Genie Spectacular UI Enhancements
   Advanced animations and effects for MDS Genie
   ================================================== */

/* Import the base spectacular UI system */
@import url('spectacular-ui.css');

/* ========================================
   Hero Section Enhancements
   ======================================== */

/* Animated gradient mesh background */
.hero-spectacular {
  position: relative;
  background: var(--spectrum-bg-void);
  overflow: hidden;
  min-height: 100vh;
  display: flex;
  align-items: center;
}

.hero-spectacular::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--spectrum-gradient-mesh);
  opacity: 0.4;
  animation: gradient-shift 20s ease infinite;
  background-size: 400% 400%;
  z-index: 0;
}

/* Floating medical icons */
.floating-icons-container {
  position: absolute;
  width: 100%;
  height: 100%;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.floating-icon {
  position: absolute;
  font-size: 2rem;
  opacity: 0.3;
  animation: float 15s ease-in-out infinite;
  filter: blur(0.5px);
  color: var(--spectrum-primary-400);
}

.floating-icon:nth-child(1) { 
  left: 10%; 
  top: 20%; 
  animation-delay: 0s; 
  font-size: 2.5rem;
}
.floating-icon:nth-child(2) { 
  left: 80%; 
  top: 10%; 
  animation-delay: 3s; 
  color: var(--spectrum-health-teal);
}
.floating-icon:nth-child(3) { 
  left: 25%; 
  top: 60%; 
  animation-delay: 6s; 
  color: var(--spectrum-health-emerald);
}
.floating-icon:nth-child(4) { 
  left: 70%; 
  top: 70%; 
  animation-delay: 9s; 
  font-size: 1.8rem;
}
.floating-icon:nth-child(5) { 
  left: 90%; 
  top: 40%; 
  animation-delay: 12s; 
  color: var(--spectrum-health-violet);
}
.floating-icon:nth-child(6) { 
  left: 15%; 
  top: 80%; 
  animation-delay: 15s; 
  color: var(--spectrum-health-sky);
}

/* Enhanced hero content */
.hero-content-spectacular {
  position: relative;
  z-index: 10;
  animation: fadeInUp 1s ease-out;
}

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

/* Glowing hero title */
.hero-title-glow {
  font-size: 4rem;
  font-weight: 700;
  background: var(--spectrum-gradient-health);
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradient-shift 8s ease infinite;
  filter: drop-shadow(0 0 30px rgba(99, 102, 241, 0.3));
  line-height: 1.1;
  margin-bottom: 1.5rem;
}

/* Animated statistics */
.hero-stats-animated {
  display: flex;
  justify-content: center;
  gap: 3rem;
  margin: 3rem 0;
  animation: fadeIn 1.5s ease-out 0.5s backwards;
}

.stat-spectacular {
  text-align: center;
  position: relative;
  transform: translateY(0);
  transition: transform 0.3s var(--spectrum-ease-bounce);
}

.stat-spectacular:hover {
  transform: translateY(-5px);
}

.stat-number-animated {
  font-size: 3rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--spectrum-primary-400), var(--spectrum-health-teal));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: block;
  animation: countUp 2s ease-out;
}

@keyframes countUp {
  from {
    opacity: 0;
    transform: scale(0.5);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* ========================================
   Enhanced Navigation
   ======================================== */

.navbar-spectacular {
  background: rgba(10, 15, 28, 0.7);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  transition: all 0.3s var(--spectrum-ease-smooth);
}

.navbar-spectacular.scrolled {
  background: rgba(10, 15, 28, 0.95);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.logo-spectacular {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transition: transform 0.3s var(--spectrum-ease-bounce);
}

.logo-spectacular:hover {
  transform: scale(1.05);
}

.logo-icon-animated {
  width: 45px;
  height: 45px;
  background: var(--spectrum-gradient-health);
  background-size: 200% 200%;
  animation: gradient-shift 4s ease infinite;
  box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
}

/* ========================================
   Form Section Enhancements
   ======================================== */

.tool-card-spectacular {
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.9) 100%);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 24px;
  padding: 3rem;
  box-shadow: 
    0 20px 60px rgba(0, 0, 0, 0.5),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  position: relative;
  overflow: hidden;
}

.tool-card-spectacular::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: var(--spectrum-gradient-mesh);
  opacity: 0.1;
  animation: gradient-shift 30s ease infinite;
  background-size: 400% 400%;
}

/* Enhanced textarea with breathing glow */
.textarea-spectacular {
  width: 100%;
  min-height: 350px;
  background: rgba(255, 255, 255, 0.03);
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 1.5rem;
  color: var(--text);
  font-family: var(--spectrum-font-body);
  font-size: 1rem;
  resize: vertical;
  transition: all 0.3s var(--spectrum-ease-smooth);
  position: relative;
}

.textarea-spectacular:focus {
  outline: none;
  border-color: var(--spectrum-primary-400);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 
    0 0 0 3px rgba(99, 102, 241, 0.1),
    0 0 40px rgba(99, 102, 241, 0.3),
    inset 0 0 20px rgba(99, 102, 241, 0.1);
  animation: glow-pulse 2s ease-in-out infinite;
}

/* Progress ring around textarea */
.textarea-wrapper {
  position: relative;
}

.textarea-progress {
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  border-radius: 18px;
  background: conic-gradient(
    from 0deg,
    transparent 0deg,
    var(--spectrum-primary-400) var(--progress, 0deg),
    transparent var(--progress, 0deg)
  );
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.textarea-wrapper:focus-within .textarea-progress {
  opacity: 1;
}

/* Character counter with animation */
.char-counter-animated {
  text-align: right;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  transition: all 0.3s ease;
}

.char-counter-animated.warning {
  color: var(--spectrum-warning);
  font-weight: 600;
  animation: pulse 1s ease-in-out infinite;
}

.char-counter-animated.danger {
  color: var(--spectrum-danger);
  font-weight: 700;
  animation: shake 0.5s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ========================================
   Section Selection Cards (3D)
   ======================================== */

.sections-grid-spectacular {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.5rem;
  margin-top: 2rem;
  perspective: 1000px;
}

.section-card-3d {
  position: relative;
  height: 120px;
  transform-style: preserve-3d;
  transition: transform 0.6s var(--spectrum-ease-smooth);
  cursor: pointer;
}

.section-card-3d:hover {
  transform: rotateY(10deg) rotateX(-10deg) translateZ(20px);
}

.section-card-face {
  position: absolute;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  transition: all 0.3s ease;
}

.section-card-face:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(139, 92, 246, 0.2) 100%);
  border-color: var(--spectrum-primary-400);
  box-shadow: 
    0 10px 30px rgba(99, 102, 241, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.section-checkbox-custom {
  position: relative;
  width: 24px;
  height: 24px;
  appearance: none;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.3s var(--spectrum-ease-bounce);
}

.section-checkbox-custom:checked {
  background: var(--spectrum-primary-500);
  border-color: var(--spectrum-primary-400);
  animation: checkmark-pop 0.4s var(--spectrum-ease-bounce);
}

@keyframes checkmark-pop {
  0% { transform: scale(0.5); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

.section-checkbox-custom:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-weight: bold;
  font-size: 14px;
}

/* ========================================
   Quick Mode Toggle Enhancement
   ======================================== */

.toggle-switch-spectacular {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 30px;
}

.toggle-slider-liquid {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, var(--spectrum-bg-surface) 0%, var(--spectrum-bg-elevated) 100%);
  transition: all 0.4s var(--spectrum-ease-smooth);
  border-radius: 30px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.toggle-slider-liquid::before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 4px;
  bottom: 3px;
  background: white;
  transition: all 0.4s var(--spectrum-ease-bounce);
  border-radius: 50%;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.toggle-slider-liquid::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--spectrum-gradient-health);
  opacity: 0;
  transition: opacity 0.4s ease;
}

input:checked + .toggle-slider-liquid {
  background: var(--spectrum-primary-600);
  border-color: var(--spectrum-primary-400);
}

input:checked + .toggle-slider-liquid::after {
  opacity: 0.3;
}

input:checked + .toggle-slider-liquid::before {
  transform: translateX(30px);
  background: white;
  box-shadow: 0 2px 15px rgba(99, 102, 241, 0.5);
}

/* ========================================
   Animated Generate Button
   ======================================== */

.analyze-btn-spectacular {
  width: 100%;
  padding: 1.75rem;
  font-size: 1.2rem;
  font-weight: 600;
  background: var(--spectrum-gradient-health);
  background-size: 200% 200%;
  color: white;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.3s var(--spectrum-ease-smooth);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  animation: gradient-shift 4s ease infinite;
}

.analyze-btn-spectacular::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.analyze-btn-spectacular:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 
    0 10px 30px rgba(99, 102, 241, 0.4),
    0 0 60px rgba(99, 102, 241, 0.3);
}

.analyze-btn-spectacular:hover::before {
  width: 300px;
  height: 300px;
}

.analyze-btn-spectacular:active:not(:disabled) {
  transform: translateY(0);
}

/* Loading state with particles */
.analyze-btn-spectacular.loading {
  color: transparent;
  pointer-events: none;
}

.analyze-btn-spectacular.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top: 3px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Particle effect on click */
.particle-burst {
  position: absolute;
  pointer-events: none;
}

.particle-burst span {
  position: absolute;
  display: block;
  width: 4px;
  height: 4px;
  background: var(--spectrum-primary-400);
  border-radius: 50%;
  animation: particle-explode 1s ease-out forwards;
}

@keyframes particle-explode {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translate(var(--x), var(--y)) scale(0);
    opacity: 0;
  }
}

/* ========================================
   Responsive Adjustments
   ======================================== */

@media (max-width: 768px) {
  .hero-title-glow {
    font-size: 2.5rem;
  }
  
  .hero-stats-animated {
    flex-direction: column;
    gap: 1.5rem;
  }
  
  .stat-number-animated {
    font-size: 2.5rem;
  }
  
  .floating-icon {
    font-size: 1.5rem;
  }
  
  .sections-grid-spectacular {
    grid-template-columns: 1fr;
  }
}