/* Crispy / Bootstrap5 form widget overrides — make form-control inherit our .input look */
.form-control,
.form-select,
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  outline: none;
  font-size: 13px;
  font-family: inherit;
}

.form-control:focus,
.form-select:focus,
input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(12, 65, 15, 0.12);
}

.form-label,
label {
  display: block;
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 13px;
}

.mb-3 { margin-bottom: 14px; }

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.form-check-input {
  width: 16px;
  height: 16px;
  margin: 0;
}
.form-check-label {
  margin-bottom: 0;
  font-weight: 500;
}

.invalid-feedback,
.errorlist {
  font-size: 12px;
  color: var(--bad);
  margin-top: 4px;
  list-style: none;
  padding: 0;
}

.is-invalid {
  border-color: var(--bad);
}

.form-text,
.helptext {
  font-size: 12px;
  color: var(--muted-2);
  margin-top: 4px;
}

/* Page action button row */
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Formset table polish */
.formset-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.formset-table th,
.formset-table td {
  padding: 8px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
.formset-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 650;
  background: var(--card-2);
}
.formset-table tr:last-child td { border-bottom: none; }
.formset-table input,
.formset-table select { width: 100%; }
.formset-table .delete-cell { width: 60px; text-align: center; }

/* Right-align numeric columns in stock/list tables */
.text-right { text-align: right; }
.fw-bold { font-weight: 700; }
.text-bad { color: var(--bad); }

/* Empty-state row */
.table .empty-row td {
  text-align: center;
  color: var(--muted-2);
  padding: 28px 12px;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 16px 12px 4px;
}
.empty-state__title { color: var(--muted); font-size: 14px; }

/* Formset row states */
.formset-row--new {
  animation: rowPulse 1.2s ease-out;
}
@keyframes rowPulse {
  0%   { background: #e8f5e9; }
  100% { background: transparent; }
}
.formset-row--deleted td {
  opacity: 0.45;
  text-decoration: line-through;
}
.formset-row--deleted td.delete-cell {
  opacity: 1;
  text-decoration: none;
}

/* Accessibility helper */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Keyboard focus rings */
.button:focus-visible,
.nav__link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Filter toolbar card */
.filter-card {
  margin-bottom: 14px;
  padding: 12px 14px;
}
.filter-card .toolbar { width: 100%; }
.filter-card .toolbar > * { margin: 0; }
.filter-card .filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-card .filter-group label { margin: 0; }
.filter-card .filter-actions {
  display: flex; gap: 8px; margin-left: auto; align-self: flex-end;
}

/* Sortable header indicator */
.table th.sortable a {
  color: inherit;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.table th.sortable a:hover { text-decoration: none; color: var(--accent); }
.table th.sortable .sort-arrow { font-size: 10px; opacity: 0.7; }

/* Pagination meta line */
.pagination-meta {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  padding: 0 0 8px;
}

/* Keyboard shortcuts help overlay */
.shortcuts-help {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.shortcuts-help[hidden] { display: none; }
.shortcuts-help__panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 18px 22px;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}
.shortcuts-help__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.shortcuts-help__panel h3 { margin: 0; font-size: 16px; }
.shortcuts-help__panel dl {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 16px;
  font-size: 13px;
}
.shortcuts-help__panel dt { display: flex; gap: 4px; align-items: center; }
.shortcuts-help__panel dd { margin: 0; color: var(--muted); align-self: center; }
.shortcuts-help__panel kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  text-align: center;
  font-family: inherit;
  font-size: 12px;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 6px;
  color: var(--text);
}

/* Bulk action bar */
.bulk-bar {
  position: sticky;
  bottom: 12px;
  margin-top: 12px;
  display: none;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--text);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}
.bulk-bar.is-open { display: flex; }
.bulk-bar__count { font-weight: 600; }
.bulk-bar form { margin: 0; display: flex; gap: 8px; }
.bulk-bar .button {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.18);
  color: #fff;
}
.bulk-bar .button:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.3);
}
.bulk-bar .button--cancel {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.18);
}
.row-select { width: 32px; }
.row-select input { cursor: pointer; }

/* Inline rename */
.rename-cell { cursor: text; }
.rename-cell.is-editing { padding: 4px 6px; }
.rename-cell input {
  width: 100%;
  font: inherit;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--accent);
  background: var(--panel);
  color: var(--text);
  outline: none;
}
.rename-cell.is-saved {
  animation: cellPulse 1.2s ease-out;
}
@keyframes cellPulse {
  0%   { background: #e8f5e9; }
  100% { background: transparent; }
}
