/**
 * Mobile-first Premium Ecommerce CSS
 * Apple / Amazon / Shopify inspired
 * Safe for existing JS hooks (cart-count, theme-toggle, mobileNavbar, etc.)
 */

/* ---------- Mobile-first base ---------- */
html, body {
  max-width: 100%;
  overflow-x: hidden;
}

img, video, iframe, svg {
  max-width: 100%;
  height: auto;
}

.container,
.container-fluid,
.row {
  max-width: 100%;
}

/* ---------- Mobile header (3 rows) ---------- */
.storefront-mobile-header {
  padding-bottom: 0 !important;
}

.mobile-header-inner {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  padding-top: 0.55rem;
  padding-bottom: 0.45rem;
}

.mobile-header-row--top {
  min-height: 44px;
}

.mobile-header-row--search {
  width: 100%;
  max-width: 100%;
  margin: 0;
}

.storefront-mobile-search .storefront-search-shell {
  display: flex !important;
  align-items: center;
  width: 100%;
  min-height: 46px;
  border-radius: 50px !important;
  border: 1.5px solid rgba(37, 99, 235, 0.18) !important;
  background: #F1F5F9 !important;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.08);
  overflow: hidden;
}

.storefront-mobile-search .storefront-search-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 46px !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 0.9rem !important;
  padding-left: 0 !important;
}

.storefront-search-filter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  color: #64748B;
  text-decoration: none;
}

.storefront-search-filter:hover,
.storefront-search-voice:hover {
  color: #2563EB;
}

.storefront-mobile-search .storefront-search-submit {
  flex: 0 0 auto;
  min-width: 48px;
  height: 46px !important;
  border-radius: 0 50px 50px 0 !important;
  background: linear-gradient(135deg, #2563EB, #1D4ED8) !important;
  color: #fff !important;
  border: 0 !important;
}

/* Horizontal chip nav — no wrap */
.mobile-chip-nav {
  margin: 0 -0.25rem;
  padding-bottom: 0.15rem;
}

.mobile-chip-track {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.45rem;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  padding: 0.15rem 0.25rem 0.35rem;
  scrollbar-width: none;
}

.mobile-chip-track::-webkit-scrollbar {
  display: none;
}

.mobile-chip {
  flex: 0 0 auto;
  scroll-snap-align: start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  background: #EFF6FF;
  color: #1E40AF !important;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none !important;
  white-space: nowrap;
  border: 1px solid rgba(37, 99, 235, 0.12);
  transition: background 300ms ease, transform 300ms ease, color 300ms ease;
}

.mobile-chip:hover,
.mobile-chip:focus {
  background: #2563EB;
  color: #fff !important;
  transform: translateY(-1px);
}

html[data-theme="dark"] .mobile-chip {
  background: rgba(37, 99, 235, 0.18);
  color: #93C5FD !important;
  border-color: rgba(255, 255, 255, 0.1);
}

/* ---------- Bottom nav ---------- */
.mobile-bottom-nav {
  position: fixed !important;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1050;
  padding: 0.45rem 0.5rem calc(0.45rem + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.92) !important;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 28px rgba(15, 23, 42, 0.1);
}

.mobile-bottom-nav-inner {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 0.15rem;
  max-width: 560px;
  margin: 0 auto;
}

.mobile-bottom-link {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15rem;
  min-width: 0;
  padding: 0.35rem 0.2rem;
  text-decoration: none !important;
  color: #64748B !important;
  font-size: 0.68rem;
  font-weight: 600;
  border-radius: 12px;
  transition: color 300ms ease, background 300ms ease, transform 300ms ease;
}

.mobile-bottom-link i {
  font-size: 1.15rem;
  line-height: 1;
}

.mobile-bottom-link:hover,
.mobile-bottom-link:focus,
.mobile-bottom-link:active {
  color: #2563EB !important;
  background: rgba(37, 99, 235, 0.08);
  transform: translateY(-1px);
}

.mobile-bottom-badge {
  position: absolute;
  top: 0;
  right: 18%;
  font-size: 9px !important;
  min-width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

html[data-theme="dark"] .mobile-bottom-nav {
  background: rgba(11, 18, 32, 0.94) !important;
  border-top-color: rgba(255, 255, 255, 0.1);
}

/* Body padding for fixed chrome */
@media (max-width: 767.98px) {
  body.mobile-nav-fixed {
    padding-top: var(--storefront-header-offset-mobile, 168px) !important;
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
  }

  main.storefront-main {
    padding-top: 0.5rem !important;
    padding-inline: clamp(10px, 3vw, 16px) !important;
  }

  /* Hero */
  #banner .carousel-item,
  #banner .carousel-item img,
  #banner .banner-slide,
  #banner .carousel-inner {
    min-height: 0;
  }

  #banner .carousel-item img,
  #banner img {
    width: 100%;
    height: clamp(220px, 48vw, 300px) !important;
    object-fit: cover !important;
    border-radius: 16px;
  }

  #banner .carousel,
  #banner .carousel-inner {
    border-radius: 16px;
    overflow: hidden;
  }

  /* Product grids: always 2 cols on phones */
  .d-md-none .siva-snap {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    overflow: visible !important;
    padding: 0 !important;
    scroll-snap-type: none !important;
  }

  .d-md-none .siva-snap-item {
    width: 100% !important;
    min-width: 0 !important;
    flex: none !important;
  }

  .siva-card,
  .product-card {
    border-radius: 20px !important;
  }

  .siva-card-body,
  .product-card .card-body {
    padding: 0.7rem !important;
  }

  .siva-name,
  .product-title {
    font-size: 0.82rem !important;
    line-height: 1.3 !important;
  }

  .siva-actions {
    flex-direction: column !important;
    gap: 0.45rem !important;
  }

  .siva-actions .btn-add-to-cart,
  .btn-add-to-cart {
    width: 100%;
    min-height: 42px;
    font-size: 0.8rem !important;
  }

  /* Categories: tighter circular chips */
  .category-scroll-item {
    width: clamp(88px, 26vw, 110px) !important;
  }

  .category-logo-container {
    width: clamp(52px, 16vw, 68px) !important;
    height: clamp(52px, 16vw, 68px) !important;
  }

  .category-name {
    font-size: 0.72rem !important;
  }

  .storefront-mobile-menu {
    max-height: min(70vh, 560px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Tiny phones */
@media (max-width: 359.98px) {
  .mobile-bottom-link span {
    font-size: 0.62rem;
  }

  .storefront-brand-text {
    font-size: 1rem !important;
  }

  .d-md-none .siva-snap {
    gap: 0.5rem;
  }
}

@media (max-width: 319.98px) {
  .d-md-none .siva-snap {
    grid-template-columns: 1fr !important;
  }
}

/* ---------- Tablet+ product grids ---------- */
@media (min-width: 768px) {
  #banner .carousel-item img,
  #banner img {
    height: clamp(360px, 42vw, 520px) !important;
    object-fit: cover !important;
  }

  .row.premium-product-grid,
  .trending-products .row.d-md-flex,
  .featured-products .row.d-md-flex {
    --bs-gutter-x: 1rem;
    --bs-gutter-y: 1rem;
  }
}

@media (min-width: 1200px) {
  #banner .carousel-item img,
  #banner img {
    height: clamp(480px, 36vw, 620px) !important;
  }
}

/* Category density across breakpoints via scroll item width */
@media (min-width: 576px) {
  .category-scroll-item { width: clamp(100px, 18vw, 120px) !important; }
}
@media (min-width: 768px) {
  .category-scroll-item { width: clamp(110px, 14vw, 130px) !important; }
}
@media (min-width: 992px) {
  .category-scroll-item { width: clamp(118px, 12vw, 140px) !important; }
}
@media (min-width: 1200px) {
  .category-scroll-item { width: clamp(120px, 10vw, 150px) !important; }
}

/* Focus accessibility */
.mobile-chip:focus-visible,
.mobile-bottom-link:focus-visible,
.storefront-icon-btn:focus-visible,
.storefront-search-filter:focus-visible,
.storefront-search-voice:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.45);
  outline-offset: 2px;
}
