/* Experience Enhancements - Onboarding, Guidance, Delight */

/* Smooth Page Transitions */
html {
  scroll-behavior: smooth;
}

body {
  opacity: 1;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Entrance Animations */
.entrance-stagger {
  animation: slideUpStagger 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

/* Stagger children animation */
.entrance-stagger > * {
  animation: slideUpStagger 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.entrance-stagger > :nth-child(1) { animation-delay: 0.1s; }
.entrance-stagger > :nth-child(2) { animation-delay: 0.2s; }
.entrance-stagger > :nth-child(3) { animation-delay: 0.3s; }
.entrance-stagger > :nth-child(4) { animation-delay: 0.4s; }
.entrance-stagger > :nth-child(5) { animation-delay: 0.5s; }
.entrance-stagger > :nth-child(6) { animation-delay: 0.6s; }

/* Micro-interaction: Button Press */
.btn {
  position: relative;
  overflow: hidden;
}

.btn::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.btn:active::before {
  animation: ripple 0.6s ease-out;
}

@keyframes ripple {
  to {
    width: 300px;
    height: 300px;
    opacity: 0;
  }
}

/* Button Bounce on Hover */
.btn:hover:not(:disabled) {
  animation: buttonBounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes buttonBounce {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Micro-interaction: Input Focus Glow */
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  box-shadow: 0 0 0 3px rgba(88, 101, 242, 0.1),
              0 0 0 6px rgba(88, 101, 242, 0.05),
              0 4px 12px rgba(88, 101, 242, 0.2);
  transform: scale(1.01);
}

/* Smooth Value Changes */
.metric-value {
  transition: color 0.3s ease, transform 0.3s ease;
}

.metric-value.highlight {
  animation: highlightPulse 0.8s ease;
}

@keyframes highlightPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.1); color: #5865F2; }
  100% { transform: scale(1); }
}

/* Smooth Visibility Toggle */
.fade-in {
  animation: fadeInSmooth 0.3s ease;
}

.fade-out {
  animation: fadeOutSmooth 0.3s ease;
}

@keyframes fadeInSmooth {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes fadeOutSmooth {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Success State Animation */
.state-success {
  animation: successPulse 0.6s ease;
}

@keyframes successPulse {
  0% {
    transform: scale(0.95);
    opacity: 0;
  }
  50% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Loading Spinner - Smooth */
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(88, 101, 242, 0.2);
  border-top-color: #5865F2;
  border-radius: 50%;
  animation: spinSmooth 0.8s linear infinite;
}

@keyframes spinSmooth {
  to { transform: rotate(360deg); }
}

/* Pulse Animation for Attention */
.pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}

/* Attention Pulse with Scale */
.pulse-scale {
  animation: pulseScale 2s ease-in-out infinite;
}

@keyframes pulseScale {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
}

/* Onboarding Welcome Message */
.onboarding-banner {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px;
  border-radius: 12px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  animation: slideInFromTop 0.5s ease;
}

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

.onboarding-icon {
  font-size: 32px;
  animation: bounce 0.6s ease;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.onboarding-content h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.onboarding-content p {
  margin: 0;
  opacity: 0.95;
  font-size: 14px;
}

.onboarding-close {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  transition: all 0.2s ease;
}

.onboarding-close:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Helpful Tooltip */
.tooltip-box {
  background: #2c2f33;
  color: white;
  padding: 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  max-width: 280px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  position: relative;
  animation: tooltipSlideIn 0.3s ease;
}

@keyframes tooltipSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tooltip-box::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 12px;
  width: 12px;
  height: 12px;
  background: #2c2f33;
  clip-path: polygon(0% 0%, 100% 0%, 0% 100%);
}

/* Contextual Help Button */
.help-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(88, 101, 242, 0.1);
  color: #5865F2;
  border: none;
  cursor: help;
  font-size: 12px;
  font-weight: 700;
  transition: all 0.2s ease;
  margin-left: 8px;
}

.help-button:hover {
  background: rgba(88, 101, 242, 0.2);
  transform: scale(1.1);
}

/* Confirmation Animation */
.confirmation-checkmark {
  display: inline-block;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #3ba55e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  margin: 0 auto 16px;
}

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

/* Progress Indicator */
.progress-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.progress-step.active {
  background: rgba(88, 101, 242, 0.1);
}

.progress-step-indicator {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e3e5e8;
  color: #72767d;
  font-weight: 700;
  font-size: 14px;
  transition: all 0.3s ease;
}

.progress-step.active .progress-step-indicator {
  background: #5865F2;
  color: white;
  animation: pulse 1.5s ease infinite;
}

.progress-step.completed .progress-step-indicator {
  background: #3ba55e;
  color: white;
}

/* Card Hover Enhancement */
.card {
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15);
}

/* Confidence Badge Glow */
.confidence-badge {
  position: relative;
}

.confidence-badge::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 8px;
  background: rgba(88, 101, 242, 0.2);
  opacity: 0;
  animation: confidenceGlow 2s ease infinite;
  z-index: -1;
}

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

/* Recommendation Card Entrance */
.recommendation-card-enter {
  animation: slideInLeft 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Empty State Animation */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  animation: fadeIn 0.5s ease;
}

.empty-state-icon {
  font-size: 64px;
  margin-bottom: 16px;
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* Error Shake Animation */
.error-shake {
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
  20%, 40%, 60%, 80% { transform: translateX(5px); }
}

/* Success Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: white;
  padding: 16px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: slideUp 0.3s ease;
  z-index: 1000;
  max-width: 400px;
}

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

.toast.success {
  border-left: 4px solid #3ba55e;
}

.toast.error {
  border-left: 4px solid #ed4245;
}

.toast.info {
  border-left: 4px solid #00b0f4;
}

/* Animated Icon */
.icon-spin {
  animation: spin 1s linear infinite;
}

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

.icon-bounce {
  animation: bounceIcon 0.6s ease infinite;
}

@keyframes bounceIcon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* Smooth Number Counter */
.counter {
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

/* Backdrop Blur for Modal */
.modal-backdrop {
  backdrop-filter: blur(4px);
}

/* Focus Visible Ring */
*:focus-visible {
  outline: 2px solid #5865F2;
  outline-offset: 2px;
  border-radius: 4px;
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* High Contrast Support */
@media (prefers-contrast: more) {
  :root {
    --primary: #0000ff;
    --text-primary: #000000;
    --bg-primary: #ffffff;
  }

  .btn {
    border: 2px solid;
  }
}

/* Dark Mode Enhancements */
[data-theme="dark"] {
  .tooltip-box {
    background: #ffffff;
    color: #2c2f33;
  }

  .tooltip-box::after {
    background: #ffffff;
  }
}

/* Print Mode - Remove Animations */
@media print {
  * {
    animation: none !important;
    transition: none !important;
  }
}
