/* 03-search.css — Advanced search: search header, filter chips, suggestions, empty state, filter drawer,
   home header search bar.
   Part of the old css/styles.css (lines 292–851); unused rules since removed.
   The number is the load order: later files override earlier ones, exactly
   as later lines in the single file used to. Keep them linked in order. */

/* ══════════════════════════════════════════════════════════
   ADVANCED SEARCH — all styles (migrated from advanced-search.js)
   ══════════════════════════════════════════════════════════ */

/* ── Search header ─────────────────────────────────────── */
.header-search {
  display: flex;
  flex-direction: column;
  padding: 0;
  height: auto;
}
.search-header-top {
  display: flex;
  align-items: center;
  gap: 8px;
  /* push below notch/Dynamic Island — the shared header rule sets padding-top
     on the outer element but .header-search overrides it to 0/auto, so we
     re-apply safe-area clearance here on the inner row instead */
  padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 8px;
  width: 100%;
  box-sizing: border-box;
}
.search-back-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #444;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s;
}
.search-back-btn:active { background: #f0f0f0; }
.search-input-wrap {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}
.search-input-wrap .search-icon-lead {
  position: absolute;
  left: 12px;
  color: #aaa;
  font-size: 20px;
  pointer-events: none;
  transition: color 0.2s;
}
.search-input-wrap:focus-within .search-icon-lead { color: #19378C; }
#searchInputExpanded {
  width: 100%;
  height: 42px;
  padding: 0 72px 0 40px !important;
  border: 1.5px solid #e0e0e0;
  border-radius: 12px;
  font-size: 15px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
  color: #1a1a2e;
  background: #f7f8fc;
  outline: none;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.2s, background 0.2s;
}
#searchInputExpanded:focus {
  border-color: #19378C;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(25,55,140,0.08);
}
#searchInputExpanded::placeholder { color: #aaa; }
.search-clear-btn {
  position: absolute;
  right: 40px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #aaa;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
}
.search-clear-btn.visible { display: flex; }
.search-filter-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #19378C;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  -webkit-tap-highlight-color: transparent;
}
.search-filter-btn-wrap {
  position: absolute;
  right: 8px;
  display: flex;
  align-items: center;
}
.filter-count-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  background: #e74c3c;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  border-radius: 50%;
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.filter-count-dot.visible { opacity: 1; }

/* ── Active filter chips strip ─────────────────────────── */
.active-filters-strip {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0 12px 10px;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  max-height: 0;
  transition: max-height 0.25s ease, padding-bottom 0.25s;
}
.active-filters-strip.has-filters {
  max-height: 52px;
  padding-bottom: 10px;
}
.active-filters-strip::-webkit-scrollbar { display: none; }
.af-chip,
.af-clear-all { scroll-snap-align: start; }
.af-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px 5px 12px;
  background: #eef1f9;
  border: 1px solid #b8c4e0;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: #19378C;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.af-chip .af-remove {
  font-size: 14px;
  line-height: 1;
  margin-left: 2px;
  opacity: 0.7;
}
.af-clear-all {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  background: #fff0f0;
  border: 1px solid #f5c6c6;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  color: #e74c3c;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ── Suggestions panel ─────────────────────────────────── */
#searchSuggestions {
  position: fixed;
  /* Initial fallback: 56px header + 10px top padding + 8px bottom padding + safe-area.
     _repositionSuggestions() corrects this precisely after each render. */
  top: calc(74px + env(safe-area-inset-top, 0px));
  left: 0; right: 0; bottom: 0;
  background: #fff;
  z-index: 9000;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 0 0 calc(80px + env(safe-area-inset-bottom, 0px));
  display: none;
  flex-direction: column;
}
#searchSuggestions.visible { display: flex; }
.suggest-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #aaa;
  padding: 16px 16px 6px;
}
.suggest-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.12s;
  border-bottom: 1px solid #f8f8f8;
}
.suggest-item:active { background: #f5f7ff; }
.suggest-icon {
  width: 34px; height: 34px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
}
.suggest-icon.history  { background: #f5f5f5; color: #999; }
.suggest-icon.trending { background: #fff3e0; color: #f57c00; }
.suggest-icon.match    { background: #eef1f9; color: #19378C; }
.suggest-text { flex: 1; font-size: 14px; color: #1a1a2e; line-height: 1.3; }
.suggest-text em { font-style: normal; color: #19378C; font-weight: 700; }
.suggest-meta { font-size: 11px; color: #aaa; margin-top: 1px; }
.suggest-arrow  { color: #ddd; font-size: 18px; flex-shrink: 0; }
.suggest-divider { height: 1px; background: #f0f0f0; margin: 4px 0; }

/* ── Search empty state (no query typed yet) ───────────── */
.se-wrap { display: flex; flex-direction: column; }
.se-hero {
  text-align: center;
  padding: 30px 28px 26px;
}
.se-illustration {
  width: 132px; height: 132px;
  margin: 0 auto 18px;
}
.se-title {
  font-family: 'Nunito', 'Fredoka One', 'Inter', sans-serif;
  font-weight: 800;
  font-size: 1.28rem;
  letter-spacing: -0.02em;
  color: #1a1a2e;
  margin: 0 0 8px;
}
.se-subtitle {
  font-size: 0.85rem;
  line-height: 1.55;
  color: #8a8f9c;
  max-width: 260px;
  margin: 0 auto 22px;
}
.se-cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #19378C;
  color: #fff;
  border: none;
  padding: 13px 26px;
  border-radius: 14px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(25,55,140,0.28);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.se-cta-btn:active { transform: scale(0.97); box-shadow: 0 4px 12px rgba(25,55,140,0.22); }
.se-cta-btn .material-symbols-rounded { font-size: 18px; }

.se-section { padding: 20px 0 4px; border-top: 8px solid #f7f8fc; }
.se-section-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px 14px;
}
.se-section-title {
  font-family: 'Nunito', 'Fredoka One', 'Inter', sans-serif;
  font-weight: 800;
  font-size: 1rem;
  color: #1a1a2e;
}
.se-section-link {
  display: flex; align-items: center; gap: 1px;
  font-size: 0.75rem; font-weight: 600; color: #999;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.se-section-link .material-symbols-rounded { font-size: 16px; }

.se-cat-row {
  display: flex; gap: 0.8rem; overflow-x: auto;
  padding: 0 1rem 0.4rem;
  scroll-padding: 0 1rem;
  scroll-behavior: smooth;
}
.se-cat-row::-webkit-scrollbar { display: none; }
.se-cat-row .cat { opacity: 1; transform: none; }

.se-chip-row {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 0 16px 4px;
}
.se-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px;
  background: #f5f6fa;
  border: 1px solid #ececf3;
  border-radius: 20px;
  font-size: 0.82rem; font-weight: 600;
  color: #333;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s, border-color 0.15s;
}
.se-chip:active { background: #eef1f9; border-color: #b8c4e0; }
.se-chip .material-symbols-rounded { font-size: 15px; color: #aaa; }
.se-chip.recent .material-symbols-rounded { color: #999; }
.se-chip-remove {
  margin-left: 2px; color: #ccc; font-size: 14px;
  display: flex; align-items: center; border-radius: 50%;
}
.se-chip-remove:active { color: #e74c3c; }

/* ── Filter drawer (bottom sheet) ─────────────────────── */
#filterDrawer {
  position: fixed;
  inset: 0;
  z-index: 99998;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0,0,0,0);
  pointer-events: none;
  transition: background 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}
#filterDrawer.open {
  background: rgba(0,0,0,0.5);
  pointer-events: all;
}
.filter-sheet {
  width: 100%;
  max-width: 600px;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 0 0 calc(env(safe-area-inset-bottom, 0px) + 16px);
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
  max-height: min(82vh, 640px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  box-sizing: border-box;
  will-change: transform;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  touch-action: pan-y;
}
#filterDrawer.open .filter-sheet { transform: translateY(0); }
.filter-sheet.dragging { transition: none !important; }
.filter-sheet-handle {
  width: 36px; height: 4px;
  background: #d8d8d8;
  border-radius: 4px;
  margin: 12px auto 0;
  cursor: grab;
  flex-shrink: 0;
}
.filter-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  border-bottom: 1px solid #f0f0f0;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 1;
}
.filter-sheet-title { font-size: 16px; font-weight: 800; color: #1a1a2e; }
.filter-reset-btn {
  background: none;
  border: none;
  color: #e74c3c;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  -webkit-tap-highlight-color: transparent;
}
.filter-reset-btn:active { background: #fff0f0; }
.filter-section { padding: 18px 20px 0; }
.filter-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: #aaa;
  margin-bottom: 10px;
}

/* Sort pills */
.sort-pills { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 4px; }
.sort-pill {
  padding: 7px 14px;
  border: 1.5px solid #e0e0e0;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: #555;
  cursor: pointer;
  background: #fff;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.sort-pill.active { border-color: #19378C; background: #19378C; color: #fff; font-weight: 600; }

/* Condition pills */
.cond-pills { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 4px; }
.cond-pill {
  padding: 7px 14px;
  border: 1.5px solid #e0e0e0;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: #555;
  cursor: pointer;
  background: #fff;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.cond-pill.active { border-color: #19378C; background: #19378C; color: #fff; font-weight: 600; }

/* Price range */
.price-range-row { display: flex; align-items: center; gap: 8px; width: 100%; box-sizing: border-box; }
.price-input {
  flex: 1 1 0;
  min-width: 0;
  width: 0;
  padding: 11px 10px;
  border: 1.5px solid #e0e0e0;
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  color: #1a1a2e;
  background: #fafafa;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}
.price-input:focus { border-color: #19378C; background: #fff; }
.price-sep { color: #aaa; font-size: 13px; flex-shrink: 0; white-space: nowrap; }

/* Category select */
.filter-select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #e0e0e0;
  border-radius: 12px;
  font-size: 14px;
  font-family: inherit;
  color: #1a1a2e;
  background: #fafafa url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23aaa'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right 12px center / 20px;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s;
}
.filter-select:focus { border-color: #19378C; background-color: #fff; }

.filter-apply-btn {
  display: block;
  width: calc(100% - 40px);
  margin: 22px 20px 0;
  padding: 16px;
  background: #19378C;
  color: #fff;
  border: none;
  border-radius: 16px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: opacity 0.15s;
}
.filter-apply-btn:active { opacity: 0.85; }

/* ══════════════════════════════════════════════════════════
   END ADVANCED SEARCH STYLES
   ══════════════════════════════════════════════════════════ */

/* ── Home header inline search bar ── */
.search-container { position: relative; display: flex; align-items: center; }
.search-bar {
  padding: 0.28rem 0.5rem; padding-right: 28px;
  border: 1.5px solid #e0e0e0;
  border-radius: 20px;
  background: #f5f6fa;
  width: 130px; font-size: 0.8rem; outline: none;
  transition: all 0.3s ease;
  color: #333;
}
.search-bar:focus {
  width: 185px;
  box-shadow: 0 2px 8px rgba(25,55,140,0.15);
  border-color: #19378C;
  background: #fff;
}
.search-icon {
  position: absolute; right: 7px; top: 50%; transform: translateY(-50%);
  font-size: 16px; color: #888; cursor: pointer; transition: color 0.2s ease;
}
.search-icon:hover { color: #19378C; }

.back-arrow { cursor: pointer; transition: transform 0.2s ease; }
.back-arrow:hover { transform: translateX(-2px); }

.post-goods-btn {
  background: #19378C; color: #fff; border: none;
  padding: 0.4rem 0.8rem; border-radius: 8px;
  font-size: 0.8rem; cursor: pointer;
  display: flex; align-items: center; gap: 0.3rem;
  transition: background 0.2s ease;
}
.post-goods-btn:hover { background: #0f2460; }
