/**
 * Animations CSS - Veterans Claims Easy
 * Smooth transitions, loading states, and micro-interactions
 * Based on example design patterns with VCE military branding
 */

/* ===== KEYFRAME ANIMATIONS ===== */

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

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

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

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

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

@keyframes bounce {
  0%, 20%, 53%, 80%, 100% {
    animation-timing-function: cubic-bezier(0.215, 0.610, 0.355, 1.000);
    transform: translate3d(0, 0, 0);
  }
  40%, 43% {
    animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
    transform: translate3d(0, -30px, 0);
  }
  70% {
    animation-timing-function: cubic-bezier(0.755, 0.050, 0.855, 0.060);
    transform: translate3d(0, -15px, 0);
  }
  90% {
    transform: translate3d(0, -4px, 0);
  }
}

@keyframes shake {
  10%, 90% {
    transform: translate3d(-1px, 0, 0);
  }
  20%, 80% {
    transform: translate3d(2px, 0, 0);
  }
  30%, 50%, 70% {
    transform: translate3d(-4px, 0, 0);
  }
  40%, 60% {
    transform: translate3d(4px, 0, 0);
  }
}

@keyframes progressFill {
  from {
    width: 0%;
  }
  to {
    width: var(--progress-width, 100%);
  }
}

/* ===== LOADING STATES ===== */

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
}

.loading-overlay.active {
  display: flex;
  animation: fadeIn 0.3s ease;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid var(--gray-200);
  border-top-color: var(--eagle-blue);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-lg);
  color: var(--white);
  text-align: center;
}

.loading-text {
  font-size: var(--font-size-lg);
  font-weight: 600;
}

/* ===== SUCCESS AND ERROR STATES ===== */

.success-message {
  background: linear-gradient(135deg, var(--success) 0%, #047857 100%);
  color: var(--white);
  padding: var(--spacing-lg);
  border-radius: var(--radius-lg);
  text-align: center;
  margin-bottom: var(--spacing-lg);
  display: none;
  box-shadow: var(--shadow-md);
}

.success-message.show {
  display: block;
  animation: slideInRight 0.5s ease;
}

.error-banner {
  background: linear-gradient(135deg, var(--error) 0%, #b91c1c 100%);
  color: var(--white);
  padding: var(--spacing-lg);
  border-radius: var(--radius-lg);
  text-align: center;
  margin-bottom: var(--spacing-lg);
  display: none;
  box-shadow: var(--shadow-md);
}

.error-banner.show {
  display: block;
  animation: shake 0.5s ease;
}

/* ===== FORM ANIMATIONS ===== */

.form-step-enter {
  animation: slideInRight 0.5s ease;
}

.form-step-exit {
  animation: slideInLeft 0.5s ease reverse;
}

.input-focus-animation {
  position: relative;
  overflow: hidden;
}

.input-focus-animation::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--eagle-blue);
  transition: width 0.3s ease;
}

.input-focus-animation:focus-within::after {
  width: 100%;
}

.form-input.animate-error {
  animation: shake 0.5s ease;
  border-color: var(--error);
}

.form-input.animate-success {
  animation: bounce 0.6s ease;
  border-color: var(--success);
}

/* ===== BUTTON ANIMATIONS ===== */

.btn-hover-lift {
  transition: var(--transition-base);
}

.btn-hover-lift:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.btn-hover-lift:active {
  transform: translateY(0);
  box-shadow: var(--shadow-md);
}

.btn-loading {
  position: relative;
  color: transparent !important;
}

.btn-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  color: var(--white);
}

/* ===== DROPDOWN ANIMATIONS ===== */

.dropdown-menu {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

.dropdown.active .dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  animation: fadeIn 0.3s ease;
}

.dropdown-arrow {
  transition: transform 0.3s ease;
}

.dropdown.active .dropdown-arrow {
  transform: rotate(180deg);
}

/* ===== MOBILE MENU ANIMATIONS ===== */

.mobile-menu {
  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.mobile-menu.active {
  transform: translateX(0);
}

.mobile-menu-overlay {
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.mobile-menu-overlay.active {
  opacity: 1;
  visibility: visible;
}

.hamburger-line {
  transition: var(--transition-base);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ===== PROGRESS ANIMATIONS ===== */

.progress-fill {
  animation: progressFill 1s ease-out;
}

.step-number {
  transition: all 0.3s ease;
}

.progress-step.completed .step-number {
  animation: bounce 0.6s ease;
}

/* ===== CARD ANIMATIONS ===== */

.card-hover {
  transition: var(--transition-base);
}

.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-xl);
}

.branch-option {
  transition: var(--transition-base);
}

.branch-option:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}

/* ===== UTILITY ANIMATIONS ===== */

.fade-in {
  animation: fadeIn 0.5s ease;
}

.slide-in-right {
  animation: slideInRight 0.5s ease;
}

.slide-in-left {
  animation: slideInLeft 0.5s ease;
}

.pulse {
  animation: pulse 2s infinite;
}

.bounce {
  animation: bounce 1s;
}

.shake {
  animation: shake 0.5s;
}

/* ===== 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;
  }
  
  .loading-spinner {
    animation: none;
    border: 4px solid var(--gray-200);
    border-top-color: var(--eagle-blue);
  }
}

/* ===== FOCUS ANIMATIONS ===== */

.focus-ring {
  transition: box-shadow 0.2s ease;
}

.focus-ring:focus-visible {
  box-shadow: 0 0 0 3px rgba(28, 58, 91, 0.3);
}

/* ===== HOVER STATES ===== */

.hover-scale {
  transition: transform 0.2s ease;
}

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

.hover-glow {
  transition: box-shadow 0.3s ease;
}

.hover-glow:hover {
  box-shadow: 0 0 20px rgba(28, 58, 91, 0.3);
}
