/* FabricAI - Beautiful Animations & Effects */

/* ===== SMOOTH SCROLL BEHAVIOR ===== */
html {
  scroll-behavior: smooth;
}

/* ===== CUSTOM EASING FUNCTIONS ===== */
:root {
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out-back: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-in-out-cubic: cubic-bezier(0.65, 0, 0.35, 1);
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ===== PAGE LOAD ANIMATIONS ===== */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

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

/* ===== FLOATING ANIMATION ===== */
@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-20px);
  }
}

@keyframes floatSlow {
  0%, 100% {
    transform: translateY(0px) rotate(0deg);
  }
  50% {
    transform: translateY(-30px) rotate(2deg);
  }
}

/* ===== PULSE & GLOW ===== */
@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.4);
  }
  50% {
    box-shadow: 0 0 40px rgba(99, 102, 241, 0.8), 0 0 60px rgba(236, 72, 153, 0.4);
  }
}

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

/* ===== GRADIENT ORB ANIMATIONS ===== */
@keyframes orb-float-1 {
  0%, 100% {
    transform: translate(0, 0) scale(1);
  }
  25% {
    transform: translate(30px, -30px) scale(1.1);
  }
  50% {
    transform: translate(-20px, 20px) scale(0.95);
  }
  75% {
    transform: translate(20px, 10px) scale(1.05);
  }
}

@keyframes orb-float-2 {
  0%, 100% {
    transform: translate(0, 0) scale(1);
  }
  33% {
    transform: translate(-40px, 20px) scale(1.15);
  }
  66% {
    transform: translate(30px, -20px) scale(0.9);
  }
}

@keyframes gradient-shift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* ===== BUTTON ANIMATIONS ===== */
.btn {
  position: relative;
  overflow: hidden;
  transition: all 0.3s var(--ease-out-expo);
}

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

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

.btn-primary {
  animation: pulse-glow 3s ease-in-out infinite;
}

.btn:hover {
  transform: translateY(-3px) scale(1.02);
}

.btn:active {
  transform: translateY(-1px) scale(0.98);
}

/* ===== CARD HOVER EFFECTS ===== */
.feature-card {
  transition: all 0.4s var(--ease-out-expo);
  transform-style: preserve-3d;
}

.feature-card:hover {
  transform: translateY(-10px) rotateX(5deg);
  box-shadow: 0 25px 50px -12px rgba(99, 102, 241, 0.25);
}

.feature-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.1) 50%, transparent 60%);
  transform: translateX(-100%);
  transition: transform 0.6s;
}

.feature-card:hover::after {
  transform: translateX(100%);
}

/* ===== PRICING CARD POPULAR ===== */
.pricing-card.popular {
  animation: float 6s ease-in-out infinite;
}

.pricing-card {
  transition: all 0.4s var(--ease-out-expo);
}

.pricing-card:hover {
  transform: translateY(-15px) scale(1.02);
}

/* ===== NAVBAR SCROLL EFFECT ===== */
.navbar {
  transition: all 0.3s var(--ease-out-expo);
}

.navbar.scrolled {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

/* ===== HERO ANIMATIONS ===== */
.hero-content > * {
  opacity: 0;
  animation: fadeInUp 0.8s var(--ease-out-expo) forwards;
}

.hero-content > *:nth-child(1) { animation-delay: 0.1s; }
.hero-content > *:nth-child(2) { animation-delay: 0.2s; }
.hero-content > *:nth-child(3) { animation-delay: 0.3s; }
.hero-content > *:nth-child(4) { animation-delay: 0.4s; }
.hero-content > *:nth-child(5) { animation-delay: 0.5s; }

.hero-visual {
  animation: fadeInScale 1s var(--ease-out-expo) 0.3s forwards;
  opacity: 0;
}

/* ===== PHONE MOCKUP ANIMATION ===== */
.phone-mockup {
  animation: floatSlow 8s ease-in-out infinite;
}

.phone-screen {
  position: relative;
  overflow: hidden;
}

.phone-screen::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 70%
  );
  animation: shimmer 3s infinite;
}

/* ===== STEP ANIMATIONS ===== */
.step {
  opacity: 0;
  transform: translateY(30px);
}

.step.visible {
  animation: fadeInUp 0.6s var(--ease-out-expo) forwards;
}

.step:nth-child(1).visible { animation-delay: 0s; }
.step:nth-child(3).visible { animation-delay: 0.2s; }
.step:nth-child(5).visible { animation-delay: 0.4s; }

.step-number {
  transition: all 0.3s var(--ease-spring);
}

.step:hover .step-number {
  transform: scale(1.2);
  box-shadow: 0 0 30px rgba(99, 102, 241, 0.5);
}

/* ===== UPLOAD AREA ANIMATIONS ===== */
.upload-card {
  transition: all 0.4s var(--ease-out-expo);
}

.upload-card:hover {
  border-color: var(--primary);
  transform: translateY(-5px);
  box-shadow: 0 20px 40px rgba(99, 102, 241, 0.15);
}

.upload-card.has-image {
  animation: pulse-glow 2s ease-in-out infinite;
}

.upload-area i {
  transition: all 0.3s var(--ease-spring);
}

.upload-card:hover .upload-area i {
  transform: scale(1.1) rotate(5deg);
}

/* ===== GARMENT TYPE SELECTION ===== */
.garment-type {
  transition: all 0.3s var(--ease-out-expo);
}

.garment-type:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.2);
}

.garment-type.active {
  animation: pulse-glow 2s ease-in-out infinite;
  transform: scale(1.05);
}

/* ===== LOADING SPINNER ===== */
.loading-spinner i {
  animation: spin 1s linear infinite;
}

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

.loading-spinner {
  position: relative;
}

.loading-spinner::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60px;
  height: 60px;
  border: 3px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: spin 1s linear infinite;
}

/* ===== MODAL ANIMATIONS ===== */
.modal-content {
  animation: modalSlideIn 0.4s var(--ease-out-expo);
}

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

.modal-overlay {
  animation: fadeIn 0.3s ease;
}

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

/* ===== TOAST NOTIFICATIONS ===== */
.toast {
  animation: toastSlideIn 0.4s var(--ease-out-expo);
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(100%) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

.toast.hiding {
  animation: toastSlideOut 0.3s var(--ease-in-out-cubic) forwards;
}

@keyframes toastSlideOut {
  to {
    opacity: 0;
    transform: translateX(100%) scale(0.9);
  }
}

/* ===== SIDEBAR ANIMATIONS ===== */
.sidebar {
  transition: transform 0.4s var(--ease-out-expo);
}

.sidebar-nav a {
  position: relative;
  overflow: hidden;
}

.sidebar-nav a::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 3px;
  background: var(--primary);
  transform: scaleY(0);
  transition: transform 0.3s var(--ease-out-expo);
}

.sidebar-nav a:hover::before,
.sidebar-nav a.active::before {
  transform: scaleY(1);
}

.sidebar-nav a i {
  transition: all 0.3s var(--ease-spring);
}

.sidebar-nav a:hover i {
  transform: scale(1.2) rotate(10deg);
}

/* ===== PAGE TRANSITIONS ===== */
.page {
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.4s var(--ease-out-expo);
}

.page.active {
  opacity: 1;
  transform: translateX(0);
}

/* ===== RESULT IMAGE REVEAL ===== */
.result-image img {
  animation: imageReveal 0.6s var(--ease-out-expo);
}

@keyframes imageReveal {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(20px);
    filter: blur(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
    filter: blur(0);
  }
}

/* ===== HISTORY GRID ANIMATIONS ===== */
.history-item {
  opacity: 0;
  transform: translateY(30px);
  animation: fadeInUp 0.5s var(--ease-out-expo) forwards;
}

.history-item:nth-child(1) { animation-delay: 0.05s; }
.history-item:nth-child(2) { animation-delay: 0.1s; }
.history-item:nth-child(3) { animation-delay: 0.15s; }
.history-item:nth-child(4) { animation-delay: 0.2s; }
.history-item:nth-child(5) { animation-delay: 0.25s; }
.history-item:nth-child(6) { animation-delay: 0.3s; }

/* ===== CREDIT PACK HOVER ===== */
.credit-pack {
  transition: all 0.4s var(--ease-out-expo);
  position: relative;
  overflow: hidden;
}

.credit-pack::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
  transition: left 0.5s;
}

.credit-pack:hover::before {
  left: 100%;
}

.credit-pack:hover {
  transform: translateY(-10px) scale(1.02);
  box-shadow: 0 20px 40px rgba(99, 102, 241, 0.2);
}

/* ===== SCROLL REVEAL ANIMATION ===== */
.reveal {
  opacity: 0;
  transform: translateY(50px);
  transition: all 0.8s var(--ease-out-expo);
}

.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ===== TYPING EFFECT ===== */
.typing-effect {
  overflow: hidden;
  border-right: 3px solid var(--primary);
  white-space: nowrap;
  animation: typing 3s steps(40, end), blink-caret 0.75s step-end infinite;
}

@keyframes typing {
  from { width: 0 }
  to { width: 100% }
}

@keyframes blink-caret {
  from, to { border-color: transparent }
  50% { border-color: var(--primary) }
}

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

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

/* ===== ROTATE IN ANIMATION ===== */
@keyframes rotateIn {
  from {
    opacity: 0;
    transform: rotate(-180deg) scale(0.5);
  }
  to {
    opacity: 1;
    transform: rotate(0) scale(1);
  }
}

.rotate-in {
  animation: rotateIn 0.6s var(--ease-out-back);
}

/* ===== GRADIENT TEXT ANIMATION ===== */
.gradient-text {
  background-size: 200% auto;
  animation: gradient-text-shift 3s ease infinite;
}

@keyframes gradient-text-shift {
  0% { background-position: 0% center; }
  50% { background-position: 100% center; }
  100% { background-position: 0% center; }
}

/* ===== STAT COUNTER ANIMATION ===== */
.stat-value {
  display: inline-block;
  transition: all 0.3s var(--ease-out-expo);
}

.stat:hover .stat-value {
  transform: scale(1.1);
  color: var(--primary);
}

/* ===== MOBILE MENU ANIMATION ===== */
.mobile-menu-btn {
  transition: all 0.3s var(--ease-spring);
}

.mobile-menu-btn:hover {
  transform: rotate(90deg);
}

/* ===== FORM INPUT FOCUS ===== */
.form-group input {
  transition: all 0.3s var(--ease-out-expo);
}

.form-group input:focus {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(99, 102, 241, 0.15);
}

/* ===== CHECKBOX/RADIO ANIMATIONS ===== */
.garment-type i {
  transition: all 0.3s var(--ease-spring);
}

.garment-type.active i {
  transform: scale(1.2);
  filter: drop-shadow(0 0 10px rgba(99, 102, 241, 0.5));
}

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

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

/* ===== SUCCESS POP ===== */
@keyframes pop {
  0% { transform: scale(0.8); opacity: 0; }
  50% { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.pop-in {
  animation: pop 0.4s var(--ease-out-back);
}

/* ===== LOADING DOTS ===== */
.loading-dots {
  display: inline-flex;
  gap: 4px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  background: var(--primary);
  border-radius: 50%;
  animation: loading-dot 1.4s ease-in-out infinite both;
}

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

@keyframes loading-dot {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* ===== PARALLAX EFFECT ===== */
.parallax {
  will-change: transform;
  transition: transform 0.1s linear;
}

/* ===== SMOOTH IMAGE LOADING ===== */
img {
  opacity: 0;
  transition: opacity 0.3s ease;
}

img.loaded {
  opacity: 1;
}

/* ===== FOCUS VISIBLE FOR ACCESSIBILITY ===== */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}