/* frontend/assets/css/products.css */

body {
  font-family: 'Poppins', sans-serif;
  background: #f8fff8;
  margin: 0;
  padding: 0;
}

.products-section {
  padding: 3rem 1rem;
  text-align: center;
}

.products-section h1 {
  color: #2e7d32;
  margin-bottom: 1.4rem;
}

/* ============================
   SEARCH + FILTER TOOLBAR
   ============================ */
.products-toolbar {
  max-width: 960px;
  margin: 0 auto 1rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-box {
  flex: 1;
  position: relative;
}

#searchInput {
  width: 100%;
  padding: 0.6rem 2.2rem 0.6rem 0.9rem;
  border-radius: 999px;
  border: 1px solid #cbd5e1;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#searchInput:focus {
  border-color: #2e7d32;
  box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.15);
}

.search-clear {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  font-size: 1rem;
  cursor: pointer;
  color: #9ca3af;
}

/* Filter button */
.filter-btn {
  border: none;
  border-radius: 999px;
  background: #2e7d32;
  color: #ffffff;
  padding: 0.5rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.filter-btn:hover {
  background: #256528;
}

/* ============================
   FILTER PANEL
   ============================ */
.filter-panel {
  max-width: 960px;
  margin: 0 auto 1.4rem;
  padding: 0.75rem 1rem 0.9rem;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 10px 25px rgba(0,0,0,0.08);
  display: none;
  text-align: left;
}

.filter-panel.open {
  display: block;
}

.filter-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 0.7rem;
}

.filter-row label {
  font-size: 0.9rem;
  color: #374151;
  min-width: 110px;
}

.filter-row select,
.filter-row input[type="number"] {
  flex: 1;
  padding: 0.4rem 0.6rem;
  border-radius: 8px;
  border: 1px solid #d1d5db;
  font-size: 0.9rem;
  outline: none;
}

.filter-row select:focus,
.filter-row input[type="number"]:focus {
  border-color: #2e7d32;
}

/* range inputs */
.filter-range {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.filter-range input {
  flex: 1;
}

.range-sep {
  color: #6b7280;
}

/* checkbox row */
.filter-checkbox-row {
  justify-content: flex-start;
}

.filter-checkbox-row label {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* buttons */
.filter-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 0.2rem;
}

.filter-apply,
.filter-reset {
  border-radius: 999px;
  padding: 0.45rem 1rem;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
}

.filter-apply {
  background: #2e7d32;
  color: #ffffff;
}

.filter-apply:hover {
  background: #256528;
}

.filter-reset {
  background: #e5e7eb;
  color: #374151;
}

.filter-reset:hover {
  background: #d1d5db;
}

/* ============================
   PRODUCT GRID
   ============================ */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 25px;
  width: 92%;
  margin: auto;
}

.product-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.08);
  transition: 0.25s;
  cursor: pointer;
}

.product-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(0,0,0,0.15);
}

.product-link {
  text-decoration: none;
  color: inherit;
}

.product-image-wrap img {
  width: 100%;
  height: 200px;
  object-fit: cover;
  border-radius: 10px;
}

.product-info {
  text-align: left;
  padding-top: 10px;
}

.category-text {
  font-size: 0.8rem;
  color: #757575;
}

.product-info h3 {
  color: #2e7d32;
  font-size: 1.05rem;
  margin: 4px 0;
}

.rating-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0;
  font-size: 0.85rem;
}

.rating-badge {
  background: #2e7d32;
  color: white;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.rating-count {
  color: #555;
}

.no-rating {
  color: #999;
}

.price-row {
  margin-top: 6px;
}

.price {
  font-weight: 700;
  color: #1b5e20;
  font-size: 1.2rem;
}

/* FREE DELIVERY TEXT ONLY */
.delivery-row {
  margin-top: 8px;
}

.delivery-free {
  font-size: 0.8rem;
  font-weight: 600;
  color: #1b5e20;
}

/* Loading / empty state */
.loading {
  text-align: center;
  grid-column: 1 / -1;
  color: #4b5563;
  font-size: 0.95rem;
}

/* MOBILE */
@media (max-width: 640px) {
  .products-section {
    padding-top: 2.3rem;
  }

  .products-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .filter-row label {
    min-width: auto;
  }

  .filter-range {
    width: 100%;
  }

  .filter-actions {
    justify-content: flex-start;
  }

  .product-card {
    padding: 12px;
  }

  .product-image-wrap img {
    height: 180px;
  }
}