/* ============================================
   SEARCH RESULTS PAGE — css/pages/search.css
   Extracted from search.html (Phase 2 refactor)
   ============================================ */

/* ---- Search layout polish (pilot redesign) ---- */
.search-layout {
  gap: 18px;
  margin: 18px 0 26px;
}

.search-results-section {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 18px 18px 16px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

.filter-sidebar {
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
  padding: 18px;
}

.filter-sidebar-header {
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.filter-sidebar-title {
  font-size: 0.9rem;
  letter-spacing: -0.01em;
}

.filter-section {
  margin-bottom: 18px;
  padding-bottom: 14px;
}

.filter-section h3 {
  font-size: 0.71rem;
  letter-spacing: 0.06em;
}

.search-header {
  margin-bottom: 14px;
  padding-bottom: 12px;
}

.search-header h1 {
  font-size: 1rem;
  letter-spacing: -0.01em;
}

.search-header .results-count {
  font-size: 0.74rem;
}

.sort-select {
  background: #fff;
  border-color: #dbe2ea;
}

.sort-select:hover {
  border-color: #cbd5e1;
}

/* ---- Active Filters Chips ---- */
.search-active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}
.search-active-filters:empty {
  display: none;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: var(--warm-bg);
  border: 1px solid #fed7aa;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #9a3412;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease;
  line-height: 1.3;
}
.filter-chip:hover {
  background: #ffedd5;
  border-color: #fdba74;
}
.filter-chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  background: rgba(154,52,18,0.08);
  border: none;
  border-radius: 50%;
  color: #9a3412;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
  flex-shrink: 0;
}
.filter-chip-remove:hover {
  background: #fecaca;
  color: #dc2626;
}
.filter-chip-remove:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
/* Clear all — styled as a subtle action link at the end of the chips row */
.filter-clear-all {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  background: transparent;
  border: 1px dashed #d1d5db;
  border-radius: 100px;
  font-size: 0.71rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
  line-height: 1.3;
}
.filter-clear-all:hover {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #dc2626;
}
.filter-clear-all:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
/* Empty state polish */
.search-empty-state {
  padding: 60px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.search-empty-state-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 18px;
  color: #9ca3af;
}
.search-empty-state h3 {
  margin-bottom: 8px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--foreground);
}
.search-empty-state p {
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 22px;
  line-height: 1.5;
  max-width: 380px;
}
/* Context line — shows what user searched for */
.search-empty-context {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--foreground);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
}

/* Suggestion tips */
.search-empty-tips {
  list-style: none;
  margin: 0 0 22px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.search-empty-tips li {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
  display: flex;
  align-items: center;
  gap: 8px;
}
.search-empty-tips li::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #d1d5db;
  flex-shrink: 0;
}

/* Action buttons */
.search-empty-state-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}
.search-empty-state-actions .btn {
  border-radius: 10px;
  font-size: 0.84rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Post CTA section */
.search-empty-cta {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.search-empty-cta-divider {
  width: 40px;
  height: 1px;
  background: var(--border-mid);
}
.search-empty-cta p {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
  margin: 0;
}
.search-empty-cta .btn-primary {
  border-radius: 10px;
  font-size: 0.87rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 22px;
}

/* Error variant icon */
.search-empty-state-icon-error {
  background: #fef2f2;
  color: #ef4444;
}

/* ---- Table wrapper ---- */
.shb-table-wrap {
  overflow-x: auto;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: var(--white);
  box-shadow: 0 1px 5px rgba(15,23,42,0.04);
}
.shb-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

/* Header */
.shb-table thead th {
  background: #fbfcfe;
  padding: 10px 12px;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-light);
  text-align: left;
  white-space: nowrap;
  user-select: none;
  position: relative;
}
.shb-table thead th.sortable {
  cursor: pointer;
  transition: color .2s ease;
}
.shb-table thead th.sortable:hover {
  color: var(--foreground);
}
.shb-table thead th.sort-active {
  color: var(--primary);
  font-weight: 800;
}
.shb-sort-icon {
  display: inline-block;
  margin-left: 4px;
  font-size: 0.6rem;
  opacity: 0.8;
}

/* Body rows */
.shb-table tbody tr {
  cursor: pointer;
  transition: background .18s ease, box-shadow .18s ease;
}
.shb-table tbody tr:nth-child(odd) {
  background: var(--white);
}
.shb-table tbody tr:nth-child(even) {
  background: #fafbfc;
}
.shb-table tbody tr:hover {
  background: var(--warm-bg);
  box-shadow: inset 3px 0 0 var(--primary);
}
.shb-table tbody tr:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  background: var(--warm-bg);
  box-shadow: inset 3px 0 0 var(--primary);
}
.shb-table tbody td {
  padding: 9px 12px;
  font-size: 0.8rem;
  color: var(--foreground);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

/* Thumbnail */
.shb-table-thumb {
  width: 80px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
  display: block;
  background: #f3f4f6;
  transition: transform 0.2s ease;
}
.shb-table tbody tr:hover .shb-table-thumb {
  transform: scale(1.03);
}

/* Title cell */
.shb-table-title {
  color: var(--foreground);
  font-weight: 600;
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.35;
}
.shb-table tbody tr:hover .shb-table-title {
  color: var(--primary);
}

/* Price cell */
.shb-table-price {
  color: var(--primary);
  font-weight: 700;
  white-space: nowrap;
  letter-spacing: -0.02em;
  font-size: 0.84rem;
}

/* KM cell */
.shb-table-km {
  white-space: nowrap;
  font-size: 0.8rem;
}

/* Date cell */
.shb-table-date {
  white-space: nowrap;
  font-size: 0.76rem;
  color: var(--muted);
}

/* Location cell */
.shb-table-location {
  font-size: 0.76rem;
  color: var(--muted);
  white-space: nowrap;
}

/* Empty / dash cells */
.shb-table-dash {
  color: #d1d5db;
  font-size: 0.78rem;
}

/* Favourite cell button */
.shb-fav-cell {
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: #d1d5db;
  transition: color .2s ease, transform .15s ease;
  padding: 4px;
  line-height: 1;
  border-radius: 6px;
}
.shb-fav-cell:hover { color: #ef4444; transform: scale(1.12); background: #fef2f2; }
.shb-fav-cell.active { color: #ef4444; }

/* Compare cell button */
.shb-cmp-cell {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: #d1d5db;
  transition: color .2s ease, transform .15s ease;
  padding: 4px;
  line-height: 1;
  border-radius: 6px;
}
.shb-cmp-cell:hover { color: var(--primary); transform: scale(1.08); background: var(--warm-bg); }
.shb-cmp-cell.active { color: var(--primary); }

/* ---- Compare bottom bar ---- */
#compare-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1a1a2e;
  color: white;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 999;
  box-shadow: 0 -4px 12px rgba(0,0,0,0.2);
  transform: translateY(100%);
  transition: transform 0.3s ease;
  gap: 16px;
}
#compare-bar.visible { transform: translateY(0); }
.cmp-items {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}
.cmp-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.1);
  border-radius: 6px;
  padding: 6px 10px;
  flex-shrink: 0;
}
.cmp-item img {
  width: 60px;
  height: 45px;
  object-fit: cover;
  border-radius: 4px;
}
.cmp-item-title {
  font-size: 0.75rem;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cmp-item-remove {
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
  line-height: 1;
}
.cmp-count {
  font-size: 0.82rem;
  white-space: nowrap;
  color: rgba(255,255,255,0.7);
}
.cmp-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
}
.cmp-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.cmp-btn:not(:disabled):hover {
  background: var(--primary-hover);
}

/* ---- Near Me ---- */
.nearme-indicator {
  background: var(--warm-bg);
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  color: #9a3412;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.nearme-indicator span {
  display: flex;
  align-items: center;
}
.nearme-indicator a {
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.76rem;
  padding: 2px 8px;
  border-radius: 5px;
  transition: background 0.15s ease;
}
.nearme-indicator a:hover {
  background: rgba(255,122,0,0.08);
}
.distance-badge {
  font-size: 0.72rem;
  color: #059669;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: 6px;
}

/* Near Me filter button */
.nearme-filter-btn {
  width: 100%;
  padding: 10px 14px;
  border: 1px dashed #d1d5db;
  border-radius: 10px;
  background: #fafbfc;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.nearme-filter-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.nearme-filter-btn:hover {
  border-color: var(--primary);
  border-style: solid;
  background: var(--warm-bg);
  color: var(--primary);
}
.nearme-filter-btn.active {
  border-color: #059669;
  border-style: solid;
  background: #ecfdf5;
  color: #059669;
}
.nearme-filter-btn.loading {
  opacity: 0.7;
  pointer-events: none;
  border-style: solid;
  border-color: var(--primary);
  color: var(--primary);
  background: var(--warm-bg);
}
.nearme-spinner {
  animation: nearme-spin 1.2s linear infinite;
}
@keyframes nearme-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.nearme-radius-row {
  display: none;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.nearme-radius-row.visible {
  display: flex;
}
.nearme-radius-row label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--muted);
  white-space: nowrap;
}
.nearme-radius-row select {
  flex: 1;
}
.nearme-clear-link {
  font-size: 0.73rem;
  font-weight: 500;
  color: #ef4444;
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
  width: 100%;
  text-align: center;
  margin-top: 8px;
  display: none;
  padding: 4px;
  border-radius: 4px;
  transition: background 0.15s ease;
}
.nearme-clear-link.visible {
  display: block;
}
.nearme-clear-link:hover {
  text-decoration: underline;
  background: #fef2f2;
}

/* ---- Card view — hidden on desktop, shown on mobile ---- */
.shb-card-view {
  display: none;
}

/* Filter close bar (mobile sticky bottom) */
.filter-close-bar {
  display: none;
  position: sticky;
  bottom: 0;
  background: white;
  padding: 16px 0 8px;
  margin-top: 24px;
  border-top: 1px solid var(--border-light);
}
.filter-close-bar .btn {
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.9rem;
  min-height: 46px;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .search-layout {
    margin: 14px 0 18px;
  }
  .search-results-section {
    border-radius: 12px;
    padding: 14px;
  }
  .filter-sidebar {
    border-radius: 0;
    padding: 18px 14px;
  }
  .search-header {
    margin-bottom: 12px;
    padding-bottom: 10px;
  }
  .shb-table-wrap {
    display: none;
  }
  .shb-card-view {
    display: block;
  }
  .nearme-filter-btn { font-size: 0.85rem; padding: 12px 14px; min-height: 46px; }
  .nearme-filter-btn.active { min-height: 46px; }
  .filter-section h3 { font-size: 0.8rem; margin-bottom: 10px; }
  .filter-close-bar {
    display: block;
  }
  .filter-close-x {
    display: flex !important;
  }
  /* Compare bar — adjust for bottom nav */
  #compare-bar { bottom: calc(62px + env(safe-area-inset-bottom, 0px)); }
}

@media (max-width: 480px) {
  .search-results-section {
    border-radius: 10px;
    padding: 12px;
  }
  /* Cards — stacked full width on very small */
  .shb-card-view .listings-grid { gap: 8px; }
  .nearme-indicator { font-size: 0.78rem; padding: 8px 12px; }

  /* Empty state — tighter on mobile */
  .search-empty-state { padding: 40px 16px; }
  .search-empty-context { font-size: 0.95rem; }
  .search-empty-state p { font-size: 0.82rem; }
  .search-empty-tips li { font-size: 0.78rem; }
  .search-empty-state-actions { flex-direction: column; gap: 8px; }
  .search-empty-state-actions .btn { width: 100%; justify-content: center; }
  .search-empty-cta .btn-primary { width: 100%; justify-content: center; }
}
