/* ============================================
   MOBILE-FIRST: Base styles are mobile (< 768px)
   ============================================ */

/* Mobile: Breadcrumbs — truncate product title, horizontal scroll */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.breadcrumb::-webkit-scrollbar { display: none; }
.breadcrumb__current {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 180px;
  display: inline-block;
  vertical-align: bottom;
}
@media (min-width: 768px) {
  .breadcrumb__current { max-width: none; }
  .breadcrumb { font-size: 0.8125rem; }
}

/* Mobile: Hamburger visible, links hidden */
.navbar__links {
  display: none;
}

.navbar__hamburger {
  display: flex;
}

/* Mobile: Hide desktop auth buttons, show only theme + hamburger */
.navbar__desktop-auth {
  display: none;
}

/* Mobile: user pill — hide name, show only avatar */
.navbar__user-name {
  display: none;
}

/* Mobile: Auth buttons inside hamburger menu */
.navbar__mobile-auth {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-top: 0.75rem;
  margin-top: 0.5rem;
  border-top: 1px solid var(--border);
}

/* Mobile: Compact navbar */
.navbar {
  padding: 0.5rem 0.75rem;
}

.navbar__logo {
  font-size: 0.9375rem;
}

.navbar__logo svg {
  width: 24px;
  height: 24px;
}

/* Mobile nav overlay */
.navbar__links.open {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: calc(0.75rem + 52px + 0.5rem);
  left: 0.75rem;
  right: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  gap: 0.75rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
  z-index: 49;
}

/* Mobile: Single column grids */
.grid-categories {
  grid-template-columns: repeat(2, 1fr);
}

.cat-page-grid {
  grid-template-columns: 1fr;
}

.grid-products {
  grid-template-columns: 1fr;
}

.grid-products--listing {
  grid-template-columns: 1fr;
}

.stats-grid-4 {
  grid-template-columns: repeat(2, 1fr);
}

.charts-grid-2 {
  grid-template-columns: 1fr;
}

/* Mobile: Footer single column */
.footer__grid {
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

.footer__bottom {
  flex-direction: column;
  gap: 0.5rem;
  text-align: center;
}

/* Mobile: Dashboard — handled by dashboard-mobile.css */

/* Mobile: Admin — handled by admin.css responsive */

.admin__main {
  margin-left: 0;
  padding: 1rem;
}

.admin-stats-6 {
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.admin-stats-5 {
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.admin-stats-4 {
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.admin-stats-6 .sc,
.admin-stats-5 .sc,
.admin-stats-4 .sc {
  padding: 0.75rem;
}

.admin-charts-2-1 {
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.admin-charts-3 {
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

/* Mobile: Hero smaller */
.hero__title {
  font-size: 1.75rem;
}

.hero__subtitle {
  font-size: 1rem;
}

.hero__search-bar {
  flex-wrap: nowrap;
}

.hero__search-input {
  min-width: 0;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
}

.hero__search-btn {
  padding: 0.75rem 1rem;
  font-size: 0.8125rem;
  white-space: nowrap;
}

/* Mobile: Stats bar wrap */
.stats-bar__grid {
  gap: 1.5rem;
}

/* Mobile: How it works */
.steps-grid {
  grid-template-columns: 1fr;
  gap: 2rem;
}

/* Mobile: Section headers — wrap on small screens */
.section > .container > div[style*="justify-content:space-between"] {
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Mobile: Carousel items smaller */
.carousel-row > div[style*="min-width:260px"] {
  min-width: 220px !important;
  max-width: 240px !important;
}

/* Mobile: Promoted carousel cards — fit 2 cards on screen */
.listing__promoted-card {
  width: 200px;
  min-width: 200px;
  max-width: 200px;
}

/* Mobile: Carousel arrows always visible (no hover on touch) */
.carousel-wrapper .carousel-arrow {
  opacity: 1;
  pointer-events: auto;
}

/* Mobile: Category grid scroll */
.category-grid {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-wrap: nowrap;
}

/* Mobile: Stats bar 2x2 grid */
.stats-bar__grid {
  display: grid !important;
  grid-template-columns: repeat(2, 1fr) !important;
  gap: 0.75rem !important;
  text-align: center;
}

/* Mobile: Listing sidebar hidden */
.listing__sidebar {
  display: none !important;
}

/* Mobile: Dashboard credit history — hide table, show cards */
.credit-history-table { display: none !important; }
.credit-history-table + div { display: none !important; } /* hide load more for table */
.credit-history-mobile { display: flex !important; }

/* Mobile: Credit packages — smaller */
.credit-pkg-card {
  padding: 1rem !important;
}
.credit-pkg-card .btn-primary {
  font-size: 0.8125rem !important;
  padding: 0.625rem !important;
}

/* Mobile: Promotions table → cards */
.promo-table { display: none !important; }
.promo-cards { display: flex !important; }

.otp-input {
  width: 38px !important;
  height: 44px !important;
  font-size: 1.125rem !important;
  padding: 0 !important;
}

[data-otp] {
  gap: 0.25rem !important;
}

.footer__anpc {
  gap: 0.375rem !important;
  margin-top: 1rem !important;
  padding-top: 0.75rem !important;
  flex-wrap: nowrap !important;
}

.footer__anpc a {
  flex: 1;
  min-width: 0;
}

.footer__anpc-badge {
  width: auto !important;
  height: auto !important;
  padding: 5px 8px !important;
  gap: 6px !important;
}

.footer__anpc-icon {
  width: 24px !important;
  height: 24px !important;
  border-radius: 4px !important;
}

.footer__anpc-icon svg {
  width: 12px !important;
  height: 12px !important;
}

.footer__anpc-title {
  font-size: 0.5625rem !important;
}

.footer__anpc-sub {
  font-size: 0.4375rem !important;
  white-space: nowrap;
}

.listing__sidebar.mobile-open {
  display: block !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 56px !important;
  z-index: 55;
  overflow-y: scroll !important;
  -webkit-overflow-scrolling: touch;
  padding: 1.25rem !important;
  border-radius: 0 !important;
  border: none !important;
  background: var(--bg) !important;
}

#mobile-filter-toggle {
  display: flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 50;
  margin: 0;
  border-radius: 0;
  padding: 14px 16px;
  font-size: 0.9375rem;
  font-weight: 700;
  color: #fff;
  background: var(--cta);
  cursor: pointer;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.25);
  -webkit-tap-highlight-color: transparent;
}

.listing__grid {
  grid-template-columns: 1fr !important;
}

/* Mobile: Product detail stacked */
.product-detail__grid {
  grid-template-columns: 1fr;
}

.product-detail__grid > div:first-child {
  display: contents;
}

.product-detail__grid .pd-gallery {
  order: 1;
}

.product-detail__sticky {
  position: static;
  order: 2;
}

.product-detail__grid > div:first-child > div:not(.pd-gallery) {
  order: 3;
}

/* Mobile: Table scroll */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================================
   TABLET: @media (min-width: 768px)
   ============================================ */
@media (min-width: 768px) {
  /* Reset mobile ANPC overrides */
  .footer__anpc { gap: 1.5rem !important; margin-top: 2rem !important; padding-top: 1.5rem !important; flex-wrap: wrap !important; }
  .footer__anpc a { flex: none; min-width: auto; }
  .footer__anpc-badge { width: 250px !important; height: 60px !important; padding: 0 20px !important; gap: 12px !important; }
  .footer__anpc-icon { width: 40px !important; height: 40px !important; border-radius: 8px !important; }
  .footer__anpc-icon svg { width: 20px !important; height: 20px !important; }
  .footer__anpc-title { font-size: 0.6875rem !important; }
  .footer__anpc-sub { font-size: 0.625rem !important; white-space: normal; }

  /* Reset mobile OTP overrides */
  .otp-input { width: 48px !important; height: 56px !important; font-size: 1.5rem !important; padding: 0 !important; }
  [data-otp] { gap: 0.5rem !important; }

  /* Reset mobile stats bar */
  .stats-bar__grid { display: flex !important; grid-template-columns: none !important; }

  /* Reset mobile promotions */
  .promo-table { display: block !important; }
  .promo-cards { display: none !important; }

  /* Reset mobile credit packages */
  .credit-pkg-card { padding: 1.5rem !important; }

  .grid-categories {
    grid-template-columns: repeat(3, 1fr);
  }

  .cat-page-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-products {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-products--listing {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Reset promoted card width for tablet+ */
  .listing__promoted-card {
    width: 260px;
    min-width: 260px;
    max-width: 260px;
  }

  .footer__grid {
    grid-template-columns: 1fr 1fr;
  }

  .stats-grid-4 {
    grid-template-columns: repeat(4, 1fr);
  }

  .admin-stats-6 {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
  }

  .admin-stats-5 {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
  }

  .admin-stats-4 {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
  }

  .admin-stats-6 .sc,
  .admin-stats-5 .sc,
  .admin-stats-4 .sc {
    padding: 1rem;
  }

  .steps-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero__title {
    font-size: 2rem;
  }
}

/* ============================================
   DESKTOP: @media (min-width: 1024px)
   ============================================ */
@media (min-width: 1024px) {
  /* Desktop: Show links, hide hamburger */
  .navbar__links {
    display: flex;
  }

  .navbar__hamburger {
    display: none;
  }

  /* Desktop: Show auth buttons in actions bar */
  .navbar__desktop-auth {
    display: inline-flex;
  }

  /* Desktop: Hide mobile auth section in nav links */
  .navbar__mobile-auth {
    display: none;
  }

  /* Desktop: Show user name */
  .navbar__user-name {
    display: inline;
  }

  /* Desktop: Reset navbar padding */
  .navbar {
    padding: 0.625rem 1.5rem;
  }

  .navbar__logo {
    font-size: 1.0625rem;
  }

  .navbar__logo svg {
    width: 28px;
    height: 28px;
  }

  .grid-categories {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }

  .cat-page-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .grid-products {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }

  .grid-products--listing {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }

  .footer__grid {
    grid-template-columns: 2fr 1fr 1fr 1fr;
  }

  .footer__bottom {
    flex-direction: row;
  }

  /* Desktop: Dashboard — handled by dashboard-desktop.css */

  /* Desktop: Admin sidebar */
  .admin__sidebar {
    display: flex;
    transform: none;
  }

  .admin__main {
    margin-left: 260px;
    padding: 2rem;
  }

  .admin-stats-6 {
    grid-template-columns: repeat(6, 1fr);
    gap: 0.75rem;
  }

  .admin-stats-5 {
    grid-template-columns: repeat(5, 1fr);
    gap: 0.75rem;
  }

  .admin-stats-6 .sc,
  .admin-stats-5 .sc,
  .admin-stats-4 .sc {
    padding: 1.25rem;
  }

  .admin-charts-2-1 {
    grid-template-columns: 2fr 1fr;
    gap: 1rem;
  }

  .admin-charts-3 {
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
  }

  .admin-charts-2-1 .sc,
  .admin-charts-3 .sc {
    padding: 1.25rem;
  }

  /* Desktop: Listing sidebar */
  .listing__sidebar {
    display: block !important;
  }

  .listing__sidebar.mobile-open {
    position: static;
    z-index: auto;
    overflow-y: visible;
  }

  #mobile-filter-toggle {
    display: none !important;
  }

  .listing__grid {
    grid-template-columns: 260px 1fr !important;
  }

  /* Desktop: Product detail */
  .product-detail__grid {
    grid-template-columns: 1fr 400px;
  }

  .product-detail__grid > div:first-child {
    display: block;
  }

  .product-detail__grid .pd-gallery,
  .product-detail__sticky,
  .product-detail__grid > div:first-child > div:not(.pd-gallery) {
    order: unset;
  }

  .product-detail__sticky {
    position: sticky;
    top: calc(0.75rem + 52px + 1rem);
  }

  /* Desktop: Hero */
  .hero__title {
    font-size: 2.5rem;
  }

  .steps-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .charts-grid-2 {
    grid-template-columns: 1fr 1fr;
  }

  /* Desktop: Carousel arrows — hide by default, show on hover */
  .carousel-wrapper .carousel-arrow {
    opacity: 0;
    pointer-events: none;
  }
  .carousel-wrapper:hover .carousel-arrow {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ============================================
   LARGE DESKTOP: @media (min-width: 1280px)
   ============================================ */
@media (min-width: 1280px) {
  .container {
    max-width: 1200px;
  }
}
