/* ============================================================
   RESPONSIVE CSS
   ============================================================ */

/* ============================================================
   LARGE SCREENS (1400px+)
   ============================================================ */
@media (min-width: 1400px) {
  .container-fluid { max-width: 1440px; }
  .footer-main { grid-template-columns: 2.5fr 1fr 1fr 1fr 1.5fr; }
}

/* ============================================================
   DESKTOP (1200px - 1399px)
   ============================================================ */
@media (max-width: 1399px) {
  .hero-slide-content { padding: var(--space-12) var(--space-12); }
  .footer-main { grid-template-columns: 2fr 1fr 1fr 1fr; gap: var(--space-8); }
  .footer-main > div:last-child { grid-column: 1 / -1; }
  .affiliate-stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ============================================================
   TABLET LANDSCAPE (992px - 1199px)
   ============================================================ */
@media (max-width: 1199px) {
  :root {
    --header-height: 64px;
    --navbar-height: 48px;
  }

  .header-search { max-width: 380px; }
  .site-logo-tagline { display: none; }

  .mega-menu { min-width: 400px; }
  .mega-menu-grid { grid-template-columns: repeat(2, 1fr); }
  .mega-menu-grid.cols-4 { grid-template-columns: repeat(2, 1fr); }

  .grid-5 { grid-template-columns: repeat(4, 1fr); }
  .grid-6 { grid-template-columns: repeat(4, 1fr); }

  .footer-main {
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--space-8);
  }

  .footer-main > div:first-child { grid-column: 1 / -1; }

  .product-detail-wrapper { grid-template-columns: 1fr 1fr; gap: var(--space-6); }

  .cart-layout { grid-template-columns: 1fr 320px; gap: var(--space-6); }

  .admin-sidebar { width: 220px; }
  .admin-main { margin-left: 220px; }
}

/* ============================================================
   TABLET PORTRAIT (768px - 991px)
   ============================================================ */
@media (max-width: 991px) {
  :root {
    --top-header-height: 36px;
    --header-height: 60px;
    --navbar-height: 0px;
    --total-header: calc(var(--top-header-height) + var(--header-height));
  }

  /* Top header - simplify */
  .top-header-right .top-header-link.hide-tablet { display: none; }

  /* Header search - compact */
  .header-search { max-width: 280px; }
  .header-search-btn span { display: none; }

  /* Hide desktop navbar */
  .site-navbar { display: none; }

  /* Show mobile hamburger */
  .navbar-mobile-toggle { display: flex; }

  /* Mobile nav overlay */
  .mobile-nav-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    z-index: var(--z-modal-backdrop);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition-base);
  }

  .mobile-nav-overlay.show { opacity: 1; visibility: visible; }

  .mobile-nav {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 300px;
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    z-index: var(--z-modal);
    overflow-y: auto;
    transform: translateX(-100%);
    transition: var(--transition-base);
    padding: var(--space-5);
  }

  .mobile-nav.open { transform: translateX(0); }

  .mobile-nav-close {
    position: absolute;
    top: var(--space-4);
    right: var(--space-4);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--bg-glass);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 16px;
  }

  .mobile-nav-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px var(--space-3);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 15px;
    font-weight: 500;
    transition: var(--transition-fast);
    cursor: pointer;
  }

  .mobile-nav-link:hover { background: var(--bg-glass); color: var(--brand-primary); }

  .mobile-nav-submenu {
    padding-left: var(--space-4);
    display: none;
    margin-top: 4px;
  }

  .mobile-nav-submenu.open { display: block; }

  .mobile-nav-submenu a {
    display: block;
    padding: 8px var(--space-3);
    font-size: 14px;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: var(--transition-fast);
  }

  .mobile-nav-submenu a:hover { color: var(--brand-primary); background: var(--bg-glass); }

  /* Grid adjustments */
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-5 { grid-template-columns: repeat(3, 1fr); }
  .grid-6 { grid-template-columns: repeat(3, 1fr); }

  /* Hero */
  .hero-slide { min-height: 420px; }
  .hero-slide-content { padding: var(--space-10) var(--space-8); }
  .hero-slide-stats { display: none; }

  /* Product detail */
  .product-detail-wrapper {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }

  /* Cart */
  .cart-layout {
    grid-template-columns: 1fr;
  }

  .cart-summary {
    position: static;
    order: -1;
  }

  /* Footer */
  .footer-main {
    grid-template-columns: 1fr 1fr;
  }

  .footer-main > div:first-child { grid-column: 1 / -1; }
  .footer-main > div:last-child { grid-column: 1 / -1; }

  /* Admin */
  .admin-sidebar {
    transform: translateX(-100%);
    width: 260px;
    z-index: var(--z-modal);
  }

  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }

  /* Account */
  .account-sidebar { position: static; }
}

/* ============================================================
   MOBILE (576px - 767px)
   ============================================================ */
@media (max-width: 767px) {
  /* Top header */
  .top-header-right { display: none; }
  .top-header { height: 32px; }

  /* Header */
  .header-search { display: none; }

  .header-search-mobile {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    padding: var(--space-3);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    z-index: var(--z-top);
    display: none;
  }

  .header-search-mobile.show { display: block; }

  /* Hide some action buttons */
  .header-action-btn.hide-mobile { display: none; }

  /* Hero */
  .hero-slide { min-height: 340px; }
  .hero-slide-content { padding: var(--space-8) var(--space-5); }
  .hero-slide-title { font-size: 28px; }
  .hero-slide-desc { display: none; }
  .hero-slide-actions .btn + .btn { display: none; }

  /* Grids */
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .grid-6 { grid-template-columns: repeat(2, 1fr); }

  /* Section */
  .section { padding: var(--space-10) 0; }
  .section-header { flex-direction: column; align-items: flex-start; gap: var(--space-3); }

  /* Flash sale */
  .flash-sale-section { padding: var(--space-5); }
  .flash-sale-header { flex-direction: column; align-items: flex-start; }

  /* Footer */
  .footer-main {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }

  .footer-bottom { flex-direction: column; text-align: center; }
  .footer-bottom-links { flex-wrap: wrap; justify-content: center; }

  /* Cart */
  .cart-item { flex-direction: column; }
  .cart-item-img { width: 60px; height: 60px; }

  /* Product detail */
  .product-info-name { font-size: 22px; }
  .product-info-price { font-size: 28px; }
  .product-actions { flex-direction: column; }
  .product-actions .btn { width: 100%; }

  /* Account layout */
  .account-layout {
    grid-template-columns: 1fr !important;
  }

  /* Stats */
  .affiliate-stats-grid { grid-template-columns: 1fr 1fr; }

  /* Notification dropdown */
  .notification-dropdown { width: 320px; right: -80px; }

  /* User dropdown */
  .header-user-dropdown { right: -80px; }

  /* Toast */
  .toast-container { right: 10px; left: 10px; }
  .toast { min-width: unset; max-width: 100%; }

  /* Back to top */
  .back-to-top { bottom: var(--space-4); right: var(--space-4); }
}

/* ============================================================
   SMALL MOBILE (< 576px)
   ============================================================ */
@media (max-width: 575px) {
  :root {
    --top-header-height: 0px;
    --header-height: 56px;
  }

  .top-header { display: none; }

  .container, .container-fluid { padding: 0 var(--space-4); }

  .site-logo-text { display: none; }

  .hero-slide { min-height: 280px; }

  .grid-3 { grid-template-columns: 1fr 1fr; }

  .deposit-method-grid { grid-template-columns: repeat(2, 1fr); }

  .flash-sale-countdown { flex-wrap: wrap; }
  .countdown-value { min-width: 36px; height: 36px; font-size: 16px; }

  .product-detail-wrapper { gap: var(--space-4); }

  .section-title { font-size: 22px; }

  .stat-card { flex-direction: column; }
  .stat-card-icon { width: 44px; height: 44px; }
  .stat-card-value { font-size: 22px; }

  .affiliate-stats-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  .site-header, .site-navbar, .top-header,
  .site-footer, .back-to-top, .toast-container,
  .loading-overlay { display: none !important; }

  body { background: white; color: black; }
  .card { border: 1px solid #ddd; }
}

/* ============================================================
   ACCOUNT LAYOUT HELPER
   ============================================================ */
.account-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: var(--space-6);
  align-items: start;
}

/* ============================================================
   SWIPER RESPONSIVE OVERRIDES
   ============================================================ */
.product-swiper .swiper-button-next,
.product-swiper .swiper-button-prev {
  width: 40px !important;
  height: 40px !important;
  background: var(--bg-card) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: var(--radius-full) !important;
  color: var(--text-primary) !important;
  box-shadow: var(--shadow-md) !important;
  transition: var(--transition-base) !important;
}

.product-swiper .swiper-button-next::after,
.product-swiper .swiper-button-prev::after {
  font-size: 12px !important;
  font-weight: 900 !important;
}

.product-swiper .swiper-button-next:hover,
.product-swiper .swiper-button-prev:hover {
  background: var(--brand-primary) !important;
  border-color: var(--brand-primary) !important;
  color: white !important;
}

/* ============================================================
   CUSTOM SCROLLBAR FOR MODALS/DROPDOWNS
   ============================================================ */
.custom-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.custom-scroll::-webkit-scrollbar { width: 4px; }
.custom-scroll::-webkit-scrollbar-track { background: transparent; }
.custom-scroll::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
}

/* ============================================================
   AOS ANIMATION OVERRIDES
   ============================================================ */
[data-aos] { pointer-events: none; }
[data-aos].aos-animate { pointer-events: auto; }

/* ============================================================
   STICKY FILTER BAR ON PRODUCTS PAGE
   ============================================================ */
.products-filter-bar {
  position: sticky;
  top: calc(var(--total-header) + var(--space-3));
  z-index: var(--z-sticky);
  background: var(--bg-primary);
  padding: var(--space-3) 0;
  margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--border-color);
}

@media (max-width: 991px) {
  .products-filter-bar {
    top: calc(var(--top-header-height) + var(--header-height) + var(--space-3));
  }
}

/* ============================================================
   PRODUCT SORT/FILTER ROW
   ============================================================ */
.sort-filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.sort-options {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.sort-btn {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.sort-btn:hover { border-color: var(--brand-primary); color: var(--brand-primary); }
.sort-btn.active {
  background: var(--brand-primary);
  color: white;
  border-color: var(--brand-primary);
}

.view-toggle {
  display: flex;
  gap: 4px;
}

.view-btn {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: var(--bg-glass);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  cursor: pointer;
  transition: var(--transition-fast);
}

.view-btn.active { background: var(--brand-primary); color: white; border-color: var(--brand-primary); }
