/* ============================================
   ANIMATIONS & TRANSITIONS - iOS Parity
   ============================================ */

/* Spring Physics - Matching iOS UISpringTimingParameters */
:root {
  --spring-quick: cubic-bezier(0.34, 1.56, 0.64, 1); /* response: 0.3s, damping: 0.7 */
  --spring-default: cubic-bezier(0.25, 1.5, 0.5, 1); /* response: 0.5s, damping: 0.7 */
  --spring-smooth: cubic-bezier(0.2, 1.0, 0.3, 1); /* response: 0.7s, damping: 0.8 */
  --spring-bouncy: cubic-bezier(0.5, 1.8, 0.3, 1); /* response: 0.5s, damping: 0.5 */
  
  --ease-in-out-smooth: cubic-bezier(0.4, 0.0, 0.2, 1);
  --ease-out-expo: cubic-bezier(0.19, 1, 0.22, 1);
  --ease-in-expo: cubic-bezier(0.95, 0.05, 0.795, 0.035);
}

/* ============================================
   PAGE TRANSITIONS
   ============================================ */

/* Slide In from Right */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Slide Out to Left */
@keyframes slideOutLeft {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(-100%);
    opacity: 0;
  }
}

/* Slide In from Left */
@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Slide Out to Right */
@keyframes slideOutRight {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Slide Up (for sheets) */
@keyframes slideUp {
  from {
    transform: translateY(100%);
  }
  to {
    transform: translateY(0);
  }
}

/* Slide Down (for sheets) */
@keyframes slideDown {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(100%);
  }
}

/* Fade In */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Fade Out */
@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* Scale In */
@keyframes scaleIn {
  from {
    transform: scale(0.1);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Scale Out */
@keyframes scaleOut {
  from {
    transform: scale(1);
    opacity: 1;
  }
  to {
    transform: scale(0.1);
    opacity: 0;
  }
}

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

/* Button Press */
.button-press,
button:not(.no-press):active,
.btn:active {
  transform: scale(0.98);
  transition: transform 0.1s ease-out;
}

/* Card Lift on Hover */
.card-lift {
  transition: all 0.3s var(--spring-default);
}

.card-lift:hover {
  transform: translateY(-4px);
  box-shadow: 
    0 12px 24px rgba(0, 0, 0, 0.12),
    0 20px 40px rgba(0, 0, 0, 0.08);
}

/* Wiggle Animation - 6 repetitions, 0.15s each */
@keyframes wiggle {
  0%, 100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(5deg);
  }
  75% {
    transform: rotate(-5deg);
  }
}

.wiggle {
  animation: wiggle 0.15s ease-in-out 6;
}

/* Pulse Animation */
@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.5);
    opacity: 0;
  }
}

.pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Pulse Ring (for notifications) */
@keyframes pulseRing {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(1.8);
    opacity: 0;
  }
}

.pulse-ring::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  border: 2px solid currentColor;
  animation: pulseRing 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Shimmer Sweep */
@keyframes shimmerSweep {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}

.shimmer {
  position: relative;
  overflow: hidden;
}

.shimmer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.3),
    transparent
  );
  animation: shimmerSweep 2s ease-in-out infinite;
}

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

.bounce {
  animation: bounce 1s ease-in-out infinite;
}

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

.shake {
  animation: shake 0.6s ease-in-out;
}

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

.spin {
  animation: spin 1s linear infinite;
}

/* Heartbeat */
@keyframes heartbeat {
  0%, 100% {
    transform: scale(1);
  }
  10%, 30% {
    transform: scale(1.1);
  }
  20%, 40% {
    transform: scale(1);
  }
}

.heartbeat {
  animation: heartbeat 1.5s ease-in-out infinite;
}

/* ============================================
   DRAWER & SHEET ANIMATIONS
   ============================================ */

/* Slide-Up Sheet */
.slide-up-sheet {
  animation: slideUp 0.4s var(--spring-default);
}

.slide-up-sheet.hiding {
  animation: slideDown 0.3s var(--ease-in-out-smooth);
}

/* Modal Backdrop */
.modal-backdrop {
  animation: fadeIn 0.3s ease-out;
}

.modal-backdrop.hiding {
  animation: fadeOut 0.2s ease-in;
}

/* ============================================
   VIEW TRANSITIONS
   ============================================ */

.view-transition-enter {
  animation: slideInRight 0.35s var(--spring-default);
}

.view-transition-exit {
  animation: slideOutLeft 0.35s var(--spring-default);
}

.view-transition-enter-reverse {
  animation: slideInLeft 0.35s var(--spring-default);
}

.view-transition-exit-reverse {
  animation: slideOutRight 0.35s var(--spring-default);
}

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

/* Skeleton Loading */
@keyframes skeletonLoading {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.skeleton {
  background: linear-gradient(
    90deg,
    #f0f0f0 25%,
    #e0e0e0 50%,
    #f0f0f0 75%
  );
  background-size: 200% 100%;
  animation: skeletonLoading 1.5s ease-in-out infinite;
  border-radius: 4px;
}

/* Dots Loading */
@keyframes dotsLoading {
  0%, 20% {
    opacity: 0.3;
    transform: scale(1);
  }
  50% {
    opacity: 1;
    transform: scale(1.2);
  }
  100% {
    opacity: 0.3;
    transform: scale(1);
  }
}

.dots-loading {
  display: flex;
  gap: 6px;
  align-items: center;
}

.dots-loading span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: dotsLoading 1.4s ease-in-out infinite;
}

.dots-loading span:nth-child(1) {
  animation-delay: 0s;
}

.dots-loading span:nth-child(2) {
  animation-delay: 0.2s;
}

.dots-loading span:nth-child(3) {
  animation-delay: 0.4s;
}

/* ============================================
   NOTIFICATION ANIMATIONS
   ============================================ */

/* Toast Slide In */
@keyframes toastSlideIn {
  from {
    transform: translateY(-100%) translateX(-50%);
    opacity: 0;
  }
  to {
    transform: translateY(0) translateX(-50%);
    opacity: 1;
  }
}

/* Toast Slide Out */
@keyframes toastSlideOut {
  from {
    transform: translateY(0) translateX(-50%);
    opacity: 1;
  }
  to {
    transform: translateY(-100%) translateX(-50%);
    opacity: 0;
  }
}

.toast-enter {
  animation: toastSlideIn 0.4s var(--spring-default);
}

.toast-exit {
  animation: toastSlideOut 0.3s var(--ease-in-out-smooth);
}

/* ============================================
   BADGE & INDICATOR ANIMATIONS
   ============================================ */

/* Badge Pop */
@keyframes badgePop {
  0% {
    transform: scale(0);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

.badge-pop {
  animation: badgePop 0.3s var(--spring-quick);
}

/* Number Count Up */
@keyframes countUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.count-up {
  animation: countUp 0.5s var(--spring-default);
}

/* ============================================
   HOVER & FOCUS STATES
   ============================================ */

.interactive {
  transition: all 0.2s var(--ease-in-out-smooth);
  cursor: pointer;
}

.interactive:hover {
  transform: translateY(-2px);
}

.interactive:active {
  transform: translateY(0) scale(0.98);
}

/* Focus Ring */
.focus-ring:focus-visible {
  outline: 2px solid var(--brokerly-primary);
  outline-offset: 2px;
  border-radius: inherit;
}

/* ============================================
   SPRING TRANSITION UTILITIES
   ============================================ */

.spring-quick {
  transition: all 0.3s var(--spring-quick);
}

.spring-default {
  transition: all 0.5s var(--spring-default);
}

.spring-smooth {
  transition: all 0.7s var(--spring-smooth);
}

.spring-bouncy {
  transition: all 0.5s var(--spring-bouncy);
}

/* ============================================
   STAGGER ANIMATIONS (for lists)
   ============================================ */

.stagger-enter > * {
  animation: fadeIn 0.4s var(--spring-default);
}

.stagger-enter > *:nth-child(1) { animation-delay: 0s; }
.stagger-enter > *:nth-child(2) { animation-delay: 0.05s; }
.stagger-enter > *:nth-child(3) { animation-delay: 0.1s; }
.stagger-enter > *:nth-child(4) { animation-delay: 0.15s; }
.stagger-enter > *:nth-child(5) { animation-delay: 0.2s; }
.stagger-enter > *:nth-child(6) { animation-delay: 0.25s; }
.stagger-enter > *:nth-child(7) { animation-delay: 0.3s; }
.stagger-enter > *:nth-child(8) { animation-delay: 0.35s; }

/* ============================================
   REDUCED MOTION
   ============================================ */

/* ============================================
   AGENTIC AI ANIMATIONS - Enhanced
   ============================================ */

/* Gentle Reveal - For thinking steps */
@keyframes gentleReveal {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.gentle-reveal {
  animation: gentleReveal 0.4s cubic-bezier(0.4, 0.0, 0.2, 1) forwards;
}

/* Subtle Pulse - For active thinking steps */
@keyframes subtlePulse {
  0%, 100% {
    transform: scale(1) translateY(0);
  }
  50% {
    transform: scale(1.01) translateY(-1px);
  }
}

.subtle-pulse {
  animation: subtlePulse 2s cubic-bezier(0.4, 0.0, 0.2, 1) infinite;
}

/* Avatar Pulse - For AI avatar in step-by-step view */
@keyframes avatarPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2), 0 0 0 1px rgba(255, 255, 255, 0.1);
  }
  50% {
    transform: scale(1.02);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25), 0 0 0 2px rgba(255, 255, 255, 0.15);
  }
}

.avatar-pulse {
  animation: avatarPulse 3s cubic-bezier(0.4, 0.0, 0.2, 1) infinite;
}

/* Result Reveal - For completed thinking results */
@keyframes resultReveal {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.result-reveal {
  animation: resultReveal 0.4s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* Success Flash - For successful completion */
@keyframes successFlash {
  0% {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.4) 0%, rgba(16, 185, 129, 0.3) 100%);
  }
  100% {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2) 0%, rgba(16, 185, 129, 0.15) 100%);
  }
}

.success-flash {
  animation: successFlash 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* Error Pulse - For error states */
@keyframes errorPulse {
  0%, 100% {
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.3), inset 0 1px 2px rgba(255, 255, 255, 0.1);
  }
  50% {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.3), 0 4px 12px rgba(239, 68, 68, 0.4), inset 0 1px 2px rgba(255, 255, 255, 0.15);
  }
}

.error-pulse {
  animation: errorPulse 0.5s cubic-bezier(0.4, 0.0, 0.2, 1);
}

/* Stagger Enter - For lists of items */
.stagger-enter-item:nth-child(1) { animation-delay: 0ms; }
.stagger-enter-item:nth-child(2) { animation-delay: 100ms; }
.stagger-enter-item:nth-child(3) { animation-delay: 200ms; }
.stagger-enter-item:nth-child(4) { animation-delay: 300ms; }
.stagger-enter-item:nth-child(5) { animation-delay: 400ms; }
.stagger-enter-item:nth-child(6) { animation-delay: 500ms; }
.stagger-enter-item:nth-child(7) { animation-delay: 600ms; }
.stagger-enter-item:nth-child(8) { animation-delay: 700ms; }

/* Rotate Gear - For loading icons */
@keyframes rotateGear {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.rotate-gear {
  animation: rotateGear 2s linear infinite;
}

/* Glassmorphism Shimmer - For premium effects */
@keyframes glassShimmer {
  0% {
    background-position: -200% center;
  }
  100% {
    background-position: 200% center;
  }
}

.glass-shimmer {
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.15) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: glassShimmer 3s ease-in-out infinite;
}

/* ============================================
   REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .wiggle,
  .pulse,
  .bounce,
  .shake,
  .heartbeat,
  .gentle-reveal,
  .subtle-pulse,
  .avatar-pulse,
  .success-flash,
  .error-pulse,
  .rotate-gear,
  .glass-shimmer {
    animation: none !important;
  }
}

/* ============================================
   PERFORMANCE OPTIMIZATIONS
   ============================================ */

/* GPU Acceleration */
.gpu-accelerated {
  transform: translateZ(0);
  will-change: transform;
}

/* Prevent layout shifts during animations */
.animating {
  backface-visibility: hidden;
  perspective: 1000px;
}

/* Filter Pills - iOS Matching */
.filter-button, .action-filter {
    font-size: 16px;
    font-weight: 500;
    padding: 12px 16px;
    border-radius: 24px;
    border: none;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--card-background);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.filter-button.active, .action-filter.active {
    background: var(--brokerly-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(52, 199, 89, 0.3);
}

/* Completed Action Card Overlay */
.action-card.completed {
    opacity: 0.5;
    position: relative;
}

.completed-overlay {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 10;
    cursor: pointer;
}

.completed-overlay span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 500;
    color: var(--brokerly-primary);
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 12px;
    border-radius: 100px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.completed-overlay span::before {
    content: '↻';
    font-size: 12px;
    font-weight: 500;
}

