/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *


 */

/*
  Design direction: "ledger / receipt" — the app is a family cashback register,
  so the visual metaphor is a paper accounting ledger, not a generic dashboard.
  Percentages read like ink-stamped totals; category rows use a dotted leader
  like an invoice line item, connecting a name to its number at a glance.
*/

:root {
  --paper: #edf1ec;
  --paper-line: #c7d2c9;
  --ink: #1f2a22;
  --ink-soft: #5b6b5e;
  --gain: #2f6f4e;
  --stamp: #b4432f;
  --card: #ffffff;

  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

/* An author display rule always beats the UA [hidden] rule; restore it explicitly
   wherever JS toggles the hidden attribute on an element that also sets display. */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.4;
}

a {
  color: inherit;
}

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 12px 32px;
}

h1 {
  font-family: var(--font-mono);
  font-size: 15px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 12px;
}

/* Bank group: a ledger section per bank, holding one card per family member */
.bank-group {
  margin-bottom: 20px;
}

.bank-group-title {
  display: flex;
  align-items: center;
  gap: 6px;
}

.bank-group-title svg {
  width: 16px;
  height: 16px;
}

/* Category filter: narrow the family's cards down to the chosen categories */
.category-filter {
  margin-bottom: 16px;
}

.category-filter-search {
  width: 100%;
  margin-bottom: 8px;
}

.category-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--paper-line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink-soft);
  font-size: 13px;
  font-family: var(--font-body);
  cursor: pointer;
}

.category-chip svg {
  width: 15px;
  height: 15px;
}

.category-chip.active {
  border-color: var(--gain);
  color: var(--gain);
  background: #eaf4ee;
}

.category-chip:focus-visible {
  outline: 2px solid var(--gain);
  outline-offset: 2px;
}

/* Month switcher: mono caps ledger-page header with a hairline rule */
.month-switcher {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 8px 0;
  border-bottom: 1px solid var(--paper-line);
  margin-bottom: 14px;
}

.month-switcher a {
  text-decoration: none;
  color: var(--ink-soft);
  padding: 4px 8px;
}

.month-switcher a:hover,
.month-switcher a:focus-visible {
  color: var(--gain);
}

.month-switcher span {
  min-width: 9ch;
  text-align: center;
}

/* Bank card: a white "statement block" laid on the ledger page */
.bank-card {
  background: var(--card);
  border: 1px solid var(--paper-line);
  border-radius: 6px;
  margin-bottom: 12px;
  overflow: hidden;
}

.bank-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--paper-line);
  font-weight: 600;
  font-size: 14px;
}

.bank-card-header span {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.bank-card-header span svg {
  width: 15px;
  height: 15px;
  color: var(--ink-soft);
  flex: 0 0 auto;
}

/* Edit affordance styled like a small rubber stamp square */
.bank-card-header a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--stamp);
  color: var(--stamp);
  border-radius: 4px;
  text-decoration: none;
  line-height: 1;
}

.bank-card-header a svg {
  width: 15px;
  height: 15px;
  display: block;
}

.bank-card-header a:hover,
.bank-card-header a:focus-visible {
  background: var(--stamp);
  color: var(--card);
}

/* Category row: icon + name ..... percent, the page's signature element */
.category-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid #f0f3f0;
}

.category-row:last-child {
  border-bottom: none;
}

.category-row svg {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  color: var(--ink-soft);
  align-self: center;
}

.category-row span:nth-of-type(1) {
  font-size: 14px;
}

/* the dotted leader: a flexible rule of dots between name and percent */
.category-row span:nth-of-type(1)::after {
  content: "";
  flex: 1 1 auto;
  margin: 0 6px;
  border-bottom: 1px dotted var(--paper-line);
  transform: translateY(-4px);
}

.category-row .percent {
  font-family: var(--font-mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--gain);
  font-size: 15px;
  flex: 0 0 auto;
}

.category-row.empty {
  color: var(--ink-soft);
  font-size: 13px;
  font-style: italic;
}

p.empty {
  color: var(--ink-soft);
  font-size: 13px;
  font-style: italic;
  padding: 8px 12px;
  margin: 0;
}

/* Forms (people/banks/person_banks/cashback_assignments edit) */
form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 480px;
}

form label {
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 600;
}

form input[type="text"],
form input[type="number"],
form input[type="email"],
form input[type="password"],
form select {
  font-family: var(--font-body);
  font-size: 16px;
  padding: 8px 10px;
  border: 1px solid var(--paper-line);
  border-radius: 4px;
  background: var(--card);
  color: var(--ink);
}

form input[type="submit"] {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 13px;
  padding: 10px 18px;
  border: none;
  border-radius: 4px;
  background: var(--gain);
  color: var(--card);
  cursor: pointer;
}

form input[type="submit"]:hover,
form input[type="submit"]:focus-visible {
  background: #244f39;
}

.assignment-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid #f0f3f0;
}

.assignment-row label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  font-weight: 400;
  color: var(--ink);
}

.assignment-row svg {
  width: 18px;
  height: 18px;
  color: var(--ink-soft);
}

.assignment-row input[type="number"] {
  width: 72px;
}

:focus-visible {
  outline: 2px solid var(--gain);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: no-preference) {
  .month-switcher a,
  .bank-card-header a,
  .icon-btn,
  .back-link,
  .add-action,
  .text-link {
    transition: color 120ms ease, border-color 120ms ease, background-color 120ms ease;
  }
}

/* Flash messages: a stamped notice/alert line under the ledger header */
.flash {
  font-size: 13px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 12px;
  border: 1px solid var(--paper-line);
}

.flash-notice {
  color: var(--gain);
  border-color: var(--gain);
  background: #eaf4ee;
}

.flash-alert {
  color: var(--stamp);
  border-color: var(--stamp);
  background: #fbeae7;
}

/* Page header: back navigation + title for sub-pages (forms, card lists) */
.page-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
}

.page-header h1 {
  margin: 0;
}

h2 {
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 10px;
}

/* Shared square icon-affordance button (edit, back, delete) */
.back-link,
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--paper-line);
  border-radius: 4px;
  color: var(--ink-soft);
  text-decoration: none;
  background: var(--card);
  flex: 0 0 auto;
  cursor: pointer;
}

.back-link svg,
.icon-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}

.back-link:hover,
.back-link:focus-visible,
.icon-btn:hover,
.icon-btn:focus-visible {
  border-color: var(--gain);
  color: var(--gain);
}

.icon-btn-danger:hover,
.icon-btn-danger:focus-visible {
  border-color: var(--stamp);
  color: var(--stamp);
}

/* Stamp-style edit affordance (bank card header), reused wherever a red stamp fits */
.icon-btn-stamp {
  border-color: var(--stamp);
  color: var(--stamp);
}

.icon-btn-stamp:hover,
.icon-btn-stamp:focus-visible {
  background: var(--stamp);
  color: var(--card);
}

/* Entity list rows: people, banks, cards — ledger rows instead of bare <ul><li> */
.entity-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.entity-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--paper-line);
  border-radius: 6px;
  padding: 10px 12px;
}

.entity-row .entity-icon {
  display: flex;
  color: var(--ink-soft);
  flex: 0 0 auto;
}

.entity-row .entity-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}

.entity-row .entity-name {
  flex: 1 1 auto;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  color: var(--ink);
}

.entity-row .entity-name:hover,
.entity-row .entity-name:focus-visible {
  color: var(--gain);
}

.entity-row .entity-meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ink-soft);
}

.entity-row .entity-actions {
  display: flex;
  gap: 6px;
  flex: 0 0 auto;
}

/* button_to renders its own <form>; drop the box so it lays out inline */
.entity-actions form {
  display: contents;
}

/* Primary "insert new entry" action, styled like a dashed ledger line */
.add-action {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  border: 1px dashed var(--paper-line);
  border-radius: 6px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

.add-action svg {
  width: 18px;
  height: 18px;
}

.add-action:hover,
.add-action:focus-visible {
  border-color: var(--gain);
  color: var(--gain);
  border-style: solid;
}

/* Empty state: icon + short line, used wherever a list has nothing yet */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 32px 16px;
  color: var(--ink-soft);
  text-align: center;
}

.empty-state svg {
  width: 32px;
  height: 32px;
  opacity: 0.6;
}

.empty-state p {
  margin: 0;
  font-size: 14px;
}

/* Validation errors, rendered above a form */
.form-errors {
  border: 1px solid var(--stamp);
  color: var(--stamp);
  background: #fbeae7;
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
}

.form-errors p {
  margin: 0 0 4px;
  font-weight: 700;
}

.form-errors ul {
  margin: 0;
  padding-left: 18px;
}

/* Bootstrap Icons sprite: symbols carry no fill, so paint via currentColor */
svg.bi {
  fill: currentColor;
}

/* Icon picker: search a couple thousand icons by name, pick the glyph itself */
.icon-picker-search {
  width: 100%;
  margin-bottom: 8px;
}

.icon-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 320px;
  overflow-y: auto;
}

.icon-picker-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.icon-picker-option label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--paper-line);
  border-radius: 6px;
  color: var(--ink-soft);
  cursor: pointer;
  background: var(--card);
}

.icon-picker-option label svg {
  width: 20px;
  height: 20px;
}

.icon-picker-option input:checked + label {
  border-color: var(--gain);
  color: var(--gain);
  background: #eaf4ee;
}

.icon-picker-option input:focus-visible + label {
  outline: 2px solid var(--gain);
  outline-offset: 2px;
}

.section-divider {
  border: none;
  border-top: 1px solid var(--paper-line);
  margin: 24px 0 16px;
}

/* Secondary inline text link (e.g. "manage people & cards") */
.text-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: none;
  margin-bottom: 12px;
}

.text-link svg {
  width: 16px;
  height: 16px;
}

.text-link:hover,
.text-link:focus-visible {
  color: var(--gain);
}

.month-switcher a svg {
  width: 16px;
  height: 16px;
  display: block;
}

.field-hint {
  font-size: 12px;
  color: var(--ink-soft);
  font-style: italic;
  margin: -4px 0 0;
}

.auth-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;
}

.danger-zone {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--paper-line);
}

.danger-zone p {
  font-size: 13px;
  color: var(--ink-soft);
  margin: 0 0 8px;
}

.danger-zone .icon-btn-danger {
  width: auto;
  height: auto;
  padding: 8px 14px;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--stamp);
}

.danger-zone .icon-btn-danger svg {
  width: 16px;
  height: 16px;
}
