/* PO Watcher - Shared Loading Animation & Logo Styles */

:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --border: #475569;
  --text-1: #f8fafc;
  --text-2: #94a3b8;
  --text-3: #64748b;
  --accent: #f59e0b;
  --accent-hover: #d97706;
  --green: #22c55e;
  --red: #ef4444;
}

/* ========== LOADING ANIMATION ========== */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease, visibility 0.5s ease;
  overflow: hidden;
}
.loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
}
.loading-logo-container {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.loading-logo {
  transform: scale(1.5) translateX(-250px);
  opacity: 0;
  animation: carZoomIn 2.8s cubic-bezier(0.25, 0.1, 0.25, 1) forwards;
}
@keyframes carZoomIn {
  0% {
    transform: scale(1.5) translateX(-250px);
    opacity: 0;
  }
  8% {
    opacity: 1;
  }
  32% {
    transform: scale(1.08) translateX(12px);
  }
  40% {
    transform: scale(0.97) translateX(-5px);
  }
  48% {
    transform: scale(1) translateX(0);
  }
  68% {
    transform: scale(1) translateX(0);
    opacity: 1;
  }
  82% {
    transform: scale(1.1) translateX(50px);
    opacity: 1;
  }
  100% {
    transform: scale(1.5) translateX(350px);
    opacity: 0;
  }
}

/* Smoke particles */
.smoke-container {
  position: absolute;
  right: -60px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
.smoke-puff {
  position: absolute;
  width: 30px;
  height: 30px;
  background: radial-gradient(circle, rgba(255,255,255,0.4) 0%, rgba(255,255,255,0) 70%);
  border-radius: 50%;
  opacity: 0;
}
.loading-logo.animating ~ .smoke-container .smoke-puff {
  animation: smokePuff 0.8s ease-out forwards;
}
.smoke-puff:nth-child(1) { animation-delay: 0.75s; right: 0; top: -20px; }
.smoke-puff:nth-child(2) { animation-delay: 0.8s; right: -15px; top: 0px; width: 40px; height: 40px; }
.smoke-puff:nth-child(3) { animation-delay: 0.85s; right: 5px; top: 20px; }
.smoke-puff:nth-child(4) { animation-delay: 0.9s; right: -25px; top: -10px; width: 25px; height: 25px; }
.smoke-puff:nth-child(5) { animation-delay: 0.95s; right: -10px; top: 30px; width: 35px; height: 35px; }
.smoke-puff:nth-child(6) { animation-delay: 0.8s; right: -30px; top: 10px; width: 45px; height: 45px; }
.smoke-puff:nth-child(7) { animation-delay: 0.88s; right: 10px; top: -5px; width: 28px; height: 28px; }
.smoke-puff:nth-child(8) { animation-delay: 0.93s; right: -20px; top: 25px; width: 32px; height: 32px; }

@keyframes smokePuff {
  0% {
    transform: scale(0.3) translateX(-30px);
    opacity: 0;
  }
  30% {
    opacity: 0.7;
  }
  100% {
    transform: scale(2.5) translateX(60px) translateY(-10px);
    opacity: 0;
  }
}

/* Skid marks - entry */
.skid-marks {
  position: absolute;
  left: 50%;
  bottom: -30px;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  opacity: 0;
}
.loading-logo.animating ~ .skid-marks {
  animation: skidAppear 0.4s ease-out 0.75s forwards, skidFade 0.3s ease-out 1.85s forwards;
}
@keyframes skidAppear {
  0% {
    opacity: 0;
    transform: translateX(-50%) scaleX(0);
  }
  100% {
    opacity: 1;
    transform: translateX(-50%) scaleX(1);
  }
}
@keyframes skidFade {
  0% { opacity: 1; }
  100% { opacity: 0; }
}
.skid-mark {
  width: 60px;
  height: 3px;
  background: linear-gradient(90deg, rgba(60,60,60,0.3), rgba(100,100,100,0.5), transparent);
  border-radius: 2px;
}

/* Peel-off tire marks */
.peel-off-marks {
  position: absolute;
  left: 50%;
  bottom: -30px;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  opacity: 0;
  pointer-events: none;
}
.loading-logo.animating ~ .peel-off-marks {
  animation: peelOffAppear 0.6s ease-out 1.9s forwards;
}
@keyframes peelOffAppear {
  0% {
    opacity: 0;
    transform: translateX(-50%) scaleX(0.3);
  }
  30% {
    opacity: 1;
  }
  100% {
    opacity: 0.6;
    transform: translateX(calc(-50% + 80px)) scaleX(1);
  }
}
.peel-mark {
  height: 3px;
  background: linear-gradient(90deg, rgba(80,80,80,0.6), rgba(50,50,50,0.3));
  border-radius: 2px;
}
.peel-mark:nth-child(1) { width: 100px; }
.peel-mark:nth-child(2) { width: 90px; }

/* Peel-off smoke */
.peel-smoke {
  position: absolute;
  left: 60%;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}
.peel-smoke .smoke-puff {
  opacity: 0;
}
.loading-logo.animating ~ .peel-smoke .smoke-puff {
  animation: peelSmoke 0.6s ease-out forwards;
}
.peel-smoke .smoke-puff:nth-child(1) { animation-delay: 1.9s; left: -20px; top: 10px; width: 35px; height: 35px; }
.peel-smoke .smoke-puff:nth-child(2) { animation-delay: 1.95s; left: 0px; top: -15px; width: 30px; height: 30px; }
.peel-smoke .smoke-puff:nth-child(3) { animation-delay: 2.0s; left: -10px; top: 25px; width: 25px; height: 25px; }
.peel-smoke .smoke-puff:nth-child(4) { animation-delay: 2.05s; left: 10px; top: 0px; width: 40px; height: 40px; }

@keyframes peelSmoke {
  0% {
    transform: scale(0.5) translateX(0);
    opacity: 0;
  }
  20% {
    opacity: 0.6;
  }
  100% {
    transform: scale(2) translateX(-40px) translateY(-15px);
    opacity: 0;
  }
}

/* Loading text */
.loading-text {
  margin-top: 50px;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-1);
  opacity: 0;
  transform: translateY(20px);
}
.loading-logo.animating ~ .loading-text {
  animation: textAppear 0.5s ease-out 1.1s forwards, textFade 0.3s ease-out 1.85s forwards;
}
@keyframes textAppear {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes textFade {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-10px);
  }
}

/* ========== MICRO-INTERACTIONS ========== */

/* Error shake */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-6px); }
  20%, 40%, 60%, 80% { transform: translateX(6px); }
}
.shake {
  animation: shake 0.5s ease-in-out;
}

/* Success checkmark draw */
@keyframes drawCheck {
  0% { stroke-dashoffset: 50; }
  100% { stroke-dashoffset: 0; }
}
.check-animated path {
  stroke-dasharray: 50;
  stroke-dashoffset: 50;
}
.check-animated.animate path {
  animation: drawCheck 0.5s ease-out forwards;
}

/* Input focus glow */
.form-input {
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.form-input:focus {
  transform: scale(1.01);
}

/* Card entrance animation */
@keyframes cardEntrance {
  0% {
    opacity: 0;
    transform: translateY(30px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
.card-animate {
  animation: cardEntrance 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Button loading morphing */
.btn-morphing {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  min-width: 150px;
}
.btn-morphing.loading {
  pointer-events: none;
}
.btn-morphing .btn-text {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: opacity 0.2s ease;
}
.btn-morphing.loading .btn-text {
  opacity: 0;
}
.btn-morphing .btn-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 20px;
  height: 20px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.btn-morphing.loading .btn-spinner {
  opacity: 1;
  animation: spin 0.6s linear infinite;
}
.btn-morphing .btn-success-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  opacity: 0;
  transition: opacity 0.2s ease;
}
.btn-morphing.success .btn-success-icon {
  opacity: 1;
}
.btn-morphing.success .btn-spinner {
  opacity: 0;
}
@keyframes spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Toast notifications */
@keyframes toastSlideIn {
  0% {
    opacity: 0;
    transform: translateX(100%) scale(0.8);
  }
  60% {
    transform: translateX(-10px) scale(1.02);
  }
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}
.toast {
  animation: toastSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Confetti */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9998;
  overflow: hidden;
}
.confetti {
  position: absolute;
  opacity: 0;
}
@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateY(100vh) rotate(720deg);
  }
}

/* Sparkles */
.sparkle {
  position: fixed;
  pointer-events: none;
  z-index: 9999;
  animation: sparkle 0.8s ease-out forwards;
}
@keyframes sparkle {
  0% {
    transform: scale(0) rotate(0deg);
    opacity: 1;
  }
  50% {
    transform: scale(1.2) rotate(180deg);
    opacity: 1;
  }
  100% {
    transform: scale(0) rotate(360deg);
    opacity: 0;
  }
}

/* Magnetic button */
.magnetic-btn {
  transition: transform 0.2s ease-out;
}

/* Pulse glow for CTAs */
.pulse-glow {
  animation: pulseGlow 2s ease-in-out infinite;
}
@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 2px 8px rgba(245,158,11,0.3);
  }
  50% {
    box-shadow: 0 4px 20px rgba(245,158,11,0.5), 0 0 40px rgba(245,158,11,0.2);
  }
}

/* Progress bar */
.progress-bar-container {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 16px;
  display: none;
}
.progress-bar-container.active {
  display: block;
}
.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--green));
  border-radius: 3px;
  width: 0;
  transition: width 0.3s ease;
}

/* Success checkmark icon */
.success-checkmark {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--green);
  margin: 0 auto 20px;
  transform: scale(0);
  animation: successPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes successPop {
  0% { transform: scale(0); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}
