/* ============================================================================
   Shared component styles (01a Task 4). Loaded between foundation.css and
   app.css. Every repeated control or state lives here; app.css keeps layout
   (shell, grids, page furniture). Demonstrated on /components-reference
   (debug builds only).
   ========================================================================== */

/* ---- cards ---- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 18px; }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); white-space: nowrap; }
th a { color: inherit; text-decoration: none; }
th a:hover { color: var(--ink); }
tbody tr:hover { background: var(--color-surface-2); }
td.num { font-variant-numeric: tabular-nums; }
table.compact { font-size: .8rem; }
table.compact th, table.compact td { padding: 6px 6px; }
table.compact th { letter-spacing: 0; }

/* ---- status badges (see status_badge macro) ---- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: .74rem; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-ok        { background: var(--color-ok-bg); color: var(--color-ok); }
.pill-monitor   { background: var(--color-warn-bg); color: var(--color-warn); }
.pill-due-soon  { background: var(--color-warn-bg); color: var(--color-warn); }
.pill-overdue   { background: var(--color-serious-bg); color: var(--color-serious); }
.pill-failed    { background: var(--color-serious-bg); color: var(--color-serious); }
.pill-quarantine{ background: var(--color-serious-bg); color: var(--color-serious); }
.pill-retired   { background: #ece9fb; color: #5b4bb5; }
.pill-missing   { background: var(--color-neutral-bg); color: var(--color-neutral); }
.pill-lost      { background: var(--color-neutral-bg); color: var(--color-neutral); }
.pill-destroyed { background: var(--color-neutral-bg); color: var(--color-neutral); }
.pill-empty     { background: var(--color-neutral-bg); color: var(--color-neutral); }  /* a set with no components */

/* ---- filter chips: active filters with a remove control ---- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 6px 3px 10px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--color-surface);
  font-size: .8rem; color: var(--ink-2);
}
.chip .chip-remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border: none; border-radius: 50%;
  background: var(--color-neutral-bg); color: var(--ink-2); cursor: pointer;
  font-size: .72rem; line-height: 1; padding: 0; text-decoration: none;
}
.chip .chip-remove:hover { background: var(--color-serious-bg); color: var(--color-serious); }

/* ---- forms ---- */
form.stack { display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: .78rem; font-weight: 600; color: var(--ink-2); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
input[type=text], input[type=search], input[type=number], input[type=date],
input[type=email], input[type=password], select, textarea {
  border: 1px solid var(--line); border-radius: var(--radius-control); padding: 8px 10px;
  font: inherit; background: #fff; width: 100%; min-height: 40px;
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast);
}
input:hover, select:hover, textarea:hover { border-color: var(--color-muted); }
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--color-brand-600); box-shadow: var(--focus-ring); }
input:disabled, select:disabled, textarea:disabled { background: var(--color-surface-2); color: var(--color-muted); cursor: not-allowed; }
textarea { min-height: 70px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-size: .88rem; color: var(--ink-2); }
.check input { width: auto; }
/* validation states: server-rendered, always paired with visible text */
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--color-serious); }
.field-error { margin: 0; font-size: .8rem; color: var(--color-serious); }
.field-help { margin: 0; font-size: .8rem; color: var(--color-muted); }
.field.is-valid input, .field.is-valid select, .field.is-valid textarea { border-color: var(--color-ok); }

/* ---- segmented result control (radio inputs styled as segments) ---- */
.segmented { border: 0; padding: 0; margin: 0; min-inline-size: 0; }
.segmented legend { font-size: .78rem; font-weight: 600; color: var(--ink-2); padding: 0; margin-bottom: 4px; }
.segmented-options { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--line); border-radius: var(--radius-control); overflow: hidden; background: var(--color-surface); }
.segmented label { position: relative; }
.segmented input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.segmented label > span {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 16px; min-height: var(--target-min); font-weight: 600; font-size: .88rem;
  color: var(--ink-2); border-left: 1px solid var(--line); cursor: pointer;
  transition: background-color var(--motion-fast), color var(--motion-fast);
}
.segmented label:first-child > span { border-left: 0; }
.segmented input:focus-visible + span { box-shadow: var(--focus-ring); position: relative; z-index: 1; }
.segmented .seg-pass    input:checked + span { background: var(--color-ok-bg); color: var(--color-ok); }
.segmented .seg-monitor input:checked + span { background: var(--color-warn-bg); color: var(--color-warn); }
.segmented .seg-fail    input:checked + span { background: var(--color-serious-bg); color: var(--color-serious); }

/* ---- buttons ---- */
.btn {
  display: inline-block; border: 1px solid var(--line); border-radius: var(--radius-control); padding: 8px 16px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
  background: var(--color-surface); color: var(--ink-2); line-height: 1.4;
  transition: background-color var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast);
}
.btn:hover { background: var(--color-surface-2); border-color: var(--color-muted); }
.btn-primary { background: var(--red); color: #fff; border-color: var(--red); }
.btn-primary:hover { background: var(--red-dark); border-color: var(--red-dark); }
.btn-outline { background: transparent; color: var(--red-dark); border-color: var(--red); }
.btn-outline:hover { background: var(--color-brand-050); border-color: var(--red-dark); }
.btn-quiet { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-quiet:hover { background: var(--color-surface-2); border-color: transparent; }
.btn-danger { background: var(--color-surface); color: var(--color-serious); border-color: #f2c4c7; }
.btn-danger:hover { background: var(--color-serious-bg); border-color: var(--color-serious); }
/* NFC/information controls: light blue so tag actions stand out from the red theme */
.btn-nfc { background: var(--color-info-bg); color: var(--color-info); border: 1px solid var(--color-info-border); }
.btn-nfc:hover { background: #dcecf7; filter: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; pointer-events: none; }
/* busy: set aria-busy="true" (and disabled) while a submission is in flight */
.btn[aria-busy="true"] { position: relative; color: transparent; pointer-events: none; }
.btn[aria-busy="true"]::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 14px; height: 14px;
  border: 2px solid currentColor; border-top-color: transparent; border-radius: 50%;
  color: var(--ink-2); animation: btn-busy-spin .7s linear infinite;
}
.btn-primary[aria-busy="true"]::after { color: #fff; }
@keyframes btn-busy-spin { to { transform: rotate(360deg); } }
@media (max-width: 560px) { .btn:not(.btn-sm) { min-height: var(--target-min); } }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
/* Button styled as an inline link (e.g. ✕ remove in the batch scan queue) */
.link-btn { background: none; border: none; padding: 0; font: inherit; color: var(--red-dark); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* ---- messages (flash + inline status) ---- */
.flash { border-radius: var(--radius-control); padding: 10px 14px; margin-bottom: 14px; font-size: .9rem; border: 1px solid; }
.flash-success { background: var(--color-ok-bg); color: #14532d; border-color: #bfe3cf; }
.flash-error { background: var(--color-serious-bg); color: #7f1d1d; border-color: #f2c4c7; }
.flash-info { background: var(--color-info-bg); color: var(--color-info); border-color: var(--color-info-border); }
small.status-error { color: var(--serious); }

/* ---- tabs (in-page category switcher, e.g. report groups) ---- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; overflow-x: auto; }
.tabs a {
  padding: 8px 14px; text-decoration: none; color: var(--ink-2); font-weight: 500; font-size: .9rem;
  border-bottom: 2px solid transparent; white-space: nowrap;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="true"], .tabs a.active { color: var(--red-dark); border-bottom-color: var(--red); font-weight: 600; }

/* ---- breadcrumbs (deeper pages only) ---- */
.breadcrumb ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 6px; padding: 0; font-size: .82rem; }
.breadcrumb li { color: var(--ink-3); }
.breadcrumb li + li::before { content: "/"; margin: 0 6px 0 2px; color: var(--line); }
.breadcrumb a { color: var(--ink-2); text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb [aria-current="page"] { color: var(--ink); font-weight: 600; }

/* ---- pagination ---- */
.pagination { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; font-size: .88rem; }
.pagination a, .pagination span {
  min-width: 32px; padding: 5px 9px; text-align: center; border-radius: var(--radius-control);
  text-decoration: none; color: var(--ink-2); border: 1px solid transparent;
}
.pagination a:hover { background: var(--color-surface-2); border-color: var(--line); }
.pagination [aria-current="page"] { background: var(--color-brand-050); color: var(--red-dark); font-weight: 600; }
.pagination .disabled { color: var(--line); }

/* ---- empty states (see empty_state macro) ---- */
.empty-state { text-align: center; padding: 28px 16px; }
.empty-state-title { margin: 0 0 4px; font-weight: 600; color: var(--ink-2); }
.empty-state-message { margin: 0 0 12px; font-size: .88rem; color: var(--color-muted); }

/* ---- menus (details-based disclosure, e.g. account/overflow menus) ---- */
.menu { position: relative; display: inline-block; }
.menu summary { list-style: none; cursor: pointer; }
.menu summary::-webkit-details-marker { display: none; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 180px;
  background: var(--color-surface); border: 1px solid var(--line); border-radius: var(--radius-panel);
  box-shadow: var(--shadow-2); padding: 6px; display: flex; flex-direction: column;
}
.menu-panel a, .menu-panel button {
  padding: 8px 10px; border: none; background: none; border-radius: var(--radius-control);
  color: var(--ink); text-decoration: none; font: inherit; text-align: left; cursor: pointer;
}
.menu-panel a:hover, .menu-panel button:hover { background: var(--color-surface-2); }
.menu-panel .menu-danger { color: var(--color-serious); }

/* ---- dialogs (native <dialog>; strong elevation is reserved for these) ---- */
dialog.dialog {
  border: 1px solid var(--line); border-radius: var(--radius-panel); box-shadow: var(--shadow-2);
  padding: 20px; max-width: min(92vw, 440px);
}
dialog.dialog::backdrop { background: rgba(20, 24, 33, .45); }
.dialog-title { margin: 0 0 8px; font-size: var(--text-h2); font-weight: 600; }
.dialog-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }

/* ---- NFC tag UIDs ---- */
code.uid { font-family: var(--font-mono); font-size: .82rem; background: var(--color-info-bg); border: 1px solid var(--color-info-border); color: var(--color-info); border-radius: 6px; padding: 1px 6px; letter-spacing: .03em; }
