/*
    File: shop.css
    Purpose: Styles for shop page including filters, product grid, and pagination
    Contains: Sidebar filters, product layouts, toolbar, pagination
    FIX: Added `min-width: 0;` to the price range input fields. This prevents the "Max" price input from overflowing its container, a common flexbox layout issue.
*/

/* ========================================
   PAGE HEADER
   ======================================== */

.page-header {
  background: linear-gradient(135deg, #1a1a1a 0%, #333333 100%);
  padding: var(--spacing-xxl) 0;
  text-align: center;
  color: var(--light-bg);
}

.page-header-content h1 {
  font-family: var(--font-heading);
  font-size: 48px;
  font-weight: 900;
  margin-bottom: var(--spacing-sm);
  text-transform: uppercase;
}

.page-header-content p {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.8);
}

/* ========================================
   SHOP SECTION LAYOUT
   ======================================== */

.shop-section {
  padding: var(--spacing-xxl) 0;
  background-color: #f5f5f5;
}

.shop-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--spacing-md);
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--spacing-xl);
}

/* ========================================
   SIDEBAR FILTERS
   ======================================== */

.shop-sidebar {
  background-color: var(--light-bg);
  padding: var(--spacing-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  overflow-x: hidden;
  position: sticky;
  top: 100px;

  /* Custom scrollbar styling */
  scrollbar-width: thin;
  scrollbar-color: var(--primary-color) #f0f0f0;
}

/* Webkit scrollbar styling for Chrome, Safari, Edge */
.shop-sidebar::-webkit-scrollbar {
  width: 8px;
}

.shop-sidebar::-webkit-scrollbar-track {
  background: #f0f0f0;
  border-radius: 10px;
}

.shop-sidebar::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 10px;
}

.shop-sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--secondary-color);
}

.sidebar-header {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-md);
  border-bottom: 2px solid #e0e0e0;
}

.sidebar-header h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-dark);
}

.filters-content {
  flex: 1;
  overflow-y: auto;
}

.filters-footer {
  display: none;
  padding: var(--spacing-md);
  border-top: 1px solid #e0e0e0;
  text-align: right;
}

/* Desktop Clear Button */
.desktop-clear-btn {
  background: transparent;
  color: var(--primary-color);
  font-size: 14px;
  font-weight: 600;
  padding: var(--spacing-xs);
  border-radius: var(--radius-sm);
  transition: var(--transition-normal);
  border: none;
}

.desktop-clear-btn:hover {
  background-color: rgba(255, 107, 53, 0.1);
}

/* Mobile Clear Button (in footer) */
.filters-footer .clear-filters-btn {
  background: var(--primary-color);
  color: white;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  transition: var(--transition-normal);
  border: none;
}

.filters-footer .clear-filters-btn:hover {
  background-color: #ff5722;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
}

/* Close Filters Button (Mobile only) */
.close-filters-btn {
  display: none;
  background: transparent;
  color: var(--text-dark);
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: var(--transition-normal);
  cursor: pointer;
  position: absolute;
  right: 12px;
  top: 12px;
}

.close-filters-btn:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.close-filters-btn svg {
  display: block;
}

@media screen and (max-width: 1024px) {
  .shop-sidebar.mobile-active .close-filters-btn {
    display: block;
  }
}

/* Filter Groups */
.filter-group {
  margin-bottom: var(--spacing-lg);
}

.filter-group h4 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: var(--spacing-md);
  color: var(--text-dark);
}

.filter-options {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
}

.filter-checkbox {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: var(--spacing-xs);
  border-radius: var(--radius-sm);
  transition: var(--transition-normal);
}

.filter-checkbox:hover {
  background-color: #f5f5f5;
}

.filter-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin-right: var(--spacing-sm);
  cursor: pointer;
}

.filter-checkbox span {
  font-size: 14px;
  color: var(--text-dark);
}

/* Filter Dropdown - inherits from global styles in style.css */
.filter-dropdown {
  /* Global styles will be applied from style.css with !important */
  /* This ensures consistency across all dropdowns */
}

/* Price Range Filter */
.price-range-inputs {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-sm);
}

.price-range-inputs input {
  flex: 1;
  padding: var(--spacing-xs) var(--spacing-sm);
  border: 1px solid #e0e0e0;
  border-radius: var(--radius-sm);
  font-size: 14px;
  min-width: 0; /* FIX: Prevents input from overflowing its flex container */
}

.price-range-inputs span {
  color: var(--text-light);
}

.apply-price-btn {
  width: 100%;
  padding: var(--spacing-sm);
  background-color: var(--primary-color);
  color: var(--light-bg);
  font-weight: 600;
  font-size: 14px;
  border-radius: var(--radius-md);
  transition: var(--transition-normal);
}

.apply-price-btn:hover {
  background-color: var(--secondary-color);
}

/* ========================================
   SHOP MAIN CONTENT
   ======================================== */

.shop-main {
  background-color: transparent;
}

/* Shop Toolbar */
.shop-toolbar {
  background-color: var(--light-bg);
  padding: var(--spacing-md) var(--spacing-lg);
  border-radius: var(--radius-lg);
  margin-bottom: var(--spacing-lg);
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 85px;
  z-index: 90;
}

.results-count {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-dark);
}

.shop-controls {
  display: flex;
  align-items: stretch;
  gap: var(--spacing-md);
}

.shop-controls label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dark);
  white-space: nowrap;
  display: flex;
  align-items: center;
}

.shop-controls select {
  padding: var(--spacing-xs) var(--spacing-md);
  border: 1px solid #e0e0e0;
  border-radius: var(--radius-md);
  font-size: 14px;
  background-color: var(--light-bg);
  cursor: pointer;
}

.shop-controls .custom-select {
  min-width: 190px;
}

/* View Toggle */
.view-toggle {
  display: flex;
  gap: var(--spacing-xs);
}

.view-btn {
  padding: var(--spacing-xs) var(--spacing-md);
  background-color: #f5f5f5;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition-normal);
  display: flex;
  align-items: center;
}

.view-btn:hover {
  background-color: #e0e0e0;
}

.view-btn.active {
  background-color: var(--primary-color);
  color: var(--light-bg);
}

/* ========================================
   PRODUCTS GRID VIEW
   ======================================== */

.products-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--spacing-lg);
  min-height: 400px;
}

/* Hide description in grid view */
.products-grid .product-description {
  display: none;
}

.products-grid.list-view {
  grid-template-columns: 1fr;
}

/* List View Product Card */
.products-grid.list-view .product-card {
  display: flex;
  flex-direction: row;
  gap: var(--spacing-lg);
  align-items: center;
  padding: var(--spacing-lg);
  background: var(--light-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-normal);
  position: relative;
}

.products-grid.list-view .product-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.products-grid.list-view .product-link-wrapper {
  display: flex;
  flex-direction: row;
  gap: var(--spacing-lg);
  align-items: center;
  flex: 1;
  min-width: 0;
}

.products-grid.list-view .product-image {
  width: 180px;
  height: 180px;
  flex-shrink: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
}

.products-grid.list-view .product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.3s ease;
}

.products-grid.list-view .product-info {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: var(--spacing-xs);
  flex: 1;
  min-width: 0;
}

.products-grid.list-view .product-name {
  font-size: 20px;
  line-height: 1.5;
  font-weight: 700;
  margin-bottom: 0;
  color: var(--text-dark);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  max-height: 3em;
}

.products-grid.list-view .product-brand {
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 0;
}

.products-grid.list-view .product-price {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: 0;
}

.products-grid.list-view .current-price {
  font-size: 24px;
  font-weight: 500;
  color: var(--primary-color);
}

.products-grid.list-view .original-price {
  font-size: 16px;
  text-decoration: line-through;
  color: var(--text-light);
}

.products-grid.list-view .product-description {
  display: block !important; /* Override grid view hidden */
  font-size: 14px;
  color: var(--text-light);
  line-height: 1.5;
  margin: 0;
  margin-top: var(--spacing-xs);
}

.products-grid.list-view .add-to-cart-btn {
  width: auto;
  min-width: 160px;
  padding: var(--spacing-md) var(--spacing-lg);
  white-space: nowrap;
  flex-shrink: 0;
  align-self: center;
}

/* Badge container for horizontal layout */
.products-grid.list-view .product-badges {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--spacing-xs);
  max-width: 120px;
}

.products-grid.list-view .product-badge {
  display: inline-block;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  border-radius: var(--radius-sm);
  background: var(--primary-color);
  color: var(--light-bg);
  white-space: nowrap;
}

/* Loading Spinner */
.loading-spinner {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--spacing-xxl);
  color: var(--text-light);
}

.loading-spinner p {
  font-size: 18px;
}

/* No Results */
.no-results {
  grid-column: 1 / -1;
  text-align: center;
  padding: var(--spacing-xxl);
}

.no-results h3 {
  font-size: 24px;
  margin-bottom: var(--spacing-sm);
  color: var(--text-dark);
}

.no-results p {
  font-size: 16px;
  color: var(--text-light);
  margin-bottom: var(--spacing-lg);
}

.no-results button {
  padding: var(--spacing-sm) var(--spacing-xl);
  background-color: var(--primary-color);
  color: var(--light-bg);
  font-weight: 600;
  border-radius: var(--radius-md);
}

/* ========================================
   PAGINATION
   ======================================== */

.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--spacing-sm);
  margin-top: var(--spacing-xl);
  padding: var(--spacing-lg);
}

.pagination button {
  padding: var(--spacing-sm) var(--spacing-md);
  background-color: var(--light-bg);
  border: 1px solid #e0e0e0;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  transition: var(--transition-normal);
  min-width: 40px;
}

.pagination button:hover:not(:disabled) {
  background-color: var(--primary-color);
  color: var(--light-bg);
  border-color: var(--primary-color);
}

.pagination button.active {
  background-color: var(--primary-color);
  color: var(--light-bg);
  border-color: var(--primary-color);
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination .page-info {
  font-size: 14px;
  color: var(--text-light);
  margin: 0 var(--spacing-sm);
}

/* ========================================
   MOBILE SIDEBAR TOGGLE
   ======================================== */

.mobile-filters-toggle {
  display: none;
  width: 100%;
  padding: var(--spacing-md);
  background-color: var(--primary-color);
  color: var(--light-bg);
  font-weight: 700;
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-md);
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* iPad Specific Styles (769px to 1024px) */
@media screen and (min-width: 769px) and (max-width: 1024px) {
  .shop-section {
    overflow: clip;
  }

  .shop-container {
    max-width: 100%;
    padding: 0 var(--spacing-lg);
    box-sizing: border-box;
    grid-template-columns: 220px 1fr !important;
    gap: var(--spacing-md);
  }

  .shop-sidebar {
    display: block !important;
    position: sticky !important;
    top: 100px;
    padding: var(--spacing-md);
    height: fit-content;
    max-height: calc(100vh - 120px);
  }

  .mobile-filters-toggle {
    display: none !important;
  }

  .shop-toolbar {
    padding: var(--spacing-md);
  }

  .shop-controls {
    gap: var(--spacing-sm);
  }

  .products-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--spacing-lg);
  }

  .products-grid.list-view {
    grid-template-columns: 1fr !important;
  }

  .products-grid.list-view .product-card {
    padding: var(--spacing-md);
  }

  .products-grid.list-view .product-image {
    width: 150px;
    height: 150px;
  }

  .page-header-content h1 {
    font-size: 42px;
  }
}

@media screen and (max-width: 1024px) {
  .shop-container {
    grid-template-columns: 250px 1fr;
    gap: var(--spacing-lg);
  }

  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }
}

@media screen and (max-width: 768px) {
  .page-header-content h1 {
    font-size: 36px;
  }

  .shop-container {
    grid-template-columns: 1fr;
  }

  .shop-sidebar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 80%;
    max-width: 320px;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
  }

  .shop-sidebar.active {
    display: block;
  }

  .mobile-filters-toggle {
    display: block;
  }

  .shop-toolbar {
    flex-direction: column;
    gap: var(--spacing-sm);
    top: 60px;
  }

  .shop-controls {
    width: 100%;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: var(--spacing-xs);
  }

  .shop-controls label {
    display: none;
  }

  .mobile-filters-toggle {
    width: auto;
    flex-shrink: 0;
    margin-bottom: 0;
    display: flex;
    align-items: center;
  }

  .shop-controls .view-btn {
    display: flex;
    align-items: center;
  }

  .shop-controls .custom-select {
    flex: 1;
    min-width: 0;
  }

  .products-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--spacing-md);
  }
}

@media screen and (max-width: 480px) {
  .page-header-content h1 {
    font-size: 28px;
  }

  .pagination {
    gap: 4px;
  }

  .pagination button {
    padding: var(--spacing-xs) var(--spacing-sm);
    min-width: 35px;
    font-size: 12px;
  }
}

/* ========================================
   SIDEBAR OVERLAY (Mobile)
   ======================================== */

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 999;
}

.sidebar-overlay.active {
  display: block;
}
