/* ===== Products Page: Sidebar + Grid Layout ===== */

#productsGrid .noon-product-media-wrap {
  position: relative;
  width: 100%;
}
#productsGrid .noon-product-media {
  width: 100%;
  border: 0;
  padding: 0;
  display: block;
  position: relative;
  overflow: hidden;
  background: #f8fafc;
}
#productsGrid .noon-product-media img {
  display: block;
  width: 100%;
  height: auto;
  max-height: none;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: #f1f5f9;
}
#productsGrid .noon-product-card {
  content-visibility: auto;
  contain-intrinsic-size: 180px 380px;
}

@media (min-width: 768px) {
  #productsGrid .noon-product-card {
    max-width: none !important;
    width: 100%;
  }
}

.products-cats-mobile {
  display: none;
}

.products-layout {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.products-sidebar {
  flex: 0 0 140px;
  position: sticky;
  top: 8px;
  max-height: calc(100vh - 80px);
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--noon-border);
  border-radius: 12px;
  padding: 12px 0;
}

.sidebar-title {
  font-size: 0.85rem;
  font-weight: 900;
  padding: 0 12px 10px;
  margin: 0 0 6px;
  border-bottom: 1px solid var(--noon-border);
  color: var(--noon-text);
}

.sidebar-cats {
  display: flex;
  flex-direction: column;
}

.sidebar-cat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: right;
  padding: 9px 12px;
  border: none;
  background: none;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--noon-text);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-right-color 0.15s;
  border-right: 3px solid transparent;
  line-height: 1.3;
  font-family: inherit;
}

.sidebar-cat-btn .material-icons-outlined {
  font-size: 17px;
  color: var(--noon-muted);
  flex-shrink: 0;
  transition: color 0.15s;
}

.sidebar-cat-btn:hover {
  background: #f0f4fe;
  color: var(--noon-blue);
}

.sidebar-cat-btn:hover .material-icons-outlined {
  color: var(--noon-blue);
}

.sidebar-cat-btn.active {
  background: #fff8e1;
  color: #b45309;
  border-right-color: var(--noon-yellow);
  font-weight: 800;
}

.sidebar-cat-btn.active .material-icons-outlined {
  color: #d97706;
}


.products-main {
  flex: 1;
  min-width: 0;
}

/* ===== Pagination ===== */
.noon-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 24px 0 8px;
  flex-wrap: wrap;
}

.noon-pagination .page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--noon-border);
  border-radius: 6px;
  background: #fff;
  color: var(--noon-text);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.noon-pagination .page-btn:hover:not(:disabled):not(.active) {
  background: #f5f5f5;
  border-color: #ccc;
}

.noon-pagination .page-btn.active {
  background: var(--noon-yellow);
  border-color: #ffd500;
  color: #1a1a1a;
}

.noon-pagination .page-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.noon-pagination .page-ellipsis {
  display: inline-flex;
  align-items: center;
  padding: 0 4px;
  font-size: 0.85rem;
  color: #999;
  letter-spacing: 2px;
}


/* --- Tablet (768-1199px) --- */
@media (min-width: 768px) {
  .products-layout {
    gap: 24px;
  }

  .products-sidebar {
    flex: 0 0 200px;
    top: 16px;
    max-height: calc(100vh - 100px);
    padding: 16px 0;
  }

  .sidebar-title {
    font-size: 0.95rem;
    padding: 0 16px 12px;
    margin: 0 0 8px;
  }

  .sidebar-cat-btn {
    padding: 10px 14px;
    font-size: 0.82rem;
    gap: 10px;
  }

  .sidebar-cat-btn .material-icons-outlined {
    font-size: 18px;
  }

  .products-main .noon-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 16px !important;
  }
}

@media (min-width: 992px) {
  .products-main .noon-grid {
    grid-template-columns: repeat(5, 1fr) !important;
  }
}

/* --- Desktop (≥1200px) --- */
@media (min-width: 1200px) {
  .products-layout {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 24px;
    gap: 32px;
  }

  .products-sidebar {
    flex: 0 0 220px;
    top: 24px;
    max-height: calc(100vh - 120px);
  }

  .sidebar-cat-btn {
    padding: 11px 16px;
    font-size: 0.85rem;
  }

  .sidebar-cat-btn .material-icons-outlined {
    font-size: 19px;
  }

  .products-main .noon-grid {
    display: grid !important;
    grid-template-columns: repeat(6, 1fr) !important;
    gap: 16px !important;
  }
}

/* ===== Mobile chips (filter-btn) with icons ===== */
.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 6px;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x proximity;
}

.chip-row::-webkit-scrollbar { display: none; }

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--noon-border);
  background: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--noon-text);
  cursor: pointer;
  white-space: nowrap;
  font-family: inherit;
  scroll-snap-align: start;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}

.filter-btn .material-icons-outlined {
  font-size: 16px;
  color: var(--noon-muted);
  transition: color 0.15s;
}

.filter-btn:hover {
  background: #f0f4fe;
  border-color: var(--noon-blue);
  color: var(--noon-blue);
}

.filter-btn:hover .material-icons-outlined {
  color: var(--noon-blue);
}

.filter-btn.active {
  background: var(--noon-blue);
  border-color: var(--noon-blue);
  color: #fff;
  box-shadow: 0 4px 12px rgba(31,111,235,0.25);
}

.filter-btn.active .material-icons-outlined {
  color: #fff;
}

/* Show sidebar on mobile on the right side, hide chips */
@media (max-width: 767px) {
  .products-cats-mobile {
    display: none;
  }
  
  .products-layout {
    gap: 6px;
  }
  
  .products-sidebar {
    display: block;
    flex: 0 0 170px; /* Set to 90px (approx 25% of viewport) to give category boxes more room */
    position: sticky;
    top: 60px; /* Adjust based on mobile header height */
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    background: #fff;
    border: 1px solid var(--noon-border);
    border-radius: 8px;
    padding: 6px 0;
    margin: 0;
  }

  .sidebar-title {
    display: none; /* Hide 'الأقسام' header on mobile to save space */
  }

  .sidebar-cats {
    display: flex;
    flex-direction: column;
    gap: 2px;
  }

  .sidebar-cat-btn {
    flex-direction: column; /* Icon on top, text on bottom */
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 4px;
    padding: 8px 4px;
    font-size: 0.64rem;
    border-right: none;
    border-bottom: 2px solid transparent;
    line-height: 1.2;
    white-space: normal; /* Allow text wrapping for long category names */
    word-break: break-word;
  }

  .sidebar-cat-btn .material-icons-outlined {
    font-size: 20px;
    margin: 0;
  }

  .sidebar-cat-btn.active {
    background: #fff8e1;
    color: #b45309;
    border-bottom-color: var(--noon-yellow);
    font-weight: 700;
  }

  .products-main {
    padding: 0 4px;
  }

  /* Make product cards fit in two columns next to sidebar on mobile */
  .products-main .noon-grid {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }
}

@media (min-width: 768px) {
  .products-cats-mobile {
    display: none;
  }
}

