/* client/styles/money.css — Money module layout + ledger + form fields (Phase 04, Plan 02) */
/* Owns: Ledger view (Plan 02), Transaction form (Plans 03/04) */

/* ============================================================
   Module shell — charcoal full-bleed
   Mirror plan.css root container + override pattern
   ============================================================ */
.money {
  background: var(--color-charcoal);
  color: var(--color-cream);
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* Override fixed-position header/footer so money-body flex:1 fills correctly.
   module-header + module-footer are position:fixed globally; money needs them in-flow.
   (Same override as .plan in plan.css lines 20-34) */
.money .module-header,
.money .module-footer {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  bottom: auto;
}

/* ============================================================
   Body: vertical scroll area for ledger rows
   ============================================================ */
.money-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}

/* ============================================================
   Ledger list + rows + two-page scroll-snap (MONEY-03, Pattern 2)
   ============================================================ */
.ledger-list {
  display: flex;
  flex-direction: column;
}

/* Per-row horizontal scroll container — CSS scroll-snap, not JS transform */
.ledger-row-scroller {
  display: flex;
  overflow-x: scroll;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.ledger-row-scroller::-webkit-scrollbar {
  display: none;
}

/* Each page occupies full width and snaps to position */
.ledger-row-page {
  scroll-snap-align: start;
  flex-shrink: 0;
  width: 100%;
  min-height: var(--tap);
  display: grid;
  align-items: center;
  padding: var(--space-sm);
  gap: var(--space-sm);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.2;
}

/* Page 1: date / time / amount / expected / actual / type (MONEY-03, UI-SPEC) */
.ledger-row-page--p1 {
  grid-template-columns: 20% 12% 18% 18% 18% 14%;
}

/* Page 2: title / description / tags / edit (MONEY-03, UI-SPEC) */
.ledger-row-page--p2 {
  grid-template-columns: 30% 34% 22% 14%;
}

/* All cells: single-line truncated (MONEY-10) */
.ledger-cell {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Right-align numeric balance cells */
.ledger-cell--amount,
.ledger-cell--balance {
  text-align: right;
}

/* ============================================================
   Row state colors (MONEY-05, D-07, UI-SPEC Row State Color Contract)
   Exact token mapping verified against 04-UI-SPEC.md §"Row State Color Contract"
   ============================================================ */
.ledger-row[data-status="projected"] .ledger-row-page {
  background: var(--color-charcoal);
  color: var(--color-cream);
}

.ledger-row[data-status="queued"] .ledger-row-page {
  background: var(--color-red);
  color: var(--color-cream);
}

/* D-07 "Resolved = light red tint": realized as --color-red-dark per 04-UI-SPEC Row State Color Contract.
   base.css has only --color-red / --color-red-dark; this is the deeper-red Resolved state vs Queued red.
   --color-red-dark IS the correct, spec-sanctioned realization of D-07. Do NOT invent a lighter token. */
.ledger-row[data-status="resolved"] .ledger-row-page {
  background: var(--color-red-dark);
  color: var(--color-cream);
}

/* Selected overrides all row states — applies to BOTH pages via shared .ledger-row parent */
.ledger-row.row--selected .ledger-row-page {
  background: var(--color-cream);
  color: var(--color-charcoal);
}

/* ============================================================
   Negative balance contrast (MONEY-08, UI-SPEC §"Negative Balance Color Contract")
   ============================================================ */
/* On cream-bg selected rows: use red text to maintain contrast */
.ledger-row.row--selected .balance--negative {
  color: var(--color-red);
}

/* On charcoal/red/red-dark bg rows: stay cream — minus sign alone distinguishes negative */
.ledger-row:not(.row--selected) .balance--negative {
  color: var(--color-cream);
}

/* ============================================================
   Pagination dots (MONEY-03, Pattern 3, UI-SPEC §"Pagination Dots")
   Two dots between ledger-list and footer
   ============================================================ */
.money-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  min-height: var(--tap);
  padding: var(--space-sm) 0;
}

.money-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid var(--color-cream);
  background: transparent;
  flex-shrink: 0;
}

/* Active dot: filled; inactive: outline only */
.money-dot.active {
  background: var(--color-cream);
}

/* ============================================================
   Empty state (MONEY-25, mirror .plan-empty)
   ============================================================ */
.money-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-xl) var(--space-md);
  flex: 1;
  min-height: 0;
}

.money-empty-cat {
  width: 200px;
  max-width: 60vw;
  height: auto;
  color: var(--color-cream); /* SVG currentColor fill */
}

.money-empty-text {
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-cream);
  text-align: center;
}

/* ============================================================
   SHARED FORM FIELD STYLES — consumed by Plans 03/04
   money.css owns these exclusively (wave parallel-safe)
   Mirror plan.css form patterns with money- prefix
   ============================================================ */

/* Form screen shell — charcoal (not red) to visually distinguish from module chrome */
.money-form {
  background: var(--color-charcoal);
  color: var(--color-cream);
  display: flex;
  flex-direction: column;
  height: 100%;
}

.money-form .module-header,
.money-form .module-footer {
  position: relative;
  top: auto;
  left: auto;
  right: auto;
  bottom: auto;
}

/* Scrollable form body */
.money-form-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

/* Date tappable button — EB Garamond Bold 20px centered, mirrors .plan-form-date */
.money-form-date {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 20px;
  line-height: 1.2;
  color: var(--color-cream);
  background: transparent;
  border: 0;
  cursor: pointer;
  text-align: center;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Field wrapper — label above input */
.money-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

/* Until-field visibility rule (UI-SPEC §"Until Field Visibility Rule") */
.money-field.is-hidden {
  display: none;
}

/* Field label — DM Mono 13px (UI-SPEC Typography) */
.money-field-label {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1;
  color: var(--color-cream);
}

/* Input/select/textarea — charcoal rounded-rectangle, DM Mono 16px */
.money-field-input,
.money-field-select,
.money-field-textarea {
  width: 100%;
  background: var(--color-charcoal);
  color: var(--color-cream);
  font-family: var(--font-mono);
  font-size: 16px;
  line-height: 1.4;
  border-radius: 8px;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid rgba(245, 240, 232, 0.2);
  appearance: none;
  -webkit-appearance: none;
}

.money-field-input:disabled,
.money-field-select:disabled {
  opacity: 0.6;
  cursor: default;
}

.money-field-textarea {
  resize: vertical;
  min-height: calc(var(--tap) * 2);
}

/* Footer row for Delete + Save ghost pills (Edit Item) */
.money-form-footer-row {
  display: flex;
  gap: var(--space-md);
}

.money-form-footer-row > .ghost-pill {
  flex: 1;
}

/* Footer module-footer override (same relative positioning) */
.money .module-footer {
  padding: var(--space-md) var(--space-md) calc(var(--sab) + var(--space-md));
}
