/* OPRator additions to Pico CSS (classless): only what Pico lacks. */

/* Layout and action tokens, built from Pico variables so the theme (light/dark) still applies.
   Values and why: context/archive/2026-10-28-ui-list-tables/tokens.md. Views use the classes below
   (`table.dense`, `button.destructive`), never literal colours or sizes. */
:root {
  --app-table-font-size: 0.85em;
  --app-table-cell-padding-y: calc(var(--pico-spacing) / 2);
  --app-table-cell-padding-x: calc(var(--pico-spacing) / 2);
  --app-nav-font-size: 0.875em;
  --app-nav-item-padding-x: 0.25rem;
  --app-destructive: var(--pico-del-color);
  --app-destructive-inverse: var(--pico-background-color);
  --app-destructive-focus: color-mix(in srgb, var(--pico-del-color) 40%, transparent);
  /* Neutral action (cancel, back); values and why: context/archive/2026-10-29-ui-forms-and-decisions/tokens.md. */
  --app-cancel: var(--pico-muted-color);
  --app-cancel-inverse: var(--pico-background-color);
  --app-cancel-focus: color-mix(in srgb, var(--app-cancel) 40%, transparent);
  /* Item detail (offers tables, row actions); values and why: context/archive/2026-10-29-ui-item-detail/tokens.md. */
  --app-offers-col-offer: 24%;
  --app-offers-col-status: 17%;
  --app-offers-col-price: 17%;
  --app-offers-col-actions: 25%;
  --app-row-action-gap: calc(var(--pico-spacing) / 2);
  --app-button-compact-font-size: 0.875rem;
  --app-button-compact-padding-y: calc(var(--pico-form-element-spacing-vertical) / 2);
  --app-button-compact-padding-x: calc(var(--pico-form-element-spacing-horizontal) * 0.75);
}

/* Dense table: wide tables (e.g. the 11-column list of approved zgłoszenia) fit the container. */
table.dense {
  font-size: var(--app-table-font-size);
}

table.dense :is(th, td) {
  padding: var(--app-table-cell-padding-y) var(--app-table-cell-padding-x);
}

/* „Gotowy” cell: a collapsed list of missing parts that keeps the row height steady. */
table.dense details {
  margin: 0;
}

table.dense summary {
  margin: 0;
  white-space: nowrap;
}

table.dense summary::after {
  display: inline-block;
  float: none;
  vertical-align: middle;
}

/* Offers table (item detail): fixed column widths so the three tables line up and long
   addresses wrap. Columns: Oferta, Status, Pierwsza cena, Ostatnia cena, Akcje. */
table.offers {
  width: 100%;
  table-layout: fixed;
}

table.offers th:nth-child(1) {
  width: var(--app-offers-col-offer);
}

table.offers th:nth-child(2) {
  width: var(--app-offers-col-status);
}

table.offers th:nth-child(3),
table.offers th:nth-child(4) {
  width: var(--app-offers-col-price);
}

table.offers th:nth-child(5) {
  width: var(--app-offers-col-actions);
}

table.offers :is(th, td) {
  overflow-wrap: anywhere;
}

/* Label + action on one line (a <form> or <div>): the label grows, the button keeps its size. */
.row-action {
  display: flex;
  align-items: center;
  gap: var(--app-row-action-gap);
}

.row-action > :nth-child(1 of :not([type="hidden"])) {
  flex: 1 1 auto;
  margin: 0;
}

.row-action :is(button, [type="submit"]) {
  flex: 0 0 auto;
  width: auto;
  margin: 0;
}

/* Compact buttons: Pico's default size looks oversized next to table text and one-line rows. */
:is(.row-action, table.offers, footer.actions, dialog) :is(button, [role="button"]) {
  font-size: var(--app-button-compact-font-size);
  padding: var(--app-button-compact-padding-y) var(--app-button-compact-padding-x);
}

/* Compact field + button group (role="group" with class compact): field and button share the compact
   size, so the pair is one low line. Without the class a group keeps Pico's size (task and period lists). */
[role="group"].compact :is(button, select, input) {
  font-size: var(--app-button-compact-font-size);
  padding-top: var(--app-button-compact-padding-y);
  padding-bottom: var(--app-button-compact-padding-y);
}

[role="group"].compact button {
  padding-right: var(--app-button-compact-padding-x);
  padding-left: var(--app-button-compact-padding-x);
}

/* Collapsible section under an <h2>: compact summary, colours stay Pico's, chevron stays. */
details.section {
  margin-bottom: 0;
}

details.section > summary {
  margin-bottom: 0;
}

/* Top menu on one line: items never wrap inside, spacing comes from the token. */
nav {
  font-size: var(--app-nav-font-size);
  --pico-nav-element-spacing-horizontal: var(--app-nav-item-padding-x);
  --pico-nav-link-spacing-horizontal: var(--app-nav-item-padding-x);
}

nav li {
  white-space: nowrap;
}

nav button {
  font-size: inherit;
}

/* Input + button groups (role="group", e.g. rename task or period): the label stays on one line,
   so the button has the same height as the field and as a lone button in the next cell. */
[role="group"] button {
  white-space: nowrap;
}

/* A group inside a table cell has no bottom margin, so its row centres with the other cells. */
td [role="group"] {
  margin-bottom: 0;
}

/* Destructive action (remove, reject, archive, withdraw): outline in the error colour that
   fills on hover. Classless Pico has no `.secondary`/`.contrast` styles, so this is the only
   button variant. A disabled button keeps Pico's reduced opacity. */
button.destructive {
  --pico-background-color: transparent;
  --pico-border-color: var(--app-destructive);
  --pico-color: var(--app-destructive);
}

/* Focus keeps the resting look (Pico would turn a focused button primary-blue). It comes before
   the hover rule on purpose: both have the same specificity, so hover (also while focused) wins. */
button.destructive:focus {
  --pico-background-color: transparent;
  --pico-border-color: var(--app-destructive);
  --pico-color: var(--app-destructive);
  --pico-box-shadow: 0 0 0 var(--pico-outline-width) var(--app-destructive-focus);
}

button.destructive:is(:hover, :active) {
  --pico-background-color: var(--app-destructive);
  --pico-border-color: var(--app-destructive);
  --pico-color: var(--app-destructive-inverse);
}

button.destructive:focus-visible {
  outline: var(--pico-outline-width) solid var(--app-destructive);
  outline-offset: 0.125rem;
}

/* Neutral action (cancel, back): grey outline that fills on hover; same state order as
   `button.destructive` so hover while focused keeps its label. A disabled button keeps Pico's look. */
button.cancel {
  --pico-background-color: transparent;
  --pico-border-color: var(--app-cancel);
  --pico-color: var(--app-cancel);
}

button.cancel:focus {
  --pico-background-color: transparent;
  --pico-border-color: var(--app-cancel);
  --pico-color: var(--app-cancel);
  --pico-box-shadow: 0 0 0 var(--pico-outline-width) var(--app-cancel-focus);
}

button.cancel:is(:hover, :active) {
  --pico-background-color: var(--app-cancel);
  --pico-border-color: var(--app-cancel);
  --pico-color: var(--app-cancel-inverse);
}

button.cancel:focus-visible {
  outline: var(--pico-outline-width) solid var(--app-cancel);
  outline-offset: 0.125rem;
}

/* Django messages and form errors rendered as alerts. */
article.alert {
  padding: var(--pico-spacing);
  border-left: 0.25rem solid var(--pico-muted-border-color);
}

article.alert-success {
  border-left-color: var(--pico-ins-color);
}

article.alert-error {
  border-left-color: var(--pico-del-color);
}

article.alert-warning {
  border-left-color: var(--pico-mark-background-color);
}

/* Django's per-field and non-field error lists. */
.errorlist {
  padding-left: 0;
  color: var(--pico-del-color);
  list-style: none;
}

.errorlist li {
  list-style: none;
}

/* Small counter, e.g. pending registrations next to a nav link. */
.badge {
  display: inline-block;
  min-width: 1.5em;
  padding: 0 0.4em;
  border-radius: 1em;
  background: var(--pico-primary-background);
  color: var(--pico-primary-inverse);
  font-size: 0.8em;
  line-height: 1.5em;
  text-align: center;
}

/* Wrapper for wide tables in later slices. */
.table-scroll {
  overflow-x: auto;
}

/* Row actions (e.g. „Zaakceptuj” / „Odrzuć”): one-button forms side by side. */
td.actions {
  white-space: nowrap;
}

td.actions form {
  display: inline-block;
  margin: 0 0.5rem 0 0;
}

td.actions button {
  margin: 0;
}

/* The fixed columns of the offers table: a row with many actions wraps instead of scrolling. */
table.offers td.actions {
  white-space: normal;
}

table.offers td.actions > :is(form, [role="button"]) {
  margin-block: calc(var(--app-row-action-gap) / 4);
}

/* Card actions (e.g. „Edytuj” / „Wycofaj” on a project): a link button and one-button forms side by side. */
footer.actions form {
  display: inline-block;
  margin: 0 0 0 0.5rem;
}

footer.actions button {
  margin: 0;
}

/* Decision bar right under the card header (project and zgłoszenie pages): space before the first section. */
article > header + footer.actions {
  margin-bottom: var(--pico-spacing);
}

/* Reason dialogs (e.g. „Odrzuć” with a reason): the opener button sits with the
   actions; the dialog's form wraps and stacks normally inside them. */
footer.actions > button {
  margin: 0 0 0 0.5rem;
}

.actions dialog {
  white-space: normal;
}

/* Dialog form: label and textarea take the full row, the buttons sit side by side at natural width. */
dialog form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--app-row-action-gap);
  margin: 0;
}

dialog form > :is(label, textarea) {
  flex: 1 1 100%;
  margin: 0;
}

dialog form button {
  width: auto;
  margin: 0;
}

/* Project people (e.g. „Usuń” next to a member): a one-button form after the name. */
ul.people form {
  display: inline-block;
  margin: 0 0 0 0.5rem;
}

ul.people button {
  margin: 0;
  padding: var(--app-button-compact-padding-y) var(--app-button-compact-padding-x);
  font-size: var(--app-button-compact-font-size);
}
