/* Built with the Secure Platform Developer Agent (SPDA v1.2.2) */
/* Practices by: A2C (2026) */
/* Artifact: the components that the payroll app and the attendance clock share (ADR 0058): banners, status tags, the
   one table component (stacked cards on a narrow card), the toast, and the rules that keep anything from leaving its
   box. ONE file, two copies kept byte for byte equal by tools/check_shared_assets.py (src/app/web/static/css/base.css
   and services/asistencia/src/asistencia/static/shared/base.css). Loaded after tokens.css and before each product's
   own stylesheet, so a product can still decide its own shell. The colors and sizes come from tokens.css only.
   Rules of the base: nothing leaves its container or the window; no page scroll (only a table that cannot fit scrolls
   inside its own box); a long text is cut with an ellipsis and its whole text goes in the title (class "cut"); a
   header never breaks a word. */

/* ---------- nothing leaves its box ---------- */
*, *::before, *::after { box-sizing: border-box; }
img, svg, video, canvas, iframe { max-width: 100%; }
main, main > *, .card, .card > :not(table), .alert > *, form > :not(table) { min-width: 0; }  /* (not a table: it keeps its own minimum) */
h1, h2, h3, p, li, label, summary, dd, dt { overflow-wrap: break-word; }
pre { max-width: 100%; overflow-x: auto; }
.cut { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }

/* a banner with the thing that needs attention and the way to do it */
.alert { padding: 14px 18px; border-radius: var(--r-card); border: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.alert.warn, .notice { background: var(--notice-bg); border-color: var(--notice-line); color: var(--notice-ink); }
.alert.warn a, .notice a { color: var(--notice-ink); font-weight: 600; }
.alert.error-box { background: var(--red-bg); border-color: var(--red-line); }
.alert.ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-ink); }
.alert.info { background: var(--info-bg); border-color: var(--info-line); color: var(--info-ink); }
.alert.info a { color: var(--link); font-weight: 600; }
.alert .icon { margin-top: 2px; }

/* a status tag: every table and card says its state with one of these (the text always says it too) */
.badge { display: inline-block; padding: 2px 10px; border-radius: var(--r-ctl); font-size: .8rem; border: 1px solid var(--notice-line); background: var(--notice-bg); color: var(--notice-ink); }
.badge.ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-ink); }
.badge.bad { background: var(--red-bg); border-color: var(--red-line); color: var(--red); }
.badge.neutral { background: var(--card-2); border-color: var(--line); color: var(--ink-2); }
.badge.info { background: var(--info-bg); border-color: var(--info-line); color: var(--link); }
.badge.warn { background: var(--notice-bg); border-color: var(--notice-line); color: var(--notice-ink); }
.badge.off { background: var(--card-2); border-color: var(--line); color: var(--ink-2); }
.badge { white-space: nowrap; }

/* ---------- tables (cards on small screens) ---------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .75rem; color: var(--ink-2); font-weight: 600; text-transform: uppercase; letter-spacing: .06em; background: var(--card-2); }
table.kv td { overflow-wrap: anywhere; }
table.kv th { width: 42%; text-transform: none; letter-spacing: 0; font-size: .85rem; background: transparent; }
td a { font-weight: 500; text-decoration: none; }
td a:hover { text-decoration: underline; }

/* ---------- THE table component (every data table of the app is table.stack) ----------
   Wide screens: a normal table that never leaves its container (long text wraps, dates, numbers and
   actions stay on one line). Under 700 px of its card: every row is a stacked card, label: value, with
   no page scroll. Cells: td.date (short date), td.num (right), td.act (small action button at the row end). */
.card:has(table.stack) { container-type: inline-size; }
table.stack { table-layout: auto; }  /* it keeps the width its words need: the card scrolls, a word is never cut */
table.stack th, table.stack td { overflow-wrap: break-word; word-break: normal; }
/* what has no place to break (an e-mail, a code, a package id: class "token") may break where it must, rather than leave its cell */
table.stack td code, table.stack td .varname, .token { overflow-wrap: anywhere; }
.card:has(table.stack) { overflow-x: auto; }
table.stack td.date, table.stack td.num { white-space: nowrap; }
table.stack td.act, table.stack th.act { text-align: right; white-space: nowrap; width: 1%; }
table.stack th { overflow-wrap: normal; word-break: keep-all; white-space: nowrap; }
table.stack td.act { overflow-wrap: normal; }
table.stack td.until { white-space: nowrap; }
table.stack .badge { white-space: nowrap; overflow-wrap: normal; }
table.stack td.date .hint { white-space: normal; }
table.stack td.until .hint { display: block; white-space: normal; max-width: 18em; }

/* long text in a cell: one line with an ellipsis (the whole text is in its title); the stacked card shows it whole */
table.stack td.cut { max-width: 15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; overflow-wrap: normal; }
/* a table that cannot fit scrolls INSIDE its own box (the page never does) */
.table-scroll { max-width: 100%; overflow-x: auto; }
.table-scroll > table.stack { max-width: none; }
.flags { display: flex; flex-wrap: wrap; gap: 4px 6px; min-width: 9rem; }  /* tags drop whole to the next line */
.flag, .badge { white-space: nowrap; overflow-wrap: normal; word-break: keep-all; }
.actions { display: inline-flex; gap: 8px; flex-wrap: nowrap; align-items: center; }

/* the table stacks by the width of ITS card (a 768 px screen with the menu open has a ~430 px card) */
@container (max-width: 699px) {
  table.stack, table.stack thead, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stack tr { border: 1px solid var(--line); border-radius: var(--r-ctl); padding: 8px 12px; margin-bottom: 12px; background: var(--card); }
  table.stack td { border: 0; padding: 6px 0; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 14px; text-align: right; white-space: normal; }
  table.stack td::before { content: attr(data-label); color: var(--ink-2); font-weight: 600; font-size: .82rem; text-align: left; flex: none; max-width: 45%; }
  table.stack td.num, table.stack td.date, table.stack td.until { text-align: right; white-space: normal; }
  table.stack td.act { width: 100%; justify-content: flex-start; align-items: flex-start; flex-wrap: wrap; text-align: left; padding-top: 10px; }
  table.stack td.cut { max-width: none; white-space: normal; overflow: visible; text-overflow: clip; }
  .actions { flex-wrap: wrap; }
}
td:not([data-label])::before { display: none; }

/* a notice that shows for a few seconds on its own (a success) or stays until the next action (a warning or an error) */
.toast { position: fixed; top: 14px; right: 14px; left: auto; z-index: 200; max-width: min(520px, calc(100vw - 28px)); margin: 0; box-shadow: var(--shadow-lift); }
.toast:empty { display: none; }
