/*
  StarshipOS — Medizin: Triage & Betten (Triage-Board + Patientenregister)

  Eingebunden von templates/medical/triage.html und medical/patient-registry.html.
  Baut auf medical-ui.css auf (.tone-*, .med-tiles, .med-panel, .med-badge, .med-meter):
  Farben kommen ausschliesslich ueber --tone, damit ROT/GELB/GRÜN/VERSTORBEN überall
  dieselben MTS-Töne tragen.

  Präfixe: .tri-* = beide Ansichten / Board, .reg-* = Register.
*/

.tri-page {
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
}

.tri-muted { color: var(--text-muted); font-size: var(--text-xs); }

/* ── Szenario-Zeile (im Entwurf rechts im Kopf) ─────────────────────────── */

.tri-scenario {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 16px;
    margin-top: -0.5rem;
    font-size: var(--text-xs);
    color: var(--text-muted);
}
.tri-scenario-text b { color: var(--text-primary); font-weight: 600; }
.tri-scenario-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.tri-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--tone);
    animation: tri-pulse 1.4s ease-in-out infinite;
}

@keyframes tri-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

/* ── Kacheln: im Entwurf größere Zahl, Label oben ───────────────────────── */

.tri-tiles .med-tile { gap: 6px; padding: 12px 14px 14px; }
.tri-tiles .med-tile-value { font-size: var(--text-xl, 1.5rem); line-height: 1.1; }

/* ── Bettenleiste (Board) ───────────────────────────────────────────────── */

.tri-bedstrip {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--med-line);
    border-radius: 4px;
}
.tri-bedstrip .med-label { margin-right: 6px; }
.tri-bed {
    font-size: var(--text-xs);
    padding: 4px 7px;
    border-radius: 2px;
    border: 1px dashed var(--med-line);
    border-top: 2px solid var(--tone, transparent);
    color: var(--text-dim, var(--text-muted));
    min-width: 2.2em;
    text-align: center;
}
/* Kein eigenes --tone an .tri-bed/.reg-bed: es käme nach medical-ui.css und schlüge .tone-*. */
.tri-bed.is-free { border-top-color: transparent; }
.tri-bed.is-occupied {
    border-style: solid;
    border-top: 2px solid var(--tone, transparent);
    background: var(--bg-panel, var(--med-well));
    color: var(--text-primary);
    font-weight: 700;
}

/* ── Leerzustand ────────────────────────────────────────────────────────── */

.tri-empty {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 28px 20px;
    text-align: center;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px dashed var(--med-line);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: var(--text-sm);
}
.tri-empty b { color: var(--text-primary); }
.tri-empty span { max-width: 60ch; line-height: 1.5; }
.tri-empty.is-inset { margin: 16px; }

/* ── Kanban-Board ───────────────────────────────────────────────────────── */

/* auto-fit: vier breite Spalten am Desktop, gestapelt am Handy — keine Seiten-Querlaufleiste. */
.tri-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 10px;
    align-items: start;
}
.tri-col {
    background: var(--bg-secondary);
    border: 1px solid var(--med-line);
    border-top: 3px solid var(--tone);
    border-radius: 4px;
    min-height: 360px;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.tri-col-head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    padding: 10px 12px;
    background: color-mix(in srgb, var(--tone) 10%, transparent);
    border-bottom: 1px solid var(--med-line);
}
.tri-col-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tri-col-name b { color: var(--tone); letter-spacing: var(--tracking-label, 0.12em); font-size: var(--text-sm); }
.tri-col-name span { font-size: var(--text-xs); color: var(--text-muted); }
.tri-col-count { font-size: var(--text-lg, 1.2rem); color: var(--text-primary); }
.tri-col.tone-black .tri-col-name b { color: var(--text-secondary, var(--text-muted)); }
.tri-col-body { display: flex; flex-direction: column; gap: 8px; padding: 10px; }
.tri-col-empty { font-size: var(--text-xs); color: var(--text-dim, var(--text-muted)); text-align: center; padding: 20px 0; }

/* Patientenkarte */
.tri-card {
    background: var(--bg-panel, var(--med-well));
    border: 1px solid var(--med-line);
    border-radius: 4px;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}
.tri-card.is-deceased { opacity: 0.6; }
.tri-card-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.tri-card-top b { font-size: var(--text-sm); color: var(--text-primary); overflow-wrap: anywhere; }
.tri-card-bed { font-size: var(--text-xs); color: var(--text-muted); white-space: nowrap; }
.tri-card-bed.is-bedded { color: var(--text-primary); font-weight: 700; }
.tri-card-meta { font-size: var(--text-xs); color: var(--text-muted); line-height: 1.4; }
.tri-card-meter { height: 4px; }
.tri-card-status { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tri-card-src { font-size: var(--text-xs); color: var(--text-muted); }
.tri-card-src.is-ok { color: var(--med-green); }
.tri-card-src.is-warn { color: var(--med-yellow); font-weight: 700; }
.med-badge.is-pulse { animation: tri-pulse 1.4s ease-in-out infinite; }

/* Umstufen + Behandlungsaktion: kleine Kontur-Knöpfe in Kategoriefarbe */
.tri-card-actions { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; }
.tri-arrow { font-size: 0.62rem; color: var(--text-muted); margin-right: 2px; }
.tri-recat,
.tri-act {
    height: 24px;
    border-radius: 2px;
    border: 1px solid var(--tone);
    background: transparent;
    color: var(--tone);
    font-family: inherit;
    font-size: 0.65rem;
    font-weight: 700;
    cursor: pointer;
    padding: 0 6px;
}
.tri-recat { flex: 1 1 0; min-width: 26px; }
.tri-act {
    --tone: var(--med-green);
    background: var(--tint-green, color-mix(in srgb, var(--med-green) 12%, transparent));
    text-transform: uppercase;
    white-space: nowrap;
}
.tri-recat:hover,
.tri-act:hover { background: color-mix(in srgb, var(--tone) 18%, transparent); }
.tri-recat:focus-visible,
.tri-act:focus-visible { outline: 2px solid var(--med-accent); outline-offset: 1px; }

/* ── Register: Bettenplan + Tabelle ─────────────────────────────────────── */

.reg-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: flex-start;
}
.reg-beds { flex: 0 1 420px; min-width: 0; }
.reg-list { flex: 1 1 560px; min-width: 0; overflow: hidden; }

.reg-bedgrid {
    display: grid;
    grid-template-columns: 22px repeat(4, minmax(0, 1fr));
    gap: 6px;
    align-items: center;
    padding: 16px;
}
.reg-bedgrid-col,
.reg-bedgrid-row { font-size: var(--text-xs); color: var(--text-muted); text-align: center; }
.reg-bed {
    height: 62px;
    box-sizing: border-box;
    padding: 6px;
    border-radius: 3px;
    border: 1px dashed var(--med-line);
    border-left: 3px solid var(--tone, transparent);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    min-width: 0;
}
.reg-bed.is-free { border-left-color: transparent; }
.reg-bed.is-occupied { border-style: solid; border-left: 3px solid var(--tone); background: var(--bg-panel, var(--med-well)); }
.reg-bed-id { font-size: 0.6rem; color: var(--text-muted); }
.reg-bed-name {
    font-size: var(--text-xs);
    color: var(--text-dim, var(--text-muted));
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.reg-bed.is-occupied .reg-bed-name { color: var(--text-primary); font-weight: 700; }

/* Tabelle scrollt in ihrem Panel quer, nie die Seite. */
.reg-table-scroll { overflow-x: auto; }
.reg-table {
    width: 100%;
    min-width: 820px;
    border-collapse: collapse;
    font-size: var(--text-sm);
}
.reg-table th {
    padding: 8px 10px;
    text-align: left;
    font-weight: 400;
    background: var(--bg-primary, var(--med-well));
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-label, 0.12em);
}
.reg-table td {
    padding: 10px;
    border-top: 1px solid var(--med-line);
    vertical-align: middle;
}
/* Statusstreifen links: inset-Schatten, weil border-left an <tr> im collapse-Modell unzuverlässig ist */
.reg-table tbody td:first-child { box-shadow: inset 3px 0 0 var(--tone); }
.reg-table tbody tr:hover td { background: color-mix(in srgb, var(--tone) 5%, transparent); }
.reg-name b { display: block; color: var(--text-primary); }
.reg-name span { display: block; margin-top: 2px; font-size: var(--text-xs); color: var(--text-muted); max-width: 30ch; }
.reg-bedcell { white-space: nowrap; }
.reg-vitals { font-size: var(--text-xs); }
.reg-vitals > span { display: inline-block; margin: 0 10px 2px 0; white-space: nowrap; }
.reg-vitals i { font-style: normal; color: var(--text-muted); }
.reg-vitals b { color: var(--text-primary); }
.reg-vitals b.is-alarm { color: var(--med-red); }
.reg-last,
.reg-time { font-size: var(--text-xs); color: var(--text-muted); }
.reg-time { white-space: nowrap; }
.reg-care { white-space: nowrap; }
.reg-care .med-link-btn { padding: 4px 8px; }
.reg-name .reg-nocase { font-size: var(--text-xs); color: var(--med-yellow, var(--accent-yellow)); font-weight: 700; }
.reg-stabilized { font-size: var(--text-xs); color: var(--med-green); }

/*
  Unter 1024px stellt responsive-v2.css jedes „*-layout“ auf flex-direction: column. Dann
  wirkt flex-basis als HÖHE und align-items: flex-start lässt die Panels auf Inhaltsbreite
  (Bettenraster 600px+) wachsen; mit flex-wrap bekäme zudem jede Zeile die Breite der
  breitesten Tabelle — also: eine Zeile, volle Breite, natürliche Höhe.
*/
@media (max-width: 1023px) {
    .station-body .reg-layout { flex-wrap: nowrap; align-items: stretch; }
    .station-body .reg-layout > * { flex: none; }
}

@media (max-width: 720px) {
    .tri-col { min-height: 0; }
    .reg-bedgrid { padding: 12px; gap: 4px; grid-template-columns: 16px repeat(4, minmax(0, 1fr)); }
    .reg-bed { height: 52px; padding: 4px; }
}
