/* Data grid. Colours come from custom properties only - see themes/. */

/* Company branding swatch. --swatch-colour is set inline per-row from a
   value the service layer has already validated as a real hex colour (see
   app/blueprints/companies/forms.py) - never string-concatenated into a
   style attribute, just this one custom property. */
/* Audit Log's per-row change list. */
.audit-changes {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
}
.audit-changes li { margin-bottom: var(--space-1); }
.audit-changes li:last-child { margin-bottom: 0; }
.audit-changes strong { font-weight: 600; }

.colour-swatch {
  display: inline-block;
  width: 1.1em;
  height: 1.1em;
  border-radius: 4px;
  border: 1px solid var(--border);
  background-color: var(--swatch-colour, transparent);
  vertical-align: middle;
}

/* Booking Manager: the Customer cell is filled with the linked company's
   brand colour, with the text forced to black or white for contrast. Both
   values are set inline per-row as custom properties from a hex the service
   layer already validated (see app/colour.py) - never concatenated into a
   style rule. */
table.data tbody td.customer-cell.is-branded {
  background-color: var(--cell-bg);
  color: var(--cell-fg);
}

/* Confirmer's reason on a sent-back booking, shown under the customer name
   on the rep's list. The brand fill is suppressed for these rows (see
   bookings/list.html) so this stays readable. */
.rejection-note {
  display: block;
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  color: var(--danger);
}

/* Call-back lock on the confirmer list. Grey (waiting) then red (overdue),
   white text on both. These are status fills, not theme colours - the grey
   is intentionally the same in every theme (same reasoning as the
   activity-feed `white`); `white` and `black` are plain CSS keywords, not
   the hex/rgb literals the theme-discipline test polices. The brand fill on
   the customer cell is suppressed for a locked row (see bookings/list.html)
   so it never competes with this. */
table.data tbody tr.callback-pending td {
  background: color-mix(in srgb, black 42%, white);
  color: white;
}
table.data tbody tr.callback-overdue td {
  background: var(--danger);
  color: white;
}

.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

table.data thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  text-align: left;
  padding: var(--space-3);
  background: var(--surface-alt);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  border-bottom: 2px solid var(--border);
}

table.data tbody td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

/* Alternating rows: the cheapest way to keep the eye on one record. */
table.data tbody tr:nth-child(even) { background: var(--surface-alt); }
table.data tbody tr:hover { background: var(--accent); color: var(--accent-text); }

/* Plain links in a hovered row invert with it - but NOT anything that carries
   its own background. Edit and Permissions are <a class="btn">, so inverting
   their text left light-on-light and made them unreadable, while the <button>
   actions next to them were unaffected. Anything with its own surface keeps its
   own colours. */
table.data tbody tr:hover a:not(.btn) { color: var(--accent-text); }

table.data tbody tr:hover .btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
table.data tbody tr:hover .btn-secondary:hover {
  background: var(--surface-alt);
  color: var(--text);
}
table.data tbody tr:hover .btn:not(.btn-secondary) {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--border);
}

/* Status pills sit on their own background too. */
table.data tbody tr:hover .pill-off { background: var(--surface); color: var(--text-muted); }

table.data tbody tr:last-child td { border-bottom: none; }

table.data td.actions {
  white-space: nowrap;
  text-align: right;
  width: 1%;
}

table.data td.numeric { text-align: right; font-variant-numeric: tabular-nums; }

.table-empty {
  padding: var(--space-6);
  text-align: center;
  color: var(--text-muted);
}

/* Status pill */
.pill {
  display: inline-block;
  padding: 2px var(--space-2);
  border-radius: 999px;
  font-size: var(--text-xs);
  font-weight: 600;
  border: 1px solid var(--border);
}
.pill-on { background: var(--success); color: var(--success-text); border-color: transparent; }
.pill-off { background: var(--surface); color: var(--text-muted); }

.inline-form { display: inline; }

/* Checkbox columns (the role permission matrix) centre under their heading and
   get a comfortable hit area. */
table.data td.check, table.data th.check { text-align: center; width: 1%; white-space: nowrap; }
table.data input[type="checkbox"] {
  width: 1.05rem;
  height: 1.05rem;
  accent-color: var(--accent);
  cursor: pointer;
}
