/* ============================================================
   SPOTREALTY — Modern Buyer Board Filter System (Phase 2.1)
   Scoped CSS: Main Toolbar, Multi-Chip Search, Advanced Drawer
   UI/UX Hardened, Scroll-Isolated, Responsive & Accessible
   ============================================================ */

/* ── Filter Toolbar ────────────────────────────────────────── */
.buyer-board-filter-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0 8px;
  margin-bottom: 8px;
  background: transparent;
  position: relative;
  z-index: 20;
}

.buyer-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  border-radius: 9999px;
  border: 1px solid var(--border2, #e2e8f0);
  background: var(--bg, #ffffff);
  color: var(--text, #334155);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
  box-sizing: border-box;
  line-height: 1;
}

.buyer-filter-btn:hover {
  background: var(--bg2, #f8fafc);
  border-color: var(--border, #cbd5e1);
}

.buyer-filter-btn:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 1px;
}

.buyer-filter-btn.is-active,
.buyer-filter-btn.has-filters {
  background: #eef2ff;
  border-color: #6366f1;
  color: #4338ca;
  font-weight: 600;
}

.buyer-filter-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #4f46e5;
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  margin-left: 2px;
}

.buyer-filter-divider {
  width: 1px;
  height: 16px;
  background: var(--border2, #e2e8f0);
  margin: 0 2px;
  flex-shrink: 0;
}

/* ── Filter Dropdown Pills ─────────────────────────────────── */
.buyer-filter-pill-group {
  display: inline-flex;
  align-items: center;
  position: relative;
}

.buyer-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 13px;
  border-radius: 9999px;
  border: 1px solid var(--border2, #e2e8f0);
  background: var(--bg, #ffffff);
  color: var(--text, #334155);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  box-sizing: border-box;
  line-height: 1;
}

.buyer-filter-pill:hover {
  background: var(--bg2, #f8fafc);
  border-color: var(--border, #cbd5e1);
}

.buyer-filter-pill:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 1px;
}

.buyer-filter-pill.is-active {
  background: #eef2ff;
  border-color: #6366f1;
  color: #4338ca;
  font-weight: 600;
}

.buyer-filter-pill .pill-chevron {
  font-size: 15px;
  color: var(--text3, #94a3b8);
  margin-left: 2px;
  transition: transform 0.2s ease;
}

.buyer-filter-pill.is-open .pill-chevron {
  transform: rotate(180deg);
}

/* ── Filter Dropdown Panels ─────────────────────────────────── */
.buyer-filter-panel {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 100;
  min-width: 240px;
  max-width: 380px;
  background: var(--bg, #ffffff);
  border: 1px solid var(--border, #cbd5e1);
  border-radius: 8px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  padding: 12px;
  display: none;
  font-size: 13px;
}

.buyer-filter-panel.is-open {
  display: block;
  animation: filterDropdownFade 0.15s ease-out;
}

@keyframes filterDropdownFade {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.buyer-filter-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border2, #f1f5f9);
}

.buyer-filter-panel-title {
  font-weight: 600;
  color: var(--text, #1e293b);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Mode Toggle (ALL / ANY / NONE) ────────────────────────── */
.buyer-mode-toggle-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.buyer-mode-match-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3, #64748b);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.buyer-mode-toggle {
  display: inline-flex;
  background: var(--bg2, #f1f5f9);
  border: 1px solid var(--border2, #e2e8f0);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.buyer-mode-btn {
  border: none;
  background: transparent;
  height: 26px;
  min-width: 38px;
  padding: 0 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 4px;
  color: var(--text3, #64748b);
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.buyer-mode-btn:hover:not(.is-selected) {
  background: rgba(0, 0, 0, 0.04);
  color: var(--text, #1e293b);
}

.buyer-mode-btn.is-selected {
  background: #2563eb;
  color: #ffffff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.25);
}

/* ── Checkbox & Radio Lists ────────────────────────────────── */
.buyer-filter-options-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

.buyer-filter-options-list::-webkit-scrollbar {
  width: 5px;
}

.buyer-filter-options-list::-webkit-scrollbar-track {
  background: transparent;
}

.buyer-filter-options-list::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.buyer-filter-option-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  user-select: none;
  color: var(--text, #334155);
  font-size: 13px;
  transition: background 0.1s ease;
}

.buyer-filter-option-row:hover {
  background: var(--bg2, #f8fafc);
}

.buyer-filter-option-row input[type="checkbox"],
.buyer-filter-option-row input[type="radio"] {
  cursor: pointer;
  accent-color: #2563eb;
  margin: 0;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.buyer-filter-category-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #64748b;
  padding: 6px 8px 2px;
  margin-top: 6px;
  background: var(--bg, #ffffff);
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid #f1f5f9;
}

.buyer-filter-category-header:first-child {
  margin-top: 0;
}

/* ── Budget Panel Specifics ────────────────────────────────── */
.buyer-budget-inputs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 10px;
}

.buyer-budget-inputs input {
  width: 80px;
  height: 32px;
  padding: 0 8px;
  border: 1px solid var(--border2, #cbd5e1);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg, #ffffff);
}

.buyer-budget-inputs select {
  height: 32px;
  padding: 0 6px;
  border: 1px solid var(--border2, #cbd5e1);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg, #ffffff);
  cursor: pointer;
}

.buyer-budget-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 10px;
}

.buyer-preset-pill {
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--border2, #e2e8f0);
  border-radius: 12px;
  background: var(--bg2, #f8fafc);
  color: var(--text2, #475569);
  cursor: pointer;
  transition: all 0.12s ease;
}

.buyer-preset-pill:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* ── Universal Search Bar ──────────────────────────────────── */
.buyer-universal-search-wrap {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 4px;
  height: 32px;
  min-height: 32px;
  padding: 0 6px 0 10px;
  border-radius: 9999px;
  border: 1px solid var(--border2, #e2e8f0);
  background: var(--bg2, #f8fafc);
  min-width: 260px;
  max-width: 620px;
  flex: 1 1 260px;
  margin-left: auto;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
  box-sizing: border-box;
  overflow: hidden;
}

.buyer-search-chips {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  max-width: calc(100% - 90px);
  overflow-x: auto;
}

.buyer-search-chips::-webkit-scrollbar {
  display: none;
}

.buyer-universal-search-wrap:focus-within {
  background: #ffffff;
  border-color: #6366f1;
  box-shadow: 0 0 0 1px #6366f1;
}

.buyer-universal-search-icon {
  font-size: 16px;
  color: var(--text3, #94a3b8);
  margin-right: 2px;
  flex-shrink: 0;
}

.buyer-search-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #e0e7ff;
  color: #3730a3;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: 9999px;
  height: 20px;
  max-width: 140px;
  white-space: nowrap;
}

.buyer-search-chip span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.buyer-search-chip-del {
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
  opacity: 0.6;
  transition: opacity 0.1s ease;
}

.buyer-search-chip-del:hover {
  opacity: 1;
  color: #ef4444;
}

.buyer-search-input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 12px;
  color: var(--text, #334155);
  min-width: 80px;
  flex: 1;
  height: 26px;
  padding: 0 4px;
}

.buyer-search-input::placeholder {
  color: var(--text3, #94a3b8);
}

.buyer-search-mode-select {
  border: none;
  border-left: 1px solid var(--border2, #e2e8f0);
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E") no-repeat right 3px center;
  border-radius: 0;
  font-size: 11px;
  font-weight: 600;
  color: var(--text2, #64748b);
  padding: 0 16px 0 8px;
  height: 18px;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  margin-left: auto;
  flex-shrink: 0;
  transition: color 0.12s ease;
}

.buyer-search-mode-select:hover {
  color: var(--text, #1e293b);
}

.buyer-search-mode-select:focus-visible {
  outline: 1px solid #6366f1;
}

.buyer-search-clear-all {
  border: none;
  background: transparent;
  color: var(--text3, #94a3b8);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  display: none;
}

.buyer-search-clear-all.is-visible {
  display: inline-flex;
}

.buyer-search-clear-all:hover {
  color: #ef4444;
}

/* ── Clear All Button ──────────────────────────────────────── */
.buyer-filter-clear-all-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 10px;
  border-radius: 9999px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #dc2626;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  box-sizing: border-box;
  white-space: nowrap;
  line-height: 1;
}

.buyer-filter-clear-all-btn:hover {
  background: #fee2e2;
  border-color: #f87171;
}

/* ── Responsive Filter Toolbar Wrapping ────────────────────── */
@media (max-width: 1200px) {
  .buyer-universal-search-wrap {
    flex: 1 1 100%;
    min-width: 100%;
    max-width: 100%;
    order: 10;
    margin-left: 0;
  }
}

/* ── Advanced Filter Drawer ────────────────────────────────── */
.buyer-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  z-index: 1050;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  touch-action: none;
  overscroll-behavior: contain;
}

.buyer-drawer-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.buyer-drawer-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  height: 100vh;
  width: 440px;
  max-width: 92vw;
  background: var(--bg, #ffffff);
  z-index: 1060;
  box-shadow: 8px 0 30px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

.buyer-drawer-panel.is-open {
  transform: translateX(0);
}

.buyer-drawer-header {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 54px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border2, #e2e8f0);
  background: var(--bg, #ffffff);
  box-sizing: border-box;
}

.buyer-drawer-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.buyer-drawer-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text, #0f172a);
}

.buyer-drawer-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text3, #64748b);
  cursor: pointer;
  font-size: 18px;
  transition: background 0.15s ease, color 0.15s ease;
}

.buyer-drawer-close-btn:hover {
  background: var(--bg2, #f1f5f9);
  color: var(--text, #0f172a);
}

.buyer-drawer-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-sizing: border-box;
}

.buyer-drawer-body::-webkit-scrollbar {
  width: 6px;
}

.buyer-drawer-body::-webkit-scrollbar-track {
  background: transparent;
}

.buyer-drawer-body::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

.buyer-drawer-body::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* ── Drawer Section Accordions ─────────────────────────────── */
.buyer-drawer-section {
  flex-shrink: 0;
  border: 1px solid var(--border2, #e2e8f0);
  border-radius: 8px;
  background: var(--bg, #ffffff);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.buyer-drawer-section.has-active {
  border-color: #93c5fd;
  background: #f8fafc;
}

.buyer-drawer-section.has-active .buyer-drawer-section-header {
  background: #f0f7ff;
}

.buyer-drawer-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 46px;
  min-height: 46px;
  padding: 0 16px;
  cursor: pointer;
  user-select: none;
  background: var(--bg, #ffffff);
  outline: none;
  box-sizing: border-box;
  transition: background 0.15s ease;
}

.buyer-drawer-section-header:hover {
  background: var(--bg2, #f8fafc);
}

.buyer-drawer-section-header:focus-visible {
  box-shadow: inset 0 0 0 2px #3b82f6;
}

.buyer-drawer-section-title-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.buyer-drawer-section-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text, #1e293b);
  line-height: 1;
}

.buyer-drawer-section-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #2563eb;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.buyer-drawer-section-chevron {
  font-size: 20px;
  color: var(--text3, #94a3b8);
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.buyer-drawer-section.is-collapsed .buyer-drawer-section-chevron {
  transform: rotate(-90deg);
}

.buyer-drawer-section.is-collapsed .buyer-drawer-section-content {
  display: none;
}

.buyer-drawer-section-content {
  padding: 12px 16px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-top: 1px solid var(--border2, #f1f5f9);
}

.buyer-drawer-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.buyer-drawer-field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
}

.buyer-drawer-field-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text3, #64748b);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.buyer-field-divider {
  height: 1px;
  background: var(--border2, #f1f5f9);
  margin: 4px 0;
}

.buyer-drawer-select,
.buyer-drawer-input {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border2, #cbd5e1);
  border-radius: 6px;
  font-size: 13px;
  background: var(--bg, #ffffff);
  color: var(--text, #1e293b);
  box-sizing: border-box;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  width: 100%;
}

.buyer-drawer-select:focus,
.buyer-drawer-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.buyer-chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.buyer-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-size: 12px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 12px;
  max-width: 220px;
}

.buyer-filter-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.buyer-chip-remove {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  color: #3b82f6;
  line-height: 1;
  padding: 0;
  display: inline-flex;
  align-items: center;
  transition: color 0.12s ease;
}

.buyer-chip-remove:hover {
  color: #dc2626;
}

/* ── Drawer Footer ─────────────────────────────────────────── */
.buyer-drawer-footer {
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 20px;
  border-top: 1px solid var(--border2, #e2e8f0);
  background: var(--bg, #ffffff);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.03);
  box-sizing: border-box;
}

.buyer-drawer-clear-btn {
  border: none;
  background: transparent;
  color: #dc2626;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  transition: background 0.12s ease;
}

.buyer-drawer-clear-btn:hover {
  background: #fee2e2;
}

.buyer-drawer-apply-btn {
  height: 36px;
  padding: 0 20px;
  border-radius: 6px;
  border: none;
  background: #2563eb;
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.12s ease;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.buyer-drawer-apply-btn:hover {
  background: #1d4ed8;
}

/* ============================================================
   HOW SELECTIONS MATCH (Phase 2.4 Centralized Match Rules)
   ============================================================ */
.buyer-match-rule-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border, #f1f5f9);
  gap: 12px;
}

.buyer-match-rule-row:last-child {
  border-bottom: none;
}

.buyer-match-rule-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.buyer-match-rule-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #1e293b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.buyer-match-rule-count {
  font-size: 11px;
  color: var(--text-muted, #64748b);
}

.buyer-match-rule-select {
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--border, #cbd5e1);
  background-color: #ffffff;
  color: var(--text, #0f172a);
  font-size: 12px;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  max-width: 175px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.buyer-match-rule-select:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.buyer-match-rules-empty {
  font-size: 12px;
  color: var(--text-muted, #94a3b8);
  padding: 10px 4px;
  line-height: 1.5;
  font-style: italic;
}
