/* ===== Inventory page ===== */

/* Section tabs (Stock / Assets) — segmented control, visible on all sizes */
.inv-tabs {
  display: flex; gap: 0.4rem;
  background: var(--accent-soft); border-radius: 10px; padding: 3px;
  margin-bottom: 1.5rem; max-width: 320px;
}
.inv-tabs button {
  flex: 1; background: transparent; border: none;
  padding: 0.55rem 0.75rem;
  font-family: inherit; font-size: 0.9rem; font-weight: 500;
  color: var(--text-muted); cursor: pointer; border-radius: 8px;
  transition: all 0.15s;
}
.inv-tabs button:hover { color: var(--text); }
.inv-tabs button.active {
  background: var(--bg); color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

/* Add form */
.inv-add {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 1.15rem 1.25rem; margin-bottom: 1.5rem;
}
.inv-add h3 { font-size: 0.95rem; margin-bottom: 0.85rem; }

.inv-form {
  display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: center;
}
.inv-form input, .inv-form select {
  flex: 1 1 140px; min-width: 0;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: 0.88rem; background: var(--bg);
}
.inv-form input:focus, .inv-form select:focus { outline: none; border-color: var(--text); }
.inv-form .btn { flex: 0 0 auto; }
/* Hide number spinners in the add form too */
.inv-form input[type="number"]::-webkit-outer-spin-button,
.inv-form input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.inv-form input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* On narrow screens, let form fields take roughly half-width rows */
@media (max-width: 640px) {
  .inv-form input, .inv-form select { flex: 1 1 45%; }
  .inv-form .btn { flex: 1 1 100%; }
}

.inv-note {
  font-size: 0.75rem; color: var(--text-muted); margin-top: 0.7rem;
}

/* Tables */
.inv-list-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.inv-table {
  width: 100%; border-collapse: collapse; font-size: 0.88rem;
  min-width: 720px;                 /* keep columns readable; wrap scrolls on mobile */
}
.inv-table th {
  text-align: left; font-weight: 500; color: var(--text-muted);
  font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.inv-table th.num { text-align: right; }
.inv-table td {
  padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.inv-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.inv-table tr:last-child td { border-bottom: none; }

.empty-row {
  text-align: center; color: var(--text-faint);
  padding: 2.5rem 0 !important; font-size: 0.9rem;
}

/* Inline editable cells (stock) */
.cell-input {
  width: 100%; border: 1px solid transparent; background: transparent;
  padding: 0.4rem 0.5rem; border-radius: 6px;
  font-family: inherit; font-size: 0.88rem; color: var(--text);
}
select.cell-input { cursor: pointer; }
.cell-input:hover { border-color: var(--border); }
.cell-input:focus { outline: none; border-color: var(--text); background: var(--bg); }
.cell-input.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Hide number-input spinner arrows — they clip long ₲ values and aren't needed */
.cell-input[type="number"]::-webkit-outer-spin-button,
.cell-input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cell-input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* Minimum widths so 6-figure guaraní totals never truncate */
.inv-table td.col-total .cell-input,
.inv-table td.col-price .cell-input { min-width: 92px; }
.inv-table td.col-qty .cell-input   { min-width: 64px; }
.inv-table .col-name  { min-width: 130px; }
.inv-table .col-cat   { min-width: 130px; }
.inv-table .col-vendor { min-width: 110px; }

/* Row actions */
.actions-col { white-space: nowrap; text-align: right; }

.date-cell { color: var(--text-muted); font-size: 0.82rem; white-space: nowrap; }

.reflect-btn {
  background: var(--text); color: var(--bg);
  border: none; border-radius: 7px;
  padding: 0.4rem 0.7rem; font-family: inherit; font-size: 0.78rem; font-weight: 500;
  cursor: pointer; transition: background 0.15s;
}
.reflect-btn:hover { background: #262626; }

.row-save {
  background: transparent; color: var(--text);
  border: 1px solid var(--border); border-radius: 7px;
  padding: 0.4rem 0.7rem; font-family: inherit; font-size: 0.78rem; font-weight: 500;
  cursor: pointer; transition: border-color 0.15s; margin-left: 0.35rem;
}
.row-save:hover { border-color: var(--text); }

.row-del {
  background: transparent; border: 1px solid var(--border); border-radius: 7px;
  width: 30px; height: 30px; color: var(--text-faint);
  font-size: 1.1rem; line-height: 1; cursor: pointer; margin-left: 0.35rem;
  transition: color 0.15s, border-color 0.15s;
}
.row-del:hover { color: var(--danger); border-color: var(--danger); }

.hidden { display: none !important; }

/* ---- Asset edit modal (the single edit path for assets) ---- */
.ast-form-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem;
  margin: 1rem 0;
}
.ast-field { display: flex; flex-direction: column; gap: 0.25rem; }
.ast-field-wide { grid-column: 1 / -1; }
.ast-field span {
  font-size: 0.72rem; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.03em;
}
.ast-field input, .ast-field select {
  padding: 0.5rem 0.6rem; border: 1px solid var(--border); border-radius: 8px;
  font-family: inherit; font-size: 0.9rem; background: var(--bg); color: var(--text);
}
.ast-field input:focus, .ast-field select:focus { outline: none; border-color: var(--text); }
.ast-field input[type="number"]::-webkit-outer-spin-button,
.ast-field input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.ast-field input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

.ast-dep-summary { background: var(--accent-soft); border-radius: 10px; padding: 0.7rem 0.9rem; }
.dep-row { display: flex; justify-content: space-between; padding: 0.2rem 0; font-size: 0.88rem; }
.dep-row span { color: var(--text-muted); }
.dep-row strong { font-variant-numeric: tabular-nums; }
.ast-note { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.7rem; }

/* Pencil edit button on a row */
.row-edit {
  width: 28px; height: 28px; border: 1px solid var(--border); border-radius: 7px;
  background: transparent; color: var(--text-muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.row-edit:hover { color: var(--text); border-color: var(--text); }

@media (max-width: 640px) {
  .ast-form-grid { grid-template-columns: 1fr; }
}

/* Restock button on a stock row — the only action that writes to Books */
.row-restock {
  padding: 0.35rem 0.6rem; border: 1px solid var(--border); border-radius: 7px;
  background: transparent; color: var(--text); cursor: pointer;
  font-family: inherit; font-size: 0.78rem; font-weight: 500; white-space: nowrap;
}
.row-restock:hover { border-color: var(--text); background: var(--accent-soft); }

.restock-preview { background: var(--accent-soft); border-radius: 10px; padding: 0.7rem 0.9rem; }
.field-hint { font-size: 0.7rem; color: var(--text-muted); text-transform: none; letter-spacing: 0; }