/* ═══════════════════════════════════════════════════════════════════════════
   PropertyDesk — Buildings Listing Page   (pd-bl-*)
   Visual design matches system: pdc-tbl / pdc-fsel / pd-ul-* patterns
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Hide default Views output on /buildings ──────────────────────────────── */
.path--buildings .view-id-buildings_view,
.path--buildings .view-id-buildings { display: none !important; }

/* ── Wrapper ──────────────────────────────────────────────────────────────── */
.pd-bl-wrap { max-width: 100%; margin: 0 0 40px; font-family: inherit; }

/* ── Sub-header ───────────────────────────────────────────────────────────── */
.pd-bl-subhdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 8px;
}
.pd-bl-subhdr__meta { font-size: 13px; color: #64748b; font-weight: 500; }
.pd-bl-subhdr__actions { display: flex; gap: 8px; align-items: center; }

/* Export buttons */
.pd-bl-btn-csv {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 14px; background: #f0faf4; color: #166534 !important;
  border: 1px solid #bbf7d0; border-radius: 5px; font-size: 12px; font-weight: 500;
  text-decoration: none !important; white-space: nowrap; transition: background .15s;
}
.pd-bl-btn-csv:hover { background: #dcfce7; border-color: #86efac; }
.pd-bl-btn-pdf {
  display: inline-flex; align-items: center; gap: 6px;
  background: #2e8b57; color: #fff !important;
  padding: 7px 16px; border-radius: 6px; font-size: 13px; font-weight: 500;
  text-decoration: none !important; white-space: nowrap; transition: background .15s;
}
.pd-bl-btn-pdf:hover { background: #267a4c; color: #fff !important; }

/* ── KPI strip ────────────────────────────────────────────────────────────── */
.pd-bl-kpi-row {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 12px; margin-bottom: 18px;
}
@media (max-width: 1000px) { .pd-bl-kpi-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 540px)  { .pd-bl-kpi-row { grid-template-columns: 1fr; } }

.pd-bl-kpi-card {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
  padding: 16px 18px;
  /* border-top comes from inline style on the element */
}
.pd-bl-kpi-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: #64748b; margin-bottom: 6px;
}
.pd-bl-kpi-value {
  font-size: 22px; font-weight: 700; color: #0f172a;
  line-height: 1; font-variant-numeric: tabular-nums;
}
.pd-bl-kpi-sub { font-size: 11px; color: #94a3b8; margin-top: 4px; }

/* ── Intelligence row ─────────────────────────────────────────────────────── */
.pd-bl-intel {
  display: grid; grid-template-columns: 3fr 2fr;
  gap: 14px; margin-bottom: 18px; align-items: start;
}
@media (max-width: 900px) { .pd-bl-intel { grid-template-columns: 1fr; } }

.pd-bl-intel__panel--left,
.pd-bl-intel__panel--right {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; overflow: hidden;
}
.pd-bl-panel-hdr {
  padding: 8px 12px; background: #f8fafc; border-bottom: 1px solid #e2e8f0;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: #475569;
  display: flex; align-items: center; gap: 6px;
}
.pd-bl-panel-hdr__icon { font-size: 14px; }
.pd-bl-panel-hdr__sub  { font-weight: 400; color: #94a3b8; text-transform: none; font-size: 11px; }

.pd-bl-pulse-empty {
  padding: 12px 14px; font-size: 12px; color: #166534;
  background: #f0fdf4; margin: 10px 12px; border-radius: 5px;
}

/* Risk list (left panel) */
.pd-bl-risk-list { list-style: none; margin: 0; padding: 0; }
.pd-bl-risk-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 6px 12px; border-bottom: 1px solid #f3f4f6;
}
.pd-bl-risk-item:last-child { border-bottom: none; }
.pd-bl-risk-icon  { flex-shrink: 0; font-size: 13px; line-height: 1.5; }
.pd-bl-risk-body  { flex: 1; min-width: 0; }
.pd-bl-risk-name  {
  color: #0f3460; font-weight: 600; font-size: 13px; text-decoration: none;
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pd-bl-risk-name:hover { text-decoration: underline; }
.pd-bl-risk-em   { color: #94a3b8; font-size: 11px; }
.pd-bl-risk-meta { font-size: 11px; color: #ef4444; white-space: nowrap; margin-top: 2px; }

.pd-bl-panel-footer { padding: 8px 14px; border-top: 1px solid #f3f4f6; background: #f8fafc; }
.pd-bl-view-all {
  font-size: 12px; color: #2e8b57 !important;
  text-decoration: none !important; font-weight: 600;
}
.pd-bl-view-all:hover { text-decoration: underline !important; }

/* Portfolio Health stats grid (right panel) — compact */
.pd-bl-health-grid { display: grid; grid-template-columns: 1fr 1fr; }
.pd-bl-health-stat {
  text-align: center; padding: 12px 8px;
  border-right: 1px solid #f3f4f6; border-bottom: 1px solid #f3f4f6;
}
.pd-bl-health-stat:nth-child(2n)    { border-right: none; }
.pd-bl-health-stat:nth-child(3),
.pd-bl-health-stat:nth-child(4)     { border-bottom: none; }
.pd-bl-health-val   { font-size: 18px; font-weight: 700; color: #0f172a; line-height: 1; }
.pd-bl-health-label { font-size: 9px; color: #64748b; text-transform: uppercase; letter-spacing: .04em; margin-top: 3px; }
.pd-bl-health-sub   { font-size: 9px; color: #94a3b8; margin-top: 1px; }

/* ── Occupancy Distribution tier list (right panel) ──────────────────────── */
.pd-bl-tier-list { list-style: none; margin: 0; padding: 0; }

.pd-bl-tier-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 12px; border-bottom: 1px solid #f3f4f6;
  cursor: pointer; transition: background .1s;
}
.pd-bl-tier-row:last-child { border-bottom: none; }
.pd-bl-tier-row:hover { background: #f0fdf4; }

.pd-bl-tier-label {
  width: 120px; flex-shrink: 0;
  font-size: 12px; color: #374151; white-space: nowrap;
}
.pd-bl-tier-bar-wrap {
  flex: 1; height: 10px; background: #f1f5f9;
  border-radius: 4px; overflow: hidden;
}
.pd-bl-tier-bar {
  height: 100%; border-radius: 4px;
  transition: width .3s ease;
  min-width: 2px; /* always show a sliver even for 0 */
}
.pd-bl-tier-count {
  width: 22px; flex-shrink: 0; text-align: right;
  font-size: 12px; font-weight: 700; color: #374151;
}

/* ── Main panel ───────────────────────────────────────────────────────────── */
.pd-bl-main { border: 1px solid #dee2e6; border-radius: 6px; overflow: hidden; background: #fff; }

/* ── Emirate tab bar — exactly like pd-ul-tabs (units page style) ─────────── */
.pd-bl-emirate-bar {
  display: flex; gap: 0;
  border-bottom: 1px solid #dee2e6;
  background: #f1f3f5;
  /* no padding — pills carry their own padding */
}

.pd-bl-em-pill {
  flex: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 12px 16px;
  border: none; border-bottom: 3px solid transparent;
  border-right: 1px solid #dee2e6; border-radius: 0;
  background: #f1f3f5; color: #2e8b57;
  font-size: 13px; font-weight: 500; font-family: inherit;
  cursor: pointer; white-space: nowrap;
  transition: background .12s, color .12s;
}
.pd-bl-em-pill:last-child { border-right: none; }
.pd-bl-em-pill:hover { color: #267a4c; background: #e9ecef; }
.pd-bl-em-pill--active {
  color: #2e8b57 !important; background: #fff !important;
  border-bottom-color: #2e8b57 !important; font-weight: 700 !important;
}
.pd-bl-em-count {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
  background: #e2e8f0; color: #475569;
}
.pd-bl-em-pill--active .pd-bl-em-count { background: #dcfce7; color: #166534; }

/* ── Filter bar ───────────────────────────────────────────────────────────── */
.pd-bl-filters {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
  padding: 12px 14px; background: #f8fafc; border-bottom: 1px solid #e5e7eb;
}
.pd-bl-fg { display: flex; flex-direction: column; gap: 3px; }
.pd-bl-fg--reset { min-width: auto; }
.pd-bl-filter-label { font-size: 11px; color: #6b7280; font-weight: 500; }

/* Search input wrapper — autocomplete positioning */
.pd-bl-search-wrap { position: relative; }
.pd-bl-search {
  padding: 7px 10px; border: 1px solid #d1d5db; border-radius: 5px;
  font-size: 13px; background: #fff; color: #374151; min-width: 200px;
}
.pd-bl-search:focus {
  outline: none; border-color: #2e8b57; box-shadow: 0 0 0 2px rgba(46,139,87,.12);
}

/* Autocomplete dropdown */
.pd-bl-ac-list {
  display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 1000;
  background: #fff; border: 1px solid #d1d5db; border-top: none;
  border-radius: 0 0 5px 5px; max-height: 200px; overflow-y: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  list-style: none; margin: 0; padding: 4px 0;
}
.pd-bl-ac-list.pd-bl-ac-open { display: block; }
.pd-bl-ac-list li {
  padding: 8px 10px; font-size: 13px; color: #374151;
  cursor: pointer; border-bottom: 1px solid #f3f4f6;
}
.pd-bl-ac-list li:last-child { border-bottom: none; }
.pd-bl-ac-list li:hover,
.pd-bl-ac-list li.pd-bl-ac-active { background: #f0fdf4; color: #2e8b57; }

/* Filter selects */
.pd-bl-fsel {
  padding: 7px 10px; border: 1px solid #d1d5db; border-radius: 5px;
  font-size: 13px; background: #fff; color: #374151; min-width: 110px;
}
.pd-bl-fsel:focus {
  outline: none; border-color: #2e8b57; box-shadow: 0 0 0 2px rgba(46,139,87,.12);
}

/* Reset button */
.pd-bl-reset-btn {
  display: none; padding: 7px 14px; border-radius: 5px; font-size: 13px;
  font-weight: 500; cursor: pointer; border: 1px solid #d1d5db;
  background: #fff; color: #374151; white-space: nowrap; align-self: flex-end;
}
.pd-bl-reset-btn:hover { background: #f3f4f6; }

/* ── Active filter chips ──────────────────────────────────────────────────── */
.pd-bl-chips {
  display: none; flex-wrap: wrap; gap: 6px;
  padding: 8px 14px; background: #f0fdf4; border-bottom: 1px solid #bbf7d0;
}
.pd-bl-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; background: #dcfce7; color: #166534;
  border: 1px solid #bbf7d0; border-radius: 20px;
  font-size: 12px; font-weight: 500;
}
/* chip remove — JS generates with class pd-bl-chip__rm */
.pd-bl-chip__rm {
  background: none; border: none; cursor: pointer;
  color: #15803d; font-size: 14px; line-height: 1; padding: 0 1px;
}
.pd-bl-chip__rm:hover { color: #dc2626; }

/* ── Table ────────────────────────────────────────────────────────────────── */
.pd-bl-tbl-wrap { overflow-x: auto; }
.pd-bl-tbl { width: 100%; border-collapse: collapse; font-size: 14px; line-height: 1.5; }

.pd-bl-tbl thead th {
  background: #2e8b57; color: #fff; padding: 10px 12px;
  text-align: left; font-weight: 600; font-size: 13px;
  text-transform: uppercase; letter-spacing: .5px; white-space: nowrap;
}
.pd-bl-th[data-col] { cursor: pointer; user-select: none; }
.pd-bl-th[data-col]:hover { background: #267a4c; }
.pd-bl-th--sorted   { background: #1f7248 !important; }
.pd-bl-sort-arrow   { font-size: 10px; opacity: .7; margin-left: 3px; }

.pd-bl-tbl tbody td {
  padding: 11px 12px; border-bottom: 1px solid #e5e7eb;
  vertical-align: middle; color: #374151; font-size: 14px;
}
.pd-bl-tbl tbody tr:nth-child(odd) td  { background: #ffffff !important; }
.pd-bl-tbl tbody tr:nth-child(even) td { background: #f0f9f3 !important; }
.pd-bl-tbl tbody tr:last-child td      { border-bottom: none; }
.pd-bl-tbl tbody tr:hover td           { background: #e2f0e6 !important; }
.pd-bl-tbl tbody tr[data-href]         { cursor: pointer; }
.pd-bl-tbl tbody td a { color: #2e8b57; text-decoration: none; }
.pd-bl-tbl tbody td a:hover { text-decoration: underline; }

/* Row left-border risk tints */
.pd-bl-tbl tbody tr { border-left: 3px solid transparent; }
.pd-bl-tr--high    { border-left-color: #ef4444 !important; }
.pd-bl-tr--medium  { border-left-color: #f59e0b !important; }
.pd-bl-tr--healthy { border-left-color: #2e8b57 !important; }
.pd-bl-tr--none    { border-left-color: #e2e8f0 !important; }

/* Building name + code */
.pd-bl-name-link { color: #0f3460; font-weight: 600; text-decoration: none; }
.pd-bl-name-link:hover { text-decoration: underline; color: #0f3460 !important; }
.pd-bl-code { font-size: 11px; color: #94a3b8; font-weight: 400; margin-left: 4px; }

/* Landlord link */
.pd-bl-landlord-link { color: #2e8b57; font-size: 13px; text-decoration: none; }
.pd-bl-landlord-link:hover { text-decoration: underline; }

/* Cell alignment */
.pd-bl-tbl tbody td.pd-bl-td--num { text-align: center; }
.pd-bl-tbl tbody td.pd-bl-td--loc { max-width: 160px; }
.pd-bl-tbl tbody td.pd-bl-td--occ { min-width: 120px; }

/* Status pills */
.pd-bl-pill {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 4px; font-size: 11px; font-weight: 600;
  text-transform: capitalize; white-space: nowrap;
}
.pd-bl-pill--active   { background: #dcfce7; color: #166534; }
.pd-bl-pill--inactive { background: #f3f4f6; color: #6b7280; }

/* Cheque health pills */
.pd-bl-ok-pill {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 4px;
  font-size: 11px; font-weight: 600;
  background: #dcfce7; color: #166534;
}
.pd-bl-chq-pill {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 4px;
  font-size: 11px; font-weight: 600;
  background: #fee2e2; color: #991b1b;
}

/* No units placeholder */
.pd-bl-no-units { font-size: 12px; color: #94a3b8; font-style: italic; }

/* Occupancy bar */
.pd-bl-occ-wrap { display: flex; align-items: center; gap: 7px; }
.pd-bl-occ-bar  {
  flex: 1; height: 8px; background: #e5e7eb;
  border-radius: 4px; overflow: hidden; min-width: 50px;
}
.pd-bl-occ-fill  { display: block; height: 100%; border-radius: 4px; }
.pd-bl-occ--good { background: #2e8b57; }
.pd-bl-occ--mid  { background: #f59e0b; }
.pd-bl-occ--low  { background: #ef4444; }
.pd-bl-occ-num   { font-size: 11px; color: #64748b; white-space: nowrap; min-width: 28px; text-align: right; }

/* Empty / Loading */
.pd-bl-empty   { padding: 28px; text-align: center; color: #6b7280; font-size: 14px; background: #f9fafb; }
.pd-bl-loading { padding: 28px; text-align: center; color: #9ca3af; font-size: 13px; }

/* ── Pager ────────────────────────────────────────────────────────────────── */
.pd-bl-pager {
  display: flex; align-items: center; gap: 4px;
  padding: 10px 14px; border-top: 1px solid #e5e7eb;
  flex-wrap: wrap;
}
/* Info text pushed to the right automatically */
.pd-bl-pager-info { margin-left: auto; font-size: 13px; color: #6b7280; font-weight: 500; }
.pd-bl-pg-btn {
  min-width: 34px; height: 34px; display: inline-flex; align-items: center;
  justify-content: center; border-radius: 5px; font-size: 13px; font-weight: 500;
  cursor: pointer; border: 1px solid #d1d5db; background: #fff;
  color: #374151; font-family: inherit;
}
.pd-bl-pg-btn:hover:not(.pd-bl-pg-btn--active):not(:disabled) { background: #f3f4f6; }
.pd-bl-pg-btn--active { background: #2e8b57 !important; color: #fff !important; border-color: #2e8b57 !important; }
.pd-bl-pg-btn:disabled { opacity: .35; cursor: not-allowed; }

/* Count line below pager */
.pd-bl-count { font-size: 11px; color: #94a3b8; padding: 0 14px 8px; text-align: right; }

/* ── Mobile ───────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .pd-bl-subhdr  { flex-direction: column; align-items: flex-start; }
  .pd-bl-filters { flex-direction: column; align-items: stretch; }
  .pd-bl-fsel, .pd-bl-search { min-width: unset; width: 100%; }
  .pd-bl-pager   { flex-direction: column; }
  .pd-bl-tbl thead th:nth-child(3),
  .pd-bl-tbl tbody td:nth-child(3) { display: none; } /* hide Location on mobile */
}
