/* ============================================================
   VENDOR PAYMENTS & ESCROW
   Ports the Wed Connect escrow facility into the WedConnect SA
   light editorial system. Uses tokens from variables.css and
   the dashboard chrome from vendor-dashboard.css.
   ------------------------------------------------------------
   Escrow status colour map (functional tokens):
     pending  -> warning  (gold/amber)
     escrow   -> info     (slate blue) = "secured / held"
     released -> success  (sage green)
     disputed -> danger   (terracotta)
     draft    -> grey
   ============================================================ */

/* ── Escrow vault hero banner ─────────────────────────────── */
.escrow-hero {
  background:
    radial-gradient(ellipse 70% 120% at 100% 0%, rgba(74,107,136,.10) 0%, transparent 60%),
    linear-gradient(135deg, var(--color-champagne) 0%, var(--color-white) 70%);
  border: 1px solid var(--color-stone);
  border-radius: var(--r-lg);
  padding: 28px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 32px;
  flex-wrap: wrap;
}

.escrow-hero-main { min-width: 260px; }

.escrow-hero-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: var(--fs-2xs);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-info);
  margin-bottom: 10px;
}

.escrow-hero-label i { width: 14px; height: 14px; }

.escrow-hero-amount {
  font-family: var(--font-display);
  font-size: clamp(2.75rem, 5vw, 3.5rem);
  font-weight: 600;
  color: var(--color-ink);
  line-height: 1;
}

.escrow-hero-sub {
  font-size: var(--fs-sm);
  color: var(--color-mid-grey);
  margin-top: 10px;
}

.escrow-hero-bar {
  height: 8px;
  width: 280px;
  max-width: 100%;
  background: var(--color-champagne-2);
  border-radius: var(--r-pill);
  overflow: hidden;
  margin-top: 16px;
}

.escrow-hero-bar span {
  display: block;
  height: 100%;
  border-radius: var(--r-pill);
  background: linear-gradient(90deg, var(--color-info), #6b8aa8);
  transition: width .6s var(--ease-out);
}

.escrow-hero-breakdown {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}

.escrow-hero-item { min-width: 88px; }

.escrow-hero-item-value {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 600;
  line-height: 1.1;
  white-space: nowrap;
}

.escrow-hero-item-label {
  font-size: var(--fs-2xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-mid-grey);
  margin-top: 4px;
}

.t-warning { color: var(--color-warning); }
.t-info    { color: var(--color-info); }
.t-success { color: var(--color-success); }
.t-danger  { color: var(--color-danger); }

/* ── Stat card escrow tint variants (extends .stat-card) ──── */
.stat-card .stat-icon.icon-escrow { background: var(--color-info-bg); }
.stat-card .stat-icon.icon-escrow i { color: var(--color-info); }
.stat-card .stat-icon.icon-released { background: var(--color-success-bg); }
.stat-card .stat-icon.icon-released i { color: var(--color-success); }
.stat-card .stat-icon.icon-pending { background: var(--color-warning-bg); }
.stat-card .stat-icon.icon-pending i { color: var(--color-warning); }

.stat-trend.neutral { background: var(--color-bone); color: var(--color-mid-grey); }
.stat-trend.escrow  { background: var(--color-info-bg); color: var(--color-info); }

/* ── Escrow journey flow strip ────────────────────────────── */
.escrow-flow {
  background: var(--color-white);
  border: 1px solid var(--color-stone);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 24px 26px 26px;
}

.escrow-flow-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.escrow-flow-head h3 {
  font-family: var(--font-display);
  font-size: var(--fs-xl);
  font-weight: 600;
  color: var(--color-charcoal);
}

.escrow-flow-head p {
  font-size: var(--fs-sm);
  color: var(--color-mid-grey);
}

.flow-steps {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
}

.flow-step {
  position: relative;
  text-align: center;
  padding: 0 8px;
}

.flow-step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 26px;
  right: -50%;
  width: 100%;
  height: 1px;
  background: repeating-linear-gradient(90deg, var(--color-champagne-2) 0 6px, transparent 6px 12px);
  z-index: 0;
}

.flow-icon {
  position: relative;
  z-index: 1;
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  border-radius: var(--r-circle);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-white);
  border: 1px solid var(--color-stone);
  box-shadow: var(--shadow-xs);
}

.flow-icon i { width: 22px; height: 22px; color: var(--color-accent); }
.flow-step.is-active .flow-icon { background: var(--color-accent-soft); border-color: var(--color-accent); }
.flow-step.is-done .flow-icon i { color: var(--color-success); }

.flow-step-label {
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--color-charcoal);
}

.flow-step-sub {
  font-size: var(--fs-xs);
  color: var(--color-mid-grey);
  margin-top: 3px;
  line-height: 1.4;
}

/* ── Invoice table additions ──────────────────────────────── */
.inv-id { font-weight: 600; color: var(--color-ink); }
.inv-amount {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--color-accent-deep);
}
.inv-amount.released { color: var(--color-success); }
.inv-amount.muted { color: var(--color-soft-grey); }

.escrow-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xs);
  font-weight: 500;
}
.escrow-cell i { width: 14px; height: 14px; }
.escrow-cell.secured { color: var(--color-info); }
.escrow-cell.releasing { color: var(--color-warning); }
.escrow-cell.released { color: var(--color-success); }
.escrow-cell.none { color: var(--color-soft-grey); }

/* Status badges — reuse .status-badge base, add escrow states */
.status-escrow  { background: var(--color-info-bg);    color: var(--color-info); }
.status-released { background: var(--color-success-bg); color: var(--color-success); }
.status-approved { background: var(--color-info-bg);    color: var(--color-info); }
.status-draft    { background: var(--color-bone);       color: var(--color-graphite); }
.status-disputed { background: var(--color-danger-bg);  color: var(--color-danger); }

/* table action buttons */
.btn-table {
  font-family: var(--font-body);
  font-size: var(--fs-2xs);
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--color-hairline-strong);
  background: var(--color-white);
  color: var(--color-graphite);
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.btn-table:hover { border-color: var(--color-accent); color: var(--color-accent-deep); background: var(--color-accent-soft); }
.btn-table.primary { border-color: var(--color-accent); background: var(--color-accent); color: #fff; }
.btn-table.primary:hover { background: var(--color-accent-hover); }

/* ── Modal ────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(45,45,45,.42);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: var(--z-modal);
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--color-white);
  border-radius: var(--r-xl);
  border: 1px solid var(--color-stone);
  box-shadow: var(--shadow-xl);
  width: 600px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn .26s var(--ease-out);
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(14px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 22px 26px;
  border-bottom: 1px solid var(--color-hairline);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 600;
  color: var(--color-ink);
}
.modal-close {
  width: 34px; height: 34px;
  border-radius: var(--r-circle);
  border: 1px solid var(--color-hairline);
  background: var(--color-white);
  color: var(--color-mid-grey);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--dur-fast) var(--ease-out);
}
.modal-close:hover { background: var(--color-champagne); color: var(--color-charcoal); }
.modal-close i { width: 18px; height: 18px; }

.modal-body { padding: 24px 26px; }
.modal-footer {
  padding: 16px 26px;
  border-top: 1px solid var(--color-hairline);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* ── Invoice detail ───────────────────────────────────────── */
.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--color-hairline);
}
.detail-no {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 600;
  color: var(--color-accent-deep);
}
.detail-meta { font-size: var(--fs-xs); color: var(--color-mid-grey); margin-top: 4px; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 20px;
  margin-bottom: 20px;
}
.detail-item-label {
  font-size: var(--fs-2xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-mid-grey);
  margin-bottom: 4px;
}
.detail-item-value { font-size: var(--fs-base); color: var(--color-charcoal); font-weight: 500; }

.li-table { width: 100%; border-collapse: collapse; margin: 8px 0 4px; }
.li-table td { padding: 11px 0; border-bottom: 1px dashed var(--color-hairline); font-size: var(--fs-sm); }
.li-table tr:last-child td { border-bottom: none; }
.li-desc { color: var(--color-graphite); }
.li-amt { text-align: right; font-family: var(--font-display); font-size: 1.05rem; font-weight: 600; color: var(--color-charcoal); white-space: nowrap; }

.invoice-total {
  background: var(--color-accent-soft);
  border: 1px solid rgba(201,168,124,.3);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
}
.invoice-total-label { font-size: var(--fs-sm); color: var(--color-graphite); font-weight: 500; }
.invoice-total-note { font-size: var(--fs-2xs); color: var(--color-mid-grey); margin-top: 3px; }
.invoice-total-value {
  font-family: var(--font-display);
  font-size: var(--fs-3xl);
  font-weight: 600;
  color: var(--color-accent-deep);
  white-space: nowrap;
}

/* ── Timeline ─────────────────────────────────────────────── */
.tl-label {
  font-size: var(--fs-2xs);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-mid-grey);
  margin: 22px 0 14px;
}
.timeline { display: flex; flex-direction: column; }
.tl-item { display: flex; gap: 14px; position: relative; padding-bottom: 18px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item:not(:last-child)::after {
  content: "";
  position: absolute;
  left: 15px; top: 32px; bottom: 0;
  width: 1px;
  background: var(--color-stone);
}
.tl-dot {
  width: 30px; height: 30px;
  border-radius: var(--r-circle);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  z-index: 1;
  border: 1px solid var(--color-stone);
  background: var(--color-white);
}
.tl-dot i { width: 15px; height: 15px; }
.tl-dot.done   { background: var(--color-success-bg); border-color: transparent; }
.tl-dot.done i { color: var(--color-success); }
.tl-dot.current{ background: var(--color-info-bg); border-color: transparent; }
.tl-dot.current i { color: var(--color-info); }
.tl-dot.pending i { color: var(--color-soft-grey); }
.tl-event { font-size: var(--fs-base); font-weight: 500; color: var(--color-charcoal); }
.tl-event.muted { color: var(--color-soft-grey); }
.tl-meta { font-size: var(--fs-xs); color: var(--color-mid-grey); margin-top: 2px; }
.tl-content { padding-top: 3px; }

/* ── New invoice line items ───────────────────────────────── */
.li-rows { display: flex; flex-direction: column; gap: 8px; }
.li-row {
  display: grid;
  grid-template-columns: 1fr 72px 110px 34px;
  gap: 8px;
  align-items: center;
}
.li-row .form-input { margin: 0; }
.li-remove {
  background: transparent;
  border: none;
  color: var(--color-danger);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  padding: 6px;
  border-radius: var(--r-sm);
}
.li-remove:hover { background: var(--color-danger-bg); }
.li-remove i { width: 16px; height: 16px; }

.li-add {
  align-self: flex-start;
  margin-top: 4px;
  background: transparent;
  border: 1px dashed var(--color-hairline-strong);
  color: var(--color-accent-deep);
  font-family: var(--font-body);
  font-size: var(--fs-xs);
  font-weight: 600;
  padding: 7px 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all var(--dur-fast) var(--ease-out);
}
.li-add:hover { border-color: var(--color-accent); background: var(--color-accent-soft); }
.li-add i { width: 14px; height: 14px; }

.fee-summary {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--color-bone);
  border: 1px solid var(--color-hairline);
  border-radius: var(--r-lg);
  padding: 14px 16px;
}
.fee-row { display: flex; justify-content: space-between; font-size: var(--fs-sm); color: var(--color-graphite); }
.fee-row.total { border-top: 1px solid var(--color-hairline); padding-top: 8px; margin-top: 2px; font-weight: 600; color: var(--color-ink); }
.fee-row .v { font-family: var(--font-display); font-weight: 600; }
.fee-row.total .v { font-size: var(--fs-xl); color: var(--color-accent-deep); }

/* ── Toast ────────────────────────────────────────────────── */
.toast-wrap {
  position: fixed;
  bottom: 24px; right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: var(--z-toast);
}
.toast-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--color-white);
  border: 1px solid var(--color-stone);
  border-left: 3px solid var(--color-accent);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  font-size: var(--fs-sm);
  color: var(--color-charcoal);
  min-width: 280px;
  max-width: 360px;
  animation: toastIn .3s var(--ease-out);
}
.toast-item.is-out { animation: toastOut .3s var(--ease-out) forwards; }
.toast-item.success { border-left-color: var(--color-success); }
.toast-item.warning { border-left-color: var(--color-warning); }
.toast-item.info    { border-left-color: var(--color-info); }
.toast-item i { width: 18px; height: 18px; flex-shrink: 0; }
.toast-item.success i { color: var(--color-success); }
.toast-item.warning i { color: var(--color-warning); }
.toast-item.info i    { color: var(--color-info); }
@keyframes toastIn  { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(18px); } }

/* ── Section subhead helper ───────────────────────────────── */
.section-sub {
  font-size: var(--fs-sm);
  color: var(--color-mid-grey);
  font-weight: 400;
}

.payments-grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 28px;
}

@media (max-width: 900px) {
  .flow-steps { grid-template-columns: 1fr 1fr; gap: 20px 8px; }
  .flow-step:not(:last-child)::after { display: none; }
  .escrow-hero { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 560px) {
  .detail-grid { grid-template-columns: 1fr; }
  .li-row { grid-template-columns: 1fr 56px 90px 30px; }
  .flow-steps { grid-template-columns: 1fr; }
}
