/* ============================================================
   Responsive Styles
   Breakpoints:
     - < 576px     Extra small (mobile portrait)
     - 576 ~ 767   Mobile landscape
     - 768 ~ 991   Tablet
     - 992 ~ 1199  Small desktop
     - >= 1200     Desktop
   ============================================================ */

/* ==================== Medium: tablet ==================== */
@media (max-width: 1199px) {
  :root {
    --container-padding: var(--space-5);
  }

  .header-top-left,
  .header-top-right {
    gap: var(--space-4);
  }

  .search-form {
    width: 220px;
  }

  .categories-grid,
  .products-grid,
  .hot-grid,
  .advantages-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-5);
  }

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

  .about-grid {
    grid-template-columns: 1fr;
    gap: var(--space-10);
  }

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

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

  .article-card {
    grid-template-columns: 220px 1fr;
  }

  .article-detail {
    padding: var(--space-8) var(--space-6);
  }

  .banner-slider {
    height: 560px;
  }

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

  .product-detail-layout,
  .archive-layout,
  .article-detail-layout {
    grid-template-columns: 1fr 280px;
  }

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

  .error-code {
    font-size: 120px;
  }
}

/* ==================== Tablet portrait / large phone ==================== */
@media (max-width: 991px) {
  .header-top {
    display: none;
  }

  .header-main {
    height: 64px;
  }

  --header-middle-height: 64px;

  .menu-toggle {
    display: inline-flex;
  }

  .search-form {
    width: 180px;
  }

    /* Mobile nav drawer */
  .main-nav {
    position: fixed;
    top: 0;
    right: -100%;
    width: 300px;
    max-width: 80vw;
    height: 100vh;
    background: var(--color-surface);
    box-shadow: -8px 0 32px rgba(10, 26, 47, 0.15);
    padding: var(--space-12) var(--space-4) var(--space-6);
    overflow-y: auto;
    transition: right var(--transition-base);
    z-index: var(--z-modal);
  }

  .main-nav.is-open {
    right: 0;
  }

  .nav-list {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
  }

  .nav-link {
    height: auto;
    padding: var(--space-3) var(--space-4);
    font-size: var(--fs-15);
    border-bottom: 1px solid var(--color-border);
  }

  .nav-link::after { display: none; }

  .nav-item.is-active > .nav-link,
  .nav-link:hover {
    background: rgba(11, 95, 255, 0.06);
  }

  .sub-menu {
    position: static;
    opacity: 1;
    visibility: visible;
    transform: none;
    box-shadow: none;
    border: none;
    border-radius: 0;
    padding: 0 0 0 var(--space-4);
    background: var(--color-bg-2);
  }

    /* Mobile backdrop overlay — must sit BELOW the .site-header stacking context
       (header has z-index:var(--z-fixed)=500 and contains .main-nav as a child,
       so the drawer's z-index is capped by its parent). Putting the overlay
       below the header guarantees the drawer sits visually on top of it. */
  .nav-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: calc(var(--z-fixed) - 1);   /* 499 < header(500) */
  }

  .nav-overlay.is-open {
    display: block;
  }

  .archive-layout,
  .product-detail-layout,
  .article-detail-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 2;
  }

  .archive-main {
    order: 1;
  }

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

  .banner-slider {
    height: 480px;
  }

  .banner-control {
    width: 44px;
    height: 44px;
    margin-top: -22px;
  }

  .banner-control-prev { left: 16px; }
  .banner-control-next { right: 16px; }

  .product-list-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
  }

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

  .article-card {
    grid-template-columns: 1fr;
  }

  .article-card-body {
    padding: var(--space-5);
  }
}

/* ==================== Mobile landscape ==================== */
@media (max-width: 767px) {
  .section,
  .categories,
  .featured,
  .hot,
  .advantages,
  .news,
  .about {
    padding-block: var(--space-12);
  }

  .categories-grid,
  .products-grid,
  .hot-grid,
  .advantages-grid {
    gap: var(--space-4);
  }

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

  .product-list-grid,
  .product-related-grid {
    grid-template-columns: 1fr;
  }

  .product-hero,
  .product-spec,
  .product-related,
  .inquiry-form-body,
  .article-detail {
    padding: var(--space-5);
  }

  .product-spec {
    padding: var(--space-6) var(--space-4);
  }

  .inquiry-form-header,
  .inquiry-form-body {
    padding: var(--space-5);
  }

  .form-grid-2 {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .archive-toolbar {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }

  .archive-sort {
    justify-content: space-between;
  }

  .pagination a,
  .pagination span {
    min-width: 38px;
    height: 38px;
  }

  .banner-slider {
    height: 380px;
  }

  .footer-bottom-inner {
    flex-direction: column;
    text-align: center;
  }

  .whatsapp-float {
    bottom: 80px;
    right: 16px;
  }

  .back-to-top {
    right: 16px;
    bottom: 24px;
    width: 40px;
    height: 40px;
  }
}

/* ==================== Extra small screen ==================== */
@media (max-width: 575px) {
  :root {
    --container-padding: var(--space-4);
  }

  .header-main {
    padding: 0;
  }

  .header-search {
    display: none;
  }

  .site-logo img,
  .site-logo svg {
    height: 36px;
  }

  .site-logo-text strong {
    font-size: var(--fs-16);
  }

  .site-logo-text span {
    font-size: 10px;
  }

  .section-title-text {
    font-size: var(--fs-24);
  }

  .category-card {
    height: 220px;
  }

  .category-name {
    font-size: var(--fs-20);
  }

  .about-stats {
    grid-template-columns: 1fr;
    gap: var(--space-3);
  }

  .advantage-card {
    padding: var(--space-6) var(--space-4);
  }

  .advantage-title {
    font-size: var(--fs-16);
  }

  .banner-slider {
    height: 320px;
  }

  .banner-control {
    display: none;
  }

  .product-detail-title {
    font-size: var(--fs-20);
  }

  .article-detail-title {
    font-size: var(--fs-24);
  }

  .error-code {
    font-size: 88px;
  }

  .error-title {
    font-size: var(--fs-20);
  }
}

/* ==================== Large screen ==================== */
@media (min-width: 1600px) {
  :root {
    --container-max: 1440px;
  }

  .banner-slider {
    height: 700px;
  }
}
