/* Transaction Form Styles */

.transaction-form {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

/* Inside the sheet, the header sticks at the top (the × already floats over it)
   and the CTA sticks at the bottom — the context and action never scroll away.
   The stacked layout itself is shared in bottom_sheet.css. */
.bottom-sheet__body .page-header.transaction-form__header {
  position: sticky;
  top: 0;
  z-index: 3;
  margin: 0 -1.25rem;
  padding: 0.75rem 2.75rem 0.75rem 1.25rem;
  background: var(--color-white);
  border-bottom: 1px solid var(--color-separator);
}

.bottom-sheet__body .transaction-form__actions {
  position: sticky;
  bottom: 0;
  z-index: 3;
  margin: 1.25rem -1.25rem -1.5rem;
  padding: 0.75rem 1.25rem calc(0.75rem + env(safe-area-inset-bottom, 0));
  background: var(--color-white);
  border-top: 1px solid var(--color-separator);
  box-shadow: 0 -4px 16px rgba(40, 42, 51, 0.05);
}

.transaction-form__title {
  font-size: var(--font-size-headline);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--tracking-headline);
  color: var(--color-dark);
}

.transaction-form__subtitle {
  font-size: var(--font-size-body);
  color: var(--color-muted-strong);
}

/* Field labels read as prompts, matching the budget-line form. */
.transaction-form .form-label {
  font-size: var(--font-size-title);
  font-weight: var(--font-weight-semibold);
  color: var(--color-dark);
}

/* Debt: four sentence cards + the resulting balance line */
.transaction-form__debt-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.debt-what {
  font-size: var(--font-size-title);
  font-weight: var(--font-weight-semibold);
  color: var(--color-dark);
}

.debt-after {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--color-surface-sunken);
  border-radius: var(--radius-lg);
}

.debt-after__label {
  font-size: var(--font-size-body);
  color: var(--color-muted-strong);
}

.debt-after__value {
  font-size: var(--font-size-body);
  font-weight: var(--font-weight-semibold);
  color: var(--color-dark);
  white-space: nowrap;
}

/* Optional-detail rows: label on the left, a quiet hint on the right. */
.tx-detail__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-sm);
}

.tx-detail__head .form-label {
  margin-bottom: 0;
}

.tx-detail__hint {
  font-size: var(--font-size-body);
  color: var(--color-muted-strong);
}

/* The detail field's own label is replaced by the head row above. */
.tx-detail .form-label-wrapper {
  display: none;
}

.tx-detail .form-field {
  margin-bottom: 0;
}

.tx-detail__date-field {
  margin-top: var(--space-md);
}

.pill-choice--three {
  grid-template-columns: repeat(3, 1fr);
}

.transaction-form__transfer .transfer-block {
  margin-top: var(--space-sm);
}

/* Both accounts' current balances, in one quiet line under the block. */
.transfer-balances {
  margin-top: var(--space-md);
  font-size: var(--font-size-label);
  color: var(--color-muted-strong);
}

.transaction-form .form-field {
  margin-bottom: 0.5rem !important;
}

/* Amount is the form's hero: the sheet's first job is capturing a number fast,
   so it gets Display weight and a prominent currency addon, not a row-height
   input equal to every other field. */
.transaction-form__amount .form-input-group .form-input {
  font-size: var(--font-size-display);
  font-weight: var(--font-weight-bold);
  padding: 0.5rem 0.75rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

.transaction-form__amount .form-input-addon--prepend {
  font-size: var(--font-size-headline);
  font-weight: var(--font-weight-semibold);
  color: var(--color-muted-strong);
}

/* Kind Selector */
.transaction-form__kind {
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Kind selector: a scalable icon grid. auto-fit makes 2 options fill the
   row (debt edit), 3 fit a row (create), and more wrap to new rows as kinds
   are added (e.g. loan / debt payment) — never overflowing on mobile. */
.kind-selector {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 0.5rem;
}

/* Top-level Expense/Income/Transfer/Debt picker: keep all four on one row,
   shrinking the cards (and labels) rather than wrapping on narrow screens. */
.kind-selector--quad {
  grid-template-columns: repeat(4, 1fr);
  gap: 0.375rem;
}

.kind-selector--quad .kind-option {
  padding: 0.625rem 0.25rem;
  gap: 0.375rem;
}

.kind-selector--quad .kind-option__icon {
  width: 1.875rem;
  height: 1.875rem;
}

.kind-selector--quad .kind-option__label {
  font-size: 0.6875rem;
}

/* Radio-driven variant (edit form): the input is visually hidden; the
   adjacent card carries the selected state. */
.kind-option__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Each card carries its kind's semantic color (matching the transaction
   palette: expense=danger, income=success, transfer=info, debt=warning) via
   --kind-accent, so background, border and selected/focus states all derive
   from one hue. Defaults to the brand color (e.g. the lent/borrowed choice). */
.kind-option {
  --kind-accent: var(--color-primary);
  --kind-accent-rgb: var(--color-primary-rgb);

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 0.5rem;
  background: rgba(var(--kind-accent-rgb), 0.07);
  border: 1.5px solid rgba(var(--kind-accent-rgb), 0.4);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: var(--text-dark);
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.kind-option--expense {
  --kind-accent: var(--color-danger);
  --kind-accent-rgb: var(--color-danger-rgb);
}

.kind-option--income {
  --kind-accent: var(--color-success);
  --kind-accent-rgb: var(--color-success-rgb);
}

.kind-option--transfer {
  --kind-accent: var(--color-info);
  --kind-accent-rgb: var(--color-info-rgb);
}

.kind-option--debt,
.kind-option--debt_in,
.kind-option--debt_out {
  --kind-accent: var(--color-warning);
  --kind-accent-rgb: var(--color-warning-rgb);
}

.kind-option:hover {
  border-color: rgba(var(--kind-accent-rgb), 0.7);
}

.kind-option--selected,
.kind-option__input:checked+.kind-option {
  background: rgba(var(--kind-accent-rgb), 0.16);
  border-color: var(--kind-accent);
  box-shadow: 0 0 0 3px rgba(var(--kind-accent-rgb), 0.18);
}

.kind-option:focus-visible,
.kind-option__input:focus-visible+.kind-option {
  outline: none;
  border-color: var(--kind-accent);
  box-shadow: 0 0 0 3px rgba(var(--kind-accent-rgb), 0.3);
}

.kind-option__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
}

.kind-option__icon svg {
  width: 1.25rem;
  height: 1.25rem;
}

.kind-option__label {
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.2;
  text-align: center;
}

/* Mono variant: one active (accent), three neutral — nothing competes with the
   chosen type. Used by the budget-line form. */
.kind-selector--mono .kind-option {
  background: var(--color-surface-sunken);
  border-color: transparent;
}

.kind-selector--mono .kind-option:hover {
  border-color: transparent;
}

.kind-selector--mono .kind-option__icon {
  background: var(--color-neutral-pill);
  color: var(--color-muted-strong);
}

.kind-selector--mono .kind-option__label {
  color: var(--color-muted-strong);
}

.kind-selector--mono .kind-option--selected {
  background: rgba(var(--kind-accent-rgb), 0.08);
  border-color: var(--kind-accent);
  box-shadow: none;
}

.kind-selector--mono .kind-option--selected .kind-option__icon {
  background: var(--kind-accent);
  color: var(--color-white);
}

.kind-selector--mono .kind-option--selected .kind-option__label {
  color: var(--kind-accent);
  font-weight: var(--font-weight-semibold);
}

/* Per-kind semantic icon colors (icons use stroke: currentColor). */
.kind-option__icon--expense {
  background: var(--color-danger-20);
  color: var(--color-danger);
}

.kind-option__icon--income {
  background: var(--color-success-20);
  color: var(--color-success);
}

.kind-option__icon--transfer {
  background: var(--color-info-20);
  color: var(--color-info);
}

.kind-option__icon--debt,
.kind-option__icon--debt_in,
.kind-option__icon--debt_out {
  background: var(--color-warning-20);
  color: var(--color-warning);
}

/* Toggle Button for More Details */
.transaction-form__toggle {
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Optional Fields */
.transaction-form__optional-fields {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-default);
}

.transaction-form__optional-fields.hidden {
  display: none;
}

/* Debt sub-sections are revealed by the debt-fields controller as the user
   picks a person and a direction. */
.transaction-form__debt-direction.hidden,
.transaction-form__debt-intents.hidden {
  display: none;
}

/* Transfer Account Fields */
.transaction-form__transfer-accounts {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.transaction-form__actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.25rem;
}


/* Responsive - Tablet */
@media (max-width: 768px) {
  .transaction-form__optional-fields {
    gap: 1.25rem;
  }
}

/* Responsive - Mobile */
@media (max-width: 640px) {
  .transaction-form__kind {
    margin-top: 0.75rem;
    margin-bottom: 0.75rem;
  }

  .transaction-form__optional-fields {
    gap: 1rem;
  }

  .transaction-form__transfer-accounts {
    gap: 0.875rem;
  }
}

/* Responsive - Small Mobile */
@media (max-width: 480px) {
  .transaction-form__optional-fields {
    gap: 0.875rem;
    padding-top: 0.75rem;
  }

  .transaction-form__transfer-accounts {
    gap: 0.75rem;
  }
}

/* Quick add — natural-language entry (the surface voice will plug into) */
.quick-entry {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.quick-entry__input {
  font-size: 1rem;
  padding: 0.875rem 1rem;
}

.quick-entry__examples {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8125rem;
  line-height: 1.4;
}
