/* ------ TOOL STYLES ------ */

/*
  No .bar-container rules here. The bar's content
  column is owned by docs-site.css §1 and §1B; an unscoped selector in a tool
  stylesheet reaches every page that loads it, which is all of them.
*/

/* -- Currency toggle row --
   Carries its own padding because it no longer borrows .dropdown-item's. It
   used to be marked up as an item with cursor: default pinned on inline, which
   is what a row that is not an item looks like when it is wearing an item's
   class. Matches .dropdown-item's padding so the panel's rows still line up. */
.calculator-currency-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-m);
  padding: var(--space-l) var(--space-m);
}

.calculator-currency-label {
  font-size: var(--font-xs);
  font-weight: var(--font-weight-semi-bold);
  color: var(--text-faded);
}

.calculator-currency-label.is-active {
  color: var(--text-primary);
}

/* -- Saved configs list -- */
.calculator-saves-list {
  display: flex;
  flex-direction: column;
  max-height: 200px;
  overflow-y: auto;
}

/* The row is a container, not a control — it holds two buttons and does nothing
   itself, so it carries no cursor and no hover. It used to carry both, which is
   what a clickable div looks like when it is pretending to be a button. */
.calculator-save-item {
  display: flex;
  align-items: center;
  gap: var(--space-s);
  font-size: var(--font-s);
  color: var(--text-primary);
}

/* Loads the saved config. Takes the row's padding so the hit area still spans
   the row, and text-align: left because a button centres its label by default. */
.calculator-save-load {
  flex: 1;
  min-width: 0;
  padding: var(--space-s) var(--space-m);
  background: none;
  border: none;
  font-size: inherit;
  font-family: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calculator-save-load:hover {
  background: var(--background-faded);
}

.calculator-save-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xs);
  background: none;
  border: none;
  color: var(--text-faded);
  cursor: pointer;
  flex-shrink: 0;
}

.calculator-save-delete:hover {
  color: var(--text-primary);
}

.calculator-save-delete .svg-icn {
  width: 1.25rem;
  height: 1.25rem;
}

/* -- Input grid (shared across tools) -- */
.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-m);
}

.tool-grid > .grid-full {
  grid-column: 1 / -1;
}

.tool-grid-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-s);
}

/* The container owns the spacing. Without this the base label's own
   margin-bottom (--space-xs) stacks on the gap and every field in every tool
   renders 12px between label and control where the grid asks for 8px — the same
   trap .bar-label neutralises for the same reason. */
.tool-grid-field label {
  margin-bottom: 0;
}

/* -- Results row -- */
.calculator-results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(0, 1fr));
  gap: var(--space-xl);
  padding: var(--space-l) 0 var(--space-xl) 0;
  border-top: var(--border-s) solid var(--border-faded);
  border-bottom: var(--border-s) solid var(--border-faded);
}

.calculator-result-label {
  display: block;
  font-size: var(--font-s);
  color: var(--text-secondary);
  margin-bottom: var(--space-xs);
}

.calculator-result-value {
  display: block;
  font-size: var(--font-6xl);
  color: var(--text-primary);
  line-height: 1.1;
}

/* -- Input overrides -- */
.calculator-input-inline {
  padding: var(--space-s) var(--space-m);
  font-size: var(--font-s);
}

/* -- Table overrides -- */
.calculator-table {
  width: 100%;
  table-layout: auto;
}

.calculator-table th,
.calculator-table td {
  min-width: 120px;
}

.calculator-table th:first-child,
.calculator-table td:first-child {
  min-width: 100px;
}

.calculator-table th:nth-child(2),
.calculator-table td:nth-child(2) {
  min-width: 160px;
}

.calculator-table tbody tr {
  border-bottom-color: var(--border-secondary);
}

.calculator-table tfoot th,
.calculator-table tfoot td {
  background-color: var(--background-primary);
}

/* -- Output cells -- */
.calculator-output-cell {
  color: var(--text-secondary);
}

/* -- Totals row -- */
.calculator-totals-row th,
.calculator-totals-row td {
  padding-top: var(--space-xl);
  padding-bottom: var(--space-xl);
}

/* -- Month abbreviation -- */
.month-abbr {
  display: none;
}

/* -- Mobile responsive -- */
@media (max-width: 768px) {
  .tool-grid {
    grid-template-columns: 1fr;
  }

  .calculator-results {
    grid-template-columns: 1fr;
    gap: var(--space-l);
  }

  .calculator-result-value {
    font-size: var(--font-6xl);
  }

  .month-full {
    display: none;
  }

  .month-abbr {
    display: inline;
  }

}
