/* css/search.css */

/* ───── Page Layout ───── */
.search-page-content {
  display: flex;
  gap: 20px;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px;
  align-items: flex-start;
}

/* ───── Left Sidebar (Filters) ───── */
.search-sidebar {
  flex: 0 0 220px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  padding: 20px;
  position: sticky;
  top: 80px;
}

.search-sidebar h2 {
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #333;
  margin-bottom: 18px;
  padding-bottom: 10px;
  border-bottom: 2px solid #556B2F;
  text-align: left;
}

.search-sidebar fieldset {
  border: none;
  padding: 0;
  margin: 0 0 16px 0;
}

.search-sidebar legend {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #777;
  margin-bottom: 6px;
  display: block;
}

.search-sidebar select {
  width: 100%;
  padding: 8px 28px 8px 10px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background-color: #fafafa;
  color: #333;
  font-size: 0.875rem;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23556B2F'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-sidebar select:focus {
  outline: none;
  border-color: #556B2F;
  box-shadow: 0 0 0 2px rgba(85, 107, 47, 0.15);
}

.apply-button {
  width: 100%;
  padding: 10px;
  background: #556B2F;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 4px;
  display: block;
  text-align: center;
}

.apply-button:hover {
  background: #3d5022;
  transform: none;
  color: #fff;
}

/* ───── Results Area ───── */
.search-results {
  flex: 1 1 0;
  min-width: 0;
  width: auto;
  padding: 0;
}

.search-results > h1 {
  font-size: 1.05rem;
  font-weight: 600;
  color: #444;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #e8e8e8;
  text-align: left;
}

/* ───── Ad Cards Grid ───── */
.search-results-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding-top: 0;
}

.ad-card-link {
  display: block;
  text-decoration: none;
  color: inherit;
  height: 100%;
  transition: none;
}

.ad-card {
  background: #fff;
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.07);
  transition: box-shadow 0.2s, transform 0.2s;
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid #f0f0f0;
  text-align: left;
  align-items: stretch;
}

.ad-card:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.13);
  transform: translateY(-2px);
  border-color: #d8e4c0;
}

/* ───── Card Image ───── */
.ad-image-container {
  position: relative;
  width: 100%;
  height: 155px;
  overflow: hidden;
  background: #f5f5f5;
  flex-shrink: 0;
}

.ad-image-container img:first-child {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  margin: 0;
  max-width: none;
  max-height: none;
  transform: translateZ(0);
  transition: transform 0.3s ease;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.ad-card:hover .ad-image-container img:first-child {
  transform: scale(1.05) translateZ(0);
}

.ad-status-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 3px 9px;
  border-radius: 4px;
  z-index: 3;
  line-height: 1.5;
  color: #fff;
  pointer-events: none;
}

.ad-status-badge--reserved { background: #d97706; }
.ad-status-badge--sold     { background: #dc2626; }

/* ───── Card Body ───── */
.ad-card-content {
  padding: 11px 13px 12px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}

.ad-card-content h2 {
  font-size: 0.88rem;
  font-weight: 600;
  color: #1a1a1a;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0 0 5px 0;
  height: auto;
  text-align: left;
}

.ad-card-content .price {
  font-size: 1rem;
  font-weight: 700;
  color: #556B2F;
  margin: 0;
  line-height: 1.2;
}

.ad-card-content .transaction-type {
  font-size: 0.73rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #888;
  margin: 0;
}

.ad-card-content .latest-username {
  font-size: 0.76rem;
  color: #999;
  margin: 0;
  padding-top: 5px;
  margin-top: auto;
}

.ad-card-content .date,
.ad-card-content .views {
  font-size: 0.73rem;
  color: #bbb;
  margin: 0;
}

/* ───── Reserved / Sold Status ───── */
.ad-reserved {
  border-color: #f0f0f0;
  background: #fff;
  opacity: 0.6;
}

.ad-sold {
  border-color: #f0f0f0;
  background: #fff;
}

/* ───── Promoted Card Styling ───── */
.latest-ad-highlight {
  border: 2px solid #f59e0b;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.2);
}

.category-ad-highlight {
  border: 2px solid #556B2F;
  box-shadow: 0 2px 10px rgba(85, 107, 47, 0.25);
}

.latest-ad-highlight.category-ad-highlight {
  border: 2px solid #556B2F;
  box-shadow: 0 2px 10px rgba(85, 107, 47, 0.25);
}

.latest-ad-highlight:hover {
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.3);
}

.category-ad-highlight:hover,
.latest-ad-highlight.category-ad-highlight:hover {
  box-shadow: 0 6px 20px rgba(85, 107, 47, 0.35);
}

/* ───── Promotion Badges (overlay on image) ───── */
.latest-ad-highlight .ad-image-container::after,
.category-ad-highlight .ad-image-container::after {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 3px 9px;
  border-radius: 4px;
  z-index: 3;
  line-height: 1.5;
}

.latest-ad-highlight .ad-image-container::after {
  content: '★ Featured';
  background: #f59e0b;
  color: #fff;
}

.category-ad-highlight .ad-image-container::after {
  content: '▲ Promoted';
  background: #556B2F;
  color: #fff;
}

.latest-ad-highlight.category-ad-highlight .ad-image-container::after {
  content: '▲ Promoted';
  background: #556B2F;
  color: #fff;
}

/* No results */
.search-results-grid > p {
  grid-column: 1 / -1;
  text-align: center;
  color: #888;
  font-size: 0.95rem;
  padding: 48px 0;
}

/* ───── Pagination ───── */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 28px;
  flex-wrap: wrap;
  text-align: left;
}

.pagination .page-link {
  display: inline-block;
  min-width: 36px;
  padding: 7px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  text-decoration: none;
  color: #333;
  font-size: 0.85rem;
  text-align: center;
  transition: all 0.2s;
  background: #fff;
  margin: 0;
}

.pagination .page-link:hover {
  background: #f0f4e8;
  border-color: #556B2F;
  color: #556B2F;
}

.pagination .page-link.active {
  background: #556B2F;
  border-color: #556B2F;
  color: #fff;
  font-weight: 700;
}

/* ───── Right Sidebar (Featured Ads) ───── */
.search-featured {
  flex: 0 0 200px;
  min-width: 0;
  min-width: unset;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
  padding: 16px;
  position: sticky;
  top: 80px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  text-align: left;
}

.search-featured h2 {
  font-size: 0.9rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #333;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid #556B2F;
  text-align: left;
}

.latest-ads {
  display: flex;
  flex-direction: column;
  gap: 10px;
  grid-template-columns: unset;
}

.latest-ad {
  border: 1px solid #eee;
  border-radius: 8px;
  overflow: hidden;
  transition: box-shadow 0.2s, border-color 0.2s;
  background: #fff;
  padding: 0;
  text-align: left;
  margin-bottom: 0;
}

.latest-ad:hover {
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
  border-color: #c5d3a0;
}

.latest-ad a {
  display: block;
  text-decoration: none;
  color: inherit;
  padding: 0;
}

.latest-ad img {
  width: 100%;
  height: 85px;
  object-fit: cover;
  display: block;
  border-radius: 0;
  max-width: none;
  max-height: none;
  margin-bottom: 0;
}

.latest-ad .latest-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #1a1a1a;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin: 0 0 3px 0;
  max-height: none;
  padding: 8px 9px 0;
}

.latest-ad .latest-price {
  font-size: 0.85rem;
  font-weight: 700;
  color: #556B2F;
  margin: 0;
  padding: 0 9px 8px;
}

.latest-ad .latest-transaction,
.latest-ad .latest-username {
  font-size: 0.72rem;
  color: #999;
  margin: 0;
  padding: 0 9px;
}

/* ───── Mobile Filter Button ───── */
.mobile-filter-icon {
  display: none;
  position: fixed;
  bottom: 22px;
  right: 22px;
  width: 50px;
  height: 50px;
  top: auto;
  left: auto;
  background: #556B2F;
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 1.3rem;
  cursor: pointer;
  z-index: 999;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.3);
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ───── Filter Overlay (mobile) ───── */
.filter-overlay {
  display: none;
  position: fixed;
  inset: 0;
  top: 0;
  left: 0;
  right: 0;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 2000;
  align-items: flex-end;
  padding: 0;
  overflow-y: auto;
}

.filter-overlay.show {
  display: flex;
}

.filter-overlay-content {
  background: #fff;
  width: 100%;
  border-radius: 16px 16px 0 0;
  padding: 24px 20px 32px;
  max-height: 88vh;
  overflow-y: auto;
  max-width: none;
  margin: 0;
}

.filter-overlay-content h2 {
  font-size: 1rem;
  font-weight: 700;
  color: #333;
  margin-bottom: 16px;
  text-align: left;
}

.filter-overlay-content fieldset {
  border: none;
  padding: 0;
  margin-bottom: 14px;
}

.filter-overlay-content legend {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #777;
  margin-bottom: 5px;
  display: block;
}

.filter-overlay-content select {
  width: 100%;
  padding: 10px 28px 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background-color: #fafafa;
  color: #333;
  font-size: 0.9rem;
  font-family: inherit;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23556B2F'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

.close-filter-overlay {
  float: right;
  position: static;
  top: auto;
  right: auto;
  background: none;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  color: #333;
  line-height: 1;
  margin-top: -4px;
}

/* ───── Responsive ───── */
@media (max-width: 1150px) {
  .search-results-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .search-featured {
    flex: 0 0 185px;
  }
}

@media (max-width: 900px) {
  .search-featured {
    display: none;
  }
}

@media (max-width: 700px) {
  .search-sidebar {
    display: none;
  }

  .mobile-filter-icon {
    display: flex;
  }

  .search-page-content {
    padding: 14px 12px;
    flex-direction: column;
  }

  .search-results,
  .search-featured {
    width: 100%;
    margin-bottom: 0;
  }

  .search-results {
    order: 1;
  }
}

@media (max-width: 500px) {
  .search-results-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .ad-image-container {
    height: 120px;
  }
}

@media (max-width: 360px) {
  .search-results-grid {
    grid-template-columns: 1fr;
  }
}
