/* ===========================================================================
 * ledger-ui.css — shared ledger UI styles (LEDGER-UI-2 task 0, spec §2.8)
 * ---------------------------------------------------------------------------
 * Modal overlay, buttons, spinner, and ledger-card surface styles for the
 * Cashflow Ledger. All colors resolve through MC's theme variables
 * (--card, --hairline, --ink, --ink-soft, --olive(-tint), --burgundy(-tint),
 * --ply-deep, --sent-bg, --overdue, --status-*, --overlay-bg) per
 * docs/ledger-token-audit.md — no ledger-local token layer (t_21f06f84).
 *
 * .ledger-card border/background per §2.8:
 *   border var(--olive), fill var(--olive-tint) (receivable);
 *   border var(--burgundy), fill var(--burgundy-tint) (expense)
 * (the base .ledger-card rules also live in index.html next to the month
 *  column CSS; the rules here re-assert them for standalone import and keep
 *  this file self-sufficient for the UI-2 card/modal components.)
 * =========================================================================== */

/* -------- §2.8 card surface (re-asserted, token-referencing) -------- */
.ledger-card {
  border-radius: 0; /* MC .card chrome: square corners (matches index.html) */
  padding: 6px 7px;
  margin-bottom: 6px;
  background: var(--card);
}
.ledger-card-recv {
  /* LEDGER-FIX-9 (t_f9b461ac): default state = Not issued — grey outline,
     no fill. Issued/Paid outline-only; Xero synced adds green infill. */
  border: 1.4px solid var(--status-not-issued-border);
  background: transparent;
}
.ledger-card-recv.st-not-issued { border-color: var(--status-not-issued-border); }
.ledger-card-recv.st-issued { border-color: var(--status-issued-border); }
.ledger-card-recv.st-paid { border-color: var(--status-paid-border); }
.ledger-card-recv.st-synced {
  border-color: var(--status-synced-border);
  background: var(--status-synced-fill);
}

/* -------- sync ticks (§4.3) -------- */
.ledger-sync-tick {
  font-size: 8.5px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}
.ledger-sync-tick.ledger-sync-manual { color: var(--status-paid-border); }
.ledger-sync-tick.ledger-sync-xero { color: var(--status-synced-border); background: var(--status-synced-fill); }

/* -------- modal overlay + modal (§2.8) -------- */
.ledger-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--overlay-bg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
}
.ledger-modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}
.ledger-modal {
  width: 100%;
  max-width: 400px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--hairline);
  border-top: 3px solid var(--ink);
  border-radius: 0; /* MC modal treatment: square corners (matches .modal) */
  padding: 18px 18px 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
  transform: translateY(8px) scale(0.98);
  transition: transform 0.18s ease-out;
}
.ledger-modal-overlay.open .ledger-modal {
  transform: translateY(0) scale(1);
}
.ledger-modal-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 2px;
  letter-spacing: -0.01em;
}
.ledger-modal-sub {
  font-size: 10.5px;
  color: var(--ink-soft);
  margin: 0 0 12px;
}
.ledger-modal label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 10px 0 3px;
}
.ledger-modal input[type="text"],
.ledger-modal input[type="url"],
.ledger-modal input[type="number"],
.ledger-modal select,
.ledger-modal textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--hairline);
  border-radius: 6px;
  background: var(--card);
  color: var(--ink);
  font-size: 12.5px;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
}
.ledger-modal input:focus,
.ledger-modal select:focus,
.ledger-modal textarea:focus {
  border-color: var(--ink-soft);
}
.ledger-modal .ledger-field-error {
  font-size: 10.5px;
  color: var(--burgundy);
  margin: 3px 0 0;
}

/* -------- buttons (§2.8) -------- */
.ledger-btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 6px;
  border: 1.4px solid var(--hairline);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: 0.15s;
}
.ledger-btn:hover { border-color: var(--ink-soft); color: var(--ink-soft); }
.ledger-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.ledger-btn-primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
.ledger-btn-primary:hover { background: var(--ink-soft); border-color: var(--ink-soft); color: var(--paper); }
.ledger-btn-danger {
  border-color: var(--burgundy);
  color: var(--burgundy);
}
.ledger-btn-danger:hover { background: var(--burgundy-tint); }
.ledger-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

/* -------- receivable detail modal (§2.4 / §4.3) -------- */
.ledger-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.ledger-m-client {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 1px;
}
.ledger-modal-close {
  flex: none;
  border: none;
  background: transparent;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}
.ledger-modal-close:hover { color: var(--ink); }
.ledger-m-inv-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 2px;
}
/* Modal-scoped invoice links (MC-CARD-14 t_e214d62e): the "View in Xero"
   link is the modal's direct path to the original Xero invoice. The
   .ledger-r-inv-link rule in index.html is card-sized + mobile-only; scope
   a desktop-size rule to the modal row so the number link reads clearly. */
.ledger-m-inv-row .ledger-r-inv-link {
  font-size: 12px;
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ledger-r-xero-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--olive);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.ledger-r-xero-link:hover { color: var(--ink); }
.ledger-m-no-inv {
  font-size: 12px;
  color: var(--ink-soft);
}
.ledger-icon-btn {
  flex: none;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--hairline);
  border-radius: 5px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  transition: 0.15s;
}
.ledger-icon-btn:hover {
  border-color: var(--ink-soft);
  color: var(--ink-soft);
  background: color-mix(in srgb, var(--ink-soft) 8%, transparent);
}
.ledger-detail-amount {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
  margin: 10px 0 2px;
}
.ledger-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 7px 0;
}
.ledger-check-row input[type="checkbox"] {
  flex: none;
  width: 15px;
  height: 15px;
  accent-color: var(--olive);
}
.ledger-check-row input[type="checkbox"]:disabled { opacity: 0.55; cursor: not-allowed; }
.ledger-check-row label {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}
.ledger-check-hint {
  font-size: 10px;
  line-height: 1.35;
  color: var(--ink-soft);
}
.ledger-detail-err {
  font-size: 11px;
  line-height: 1.4;
  color: var(--burgundy);
  min-height: 14px;
  margin: 8px 0 0;
}
.ledger-modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
}

/* -------- spinner -------- */
.ledger-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--hairline);
  border-top-color: var(--ink);
  border-radius: 50%;
  animation: ledger-spin 0.7s linear infinite;
  vertical-align: middle;
}
.ledger-btn .ledger-spinner { margin-right: 6px; }
@keyframes ledger-spin {
  to { transform: rotate(360deg); }
}
