/* ==========================================================================
   Contracts Listing Page — pd-cl-*
   Scope: .pd-cl-wrap  (contracts listing, not contract portfolio which uses .pdcp-wrap)
   Mirrors: pd-ov-kpi (KPIs), pd-ov-tbl (table zebra), pdbp-csv-btn / pdlp-pdf-btn (buttons)
   ========================================================================== */

/* Hide default Views / QuickTabs output on /contracts path */
.path--contracts .quicktabs-wrapper,
.path--contracts .block-views-blockcontracts-view-block-1,
.path--contracts .block-views-blockcontracts-view-block-2,
.path--contracts .view-id-contracts_view { display: none !important; }

/* ── Wrap ──────────────────────────────────────────────────────────────────── */
.pd-cl-wrap { font-family: inherit; color: #374151; }

/* ── Sub-header ────────────────────────────────────────────────────────────── */
.pd-cl-subhdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; flex-wrap: wrap; gap: 10px;
}
.pd-cl-subhdr__meta { font-size: 13px; color: #6b7280; }
.pd-cl-subhdr__actions { display: flex; gap: 10px; align-items: center; }

/* Export buttons — exact building-portfolio.css pattern */
.pd-cl-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-cl-btn-csv:hover { background: #dcfce7; border-color: #86efac; }

.pd-cl-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-cl-btn-pdf:hover { background: #267a4c; color: #fff !important; }

/* ── KPI strip ─────────────────────────────────────────────────────────────── */
.pd-cl-kpi-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
/* pd-ov-kpi pattern */
.pd-cl-kpi {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 10px;
  padding: 16px 18px; border-top: 3px solid #cbd5e1;
}
.pd-cl-kpi__lbl {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: #64748b; margin-bottom: 6px;
}
.pd-cl-kpi__val { font-size: 22px; font-weight: 700; color: #0f172a; line-height: 1; font-variant-numeric: tabular-nums; }
.pd-cl-kpi__sub { font-size: 11px; color: #94a3b8; margin-top: 4px; }

/* ── Intelligence row ──────────────────────────────────────────────────────── */
.pd-cl-intel {
  display: grid;
  grid-template-columns: 3fr 2fr;
  gap: 16px;
  margin-bottom: 20px;
}
.pd-cl-intel__panel {
  background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; padding: 16px;
}

.pd-cl-panel-hdr {
  font-size: 12px; font-weight: 700; color: #0f3460; text-transform: uppercase;
  letter-spacing: .05em; margin-bottom: 12px; display: flex; align-items: center; gap: 6px;
}
.pd-cl-panel-hdr__icon { font-size: 14px; }
.pd-cl-panel-footer { margin-top: 10px; border-top: 1px solid #e2e8f0; padding-top: 8px; }
.pd-cl-view-all { font-size: 12px; color: #2e8b57; text-decoration: none; font-weight: 500; }
.pd-cl-view-all:hover { text-decoration: underline; }
.pd-cl-pulse-empty { font-size: 12px; color: #94a3b8; padding: 12px 0; }

/* Urgency list — compact single-line rows */
.pd-cl-urgency-list { list-style: none; margin: 0; padding: 0; }
.pd-cl-urgency-item {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
  padding: 6px 0; border-bottom: 1px solid #f1f5f9;
}
.pd-cl-urgency-item:last-child { border-bottom: none; }
.pd-cl-urgency-icon { font-size: 12px; flex-shrink: 0; }
.pd-cl-urgency-cno  { font-size: 12px; font-weight: 700; color: #0f3460; text-decoration: none; flex-shrink: 0; }
.pd-cl-urgency-cno:hover { text-decoration: underline; }
.pd-cl-urgency-sep  { font-size: 11px; color: #d1d5db; flex-shrink: 0; }
.pd-cl-urgency-meta { font-size: 11px; font-weight: 600; color: #dc2626; flex-shrink: 0; }
.pd-cl-urgency-sub  { font-size: 11px; color: #6b7280; }
.pd-cl-urgency-sub-link { color: #2e8b57; text-decoration: none; }
.pd-cl-urgency-sub-link:hover { text-decoration: underline; }

/* Expiry bands */
.pd-cl-bands { display: flex; flex-direction: column; gap: 10px; }
.pd-cl-band {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-radius: 8px; cursor: pointer; transition: opacity .15s;
  border-left: 4px solid transparent;
}
.pd-cl-band:hover { opacity: .85; }
.pd-cl-band--urgent  { background: #fef3c7; border-left-color: #f59e0b; }
.pd-cl-band--warning { background: #fff7ed; border-left-color: #fb923c; }
.pd-cl-band--notice  { background: #f0fdf4; border-left-color: #4ade80; }
.pd-cl-band__label { font-size: 12px; font-weight: 600; color: #374151; }
.pd-cl-band__count { font-size: 20px; font-weight: 700; color: #0f172a; min-width: 32px; text-align: center; }
.pd-cl-band__rent  { font-size: 11px; color: #6b7280; text-align: right; }

/* ── Main panel ────────────────────────────────────────────────────────────── */
.pd-cl-main {
  background: #fff; border: 1px solid #dee2e6; border-radius: 6px; overflow: hidden;
}
/* Content below tabs needs padding */
.pd-cl-chips,
.pd-cl-tbl-wrap,
.pd-cl-pager,
.pd-cl-count { padding-left: 16px; padding-right: 16px; }
.pd-cl-chips { padding-top: 10px; }
.pd-cl-tbl-wrap { padding-left: 0; padding-right: 0; }
.pd-cl-pager { padding-top: 12px; padding-bottom: 4px; }
.pd-cl-count { padding-bottom: 12px; }

/* Status tabs — exact pd-ul-tab / pdc-tabn pattern from units page */
.pd-cl-tabs {
  display: flex; gap: 0; border-bottom: 1px solid #dee2e6;
  background: #f1f3f5; border-radius: 6px 6px 0 0; overflow: hidden;
  flex-wrap: wrap;
}
.pd-cl-tab {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  padding: 12px 16px; font-size: 13px; font-weight: 500; color: #2e8b57;
  cursor: pointer; border: none; border-bottom: 3px solid transparent;
  border-right: 1px solid #dee2e6; background: #f1f3f5; white-space: nowrap;
  transition: background .12s, color .12s;
}
.pd-cl-tab:last-child { border-right: none; }
.pd-cl-tab:hover { color: #267a4c; background: #e9ecef; }
.pd-cl-tab--active,
.pd-cl-tab--active:hover {
  color: #2e8b57 !important; background: #fff !important;
  border-bottom-color: #2e8b57 !important; font-weight: 700 !important;
}
.pd-cl-tab-badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
  background: #e2e8f0; color: #475569;
}
.pd-cl-tab--active .pd-cl-tab-badge { background: #dcfce7; color: #166534; }
.pd-cl-tab-badge--warn { background: #fef3c7; color: #92400e; }
.pd-cl-tab-badge--red  { background: #fee2e2; color: #991b1b; }

/* Filter bar — pd-ul-fg / pd-ul-filters pattern */
.pd-cl-filters {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  padding: 12px 14px; background: #f8fafc; border-bottom: 1px solid #e5e7eb;
  margin-bottom: 0;
}
/* Filter group: label on top, input below */
.pd-cl-fg { display: flex; flex-direction: column; gap: 3px; }
.pd-cl-filter-label { font-size: 11px; color: #6b7280; font-weight: 500; }
.pd-cl-fg--reset { justify-content: flex-end; }

.pd-cl-search-wrap { position: relative; }
.pd-cl-search {
  padding: 8px 12px; border: 1px solid #d1d5db; border-radius: 6px;
  font-size: 13px; color: #374151; background: #fff; width: 200px;
  outline: none; transition: border-color .15s;
}
.pd-cl-search:focus { border-color: #2e8b57; box-shadow: 0 0 0 2px rgba(46,139,87,.12); }
.pd-cl-fsel {
  padding: 8px 10px; border: 1px solid #d1d5db; border-radius: 6px;
  font-size: 13px; color: #374151; background: #fff; cursor: pointer;
  outline: none; transition: border-color .15s;
}
.pd-cl-fsel:focus { border-color: #2e8b57; }
.pd-cl-reset-btn {
  padding: 7px 14px; background: none; border: 1px solid #d1d5db;
  border-radius: 6px; font-size: 13px; color: #6b7280; cursor: pointer;
  transition: all .15s;
}
.pd-cl-reset-btn:hover { border-color: #9ca3af; color: #374151; }

/* Autocomplete dropdown */
.pd-cl-ac-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 999;
  background: #fff; border: 1px solid #d1d5db; border-top: none;
  border-radius: 0 0 6px 6px; list-style: none; margin: 0; padding: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,.08); display: none;
  max-height: 240px; overflow-y: auto;
}
.pd-cl-ac-list.pd-cl-ac-open { display: block; }
.pd-cl-ac-item {
  padding: 9px 12px; font-size: 13px; color: #374151; cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
}
.pd-cl-ac-item:last-child { border-bottom: none; }
.pd-cl-ac-item:hover { background: #f0f9f4; color: #2e8b57; }

/* Active chips */
.pd-cl-chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 0; margin-bottom: 4px; }
.pd-cl-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: #f0f9f4; color: #166534; border: 1px solid #bbf7d0;
  border-radius: 20px; padding: 3px 10px; font-size: 12px; font-weight: 500;
}
.pd-cl-chip-remove {
  background: none; border: none; color: #166534; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0; margin-left: 2px;
}

/* ── Table ─────────────────────────────────────────────────────────────────── */
.pd-cl-tbl-wrap { overflow-x: auto; }
.pd-cl-tbl { width: 100%; border-collapse: collapse; min-width: 860px; }

.pd-cl-tbl thead tr { background: #2e8b57; }
.pd-cl-th {
  padding: 10px 12px; color: #fff; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em; text-align: left;
  white-space: nowrap; cursor: pointer; user-select: none;
  border: 1px solid #1f6e44; background: #2e8b57;
}
.pd-cl-th:last-child { cursor: default; } /* Status — not sortable */
.pd-cl-sort-arrow { opacity: .6; font-size: 12px; }
.pd-cl-th--asc  .pd-cl-sort-arrow::before { content: '↑'; }
.pd-cl-th--desc .pd-cl-sort-arrow::before { content: '↓'; }
.pd-cl-th--asc  .pd-cl-sort-arrow,
.pd-cl-th--desc .pd-cl-sort-arrow { opacity: 1; }

/* Zebra — exact pd-ov-tbl pattern */
.pd-cl-tbl tbody td { text-align: left; }
.pd-cl-tbl tbody tr:nth-child(odd) td  { background: #ffffff !important; }
.pd-cl-tbl tbody tr:nth-child(even) td { background: #f0f9f3 !important; }
.pd-cl-tbl tbody tr:last-child td  { border-bottom: none; }
.pd-cl-tbl tbody tr:hover td       { background: #e2f0e6 !important; }

/* Row status left borders (urgency overlay) */
.pd-cl-tr--expired td:first-child { border-left: 3px solid #dc2626 !important; }
.pd-cl-tr--urgent  td:first-child { border-left: 3px solid #f59e0b !important; }
.pd-cl-tr--warning td:first-child { border-left: 3px solid #fcd34d !important; }
.pd-cl-tr--active  td:first-child { border-left: 3px solid #86efac !important; }

.pd-cl-tr { cursor: pointer; }
.pd-cl-td {
  padding: 9px 12px; font-size: 13px; color: #374151;
  border-bottom: 1px solid #e2e8f0; vertical-align: middle;
}
.pd-cl-td--days { text-align: left; }
.pd-cl-td--rent { text-align: left; font-variant-numeric: tabular-nums; }
.pd-cl-cno { color: #0f3460; font-weight: 600; text-decoration: none; }
.pd-cl-cno:hover { text-decoration: underline; }
.pd-cl-td a { color: #2e8b57; text-decoration: none; }
.pd-cl-td a:hover { text-decoration: underline; }

/* Status pills */
.pd-cl-pill {
  display: inline-block; padding: 2px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em;
}
.pd-cl-pill--active    { background: #dcfce7; color: #166534; }
.pd-cl-pill--expiring  { background: #fef3c7; color: #92400e; }
.pd-cl-pill--expired   { background: #fee2e2; color: #991b1b; }
.pd-cl-pill--urgent    { background: #fed7aa; color: #7c2d12; }
.pd-cl-pill--warning   { background: #fef3c7; color: #92400e; }
.pd-cl-pill--draft     { background: #f3f4f6; color: #4b5563; }
.pd-cl-pill--cancelled { background: #f3f4f6; color: #6b7280; }

/* Empty state */
.pd-cl-empty {
  text-align: center !important; color: #9ca3af; font-style: italic;
  padding: 32px 0 !important; background: #ffffff !important;
}

/* ── Pager ─────────────────────────────────────────────────────────────────── */
.pd-cl-pager {
  display: flex; align-items: center; gap: 4px; margin-top: 16px; flex-wrap: wrap;
}
.pd-cl-pg-btn {
  padding: 6px 12px; background: #fff; border: 1px solid #d1d5db;
  border-radius: 6px; font-size: 13px; color: #374151; cursor: pointer;
  transition: all .15s;
}
.pd-cl-pg-btn:hover:not(:disabled) { border-color: #2e8b57; color: #2e8b57; }
.pd-cl-pg-btn--active { background: #2e8b57; color: #fff !important; border-color: #2e8b57; }
.pd-cl-pg-btn:disabled { opacity: .4; cursor: default; }
.pd-cl-pager-info { font-size: 12px; color: #6b7280; margin-left: 8px; }

/* Count line */
.pd-cl-count { font-size: 12px; color: #94a3b8; margin-top: 8px; text-align: right; }

/* ── Loading overlay ───────────────────────────────────────────────────────── */
.pd-cl-tbl-wrap.pd-cl-loading { opacity: .5; pointer-events: none; transition: opacity .15s; }

/* ── Mobile ────────────────────────────────────────────────────────────────── */
@media (max-width: 1200px) {
  .pd-cl-kpi-row { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 900px) {
  .pd-cl-intel { grid-template-columns: 1fr; }
  .pd-cl-kpi-row { grid-template-columns: repeat(2, 1fr); }
  /* Hide Building column on small screens (col 4) */
  .pd-cl-tbl thead th:nth-child(4),
  .pd-cl-tbl tbody td:nth-child(4) { display: none; }
}
@media (max-width: 640px) {
  .pd-cl-kpi-row { grid-template-columns: 1fr 1fr; }
  .pd-cl-subhdr { flex-direction: column; align-items: flex-start; }
}
