/* ==========================================================================
   DEXO QUICK — MOBILE UI ANIMATION SYSTEM
   Smooth, modern, delightful micro-interactions
   ========================================================================== */

/* ------------------------------------------------------------------
   1. SKELETON LOADING SHIMMER
   ------------------------------------------------------------------ */
@keyframes shimmer {
  0% { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

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

.skeleton {
  background: linear-gradient(90deg, var(--bg-subtle, #f1f5f9) 25%, rgba(255,255,255,0.6) 50%, var(--bg-subtle, #f1f5f9) 75%);
  background-size: 800px 100%;
  animation: shimmer 1.2s ease-in-out infinite;
  border-radius: var(--radius-sm, 8px);
}

[data-theme="dark"] .skeleton {
  background: linear-gradient(90deg, #1e293b 25%, #2d3f58 50%, #1e293b 75%);
  background-size: 800px 100%;
}

.skeleton-card {
  border-radius: 14px;
  overflow: hidden;
  padding: 0;
  background: var(--bg-card, #fff);
  border: 1px solid var(--border-light, #e2e8f0);
}
.skeleton-card .skeleton-img {
  width: 100%;
  height: 130px;
  border-radius: 14px 14px 0 0;
}
.skeleton-card .skeleton-text {
  height: 13px;
  margin: 12px 14px 0;
  width: 70%;
}
.skeleton-card .skeleton-text-short {
  height: 11px;
  margin: 7px 14px 14px;
  width: 45%;
}
.skeleton-card .skeleton-price {
  height: 18px;
  margin: 4px 14px 14px;
  width: 35%;
}

/* ------------------------------------------------------------------
   2. STAGGERED FADE-IN (for product cards & list items)
   ------------------------------------------------------------------ */
@keyframes staggerFadeIn {
  0% {
    opacity: 0;
    transform: translateY(24px) scale(0.95);
  }
  60% {
    opacity: 1;
    transform: translateY(-3px) scale(1.01);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.stagger-item {
  opacity: 0;
  animation: staggerFadeIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  will-change: opacity, transform;
}

/* Safety: ensure cards beyond 16th still appear */
.stagger-item:nth-child(n+17) {
  animation-delay: 0s !important;
  opacity: 1;
}

/* Delay classes — applied via JS */
.stagger-item:nth-child(1)  { animation-delay: 0.04s; }
.stagger-item:nth-child(2)  { animation-delay: 0.08s; }
.stagger-item:nth-child(3)  { animation-delay: 0.12s; }
.stagger-item:nth-child(4)  { animation-delay: 0.16s; }
.stagger-item:nth-child(5)  { animation-delay: 0.20s; }
.stagger-item:nth-child(6)  { animation-delay: 0.24s; }
.stagger-item:nth-child(7)  { animation-delay: 0.28s; }
.stagger-item:nth-child(8)  { animation-delay: 0.32s; }
.stagger-item:nth-child(9)  { animation-delay: 0.36s; }
.stagger-item:nth-child(10) { animation-delay: 0.40s; }
.stagger-item:nth-child(11) { animation-delay: 0.44s; }
.stagger-item:nth-child(12) { animation-delay: 0.48s; }
.stagger-item:nth-child(13) { animation-delay: 0.52s; }
.stagger-item:nth-child(14) { animation-delay: 0.56s; }
.stagger-item:nth-child(15) { animation-delay: 0.60s; }
.stagger-item:nth-child(16) { animation-delay: 0.64s; }

/* ------------------------------------------------------------------
   3. SCROLL REVEAL (sections slide up as they enter viewport)
   ------------------------------------------------------------------ */
.reveal-section {
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.7s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
}
.reveal-section.revealed {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered children inside revealed sections */
.reveal-section.revealed .reveal-child {
  opacity: 0;
  animation: staggerFadeIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
.reveal-section.revealed .reveal-child:nth-child(1) { animation-delay: 0.05s; }
.reveal-section.revealed .reveal-child:nth-child(2) { animation-delay: 0.1s; }
.reveal-section.revealed .reveal-child:nth-child(3) { animation-delay: 0.15s; }
.reveal-section.revealed .reveal-child:nth-child(4) { animation-delay: 0.2s; }

/* ------------------------------------------------------------------
   4. CARD PRESS / TAP EFFECT
   ------------------------------------------------------------------ */
.product-card {
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.25s cubic-bezier(0.22, 1, 0.36, 1),
              border-color 0.25s ease;
}
.product-card:active {
  transform: scale(0.97) !important;
  transition: transform 0.1s ease !important;
}

.category-grid-item {
  transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.2s ease;
}
.category-grid-item:active {
  transform: scale(0.93) !important;
  transition: transform 0.08s ease !important;
}

.bs-card:active {
  transform: scale(0.96) !important;
  transition: transform 0.08s ease !important;
}

/* ------------------------------------------------------------------
   5. RIPPLE EFFECT (Material Design style)
   ------------------------------------------------------------------ */
.ripple-btn {
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.ripple-btn .ripple-wave {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transform: scale(0);
  animation: rippleExpand 0.55s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  pointer-events: none;
}

@keyframes rippleExpand {
  0%   { transform: scale(0); opacity: 0.6; }
  100% { transform: scale(4); opacity: 0; }
}

/* Ripple on green buttons */
.btn-add-cart, .cart-button, .btn-checkout-proceed, .scb-btn {
  position: relative;
  overflow: hidden;
}

/* ------------------------------------------------------------------
   6. BOTTOM NAV BOUNCE + ACTIVE INDICATOR
   ------------------------------------------------------------------ */
@keyframes navBounce {
  0%   { transform: translateY(0); }
  30%  { transform: translateY(-6px); }
  50%  { transform: translateY(-2px); }
  70%  { transform: translateY(-4px); }
  100% { transform: translateY(-2px); }
}

.bottom-nav-item.active .nav-icon {
  animation: navBounce 0.45s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.bottom-nav-item .nav-icon {
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Animated active indicator bar */
.bottom-nav-item::before {
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
              width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ------------------------------------------------------------------
   7. SEARCH EXPAND ANIMATION
   ------------------------------------------------------------------ */
.header-search-container {
  transition: flex 0.35s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.35s ease;
}

.header-search-box {
  transition: box-shadow 0.3s ease,
              border-color 0.3s ease,
              transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.header-search-box.focused {
  box-shadow: 0 4px 20px rgba(16, 185, 129, 0.15);
  border-color: var(--primary-500);
  transform: scale(1.02);
}

@keyframes searchPulse {
  0%   { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.2); }
  70%  { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.header-search-box.focused .search-icon {
  animation: searchPulse 0.6s ease;
  color: var(--primary-600);
}

/* Search suggestions dropdown slide */
.search-suggestions-dropdown {
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
  transform-origin: top center;
}

/* ------------------------------------------------------------------
   8. HERO BANNER AUTO-ROTATE
   ------------------------------------------------------------------ */
.hero-slide {
  display: none;
}
.hero-slide.active {
  display: block;
  animation: heroFadeIn 0.6s ease forwards;
}

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

.hero-dots {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 12px;
}

.hero-dots .hero-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.4);
  transition: all 0.3s ease;
  cursor: pointer;
}
.hero-dots .hero-dot.active {
  background: #fff;
  width: 22px;
  border-radius: 4px;
}

/* ------------------------------------------------------------------
   9. ADD-TO-CART ANIMATION
   ------------------------------------------------------------------ */
@keyframes cartPop {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.25); }
  50%  { transform: scale(0.95); }
  70%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.cart-pop {
  animation: cartPop 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes flyToCart {
  0%   { opacity: 1; transform: translate(0, 0) scale(1); }
  50%  { opacity: 0.8; transform: translate(40px, -40px) scale(0.5); }
  100% { opacity: 0; transform: translate(80px, -80px) scale(0.2); }
}

.fly-to-cart {
  animation: flyToCart 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  pointer-events: none;
}

/* ------------------------------------------------------------------
   10. FLOATING CART BUTTON PULSE
   ------------------------------------------------------------------ */
@keyframes floatPulse {
  0%, 100% { box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3); }
  50%      { box-shadow: 0 4px 25px rgba(16, 185, 129, 0.5); }
}

#rightFloatingActions .cart-button {
  animation: floatPulse 2s ease-in-out infinite;
}

/* ------------------------------------------------------------------
   11. CATEGORY PILL ACTIVE ANIMATION
   ------------------------------------------------------------------ */
.category-pill {
  transition: all 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.category-pill.active {
  transform: scale(1.05);
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.3);
}

.category-pill:active {
  transform: scale(0.95);
  transition: transform 0.08s ease;
}

/* ------------------------------------------------------------------
   12. MODAL / SHEET ANIMATIONS (improved)
   ------------------------------------------------------------------ */
@keyframes sheetSlideUp {
  from { transform: translateY(100%); opacity: 0.5; }
  to   { transform: translateY(0); opacity: 1; }
}

@keyframes backdropFadeIn {
  from { opacity: 0; backdrop-filter: blur(0px); }
  to   { opacity: 1; backdrop-filter: blur(4px); }
}

.modal-overlay.active .modal-card,
.admin-modal-overlay.active .admin-modal-card {
  animation: sheetSlideUp 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.modal-overlay.active,
.admin-modal-overlay.active {
  animation: backdropFadeIn 0.3s ease forwards;
}

/* ------------------------------------------------------------------
   13. TOAST IMPROVED ANIMATION
   ------------------------------------------------------------------ */
@keyframes toastBounceIn {
  0%   { transform: translateX(120%) scale(0.8); opacity: 0; }
  50%  { transform: translateX(-8px) scale(1.02); opacity: 1; }
  70%  { transform: translateX(4px) scale(0.99); }
  100% { transform: translateX(0) scale(1); opacity: 1; }
}

@keyframes toastSlideOut {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(120%); opacity: 0; }
}

/* ------------------------------------------------------------------
   14. PULL-TO-REFRESH INDICATOR
   ------------------------------------------------------------------ */
@keyframes ptrSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.ptr-indicator {
  position: fixed;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary-600);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  transition: top 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 1000;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}
.ptr-indicator.visible {
  top: 20px;
}
.ptr-indicator.spinning svg {
  animation: ptrSpin 0.8s linear infinite;
}

/* ------------------------------------------------------------------
   15. MICRO-ANIMATIONS
   ------------------------------------------------------------------ */

/* Heart wishlist pop */
@keyframes heartPop {
  0%   { transform: scale(1); }
  25%  { transform: scale(1.3); }
  50%  { transform: scale(0.9); }
  75%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}
.wishlist-heart-btn.pop svg {
  animation: heartPop 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Badge count bump */
@keyframes badgeBump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.4); }
  70%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}
.badge-bump {
  animation: badgeBump 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

/* Trust badge hover */
.trust-badge-item {
  transition: transform 0.25s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.25s ease;
}
.trust-badge-item:active {
  transform: scale(0.96);
}

/* Price shimmer on change */
@keyframes priceFlash {
  0%   { color: var(--primary-600); transform: scale(1.1); }
  100% { color: inherit; transform: scale(1); }
}
.price-flash {
  animation: priceFlash 0.4s ease;
}

/* ------------------------------------------------------------------
   16. MOBILE-SPECIFIC SMOOTH SCROLL
   ------------------------------------------------------------------ */
@media (max-width: 768px) {
  html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
  }

  /* Hide scrollbar but keep scroll */
  .category-scroll-container,
  .bs-scroll-container,
  .deals-scroll-container {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
  .category-scroll-container::-webkit-scrollbar,
  .bs-scroll-container::-webkit-scrollbar,
  .deals-scroll-container::-webkit-scrollbar {
    display: none;
  }

  /* Snappy horizontal scroll snap */
  .category-scroll-container {
    scroll-snap-type: x mandatory;
    scroll-padding: 0 16px;
  }
  .category-pill {
    scroll-snap-align: start;
  }
}
