/* ================================================================
   MasterStock - PREMIUM UI Enhancement Layer v4.0
   Next-Level: Animated Mesh, 3D Tilt, Magnetic Buttons,
   Scroll Reveals, Glassmorphism, Neon Accents, Cursor FX
   ================================================================ */

/* -- Custom Cursor ------------------------------------------------ */
*, *::before, *::after { cursor: none !important; }

#ms-cursor {
  position: fixed; width: 10px; height: 10px;
  background: #fbbf24; border-radius: 50%; pointer-events: none;
  z-index: 99999; mix-blend-mode: difference;
  transition: transform 0.1s ease, opacity 0.2s ease;
  transform: translate(-50%, -50%);
}

#ms-cursor-ring {
  position: fixed; width: 36px; height: 36px;
  border: 1.5px solid rgba(245,158,11,0.5); border-radius: 50%;
  pointer-events: none; z-index: 99998;
  transform: translate(-50%, -50%);
  transition: width 0.3s ease, height 0.3s ease, border-color 0.3s ease;
}

#ms-cursor-ring.hovering {
  width: 56px; height: 56px;
  border-color: rgba(245,158,11,0.8);
  background: rgba(245,158,11,0.04);
}

/* -- Scroll Reveal ------------------------------------------------- */
.ms-reveal {
  opacity: 0; transform: translateY(28px);
  transition: opacity 0.65s cubic-bezier(0.16,1,0.3,1),
              transform 0.65s cubic-bezier(0.16,1,0.3,1);
}
.ms-reveal.ms-visible { opacity: 1; transform: translateY(0); }

.ms-reveal-left { opacity: 0; transform: translateX(-30px);
  transition: opacity 0.65s cubic-bezier(0.16,1,0.3,1), transform 0.65s cubic-bezier(0.16,1,0.3,1); }
.ms-reveal-left.ms-visible { opacity: 1; transform: translateX(0); }

.ms-reveal-right { opacity: 0; transform: translateX(30px);
  transition: opacity 0.65s cubic-bezier(0.16,1,0.3,1), transform 0.65s cubic-bezier(0.16,1,0.3,1); }
.ms-reveal-right.ms-visible { opacity: 1; transform: translateX(0); }

.ms-reveal-scale { opacity: 0; transform: scale(0.92);
  transition: opacity 0.6s cubic-bezier(0.16,1,0.3,1), transform 0.6s cubic-bezier(0.34,1.56,0.64,1); }
.ms-reveal-scale.ms-visible { opacity: 1; transform: scale(1); }

.ms-stagger-1 { transition-delay: 0.05s !important; }
.ms-stagger-2 { transition-delay: 0.10s !important; }
.ms-stagger-3 { transition-delay: 0.15s !important; }
.ms-stagger-4 { transition-delay: 0.20s !important; }
.ms-stagger-5 { transition-delay: 0.25s !important; }
.ms-stagger-6 { transition-delay: 0.30s !important; }

/* -- Navbar Glassmorphism on Scroll -------------------------------- */
.topbar, .store-nav {
  transition: background 0.4s ease, box-shadow 0.4s ease, backdrop-filter 0.4s ease !important;
}
.topbar.scrolled, .store-nav.scrolled {
  background: rgba(255,255,255,0.85) !important;
  backdrop-filter: blur(24px) saturate(1.8) !important;
  -webkit-backdrop-filter: blur(24px) saturate(1.8) !important;
  box-shadow: 0 4px 32px rgba(15,23,42,0.12), 0 1px 0 rgba(15,23,42,0.06) !important;
}

/* -- Announcement Bar Shimmer -------------------------------------- */
.announcement-bar {
  background: linear-gradient(90deg, #0f172a, #1e293b, #0f172a);
  background-size: 200% 100%;
  animation: announcementShimmer 8s linear infinite;
}
@keyframes announcementShimmer {
  0% { background-position: 0% 0%; } 100% { background-position: 200% 0%; }
}

/* -- Product Card 3D + Shimmer ------------------------------------- */
.product-card, .catalog-card {
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.4s ease !important;
  will-change: transform;
  position: relative; overflow: hidden;
}
.product-card::before, .catalog-card::before {
  content: ''; position: absolute; top: 0; left: -100%;
  width: 60%; height: 100%;
  background: linear-gradient(105deg, transparent 0%, rgba(255,255,255,0.06) 50%, transparent 100%);
  transition: left 0.6s ease; z-index: 1; pointer-events: none;
}
.product-card:hover::before, .catalog-card:hover::before { left: 150%; }
.product-card:hover, .catalog-card:hover {
  box-shadow: 0 20px 60px rgba(15,23,42,0.15), 0 0 0 1px rgba(245,158,11,0.15),
              0 0 40px rgba(245,158,11,0.05) !important;
}

/* -- Product Image Zoom ------------------------------------------- */
.product-card .card-img, .catalog-card img, .card-img-wrap img {
  transition: transform 0.6s cubic-bezier(0.16,1,0.3,1) !important;
  transform-origin: center center;
}
.product-card:hover .card-img, .catalog-card:hover img, .card-img-wrap:hover img {
  transform: scale(1.07) !important;
}

/* -- Stat Card Hover Glow ----------------------------------------- */
.stat-card {
  position: relative; overflow: hidden;
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1), box-shadow 0.35s ease !important;
}
.stat-card::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, #fbbf24, transparent);
  opacity: 0; transition: opacity 0.3s ease;
}
.stat-card:hover::after { opacity: 1; }
.stat-card:hover {
  transform: translateY(-6px) scale(1.01) !important;
  box-shadow: 0 20px 40px rgba(15,23,42,0.12), 0 0 0 1px rgba(245,158,11,0.1),
              inset 0 1px 0 rgba(255,255,255,0.8) !important;
}

/* -- Button Ripple ------------------------------------------------- */
.btn {
  transition: transform 0.2s cubic-bezier(0.34,1.56,0.64,1),
              box-shadow 0.2s ease, background 0.2s ease !important;
  will-change: transform;
}
.btn-ripple {
  position: absolute; border-radius: 50%;
  background: rgba(255,255,255,0.3);
  transform: scale(0); animation: btnRipple 0.6s linear;
  pointer-events: none;
}
@keyframes btnRipple { to { transform: scale(4); opacity: 0; } }

/* -- Table Row Hover ---------------------------------------------- */
table tbody tr {
  transition: background 0.15s ease, transform 0.15s ease !important;
}
table tbody tr:hover {
  background: rgba(245,158,11,0.04) !important;
  transform: translateX(2px);
}

/* -- Glow Pulse for CTA ------------------------------------------- */
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 20px rgba(245,158,11,0.3), 0 4px 14px rgba(245,158,11,0.25); }
  50% { box-shadow: 0 0 35px rgba(245,158,11,0.5), 0 4px 20px rgba(245,158,11,0.35); }
}
.btn-glow { animation: glowPulse 2.5s ease-in-out infinite; }

/* -- Animated Grid Background Hero --------------------------------- */
.hero-section { position: relative; overflow: hidden; }
.hero-section::after {
  content: ''; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(245,158,11,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(245,158,11,0.04) 1px, transparent 1px);
  background-size: 60px 60px; pointer-events: none;
  animation: gridDrift 25s linear infinite;
}
@keyframes gridDrift {
  0% { background-position: 0px 0px, 0px 0px; }
  100% { background-position: 60px 60px, 60px 60px; }
}

/* -- Top Progress Bar ---------------------------------------------- */
#ms-progress-bar {
  position: fixed; top: 0; left: 0; height: 3px; width: 0%;
  background: linear-gradient(90deg, #fbbf24, #f97316, #f59e0b);
  background-size: 200% 100%;
  animation: progressGlow 2s linear infinite;
  z-index: 99997; transition: width 0.15s ease;
  box-shadow: 0 0 10px rgba(245,158,11,0.5);
}
@keyframes progressGlow {
  0% { background-position: 0% 0%; } 100% { background-position: 200% 0%; }
}

/* -- Status Dot Live ---------------------------------------------- */
.status-dot-live {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; background: #10b981; position: relative;
}
.status-dot-live::before {
  content: ''; position: absolute; inset: -3px; border-radius: 50%;
  background: #10b981; opacity: 0.4;
  animation: dotPing 1.5s ease-in-out infinite;
}
@keyframes dotPing {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50% { transform: scale(1.8); opacity: 0; }
}

/* -- Blob Decorations ---------------------------------------------- */
.ms-blob {
  position: absolute; filter: blur(40px); opacity: 0.08;
  animation: blobMorph 12s ease-in-out infinite; pointer-events: none;
  border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
}
.ms-blob-1 { width: 400px; height: 400px; background: #fbbf24; top: -100px; right: -100px; }
.ms-blob-2 { width: 300px; height: 300px; background: #6366f1; bottom: -80px; left: -80px; animation-delay: -6s; }
@keyframes blobMorph {
  0%, 100% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; }
  25% { border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%; }
  50% { border-radius: 50% 60% 30% 60% / 30% 60% 70% 40%; }
  75% { border-radius: 60% 40% 60% 30% / 70% 30% 60% 40%; }
}

/* -- Premium Alert ------------------------------------------------- */
.alert { animation: alertSlideIn 0.4s cubic-bezier(0.34,1.56,0.64,1) both !important; }
@keyframes alertSlideIn {
  from { opacity: 0; transform: translateX(-16px); }
  to { opacity: 1; transform: translateX(0); }
}

/* -- Sidebar Indicator Bar ---------------------------------------- */
.nav-item a, .sidebar-nav a {
  position: relative; overflow: hidden;
  transition: all 0.2s cubic-bezier(0.16,1,0.3,1) !important;
}
.nav-item a::before, .sidebar-nav a::before {
  content: ''; position: absolute; left: 0; top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 3px; height: 60%;
  background: linear-gradient(180deg, #fbbf24, #d97706);
  border-radius: 0 4px 4px 0;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
}
.nav-item a:hover::before, .nav-item.active a::before,
.sidebar-nav a:hover::before { transform: translateY(-50%) scaleY(1); }

/* -- Text Gradient ------------------------------------------------- */
.text-gradient {
  background: linear-gradient(135deg, #fbbf24 0%, #f97316 50%, #d97706 100%);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  animation: gradientShift 4s ease-in-out infinite alternate; background-size: 200% auto;
}
@keyframes gradientShift { 0% { background-position: 0% 50%; } 100% { background-position: 100% 50%; } }

/* -- Premium Scrollbar -------------------------------------------- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: linear-gradient(180deg, #fbbf24, #d97706); border-radius: 10px; }

/* -- Selection ---------------------------------------------------- */
::selection { background: rgba(245,158,11,0.2); color: #0f172a; }

/* -- Modal Backdrop Blur ------------------------------------------ */
.modal-backdrop {
  backdrop-filter: blur(8px) !important; -webkit-backdrop-filter: blur(8px) !important;
  background: rgba(15,23,42,0.6) !important;
}

/* -- Badge Float Animation ---------------------------------------- */
.badge-float { animation: badgeFloat 4s ease-in-out infinite; }
@keyframes badgeFloat {
  0%, 100% { transform: translateY(0px); } 50% { transform: translateY(-5px); }
}

/* -- Focus Ring --------------------------------------------------- */
:focus-visible { outline: 2px solid #fbbf24 !important; outline-offset: 3px !important; border-radius: 6px !important; }

/* -- Mobile: disable custom cursor -------------------------------- */
@media (pointer: coarse) {
  *, *::before, *::after { cursor: auto !important; }
  #ms-cursor, #ms-cursor-ring { display: none !important; }
}