/* ===== KASHSURG PREMIUM E-COMMERCE STYLES ===== */

/* Typography variables */
:root {
  --font-sans: 'Inter', sans-serif;
  --font-display: 'Outfit', sans-serif;
}

/* Universal Mobile Viewport & Overflow-X Protection */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  overflow-x: clip !important;
  max-width: 100% !important;
  width: 100% !important;
  -webkit-text-size-adjust: 100%;
}

body {
  overflow-x: clip !important;
  max-width: 100% !important;
  width: 100% !important;
  position: relative;
  font-family: var(--font-sans);
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

img, svg, video, canvas, audio, iframe, embed, object {
  max-width: 100% !important;
  height: auto;
}

/* ===== SVG Logo Size Safety (Prevents giant SVG when Tailwind CDN fails) ===== */
header svg,
footer svg,
.checkout-logo-icon svg {
  max-width: 1.5rem;
  max-height: 1.5rem;
}

/* Header layout fallback strictly for single-row checkout header (works without Tailwind) */
header > div.checkout-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Keep navigation bar items & brand badge single-line without breaking dropdown overflow */
header {
  overflow-x: clip;
  overflow-y: visible;
}

header nav a,
header a[href="about-us.html"] {
  white-space: nowrap;
  flex-shrink: 0;
}

header form,
header form input[name="search"] {
  min-width: 0;
}

header a[href="/"] {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  flex-shrink: 0;
}

/* Logo container: always constrained */
.checkout-logo-icon {
  width: 2rem !important;
  height: 2rem !important;
  min-width: 2rem !important;
  min-height: 2rem !important;
  max-width: 2.25rem !important;
  max-height: 2.25rem !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  overflow: hidden !important;
  flex-shrink: 0 !important;
  border-radius: 0.75rem;
}

.checkout-logo-icon svg {
  width: 1rem !important;
  height: 1rem !important;
  max-width: 1.25rem !important;
  max-height: 1.25rem !important;
  flex-shrink: 0 !important;
}

@media (min-width: 640px) {
  .checkout-logo-icon {
    width: 2.25rem !important;
    height: 2.25rem !important;
  }
  .checkout-logo-icon svg {
    width: 1.25rem !important;
    height: 1.25rem !important;
  }
}

/* Universal Mobile Responsive Overflow Defense */
@media (max-width: 768px) {
  html, body {
    overflow-x: clip !important;
    max-width: 100% !important;
    width: 100% !important;
  }
  
  header {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: clip !important;
  }
  
  header a[href*="wishlist.html"]:not(#mobile-nav-drawer a),
  header a[href*="login.html"]:not(#mobile-nav-drawer a) {
    display: none !important;
  }
  
  #topbar-announcement {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }
  #topbar-announcement > div {
    flex-wrap: wrap !important;
  }
  
  /* Prevent flex & grid child content blowout */
  .flex > *,
  .grid > * {
    min-width: 0;
  }
  
  /* Prevent long unspaced words from blowing out mobile cards */
  h1, h2, h3, h4, h5, h6, p, a, span, td, th {
    overflow-wrap: break-word !important;
    word-break: break-word;
  }
  
  /* Mobile tables */
  table {
    max-width: 100% !important;
  }
  
  .clinical-description table,
  .prose table {
    width: 100% !important;
    max-width: 100% !important;
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  input, select, textarea, button {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
}

/* Prevent duplicate floating WhatsApp widgets */
#ks-whatsapp-widget {
  display: none !important;
}

.heading-display {
  font-family: var(--font-display);
}

/* Universal Controlled Brand Logo Sizing */
#main-site-logo,
.site-header-logo,
header img[src*="Kashsurg Logo"],
header img[src*="kashsurg-logo"],
header a[href] > img {
  height: 24px !important;
  max-height: 24px !important;
  max-width: 140px !important;
  width: auto !important;
  object-fit: contain !important;
  display: inline-block !important;
  vertical-align: middle !important;
}

@media (max-width: 640px) {
  #main-site-logo,
  .site-header-logo,
  header img[src*="Kashsurg Logo"],
  header img[src*="kashsurg-logo"],
  header a[href] > img {
    height: 20px !important;
    max-height: 20px !important;
    max-width: 115px !important;
  }
}

footer img[src*="Kashsurg Logo"],
footer img[src*="kashsurg-logo"],
.site-footer-logo {
  height: 22px !important;
  max-height: 22px !important;
  max-width: 120px !important;
  width: auto !important;
  object-fit: contain !important;
  display: inline-block !important;
}

/* Glassmorphism Styles */
.glass {
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.glass-dark {
  background: rgba(11, 19, 42, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #F8F9FA;
}

::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94A3B8;
}

/* Foolproof Infinite Continuous Brands Marquee (Hardware Accelerated) */
@-webkit-keyframes marquee-scroll {
  0% { -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); }
  100% { -webkit-transform: translate3d(-100%, 0, 0); transform: translate3d(-100%, 0, 0); }
}

@keyframes marquee-scroll {
  0% { -webkit-transform: translate3d(0, 0, 0); transform: translate3d(0, 0, 0); }
  100% { -webkit-transform: translate3d(-100%, 0, 0); transform: translate3d(-100%, 0, 0); }
}

.marquee-wrapper {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  width: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* Edge Fade Gradients for Luxury Look */
.marquee-wrapper::before,
.marquee-wrapper::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2rem;
  z-index: 10;
  pointer-events: none;
}

@media (min-width: 640px) {
  .marquee-wrapper::before,
  .marquee-wrapper::after {
    width: 3rem;
  }
}

.marquee-wrapper::before {
  left: 0;
  background: linear-gradient(to right, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0) 100%);
}

.marquee-wrapper::after {
  right: 0;
  background: linear-gradient(to left, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0) 100%);
}

.animate-marquee {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  gap: 0.75rem;
  will-change: transform;
  -webkit-animation-name: marquee-scroll;
  animation-name: marquee-scroll;
  -webkit-animation-duration: 30s;
  animation-duration: 30s;
  -webkit-animation-timing-function: linear;
  animation-timing-function: linear;
  -webkit-animation-iteration-count: infinite;
  animation-iteration-count: infinite;
  -webkit-animation-play-state: running;
  animation-play-state: running;
  white-space: nowrap;
}

@media (min-width: 640px) {
  .animate-marquee {
    gap: 1.25rem;
    -webkit-animation-duration: 38s;
    animation-duration: 38s;
  }
}

/* Explicit pause via toggle or JS */
.marquee-wrapper.is-paused .animate-marquee {
  -webkit-animation-play-state: paused !important;
  animation-play-state: paused !important;
}

/* Desktop mouse-only hover pause (bypasses touch devices) */
@media (hover: hover) and (pointer: fine) {
  .marquee-wrapper:not(.is-paused):hover .animate-marquee {
    -webkit-animation-play-state: paused;
    animation-play-state: paused;
  }
}

.brand-carousel-card {
  flex-shrink: 0;
  width: 135px;
  min-width: 135px;
  padding: 0.6rem 0.75rem;
}

@media (min-width: 640px) {
  .brand-carousel-card {
    width: 180px;
    min-width: 180px;
    padding: 0.85rem 1.25rem;
  }
}

/* Image Zoom Frame */
.zoom-img-container {
  overflow: hidden;
  position: relative;
}

.zoom-img-container img {
  transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.zoom-img-container:hover img {
  transform: scale(1.1);
}

/* Mobile Optimization Utilities */
@media (max-width: 640px) {
  html, body {
    overflow-x: hidden;
  }
  .max-w-7xl {
    padding-left: 1rem;
    padding-right: 1rem;
  }

}

/* Cart Impact & Floating Cart Animations */
@keyframes cart-bounce {
  0% { transform: scale(1); }
  30% { transform: scale(1.35) rotate(-8deg); }
  50% { transform: scale(0.9) rotate(5deg); }
  75% { transform: scale(1.15) rotate(-2deg); }
  100% { transform: scale(1) rotate(0deg); }
}

@keyframes float-pulse {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-4px) scale(1.04); }
}

.cart-impact-active {
  animation: cart-bounce 0.65s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards !important;
}

.floating-cart-pulse {
  animation: float-pulse 2.5s ease-in-out infinite;
}

/* ===== Add-to-Cart Visual Effects (dynamic JS classes) ===== */
/* These classes are added via JavaScript at runtime,
   so Tailwind CDN doesn't generate them automatically. */

/* Button "Added!" ring effect */
.ring-2 {
  --tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width, 0px) var(--tw-ring-offset-color, #fff);
  --tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width, 0px)) var(--tw-ring-color, #3b82f6);
  box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
}

.ring-emerald-400 {
  --tw-ring-color: #34d399;
}

/* Button & badge scale effects */
.scale-105 {
  transform: scale(1.05);
}

.scale-150 {
  transform: scale(1.5);
}

/* Toast slide-in/out transitions */
.translate-y-0 {
  transform: translateY(0);
}

.translate-y-24 {
  transform: translateY(6rem);
}

/* Fly-to-cart orb glow */
.fly-to-cart-flying-orb {
  will-change: left, top, width, height, opacity, transform;
}

/* Ensure smooth transitions on dynamically toggled classes */
.cart-badge {
  transition: transform 0.3s ease, background-color 0.3s ease;
}

/* ===== MOBILE RESPONSIVENESS OVERHAUL (v4.0) ===== */

/* 1. Root & Viewport Protection (Zero horizontal overflow across 360px - 414px) */
html, body {
  width: 100%;
  max-width: 100vw;
  overflow-x: hidden !important;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  position: relative;
}

*, *::before, *::after {
  box-sizing: border-box;
}

img, svg, video, canvas, audio, iframe, embed, object {
  max-width: 100%;
}

/* 2. iOS Safari Auto-Zoom Fix & Form Input Ergonomics */
@media (max-width: 768px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="number"],
  input[type="password"],
  input[type="search"],
  input[type="url"],
  select,
  textarea {
    font-size: 16px !important; /* CRITICAL: Prevents iOS Safari auto-zoom on focus */
    min-height: 44px !important;
    line-height: 1.3 !important;
  }

  /* Search forms */
  header form input,
  .mobile-search-input {
    font-size: 16px !important;
    min-height: 44px !important;
  }

  header form button {
    min-height: 44px !important;
    min-width: 44px !important;
  }
}

/* 3. Touch Usability & Ergonomics (44px Minimum Tap Targets) */
@media (max-width: 768px) {
  /* Header Icons & Buttons */
  header button,
  header a[title],
  #header-cart-btn,
  .pwa-install-btn,
  #brand-view-toggle-btn {
    min-height: 44px !important;
    min-width: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Hero CTA Button */
  #hero-slider-cta {
    min-height: 44px !important;
    padding-left: 1.25rem !important;
    padding-right: 1.25rem !important;
    font-size: 0.8125rem !important;
    font-weight: 700 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Quantity buttons */
  button[onclick*="adjustLocalQty"],
  button[onclick*="Cart.updateQty"],
  .qty-btn {
    min-width: 40px !important;
    min-height: 40px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  /* Variation pills on product detail page */
  .variant-pill {
    min-height: 44px !important;
    padding: 0.5rem 0.85rem !important;
    display: inline-flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
  }

  /* Tabs on product page */
  #tab-btn-specs,
  #tab-btn-details {
    min-height: 44px !important;
    padding: 0.75rem 1rem !important;
    display: inline-flex !important;
    align-items: center !important;
  }

  /* Drawer Navigation Links */
  #mobile-nav-drawer nav a,
  #mobile-menu-links a {
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
    padding: 0.625rem 1rem !important;
    font-size: 0.9375rem !important;
    border-radius: 0.75rem !important;
  }

  #mobile-nav-drawer button[onclick*="toggleMobileNav"] {
    min-width: 44px !important;
    min-height: 44px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 1.25rem !important;
  }

  /* Wishlist floating toggle buttons */
  button[onclick*="toggleWish"] {
    min-width: 36px !important;
    min-height: 36px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }
}

/* 4. Balanced 2-Column Mobile Catalog & Best Sellers Grids */
@media (max-width: 639px) {
  #products-grid,
  #best-sellers-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.625rem !important;
    width: 100% !important;
  }

  #products-grid > div,
  #best-sellers-grid > div {
    padding: 0.625rem !important;
    border-radius: 1rem !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
  }

  #products-grid img,
  #best-sellers-grid img {
    height: 7.5rem !important;
    max-height: 7.5rem !important;
    width: 100% !important;
    object-fit: contain !important;
  }

  #products-grid .aspect-\[4\/3\],
  #best-sellers-grid .aspect-\[4\/3\],
  #best-sellers-grid .aspect-square {
    aspect-ratio: 1 / 1 !important;
    padding: 0.35rem !important;
    margin-bottom: 0.5rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 0.75rem !important;
  }

  /* Product titles: balanced 2 lines with consistent height */
  #products-grid h4,
  #best-sellers-grid h4 {
    font-size: 0.72rem !important;
    line-height: 1.25 !important;
    height: 1.85rem !important;
    max-height: 1.85rem !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2 !important;
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Action buttons row */
  #products-grid .grid.grid-cols-2,
  #best-sellers-grid .grid.grid-cols-2 {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 0.375rem !important;
    margin-top: 0.5rem !important;
    padding-top: 0.375rem !important;
    border-top-width: 1px !important;
  }

  #products-grid .grid.grid-cols-2 button,
  #best-sellers-grid .grid.grid-cols-2 button {
    min-height: 38px !important;
    font-size: 0.6875rem !important;
    font-weight: 700 !important;
    padding: 0.375rem 0.25rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 0.5rem !important;
    width: 100% !important;
  }
}

/* 5. Safe End-Padding & Touch Inertia for Horizontal Scroll Rows */
.overflow-x-auto,
#home-category-filters,
#thumbnails,
.mobile-scroll-row {
  -webkit-overflow-scrolling: touch !important;
  scroll-behavior: smooth !important;
  scrollbar-width: none !important; /* Firefox */
}

.overflow-x-auto::-webkit-scrollbar,
#home-category-filters::-webkit-scrollbar,
#thumbnails::-webkit-scrollbar {
  display: none !important; /* Chrome / Safari */
}

#home-category-filters {
  padding-right: 1.5rem !important;
}

#thumbnails {
  padding-right: 1rem !important;
}

/* 6. Non-Blocking Floating Elements & Safe Areas */
#cart-fly-toast {
  max-width: calc(100vw - 2rem) !important;
}

@media (max-width: 640px) {
  #cart-fly-toast {
    left: 1rem !important;
    right: 1rem !important;
    bottom: 5.5rem !important; /* Clear floating cart button */
    width: auto !important;
    max-width: calc(100vw - 2rem) !important;
    padding: 0.75rem 1rem !important;
    border-radius: 1rem !important;
  }

  #floating-cart-container {
    bottom: calc(5rem + env(safe-area-inset-bottom, 0px)) !important;
    right: 1rem !important;
  }

  body:has(#mobile-sticky-bar) #floating-cart-container {
    display: none !important;
  }

  body:has(#mobile-sticky-bar) #ks-whatsapp-widget {
    bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px)) !important;
    right: 1rem !important;
  }

  #floating-cart-btn {
    width: 3.25rem !important;
    height: 3.25rem !important;
  }
}

/* 7. Brand Marquee Mobile Polish */
@media (max-width: 640px) {
  .marquee-wrapper::before,
  .marquee-wrapper::after {
    width: 1.25rem !important;
  }

  .brand-carousel-card {
    width: 120px !important;
    min-width: 120px !important;
    height: 3.25rem !important;
    padding: 0.35rem 0.6rem !important;
  }

  .brand-carousel-card img {
    max-height: 1.5rem !important;
    max-width: 80px !important;
  }
}

/* 8. Safe Area Insets for Modern Mobile Notches */
@supports (padding: max(0px)) {
  body {
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* 9. Responsive Data Tables & Specs */
table,
.table-responsive,
#tab-content-specs table {
  display: block !important;
  width: 100% !important;
  max-width: 100% !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
}

/* 10. Drawer Hardware Acceleration & Smooth Slide */
#mobile-nav-drawer,
#cart-drawer,
.mobile-filter-drawer {
  will-change: transform;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* Mobile Filter Drawer Animation (products page) */
.mobile-filter-drawer {
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-filter-drawer.open {
  transform: translateX(0) !important;
}

/* Rich Clinical Description Styling */
.clinical-description h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: #1e293b;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}
.clinical-description p {
  color: #475569;
  line-height: 1.625;
  margin-bottom: 0.75rem;
}
.clinical-description ul {
  list-style-type: disc;
  padding-left: 1.25rem;
  margin-bottom: 1rem;
  color: #475569;
  line-height: 1.625;
}
.clinical-description ol {
  list-style-type: decimal;
  padding-left: 1.25rem;
  margin-bottom: 1rem;
  color: #475569;
  line-height: 1.625;
}
.clinical-description li {
  margin-bottom: 0.35rem;
}
.clinical-description strong {
  color: #0f172a;
  font-weight: 600;
}

/* ==========================================================================
   Mobile Product Page & Global Layout Robustness (Zero Horizontal Wobble)
   ========================================================================== */
html, body {
  overflow-x: clip !important;
  max-width: 100vw !important;
  width: 100% !important;
}

main {
  min-width: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
  overflow-x: clip !important;
}

#product-tabs,
#product-detail-content,
#product-detail-loader,
#related-products-section,
#related-products-grid {
  min-width: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
}

/* Ensure horizontal tab buttons bar scrolls smoothly inside its bounds without expanding parent */
#product-tabs > div:first-child {
  min-width: 0 !important;
  max-width: 100% !important;
  width: 100% !important;
  overflow-x: auto !important;
  -webkit-overflow-scrolling: touch !important;
}

/* Touch screen zoom protection */
@media (hover: hover) and (pointer: fine) {
  .zoom-container:hover .zoom-lens-img {
    transform: scale(1.75);
  }
}
@media (hover: none) or (pointer: coarse) {
  .zoom-container:hover .zoom-lens-img {
    transform: none !important;
  }
}



