/* TradeHive Directory UI (v2025-11-15 - Updated for neater filters) */
/* Wrap */
.th-wrap { max-width: 1100px; margin: 0 auto; padding: 8px; }

/* Vars for unified green look (merged blue/green for consistency) */
:root {
  --th-green-bg: #e5f6e5;
  --th-green-bd: #b9e4b9;
  --th-green-shadow: 0 4px 10px rgba(0,128,0,0.05);
  --th-green-ring: 0 0 0 4px rgba(100,200,100,0.15);
  --th-green-focus-bd: #90d790;
}

/* Filter bar */
.th-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0 0 10px 0; flex-wrap: wrap; }
.th-bar-left { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }

/* Filter labels (new for user-friendliness) */
.th-filter-label {
  display: block;
  font-weight: 700;
  margin-bottom: 6px;
  color: #475569;
  font-size: 14px;
}

/* ---------- GREEN CHIP WRAPPERS (unified from blue) ---------- */
.th-bar-left .th-lab,
.th-bar-left .th-townui {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--th-green-bg) !important;
  border: 1px solid var(--th-green-bd) !important;
  border-radius: 12px !important;
  padding: 8px 10px !important;
  box-shadow: var(--th-green-shadow) !important;
}
.th-bar-left .th-lab:has(.th-sel:focus),
.th-bar-left .th-townui:has(select:focus) {
  box-shadow: var(--th-green-ring), var(--th-green-shadow) !important;
  border-color: var(--th-green-focus-bd) !important;
}

/* Province, Region, Category (native selects) */
.th-bar-left .th-province,
.th-bar-left .th-region,
.th-bar-left .th-sel {
  border: none !important;
  background: transparent !important;
  outline: none !important;
  font-weight: 800 !important;
  color: #0f172a !important;
  cursor: pointer !important;
  padding-right: 28px !important;
  -webkit-appearance: none; -moz-appearance: none; appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, #98A2B3 50%),
    linear-gradient(135deg, #98A2B3 50%, transparent 50%) !important;
  background-position:
    calc(100% - 16px) 55%,
    calc(100% - 10px) 55% !important;
  background-size: 6px 6px, 6px 6px !important;
  background-repeat: no-repeat !important;
  width: 100%;
}
.th-bar-left .th-province:focus,
.th-bar-left .th-region:focus,
.th-bar-left .th-sel:focus {
  border-color: var(--th-green-focus-bd) !important;
}

/* Town (Select2) */
.select2-container--default .select2-selection--single {
  border: none !important;
  background: transparent !important;
  border-radius: 0 !important;
  min-height: auto !important;
  display: flex !important; align-items: center !important;
  padding: 0 !important;
  box-shadow: none !important;
}
.select2-selection__rendered { line-height: 1.2 !important; padding-left: 0 !important; font-weight: 800 !important; color: #0f172a !important; }
.select2-selection__placeholder { color: #475569 !important; font-weight: 700 !important; }
.select2-selection__arrow { height: 100% !important; right: 8px !important; }
.select2-container--open .select2-selection--single {
  box-shadow: none !important; border-color: transparent !important;
}
.select2-dropdown {
  border: 1px solid var(--th-green-bd) !important; border-radius: 12px !important;
  box-shadow: 0 12px 24px rgba(16,24,40,.12), 0 3px 8px rgba(16,24,40,.06) !important;
  overflow: hidden !important;
}
.select2-results__option--highlighted { background: #16a34a !important; color: #fff !important; }
.select2-selection__clear { color: #64748b !important; }

/* ---------- BUTTONS IN FILTER BAR ---------- */
.th-bar-left button,
.th-btn-ghost,
.th-reset-btn {
  padding: .6rem 1rem; border: 1px solid var(--th-green-bd) !important; border-radius: 12px !important;
  background: #fff !important; color: #0f172a !important; cursor: pointer; font-weight: 800;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .02s ease;
}
.th-bar-left button:hover,
.th-btn-ghost:hover,
.th-reset-btn:hover { background: #f5f6f8 !important; border-color: var(--th-green-focus-bd) !important; box-shadow: 0 1px 3px rgba(16,24,40,.06); }
.th-bar-left button:active,
.th-btn-ghost:active,
.th-reset-btn:active { transform: translateY(1px); }
/* Town not listed? (assume this is the red text in screenshot - make subtle) */
.th-bar-left button:nth-of-type(2) {
  background: var(--th-green-bg) !important;
  color: #475569 !important; /* Neutralize red */
}

/* Sticky hint bar (made more prominent) */
.th-quote-bar {
  position: sticky; top: 0; z-index: 1;
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: var(--th-green-bg); border: 1px solid var(--th-green-bd); border-radius: 12px;
  padding: 12px; margin: 14px 0 12px;
  box-shadow: var(--th-green-shadow);
}
.th-quote-bar__text { flex: 1; font-weight: 800; color: #0f172a; }
.th-quote-bar__actions { display: flex; gap: 8px; flex: 0 0 auto; }
.th-quote-btn { background: #16a34a; color: #fff; border: none; border-radius: 12px; padding: .6rem 1.1rem; font-weight: 800; cursor: pointer; box-shadow: 0 6px 14px rgba(22,163,74,.22); }
.th-quote-btn:hover { filter: brightness(0.97); }
.th-quote-btn:disabled { opacity: .55; cursor: not-allowed; }

/* Grid */
.th-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 900px) { .th-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .th-grid { grid-template-columns: 1fr; } }

/* Card (unchanged) */
.th-card { position: relative; }
.th-card--ui {
  border: 1px solid #d0d7de; border-radius: 18px; background: #ffffff; padding: 14px;
  box-shadow: 0 2px 4px rgba(0,0,0,.04); transition: box-shadow .2s ease, border-color .2s ease;
  min-height: 220px; display: flex; flex-direction: column; overflow: visible;
}
.th-card--ui:hover { box-shadow: 0 4px 10px rgba(0,0,0,.08); border-color: #cbd5e1; }

/* Checkbox selector */
.th-ui-select { position: absolute; top: 10px; right: 10px; z-index: 3; }
.th-ui-select input[type="checkbox"] { width: 20px; height: 20px; accent-color: #16a34a; cursor: pointer; display: block; }

/* Top row */
.th-ui-top { display: grid; grid-template-columns: 76px 1fr; gap: 14px; align-items: start; flex: 1; }
.th-ui-logo { width: 76px; height: 76px; border: 1px solid #e6e8ea; border-radius: 16px; background: #f7f8f9; display: grid; place-items: center; overflow: hidden; }
.th-ui-logo img { max-width: 90%; max-height: 90%; object-fit: contain; display: block; }
.th-ui-title { margin: 0 0 4px 0; font-size: 20px; line-height: 1.2; font-weight: 800; color: #0f172a; word-break: break-word; }

/* Towns line */
.th-ui-town { color: #475569; font-size: 14px; margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.th-ui-more { display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 999px; background: #eef2f6; border: 1px solid #d3dae2; color: #334155; font-size: 12px; line-height: 1; }

/* Trade chips */
.th-ui-chips { display: flex; flex-wrap: wrap; gap: 6px; overflow: hidden; }
.th-ui-chip { display: inline-block; background: #eef2f6; border: 1px solid #d3dae2; color: #334155; padding: 4px 10px; border-radius: 999px; font-size: 13px; line-height: 1.2; white-space: nowrap; }
.th-ui-chip--more { background: #f1f5f9; border-color: #d8dee6; }

/* Actions row */
.th-ui-actions { margin-left: 90px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-top: 8px; }
.th-ui-icbtn { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; background: #ffffff; border: 1px solid #d0d7de; color: #111827; text-decoration: none; }
.th-ui-icbtn:hover { background: #f5f6f8; }
.th-ui-icbtn--disabled { opacity: .45; cursor: not-allowed; }
.th-ui-viewbtn { padding: 8px 14px; border: 1px solid #cfd6dd; background: #fff; border-radius: 10px; text-decoration: none; color: #0f172a; font-weight: 700; font-size: 14px; }
.th-ui-viewbtn:hover { background: #f5f6f8; }

/* Footer */
.th-ui-footer { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 10px; border-top: 1px dashed #e6e8ea; }
.th-badge--verified { display: inline-flex; align-items: center; gap: 8px; background: #fff7e6; border: 1px solid #facc15; color: #92400e; border-radius: 999px; padding: 6px 12px; font-weight: 800; font-size: 14px; white-space: nowrap; }
.th-badge--placeholder { visibility: hidden; min-width: 120px; height: 1em; display: inline-block; }
.th-ratingpill { background: #eef2ff; border: 1px solid #c7d2fe; color: #1e3a8a; border-radius: 999px; padding: 4px 10px; font-weight: 700; white-space: nowrap; }
.th-rating--placeholder { visibility: hidden; min-width: 64px; height: 1em; display: inline-block; }
.th-like { width: 38px; height: 38px; border-radius: 10px; border: 1px solid #d0d7de; background: #fff; display: inline-grid; place-items: center; cursor: pointer; padding: 0; line-height: 0; }
.th-like.is-liked { background: #ffe6ea; border-color: #f5a1b3; }

/* Empty */
.th-empty { padding: 18px; border: 1px dashed #d0d7de; border-radius: 12px; color: #666; text-align: center; }

/* Plan badge & highlight */
.th-plan-badge { position: absolute; top: -12px; right: 18px; display: inline-block; padding: 6px 12px; border-radius: 999px; font-weight: 800; font-size: 12px; line-height: 1; color: #fff; background: #64748b; border: 0; z-index: 3; box-shadow: 0 4px 10px rgba(0,0,0,.08); }
.th-plan--boost { background: #16a34a; } .th-plan--pro { background: #2563eb; } .th-plan--free { background: #475569; }
.th-ui-select { top: 38px !important; }
.th-card--highlight { background: #f0f6ff; box-shadow: 0 0 0 1px #dbe7ff, 0 10px 20px rgba(0,0,0,0.04); }
@media (max-width: 480px) {
  .th-plan-badge { top: -10px; right: 14px; padding: 5px 10px; font-size: 11px; }
  .th-ui-select { top: 36px !important; }
}

/* Harmonize Towns UI labels (updated) */
.th-town-filter label { font-weight: 700; margin: 2px 0 4px 6px; color: #475569; display: block; }

/* ============================================================
   OVERRIDES — unified green selects + layout tweaks
   ============================================================ */

/* Province & Region (any native select inside Towns UI block) */
.th-bar .th-townui select {
  background: var(--th-green-bg) !important;
  border: 1px solid var(--th-green-bd) !important;
  box-shadow: var(--th-green-shadow) !important;
  border-radius: 12px !important;
  padding: 10px 36px 10px 12px !important;
  min-height: 42px !important;
}
/* Focus */
.th-bar .th-townui select:focus {
  outline: none !important;
  border-color: var(--th-green-focus-bd) !important;
  box-shadow: var(--th-green-ring), var(--th-green-shadow) !important;
}

/* Town (Select2) — only within Towns UI */
.th-bar .th-townui .select2-container--default .select2-selection--single {
  background: var(--th-green-bg) !important;
  border: 1px solid var(--th-green-bd) !important;
  box-shadow: var(--th-green-shadow) !important;
  border-radius: 12px !important;
  min-height: 42px !important;
  padding: 6px 10px !important;
}
.th-bar .th-townui .select2-container--open .select2-selection--single {
  border-color: var(--th-green-focus-bd) !important;
  box-shadow: var(--th-green-ring), var(--th-green-shadow) !important;
}

/* Remove category nudge (for even layout) */
.th-bar-left .th-lab:has(#thTrade) { margin-left: 0 !important; }
.th-cat-lab { margin-left: 0 !important; }

/* Extra breathing room above Get Quotes bar */
.th-quote-bar { margin-top: 14px !important; }

/* Keep Get Quotes button on the right */
.th-quote-bar__text { flex: 1 !important; }
.th-quote-bar__actions { justify-content: flex-end !important; flex: 0 0 auto !important; }

/* Responsiveness for filters (new) */
@media (max-width: 768px) {
  .th-bar-left {
    flex-direction: column;
    align-items: stretch;
    gap: 15px;
  }
  .th-bar-left .th-lab,
  .th-bar-left .th-townui {
    width: 100%;
  }
  .th-reset-btn {
    width: 100%;
    text-align: center;
  }
}

/* ============================================================
   Helper classes added by JS (work even if markup changes)
   ============================================================ */
.th-green-select {
  background: var(--th-green-bg) !important;
  border: 1px solid var(--th-green-bd) !important;
  box-shadow: var(--th-green-shadow) !important;
  border-radius: 12px !important;
  padding: 10px 36px 10px 12px !important;
  min-height: 42px !important;
}
.th-green-select:focus {
  outline: none !important;
  border-color: var(--th-green-focus-bd) !important;
  box-shadow: var(--th-green-ring), var(--th-green-shadow) !important;
}
.th-green-select2 .select2-selection--single {
  background: var(--th-green-bg) !important;
  border: 1px solid var(--th-green-bd) !important;
  box-shadow: var(--th-green-shadow) !important;
  border-radius: 12px !important;
  min-height: 42px !important;
  padding: 6px 10px !important;
}
.th-green-select2.select2-container--open .select2-selection--single {
  border-color: var(--th-green-focus-bd) !important;
  box-shadow: var(--th-green-ring), var(--th-green-shadow) !important;
}
