/* SLBI Quadplex Hunt — Sidebar styles  [Agent 3 Sidebar]
 *
 * Decisions locked in PHASE_1_ANSWERS_FOR_SIGNOFF.md:
 *   - 400px desktop, full-width below 720px
 *   - System font + tabular-nums (NOT SF Mono)
 *   - Tier tints: TIER 1 #dcfce7 / 1B #fef9c3 / 2 #fef3c7 / 4 #fed7aa / 5 #f3f4f6 / null #f3f4f6
 *   - Status pill: ACTIVE #2563EB (blue), SOLD_12MO #6b7280 (gray)
 *   - Bucket colors: TM #3b82f6 / TD #10b981 / WD #f59e0b
 *   - 120ms opacity fade on content swap
 *   - "Neighborhood Report" header bar matching Seekly .lot-drawer-head convention
 */

/* ---------------------------------------------------------------------------
 * Host + root
 * --------------------------------------------------------------------------- */

.slbi-sb-host {
  width: 400px;
  flex-shrink: 0;
}

.slbi-sb {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 400px;
  height: 100%;
  min-height: 100%;
  background: #fff;
  border-left: 1px solid #E5E7EB;
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color: #111827;
  font-size: 13px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------------------------------------------------------------------------
 * Header bar (matches Seekly .lot-drawer-head convention)
 * --------------------------------------------------------------------------- */

.slbi-sb-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid #F3F4F6;
  flex-shrink: 0;
  background: #fff;
}

.slbi-sb-head-title {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
  letter-spacing: -0.005em;
}

/* ---------------------------------------------------------------------------
 * Body — scrollable, fade-friendly
 * --------------------------------------------------------------------------- */

.slbi-sb-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  /* opacity controlled by JS for content fade */
}

/* ---------------------------------------------------------------------------
 * Empty state / loading / error
 * --------------------------------------------------------------------------- */

.slbi-sb-placeholder {
  padding: 40px 24px;
  text-align: center;
  color: #6b7280;
}
.slbi-sb-placeholder-title {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 4px;
}
.slbi-sb-placeholder-sub {
  font-size: 12px;
  color: #9ca3af;
}

.slbi-sb-loading {
  padding: 32px 24px;
  text-align: center;
  color: #6b7280;
}
.slbi-sb-loading-spin {
  width: 24px; height: 24px;
  margin: 0 auto 12px;
  border: 2px solid #e5e7eb;
  border-top-color: #2563EB;
  border-radius: 50%;
  animation: slbi-sb-spin 0.8s linear infinite;
}
@keyframes slbi-sb-spin {
  to { transform: rotate(360deg); }
}
.slbi-sb-loading-text { font-size: 12px; }

.slbi-sb-error {
  margin: 16px 18px;
  padding: 12px 14px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  border-radius: 6px;
  color: #991b1b;
}
.slbi-sb-error-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.slbi-sb-error-sub   { font-size: 11px; color: #b91c1c; }

/* ---------------------------------------------------------------------------
 * Tier banner (top section, color-tinted by target_tier)
 * --------------------------------------------------------------------------- */

.slbi-sb-tier {
  padding: 16px 18px 14px;
  border-bottom: 1px solid #e5e7eb;
}

.slbi-sb-nbhd {
  font-size: 20px;
  font-weight: 700;
  color: #111827;
  letter-spacing: -0.015em;
  line-height: 1.2;
  margin-bottom: 4px;
}

.slbi-sb-tier-line {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.slbi-sb-path {
  font-size: 12px;
  color: #4b5563;
  line-height: 1.35;
}

/* ---------------------------------------------------------------------------
 * Section blocks
 * --------------------------------------------------------------------------- */

.slbi-sb-sec {
  padding: 12px 18px;
  border-bottom: 1px solid #f3f4f6;
}
.slbi-sb-sec:last-child { border-bottom: 0; }

.slbi-sb-sec-title {
  font-size: 11px;
  font-weight: 700;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
/* v2.1: section title bar layout (title left, View All button right) */
.slbi-sb-sec-title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.slbi-sb-sec-title-bar .slbi-sb-sec-title {
  margin-bottom: 0;
}
.slbi-sb-view-all {
  border: none;
  background: transparent;
  color: #2563EB;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: inherit;
  transition: background 0.12s ease;
}
.slbi-sb-view-all:hover {
  background: #eff6ff;
}
.slbi-sb-top-list-expanded {
  max-height: 60vh;
  overflow-y: auto;
}

/* ---------------------------------------------------------------------------
 * Totals tiles + status chips
 * --------------------------------------------------------------------------- */

.slbi-sb-total {
  font-size: 13px;
  color: #374151;
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}
.slbi-sb-total b {
  color: #111827;
  font-weight: 700;
}

.slbi-sb-status-line {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}
.slbi-sb-status-line:last-child { margin-bottom: 0; }

.slbi-sb-status-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  border: 1px solid transparent;
}
.slbi-sb-status-chip.slbi-sb-active {
  background: #dbeafe;
  color: #1e40af;
  border-color: #bfdbfe;
}
.slbi-sb-status-chip.slbi-sb-sold {
  background: #f3f4f6;
  color: #374151;
  border-color: #e5e7eb;
}
.slbi-sb-status-chip.slbi-sb-offmkt {
  background: #f9fafb;
  color: #6b7280;
  border-color: #e5e7eb;
}
/* v2.27: pending chip for the Selected Area breakdown line */
.slbi-sb-status-chip.slbi-sb-pending {
  background: #fef3c7;
  color: #92400e;
  border-color: #fde68a;
}

/* ---------------------------------------------------------------------------
 * v2.27: Selected Area mode (nbhd click -> tag list of MLS listings)
 * --------------------------------------------------------------------------- */

.slbi-sb-selarea-headrow {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.slbi-sb-selarea-clear {
  border: 1px solid #cbd5f5;
  background: #fff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  flex-shrink: 0;
  transition: background 100ms ease-out, border-color 100ms ease-out;
}
.slbi-sb-selarea-clear:hover {
  background: #eff6ff;
  border-color: #2563EB;
}

.slbi-sb-selarea-stats {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.slbi-sb-selarea-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 -8px;
}

.slbi-sb-selarea-tag {
  display: grid;
  grid-template-columns: 10px auto 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 80ms ease-out;
  border: 1px solid transparent;
}
.slbi-sb-selarea-tag:hover {
  background: #f8fafc;
  border-color: #e5e7eb;
}

.slbi-sb-selarea-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid #1f2937;
}

.slbi-sb-selarea-pill {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  white-space: nowrap;
  text-transform: uppercase;
}

.slbi-sb-selarea-addr {
  font-size: 12.5px;
  color: #1f2937;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.slbi-sb-selarea-price {
  font-size: 12.5px;
  font-weight: 700;
  color: #111827;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  text-align: right;
  white-space: nowrap;
}

/* v2.28: 2-tier (on-hunt vs off-hunt) mini-legend under the selarea header */
.slbi-sb-selarea-legend {
  margin-top: 6px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 10.5px;
  color: #4b5563;
  letter-spacing: 0.02em;
}
.slbi-sb-selarea-legend-grp {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.slbi-sb-legend-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid rgba(31, 41, 55, 0.2);
  margin-left: 2px;
}
/* v2.29: dim cumulative totals in the header counter when a hunt toggle is
   active so the user can see "Showing 25 + 30 (of 56/74)" at a glance. */
.slbi-sb-selarea-totalhint {
  color: #94a3b8;
  font-weight: 500;
  font-size: 11px;
  margin-left: 4px;
}

/* v2.28: small uppercase off-hunt flag inside the address line */
.slbi-sb-selarea-offflag {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 1px 4px;
  margin-left: 4px;
  border-radius: 3px;
  background: #e2e8f0;
  color: #475569;
  vertical-align: middle;
}

/* ---------------------------------------------------------------------------
 * v2.30: multi-nbhd Selected Area accordion
 * --------------------------------------------------------------------------- */

/* The blue tier header carries the aggregate counter + Clear All button. */
.slbi-sb-selarea-tier {
  background: #eff6ff !important;
}
.slbi-sb-selarea-counter {
  flex: 1 1 auto;
  font-size: 13.5px;
  font-weight: 600;
  color: #1e293b;
  letter-spacing: 0.01em;
  line-height: 1.4;
}

/* Container for the accordion sections (one per selected nbhd) */
.slbi-sb-selarea-sec {
  padding: 0;
}

.slbi-sb-accordion {
  border-bottom: 1px solid #e5e7eb;
}
.slbi-sb-accordion:last-child {
  border-bottom: 0;
}

.slbi-sb-accordion-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  cursor: pointer;
  background: #f8fafc;
  transition: background 80ms ease-out;
  user-select: none;
}
.slbi-sb-accordion-head:hover {
  background: #f1f5f9;
}

.slbi-sb-accordion.is-open .slbi-sb-accordion-head {
  background: #ffffff;
  border-bottom: 1px solid #f3f4f6;
}

.slbi-sb-accordion-caret {
  display: inline-block;
  width: 12px;
  font-size: 11px;
  color: #475569;
  text-align: center;
  flex-shrink: 0;
}

.slbi-sb-accordion-title {
  flex: 1 1 auto;
  font-size: 13.5px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slbi-sb-accordion-count {
  font-size: 11.5px;
  font-weight: 600;
  color: #64748b;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
}

.slbi-sb-accordion-body {
  padding: 6px 8px 10px;
  background: #ffffff;
}
.slbi-sb-accordion-body .slbi-sb-selarea-list {
  margin: 0;
}

/* ---------------------------------------------------------------------------
 * Generic stat row (label / num / pct / bar)
 * --------------------------------------------------------------------------- */

.slbi-sb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 12.5px;
  color: #374151;
  line-height: 1.35;
}

.slbi-sb-row-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.slbi-sb-row-label {
  flex: 1;
  color: #4b5563;
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slbi-sb-row-num {
  font-weight: 600;
  color: #111827;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  text-align: right;
  min-width: 48px;
}

.slbi-sb-row-pct {
  color: #6b7280;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  min-width: 56px;
  text-align: right;
}

.slbi-sb-row-bar {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: #9ca3af;
  letter-spacing: 0.5px;
  min-width: 88px;
  text-align: right;
  /* 60% opacity look via gray color */
  opacity: 0.85;
}

/* ---------------------------------------------------------------------------
 * Top 5 lists (clickable rows)
 * --------------------------------------------------------------------------- */

.slbi-sb-top-list {
  display: flex;
  flex-direction: column;
  margin: 0 -18px;
}

.slbi-sb-top-row {
  display: grid;
  grid-template-columns: 1fr auto 16px;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  cursor: pointer;
  border-bottom: 1px solid #f9fafb;
  transition: background 100ms ease-out;
}
.slbi-sb-top-row:hover {
  background: #f3f4f6;
}
.slbi-sb-top-row:last-child {
  border-bottom: 0;
}

.slbi-sb-top-addr {
  font-size: 12.5px;
  font-weight: 600;
  color: #1f2937;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slbi-sb-top-meta {
  font-size: 11.5px;
  color: #6b7280;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum';
  white-space: nowrap;
}

.slbi-sb-top-arrow {
  color: #9ca3af;
  font-size: 16px;
  line-height: 1;
  text-align: right;
}
.slbi-sb-top-row:hover .slbi-sb-top-arrow {
  color: #2563EB;
}

.slbi-sb-empty {
  font-size: 12px;
  color: #9ca3af;
  font-style: italic;
  padding: 4px 0;
}

/* ---------------------------------------------------------------------------
 * Parcel detail view
 * --------------------------------------------------------------------------- */

.slbi-sb-parcel-head {
  background: #fafafa;
  padding-top: 16px;
  padding-bottom: 14px;
}

.slbi-sb-parcel-addr {
  font-size: 17px;
  font-weight: 700;
  color: #111827;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin-bottom: 6px;
}

.slbi-sb-parcel-sub {
  font-size: 12px;
  color: #6b7280;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
  align-items: center;
  line-height: 1.5;
}

/* Status pill inside parcel detail */
.slbi-sb-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
}
.slbi-sb-pill.slbi-sb-pill-off {
  background: #f3f4f6;
  color: #6b7280;
}

/* Bucket tag chip (parcel detail subline) */
.slbi-sb-bucket-tag {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

/* Zone code chip — mono via tabular-nums + monospace fallback only here */
.slbi-sb-zone-chip {
  display: inline-block;
  padding: 1px 6px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  color: #374151;
  letter-spacing: 0;
}

.slbi-sb-apn {
  font-family: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  font-size: 11.5px;
  font-weight: 500;
  color: #4b5563;
}

/* Back-to-neighborhood link */
.slbi-sb-back-wrap {
  background: #fafafa;
  padding-top: 10px;
  padding-bottom: 10px;
}
.slbi-sb-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #2563EB;
  text-decoration: none;
  cursor: pointer;
}
.slbi-sb-back:hover {
  color: #1d4ed8;
  text-decoration: underline;
}

/* ---------------------------------------------------------------------------
 * Responsive — Decision 6 + 7 (720px breakpoint, full-width stack below map)
 * --------------------------------------------------------------------------- */

@media (max-width: 720px) {
  .slbi-sb-host {
    width: 100%;
    max-width: 100%;
  }
  .slbi-sb {
    width: 100%;
    max-width: 100%;
    border-left: 0;
    border-top: 1px solid #E5E7EB;
    box-shadow: none;
  }
  .slbi-sb-head {
    padding: 12px 14px;
  }
  .slbi-sb-tier {
    padding: 14px 14px 12px;
  }
  .slbi-sb-sec {
    padding: 12px 14px;
  }
  .slbi-sb-top-list {
    margin: 0 -14px;
  }
  .slbi-sb-top-row {
    padding: 8px 14px;
  }
  .slbi-sb-nbhd {
    font-size: 18px;
  }
  .slbi-sb-parcel-addr {
    font-size: 16px;
  }
  .slbi-sb-row-bar {
    /* On mobile, hide bars to save horizontal space — numbers still right-aligned */
    display: none;
  }
}
