/* ============================================
   AgroLink Africa — Marketplace Page Styles
   ============================================ */

.marketplace-hero {
  background: linear-gradient(135deg, var(--primary-900) 0%, var(--primary-700) 100%);
  padding: var(--sp-12) 0;
  color: white;
  position: relative;
  overflow: hidden;
}

.marketplace-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: url('https://images.unsplash.com/photo-1625246333195-78d9c38ad449?w=1920&h=600&fit=crop&q=80');
  background-size: cover;
  background-position: center;
  opacity: 0.12;
}

.marketplace-hero > * {
  position: relative;
  z-index: 1;
}

.marketplace-hero h1 {
  color: white;
  font-size: var(--text-4xl);
  margin-bottom: var(--sp-2);
}

.marketplace-hero p {
  color: var(--primary-200);
  font-size: var(--text-lg);
  margin-bottom: var(--sp-6);
}

.marketplace-search {
  max-width: 700px;
  margin: 0 auto;
}

.marketplace-search .search-bar {
  border-color: transparent;
  box-shadow: var(--shadow-xl);
}

.marketplace-search .search-bar:focus-within {
  border-color: transparent;
  box-shadow: var(--shadow-xl), 0 0 0 3px rgba(76,175,80,0.2);
}

.marketplace-search .search-bar input {
  font-size: var(--text-base);
  padding: var(--sp-3);
}

/* Filter bar */
.marketplace-filters {
  background: white;
  border-bottom: 1px solid var(--border-light);
  padding: var(--sp-4) 0;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.filter-bar__count {
  font-size: var(--text-sm);
  color: var(--text-sec);
  margin-right: auto;
}

.filter-bar__count strong {
  color: var(--text);
  font-weight: 700;
}

.filter-select {
  padding: var(--sp-2) var(--sp-8) var(--sp-2) var(--sp-3);
  font-size: var(--text-sm);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  background: white;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23757575' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.filter-select:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(76,175,80,0.1);
}

.active-filters {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
  padding: var(--sp-3) 0;
}

/* Main content area */
.marketplace-content {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: var(--sp-10);
  padding: var(--sp-8) 0;
}

/* Sidebar filters */
.filter-sidebar {
  position: sticky;
  top: 80px;
  align-self: start;
  max-height: calc(100vh - 100px);
  overflow-y: auto;
}

.filter-sidebar__section {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  padding: var(--sp-6);
  margin-bottom: var(--sp-4);
}

.filter-sidebar__title {
  font-family: var(--font-heading);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text);
  margin-bottom: var(--sp-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.filter-sidebar__clear {
  font-size: var(--text-xs);
  color: var(--primary-500);
  cursor: pointer;
  font-weight: 500;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) 0;
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--text-sec);
}

.filter-option:hover {
  color: var(--text);
}

.filter-checkbox {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.filter-option:hover .filter-checkbox {
  border-color: var(--primary-500);
}

.filter-option.selected .filter-checkbox {
  background: var(--primary-700);
  border-color: var(--primary-700);
}

.filter-option.selected .filter-checkbox::after {
  content: '';
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  margin-top: -2px;
}

.filter-option.selected {
  color: var(--text);
  font-weight: 500;
}

.filter-count {
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--text-light);
}

/* Price range slider (static) */
.price-range {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.price-input {
  flex: 1;
  padding: var(--sp-2) var(--sp-3);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  text-align: center;
}

.price-range__sep {
  color: var(--text-light);
  font-size: var(--text-sm);
}

/* Product grid */
.product-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-8);
}

/* Product card image with real photos */
.product-card__image {
  height: 240px;
  overflow: hidden;
  position: relative;
}

.product-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.product-card:hover .product-card__image img {
  transform: scale(1.06);
}

.product-card__image-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 50%, rgba(0,0,0,0.4) 100%);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.product-card:hover .product-card__image-overlay {
  opacity: 1;
}

.product-card__view-btn {
  position: absolute;
  bottom: var(--sp-4);
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: white;
  color: var(--primary-700);
  padding: var(--sp-2) var(--sp-5);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all var(--transition-base);
  white-space: nowrap;
}

.product-card:hover .product-card__view-btn {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Enhanced product card body */
.product-card__body {
  padding: var(--sp-5);
}

.product-card__crop {
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--primary-500);
  margin-bottom: var(--sp-2);
}

.product-card__title {
  font-size: var(--text-base);
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: var(--sp-3);
}

.product-card__farmer {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--text-sm);
  color: var(--text-sec);
  margin-bottom: var(--sp-3);
}

.product-card__meta {
  display: flex;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
  font-size: var(--text-xs);
  color: var(--text-light);
}

.product-card__meta-item {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.product-card__meta-item svg {
  width: 14px;
  height: 14px;
}

.product-card__price {
  display: flex;
  align-items: baseline;
  gap: var(--sp-1);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border-light);
}

.product-card__price-value {
  font-family: var(--font-heading);
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--primary-700);
}

.product-card__price-unit {
  font-size: var(--text-sm);
  color: var(--text-sec);
}

/* Sort / View controls */
.grid-controls {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.grid-controls__view {
  display: flex;
  gap: var(--sp-1);
}

.grid-controls__btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  color: var(--text-light);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.grid-controls__btn.active,
.grid-controls__btn:hover {
  border-color: var(--primary-500);
  color: var(--primary-700);
  background: var(--primary-50);
}

.grid-controls__btn svg {
  width: 18px;
  height: 18px;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: var(--sp-8) 0;
}

.pagination__btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--text-sec);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pagination__btn:hover {
  border-color: var(--primary-500);
  color: var(--primary-700);
}

.pagination__btn.active {
  background: var(--primary-700);
  border-color: var(--primary-700);
  color: white;
}

.pagination__btn svg {
  width: 16px;
  height: 16px;
}

/* Mobile filter toggle */
.mobile-filter-toggle {
  display: none;
}

@media (max-width: 1024px) {
  .marketplace-content {
    grid-template-columns: 1fr;
  }

  .filter-sidebar {
    display: none;
    position: fixed;
    inset: 0;
    z-index: var(--z-overlay);
    background: white;
    padding: var(--sp-6);
    overflow-y: auto;
    max-height: 100vh;
    top: 0;
  }

  .filter-sidebar.active {
    display: block;
  }

  .mobile-filter-toggle {
    display: inline-flex;
  }

  .product-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .product-card__image {
    height: 200px;
  }
}

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

  .filter-bar {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: var(--sp-2);
  }

  .marketplace-hero h1 {
    font-size: var(--text-3xl);
  }

  .product-card__image {
    height: 220px;
  }
}
