/**
 * PRODUCT GRID STYLES
 * Toledo Indoor Garden - Green: #008b44, Gold: #F7C951
 */

/* Loading & Error States */
.product-grid-loading,
.product-grid-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  gap: 1rem;
}

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #008b44;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Controls */
.product-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: center;
  padding: 1rem 0;
  border-bottom: 2px solid #f0f0f0;
  margin-bottom: 2rem;
}

.search-box {
  flex: 1;
  min-width: 280px;
  display: flex;
  gap: 0.5rem;
}

.search-box input {
  flex: 1;
  padding: 0.75rem 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 0.5rem;
  font-size: 1rem;
  transition: border-color 0.3s ease;
}

.search-box input:focus {
  outline: none;
  border-color: #008b44;
}

.search-btn {
  padding: 0.75rem 1.5rem;
  background: #008b44;
  color: white;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 1.2rem;
  transition: background 0.3s ease;
}

.search-btn:hover {
  background: #3a8043;
}

.sort-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.sort-control label {
  font-weight: 600;
  color: #333;
}

.sort-control select {
  padding: 0.75rem 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 0.5rem;
  font-size: 1rem;
  cursor: pointer;
  background: white;
}

.filter-toggle {
  display: none;
  padding: 0.75rem 1.5rem;
  background: #008b44;
  color: white;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 1rem;
}

/* Main Layout */
.product-grid-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.product-grid-main {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 2rem;
}

/* Sidebar Filters */
.product-filters {
  background: white;
  border: 2px solid #f0f0f0;
  border-radius: 0.75rem;
  padding: 1.5rem;
  height: fit-content;
  position: sticky;
  top: 100px;
}

.filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #f0f0f0;
}

.filter-header h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #333;
  margin: 0;
}

.clear-filters {
  background: none;
  border: none;
  color: #008b44;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: underline;
}

.clear-filters:hover {
  color: #3a8043;
}

.filter-section {
  margin-bottom: 2rem;
}

.filter-section h4 {
  font-size: 1rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 1rem;
}

.filter-checkbox {
  display: block;
  margin-bottom: 0.75rem;
  cursor: pointer;
  font-size: 0.9375rem;
  color: #555;
}

.filter-checkbox input {
  margin-right: 0.5rem;
  cursor: pointer;
}

.filter-list {
  max-height: 250px;
  overflow-y: auto;
}

.price-range {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.price-range input[type="range"] {
  width: 100%;
  cursor: pointer;
}

.price-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #008b44;
}

/* Results Header */
.results-header {
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: #f9f9f9;
  border-radius: 0.5rem;
}

.results-header p {
  margin: 0;
  font-size: 0.9375rem;
  color: #666;
}

/* Product Grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
}

.product-card {
  background: white;
  border: 2px solid #f0f0f0;
  border-radius: 0.75rem;
  overflow: hidden;
  transition: all 0.3s ease;
  cursor: pointer;
}

.product-card:hover {
  border-color: #008b44;
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.1);
}

.product-image {
  position: relative;
  height: 220px;
  overflow: hidden;
  background: #fff;
  aspect-ratio: 1;
  contain: layout style paint;
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  padding: 10px;
  background: #fff;
  transition: transform 0.3s ease;
}

/* Override inline width/height attributes from JS */
.product-image img[width],
.product-image img[height] {
  width: 100% !important;
  height: 100% !important;
}

.product-card:hover .product-image img {
  transform: scale(1.05);
}

/* No-image state for product grid cards */
.product-image.no-product-image {
  background: #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.product-image img[src=""] {
  display: none;
}

.featured-badge {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  background: #F7C951;
  color: #333;
  padding: 0.25rem 0.75rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  z-index: 1;
}

.stock-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.25rem 0.75rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 700;
  z-index: 1;
}

.stock-badge.in-stock {
  background: #008b44;
  color: white;
}

.stock-badge.low-stock {
  background: #F7C951;
  color: #333;
}

.stock-badge.out-of-stock {
  background: #e53e3e;
  color: white;
}

.product-info {
  padding: 1rem;
}

.product-brand {
  font-size: 0.875rem;
  color: #008b44;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.product-name {
  font-size: 1rem;
  font-weight: 600;
  color: #333;
  margin: 0 0 0.75rem 0;
  line-height: 1.3;
  min-height: 2.6em;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  text-overflow: ellipsis;
}

.product-price {
  font-size: 1.25rem;
  font-weight: 700;
  color: #333;
  margin-bottom: 0.5rem;
}

.product-sku {
  font-size: 0.75rem;
  color: #999;
  margin-bottom: 0.5rem;
}
.stock-badge-grid {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.5rem;
  border-radius: 0.25rem;
  display: inline-block;
  margin-bottom: 0.5rem;
}
.stock-badge-grid.in-stock {
  background: #e8f5e9;
  color: #2e7d32;
}
.stock-badge-grid.low-stock {
  background: #fff3e0;
  color: #e65100;
}
.stock-badge-grid.out-of-stock {
  background: #fce4ec;
  color: #c62828;
}

.btn-view-details {
  display: block;
  width: 100%;
  padding: 0.75rem;
  background: #008b44;
  color: white;
  text-align: center;
  text-decoration: none;
  border-radius: 0.5rem;
  font-weight: 600;
  transition: background 0.3s ease;
}

.btn-view-details:hover {
  background: #3a8043;
}

/* No Products */
.no-products {
  text-align: center;
  padding: 4rem 2rem;
}

.no-products p {
  font-size: 1.125rem;
  color: #666;
  margin-bottom: 1.5rem;
}

.btn-primary {
  padding: 0.75rem 2rem;
  background: #008b44;
  color: white;
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: background 0.3s ease;
}

.btn-primary:hover {
  background: #3a8043;
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.page-btn {
  padding: 0.5rem 1rem;
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 600;
  color: #333;
  transition: all 0.3s ease;
  min-width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.page-btn.page-num {
  padding: 0;
  width: 44px;
}

.page-btn:hover:not(:disabled) {
  background: #008b44;
  color: white;
  border-color: #008b44;
}

.page-btn.active {
  background: #008b44;
  color: white;
  border-color: #008b44;
}

.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-ellipsis {
  padding: 0.75rem 0.5rem;
  color: #999;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }
}

@media (max-width: 768px) {
  .filter-toggle {
    display: block;
  }
  
  .product-grid-main {
    grid-template-columns: 1fr;
  }
  
  .product-filters {
    position: fixed;
    top: 0;
    left: -100%;
    width: 85%;
    max-width: 320px;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: left 0.3s ease;
  }
  
  .product-filters.active {
    left: 0;
  }
  
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
  }
  
  .product-name {
    font-size: 0.9375rem;
    min-height: 2.8em;
  }
  
  .product-price {
    font-size: 1.125rem;
  }
}

@media (max-width: 375px) {
  .product-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
  
  .search-box {
    min-width: 100%;
  }
}

@media (max-width: 320px) {
  .product-grid {
    grid-template-columns: 1fr;
  }
}

/* Card link (wraps entire card content) */
.product-card-link {
  text-decoration: none;
  color: inherit;
  display: block;
}

/* Variant badge */
.variant-badge {
  position: absolute;
  bottom: 0.5rem;
  left: 0.5rem;
  background: rgba(71, 158, 82, 0.9);
  color: white;
  padding: 0.2rem 0.6rem;
  border-radius: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  z-index: 1;
}

/* Brand pills filter bar */
.brand-pills {
  display: flex;
  gap: 0.5rem;
  padding: 1rem 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.brand-pill {
  flex-shrink: 0;
  padding: 0.5rem 1rem;
  background: white;
  border: 2px solid #e0e0e0;
  border-radius: 2rem;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: #555;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.brand-pill:hover {
  border-color: #008b44;
  color: #008b44;
}

.brand-pill.active {
  background: #008b44;
  border-color: #008b44;
  color: white;
}

/* Sort + Page Size controls row */
.sort-pagesize-controls {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-shrink: 0;
}

.pagesize-control {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pagesize-control label {
  font-weight: 600;
  color: #333;
  white-space: nowrap;
}

.pagesize-control select {
  padding: 0.75rem 1rem;
  border: 2px solid #e0e0e0;
  border-radius: 0.5rem;
  font-size: 1rem;
  cursor: pointer;
  background: white;
}

@media (max-width: 768px) {
  .sort-pagesize-controls {
    width: 100%;
    flex-wrap: wrap;
  }
  .sort-control,
  .pagesize-control {
    flex: 1;
    min-width: 0;
  }
  .sort-control select,
  .pagesize-control select {
    width: 100%;
    min-width: 0;
  }
  .spg-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

/* Search autocomplete thumbnails — uniform sizing */
.ss-thumb {
  width: 44px;
  height: 44px;
  object-fit: contain !important;
  object-position: center;
  background: #fff;
  border-radius: 8px;
  flex-shrink: 0;
  padding: 2px;
}

/* Static grid wrapper */
.static-grid-wrapper {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1rem;
}
