/**
 * Responsive Styles and Viewport Overrides
 *
 * @package Affrosonic
 */

.as-mobile-header {
  display: none;
}

.as-nav-drawer-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 18px 0;
  border: 0;
  background: transparent;
  color: var(--as-blue-500);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

body.as-overlay-open {
  overflow: hidden;
}

.as-mobile-nav button.as-mobile-nav__item {
  border: 0;
  background: transparent;
  font-family: inherit;
}

.as-mobile-search-overlay__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--as-border-light);
}

.as-mobile-search-container {
  width: 100%;
  margin-top: 18px;
}

.as-mobile-search-container form,
.as-mobile-search-container input {
  width: 100%;
}

/* ==========================================
   STIKY AND MOBILE NAVIGATION BARS
   ========================================== */
.as-mobile-buybar {
  display: none; /* Desktop default */
}

/* Sticky Bottom Mobile Bar */
.as-mobile-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 56px;
  background: var(--as-white);
  border-top: 1px solid var(--as-border-light);
  box-shadow: 0 -4px 14px rgba(15, 23, 42, 0.05);
  display: none;
  grid-template-columns: repeat(5, 1fr);
  z-index: 900;
}

.as-mobile-nav__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--as-gray-500);
  font-size: 11px;
  font-weight: 500;
  text-decoration: none;
}

.as-mobile-nav__item svg {
  width: 20px;
  height: 20px;
  margin-bottom: 2px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
}

.as-mobile-nav__item.is-active,
.as-mobile-nav__item:hover {
  color: var(--as-blue-600);
}

/* Mobile Sidebar Drawer Overlay */
.as-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 20, 38, 0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease;
}

.as-drawer-overlay.is-active {
  opacity: 1;
  pointer-events: auto;
}

/* Off-canvas Drawer Sliding Panel */
.as-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: -320px; /* Starts hidden */
  width: 300px;
  background: var(--as-white);
  box-shadow: var(--as-shadow-lg);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  transition: transform 250ms cubic-bezier(0.16, 1, 0.3, 1);
}

.as-drawer.is-active {
  transform: translateX(320px);
}

.as-drawer__header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--as-border-light);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.as-drawer__title {
  margin: 0;
  font-size: var(--fs-md);
  font-weight: 700;
}

.as-drawer__body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* Mobile Search Overlay */
.as-mobile-search-overlay {
  position: fixed;
  inset: 0;
  background: var(--as-white);
  z-index: 9999;
  padding: 20px;
  display: none;
  flex-direction: column;
}

.as-mobile-search-overlay.is-active {
  display: flex;
}

/* ==========================================
   BREAKPOINTS
   ========================================== */

/* 1. Large Desktops */
@media (min-width: 1440px) {
  /* Expand layout limits */
}

/* 2. Laptops and Standard Desktops */
@media (max-width: 1399px) {
  .as-grid-4,
  .as-product-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* 3. Mini Laptop Viewport */
@media (max-width: 1199px) {
  .as-header-main > .as-container {
    grid-template-columns: 190px minmax(260px, 1fr) auto !important;
    gap: 20px !important;
  }

  .as-grid-4,
  .as-product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
  }
  .as-grid-5 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* 4. Tablet Viewport */
@media (max-width: 1023px) {
  .as-404-grid-layout {
    grid-template-columns: 1fr !important;
    gap: 40px !important;
  }

  .as-404-trending-panel {
    order: 2;
  }

  .woocommerce-cart-form {
    grid-template-columns: 1fr !important;
  }

  .as-cart-item-row {
    position: relative;
    grid-template-columns: 80px 1fr !important;
    gap: 16px !important;
  }

  .as-cart-item-right {
    grid-column: 1 / -1;
    justify-content: space-between !important;
    margin-top: 6px;
    padding: 10px;
    border-radius: var(--as-radius-xs);
    background: var(--as-gray-50);
  }
  .as-header-announcement-strip,
  .as-header-nav-bar {
    display: none !important;
  }

  .as-header-main > .as-container {
    grid-template-columns: 170px minmax(240px, 1fr) auto !important;
  }

  .as-header-actions {
    gap: 8px !important;
  }

  .as-grid-4,
  .as-product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
  .as-grid-5 {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* 5. Mobile & Large Mobile (Standard Mobile sizes) */
@media (max-width: 767px) {
  :root {
    --fs-3xl: 32px;
    --fs-4xl: 40px;
  }
  .as-site-header {
    position: sticky;
    top: 0;
    z-index: 900;
  }

  .as-header-main {
    display: none !important;
  }

  .as-mobile-header {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 64px;
    padding: 10px 16px;
    background: var(--as-white);
    border-bottom: 1px solid var(--as-border-light);
  }

  .as-mobile-header__logo {
    min-width: 0;
    color: var(--as-navy-950);
    font-size: 16px;
    font-weight: 800;
    text-decoration: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .as-mobile-header__logo img {
    display: block;
    width: auto;
    max-width: 150px;
    height: 40px;
    object-fit: contain;
  }

  .as-mobile-header__actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .as-mobile-cart-link {
    position: relative;
  }

  .as-mobile-cart-link > span {
    position: absolute;
    top: -5px;
    right: -5px;
    display: grid;
    place-items: center;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--as-danger);
    color: var(--as-white);
    font-size: 10px;
    font-weight: 700;
  }

  .as-mobile-search-overlay {
    overflow-y: auto;
  }

  .as-mobile-search-overlay .as-search-results-dropdown {
    position: static;
    max-height: none;
    margin-top: 10px;
    box-shadow: none;
  }

  .woocommerce-orders-table,
  .woocommerce-orders-table tbody,
  .woocommerce-orders-table tr,
  .woocommerce-orders-table td {
    display: block;
    width: 100%;
  }

  .woocommerce-orders-table thead {
    display: none;
  }

  .woocommerce-orders-table tr {
    padding: 14px 10px;
    border-bottom: 2px solid var(--as-border-medium) !important;
  }

  .woocommerce-orders-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 10px !important;
  }

  .woocommerce-orders-table td::before {
    content: attr(data-title);
    color: var(--as-navy-950);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
  }

  /* Toggle Layout Containers */
  .as-grid-4,
  .as-product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .as-grid-5 {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Show Bottom Mobile Navigation and reserve bottom spacing */
  body {
    padding-bottom: 56px;
  }
  
  .as-mobile-nav {
    display: grid;
  }

  /* Stack columns globally */
  .as-flex-stack {
    flex-direction: column !important;
  }

  /* Sticky buybar for product single page */
  .as-mobile-buybar {
    display: grid;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 56px; /* Sits above mobile nav */
    z-index: 890;
    background: var(--as-white);
    border-top: 1px solid var(--as-border-light);
    padding: 10px 14px;
    grid-template-columns: 1fr auto auto;
    gap: 10px;
    align-items: center;
    box-shadow: 0 -10px 24px rgba(15, 23, 42, 0.08);
  }

  .as-mobile-buybar__price {
    font-size: 16px;
    font-weight: 800;
    color: var(--as-navy-950);
  }
}

/* 6. Mini Mobiles (320px–374px) */
@media (max-width: 374px) {
  .as-grid-4,
  .as-product-grid {
    grid-template-columns: 1fr;
    gap: var(--space-4);
  }
  .as-grid-5 {
    grid-template-columns: 1fr;
  }
  
  /* Buttons expand full width */
  .as-btn {
    width: 100%;
  }

  /* Reduce heading titles to avoid overflowing */
  h1 {
    font-size: var(--fs-xl) !important;
  }
}
