/**
 * pd_approval — approvals list, review drawer, my requests.
 *
 * Prefix: pd-apv-*
 * Palette: #0f6e56 headings, #1d9e75 accent, 8px radii, matching the rest of
 * the PropertyDesk workspace.
 *
 * The diff is the centrepiece: current in a soft red, proposed in a soft
 * green, so the decision is readable at a glance without reading labels.
 */

.pd-apv-page {
  max-width: 1180px;
  margin: 0 auto;
  padding: 24px 20px 60px;
  color: #1f2a27;
}

/* ── Header ───────────────────────────────────────────────────────────── */
.pd-apv-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.pd-apv-header__title {
  margin: 0 0 4px;
  font-size: 26px;
  font-weight: 700;
  color: #0f6e56;
  letter-spacing: -0.2px;
}

.pd-apv-header__subtitle {
  margin: 0;
  font-size: 14px;
  color: #5b6b66;
}

/* ── KPI strip ────────────────────────────────────────────────────────── */
.pd-apv-kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

.pd-apv-kpi {
  background: #fff;
  border: 1px solid #e3e9e7;
  border-radius: 10px;
  padding: 16px 18px;
  border-top: 3px solid #1d9e75;
}

.pd-apv-kpi--waiting  { border-top-color: #d9922e; }
.pd-apv-kpi--oldest   { border-top-color: #8a94a6; }
.pd-apv-kpi--approved { border-top-color: #1d9e75; }
.pd-apv-kpi--rejected { border-top-color: #c0392b; }

.pd-apv-kpi__value {
  font-size: 24px;
  font-weight: 700;
  color: #0f6e56;
  line-height: 1.2;
}

.pd-apv-kpi__label {
  margin-top: 2px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #6b7a75;
}

/* ── Filters ──────────────────────────────────────────────────────────── */
.pd-apv-filters {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.pd-apv-tabs {
  display: inline-flex;
  background: #eef3f1;
  border-radius: 9px;
  padding: 3px;
  gap: 2px;
}

.pd-apv-tab {
  border: 0;
  background: transparent;
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  color: #5b6b66;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.pd-apv-tab:hover { color: #0f6e56; }

.pd-apv-tab.is-active {
  background: #fff;
  color: #0f6e56;
  box-shadow: 0 1px 3px rgba(15, 110, 86, 0.15);
}

.pd-apv-select {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  background: #fff;
  color: #1f2a27;
}

.pd-apv-select:focus {
  border-color: #1d9e75;
  outline: none;
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.12);
}

/* ── Table ────────────────────────────────────────────────────────────── */
.pd-apv-tablewrap {
  background: #fff;
  border: 1px solid #e3e9e7;
  border-radius: 10px;
  overflow-x: auto;
  transition: opacity 0.15s ease;
}

.pd-apv-tablewrap.is-loading { opacity: 0.5; }

/* This table is styled entirely here and deliberately does NOT carry the
 * global pd-ov-tbl class — that class expects a dark header and forces white
 * header text, which rendered as white-on-grey here. Colours below are
 * written with page-level specificity so a theme update cannot wash them out
 * again. See gotcha A-015. */
table.pd-apv-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  background: #fff;
}

/* !important is deliberate and necessary here. The Aspiration theme forces
 * white header text on tables (it assumes a dark header band). Raising
 * specificity alone did not win — the background applied and the colour did
 * not, which is the signature of an !important rule on the other side.
 * Without this the column labels are white on a light band: invisible. */
.pd-apv-page table.pd-apv-table thead th,
.pd-apv-page table.pd-apv-table thead tr th {
  text-align: start;
  padding: 12px 14px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #55635e !important;
  background: #f2f6f4 !important;
  background-image: none !important;
  text-shadow: none !important;
  border-bottom: 1px solid #e3e9e7;
  white-space: nowrap;
}

.pd-apv-page table.pd-apv-table tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid #f0f4f2;
  vertical-align: middle;
  color: #1f2a27;
}

/* Neutralise inherited link colouring inside cells — the change summary is
 * plain text, and it read as a clickable link. */
.pd-apv-page table.pd-apv-table tbody td a { color: #0f6e56; }

.pd-apv-table tbody tr:last-child td { border-bottom: 0; }

.pd-apv-table tbody tr:nth-child(even) td { background: #fbfdfc; }

.pd-apv-row { cursor: pointer; transition: background 0.12s ease; }
.pd-apv-page .pd-apv-row:hover td { background: #f2f9f5; }

.pd-apv-row:focus-visible {
  outline: 2px solid #1d9e75;
  outline-offset: -2px;
}

.pd-apv-page .pd-apv-cell--record { font-weight: 700; color: #0f6e56; }
.pd-apv-cell--action { text-align: end; white-space: nowrap; }

.pd-apv-age { color: #6b7a75; white-space: nowrap; }
.pd-apv-age--warn { color: #b4791f; font-weight: 600; }
.pd-apv-age--late { color: #c0392b; font-weight: 700; }

/* ── Status pills ─────────────────────────────────────────────────────── */
.pd-apv-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.pd-apv-pill--pending       { background: #fdf3e3; color: #a8701a; }
.pd-apv-pill--approved      { background: #e7f6ef; color: #12744f; }
.pd-apv-pill--rejected      { background: #fdecea; color: #a72d1f; }
.pd-apv-pill--cancelled     { background: #eef0f2; color: #5b6b66; }
.pd-apv-pill--expired       { background: #eef0f2; color: #5b6b66; }
.pd-apv-pill--void_tampered { background: #3a1d1a; color: #ffd9d3; }

.pd-apv-newchip {
  display: inline-block;
  margin-inline-start: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e7f6ef;
  color: #12744f;
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  vertical-align: middle;
}

.pd-apv-diff--create tbody th { width: 40%; }

.pd-apv-reason {
  margin-top: 5px;
  font-size: 12px;
  color: #6b7a75;
  max-width: 320px;
  line-height: 1.45;
}

/* ── Empty state ──────────────────────────────────────────────────────── */
.pd-apv-empty {
  padding: 48px 20px;
  text-align: center;
  color: #6b7a75;
  font-size: 14px;
}

.pd-apv-empty__mark {
  width: 44px;
  height: 44px;
  margin: 0 auto 12px;
  border-radius: 50%;
  background: #e7f6ef;
  color: #1d9e75;
  font-size: 22px;
  line-height: 44px;
}

/* ── Buttons ──────────────────────────────────────────────────────────── */
.pd-apv-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, opacity 0.15s ease;
}

.pd-apv-btn--sm { padding: 6px 12px; font-size: 12.5px; }

.pd-apv-btn--ghost {
  background: #fff;
  border-color: #d1d5db;
  color: #3c4a45;
}

.pd-apv-btn--ghost:hover { border-color: #1d9e75; color: #0f6e56; }

.pd-apv-btn--approve { background: #1d9e75; color: #fff; }
.pd-apv-btn--approve:hover { background: #17805f; }

.pd-apv-btn--reject {
  background: #fff;
  border-color: #e6b3ab;
  color: #a72d1f;
}

.pd-apv-btn--reject:hover { background: #fdecea; }

.pd-apv-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Pager ────────────────────────────────────────────────────────────── */
.pd-apv-pager {
  display: flex;
  gap: 6px;
  padding: 12px 14px;
  border-top: 1px solid #f0f4f2;
  flex-wrap: wrap;
}

.pd-apv-pagebtn {
  min-width: 32px;
  border: 1px solid #e3e9e7;
  background: #fff;
  border-radius: 7px;
  padding: 6px 10px;
  font-size: 12.5px;
  cursor: pointer;
  color: #3c4a45;
}

.pd-apv-pagebtn.is-active {
  background: #0f6e56;
  border-color: #0f6e56;
  color: #fff;
  font-weight: 700;
}

/* ── Review drawer ────────────────────────────────────────────────────── */
body.pd-apv-noscroll { overflow: hidden; }

.pd-apv-drawer {
  position: fixed;
  inset: 0;
  z-index: 1200;
}

.pd-apv-drawer__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(16, 32, 27, 0.45);
}

.pd-apv-drawer__panel {
  position: absolute;
  inset-block: 0;
  inset-inline-end: 0;
  width: min(620px, 100%);
  background: #fff;
  box-shadow: -8px 0 28px rgba(0, 0, 0, 0.18);
  overflow-y: auto;
  padding: 22px 24px 32px;
  animation: pd-apv-slide 0.18s ease-out;
}

.pd-apv-drawer__panel:focus { outline: none; }

@keyframes pd-apv-slide {
  from { transform: translateX(24px); opacity: 0.4; }
  to   { transform: translateX(0); opacity: 1; }
}

.pd-apv-review__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid #eef2f0;
}

.pd-apv-review__title {
  margin: 0 0 3px;
  font-size: 19px;
  font-weight: 700;
  color: #0f6e56;
}

.pd-apv-review__meta {
  margin: 0;
  font-size: 12.5px;
  color: #6b7a75;
}

.pd-apv-review__note {
  margin: 14px 0 0;
  padding: 11px 14px;
  background: #f7faf9;
  border-inline-start: 3px solid #1d9e75;
  border-radius: 6px;
  font-size: 13px;
  color: #3c4a45;
  font-style: italic;
}

.pd-apv-close {
  border: 0;
  background: transparent;
  font-size: 26px;
  line-height: 1;
  color: #8a948f;
  cursor: pointer;
  padding: 0 4px;
}

.pd-apv-close:hover { color: #1f2a27; }

/* ── The diff ─────────────────────────────────────────────────────────── */
table.pd-apv-diff {
  width: 100%;
  border-collapse: collapse;
  margin: 18px 0 6px;
  font-size: 13.5px;
}

.pd-apv-diff thead th {
  text-align: start;
  padding: 8px 10px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: #6b7a75;
  border-bottom: 1px solid #e3e9e7;
}

.pd-apv-diff tbody th {
  text-align: start;
  padding: 11px 10px;
  font-weight: 600;
  color: #3c4a45;
  width: 34%;
  vertical-align: top;
  border-bottom: 1px solid #f2f5f4;
}

.pd-apv-diff tbody td {
  padding: 11px 10px;
  vertical-align: top;
  border-bottom: 1px solid #f2f5f4;
  word-break: break-word;
}

.pd-apv-diff__old {
  background: #fdf2f2;
  border-inline-start: 3px solid #c0392b;
  color: #7d2b20;
  text-decoration: line-through;
  text-decoration-color: rgba(125, 43, 32, 0.35);
}

.pd-apv-diff__new {
  background: #f0f9f4;
  border-inline-start: 3px solid #1d9e75;
  color: #12603f;
  font-weight: 600;
}

.pd-apv-recordlink {
  display: inline-block;
  margin-top: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #0f6e56;
  text-decoration: none;
}

.pd-apv-recordlink:hover { text-decoration: underline; }

/* ── Decision area ────────────────────────────────────────────────────── */
.pd-apv-actions {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid #eef2f0;
}

.pd-apv-actions__label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #6b7a75;
  margin-bottom: 6px;
}

.pd-apv-note {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13.5px;
  font-family: inherit;
  resize: vertical;
}

.pd-apv-note:focus {
  border-color: #1d9e75;
  outline: none;
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.12);
}

.pd-apv-actions__buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.pd-apv-blocked,
.pd-apv-decided {
  margin-top: 20px;
  padding: 13px 16px;
  border-radius: 8px;
  background: #f4f6f5;
  color: #5b6b66;
  font-size: 13px;
}

.pd-apv-decided__note {
  margin: 6px 0 0;
  color: #3c4a45;
  font-style: italic;
}

.pd-apv-loading {
  padding: 40px 0;
  text-align: center;
  color: #8a948f;
  font-size: 14px;
}

/* ── Toast ────────────────────────────────────────────────────────────── */
.pd-apv-toast {
  position: fixed;
  inset-block-end: 24px;
  inset-inline-start: 50%;
  transform: translateX(-50%);
  z-index: 1400;
  padding: 13px 22px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.2);
  max-width: min(520px, 92vw);
  text-align: center;
}

.pd-apv-toast.is-ok    { background: #17805f; }
.pd-apv-toast.is-error { background: #a72d1f; }

/* ── Pending banner on a record page ──────────────────────────────────── */
.pd-apv-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 8px;
  background: #fffaf0;
  border: 1px solid #f0d9a8;
  border-inline-start: 4px solid #d9922e;
  color: #7a5316;
  font-size: 13.5px;
}

.pd-apv-banner a {
  color: #0f6e56;
  font-weight: 600;
  text-decoration: underline;
}

/* ── Right-to-left ────────────────────────────────────────────────────── */
[dir="rtl"] .pd-apv-drawer__panel {
  box-shadow: 8px 0 28px rgba(0, 0, 0, 0.18);
}

[dir="rtl"] .pd-apv-diff__old,
[dir="rtl"] .pd-apv-diff__new,
[dir="rtl"] .pd-apv-review__note,
[dir="rtl"] .pd-apv-banner {
  /* Logical properties above already flip; nothing further needed. */
}

@keyframes pd-apv-slide-rtl {
  from { transform: translateX(-24px); opacity: 0.4; }
  to   { transform: translateX(0); opacity: 1; }
}

[dir="rtl"] .pd-apv-drawer__panel { animation-name: pd-apv-slide-rtl; }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .pd-apv-kpis { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .pd-apv-page { padding: 16px 12px 48px; }
  .pd-apv-kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .pd-apv-header { flex-direction: column; }
  .pd-apv-drawer__panel { width: 100%; padding: 18px 16px 28px; }
  .pd-apv-diff tbody th { width: 40%; }
  .pd-apv-actions__buttons { flex-direction: column-reverse; }
  .pd-apv-actions__buttons .pd-apv-btn { justify-content: center; }
}
