/* Dashboard styles, part 3 of 8: switches, Multiview, toolbars, the stream page, forms, media, toasts.
 * The parts load in this order, and a later rule wins over an earlier one. */

/* ---------- switch ---------- */
.switch-row { display: flex; align-items: center; gap: 14px; }
.switch { position: relative; width: 44px; height: 24px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--border-strong); cursor: pointer; padding: 0; flex: none; transition: background 0.15s; }
.switch .knob { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(15, 23, 42, 0.3); transition: transform 0.15s; }
.switch[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.switch[aria-checked="true"] .knob { transform: translateX(20px); }
.switch:disabled { opacity: 0.6; cursor: default; }

/* ---------- multiview ---------- */
.wall { --tile: 320px; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, var(--tile)), 1fr)); gap: 14px; }
.tile { display: block; color: inherit; text-decoration: none; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.tile:hover { border-color: var(--accent); }
.tile:focus-visible { outline-offset: 0; }
.shot { position: relative; aspect-ratio: 16 / 9; background: #0b1220; }
.shot img { width: 100%; height: 100%; object-fit: contain; display: block; }
.shot .msg { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 8px; color: #cbd5e1; font-size: 12.5px; }
.shot .badge { position: absolute; left: 8px; top: 8px; }
.shot .age { position: absolute; right: 8px; bottom: 6px; font-size: 11px; color: #e2e8f0; background: rgba(15, 23, 42, 0.6); border-radius: 4px; padding: 0 5px; font-variant-numeric: tabular-nums; }
/* Sound meters: left and right, -60 to 0 dBFS. The colours are fixed to the bar's height (green, yellow above -18, red above -6); a dark cover hides what is above the level. */
.vu { position: absolute; right: 6px; top: 6px; bottom: 6px; display: flex; gap: 3px; pointer-events: none; }
.vu-bar { position: relative; width: 6px; border-radius: 2px; overflow: hidden; background: linear-gradient(to top, #22c55e 0 70%, #eab308 70% 90%, #ef4444 90% 100%); }
.vu-cover { position: absolute; left: 0; right: 0; top: 0; height: 100%; background: rgba(15, 23, 42, 0.88); transition: height 0.2s linear; }
.vu-peak { position: absolute; left: 0; right: 0; height: 2px; margin-bottom: -1px; background: #f8fafc; }
.shot.has-vu .age { right: 26px; }
.shot .sound-alarm { position: absolute; left: 8px; bottom: 6px; font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; color: #fff; background: rgba(220, 38, 38, 0.92); border-radius: 4px; padding: 1px 7px; }
.shot .sound-alarm.muted-alarm { font-weight: 600; letter-spacing: 0; background: rgba(15, 23, 42, 0.7); color: #e2e8f0; }
.tile.no-sound { border-color: var(--danger); box-shadow: 0 0 0 1px var(--danger); }
/* the figures and tags go under the name when a small tile can't hold both: the name is never squeezed away */
.tile-info { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 2px 8px; padding: 9px 12px; }
.tile-info .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; max-width: 100%; }
.tile-info .meta { color: var(--muted); font-size: 12.5px; white-space: nowrap; display: inline-flex; flex-wrap: wrap; row-gap: 4px; align-items: center; font-variant-numeric: tabular-nums; }

/* ---------- streams toolbar ---------- */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.search { position: relative; flex: 1 1 220px; max-width: 340px; }
.search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search input { padding-left: 32px; }
.sess-table td { white-space: nowrap; }
.sess-table td.name { white-space: normal; min-width: 140px; }
.sess-filters select, .sess-filters input[type=search] { width: auto; flex: 0 1 auto; max-width: 100%; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-btn { font: inherit; font-size: 13px; font-weight: 600; color: var(--muted); background: var(--surface); border: 1px solid var(--border-strong); border-radius: 999px; padding: 3px 11px; cursor: pointer; }
.chip-btn:hover { color: var(--text); background: var(--surface-2); }
.chip-btn[aria-pressed="true"] { color: var(--accent-strong); background: var(--accent-soft); border-color: var(--accent-border); }
.chip-btn .n { font-variant-numeric: tabular-nums; opacity: 0.8; margin-left: 4px; }

/* ---------- stream detail ---------- */
.subtabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 0 0 16px; overflow-x: auto; scrollbar-width: none; }
.subtabs::-webkit-scrollbar { display: none; }
.subtabs a { padding: 9px 14px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.subtabs a:hover { color: var(--text); }
.subtabs a[aria-current="page"] { color: var(--accent-strong); border-bottom-color: var(--accent); }
/* multi-channel bundle forms */
.mpts-form { border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin: 8px 0 16px; background: var(--surface-2, var(--bg)); }
.mpts-form h3 { margin: 0 0 12px; font-size: 15px; }
.mpts-row { display: grid; grid-template-columns: 1.3fr 0.6fr 1.4fr 1.3fr 0.9fr 36px; gap: 8px; align-items: center; margin-bottom: 6px; }
.mpts-row input, .mpts-row select { width: 100%; min-width: 0; }
.mpts-row-head span { font-size: 12px; font-weight: 600; color: var(--muted); }
.mpts-channel { margin-bottom: 8px; }
.mpts-pids { margin: -2px 0 0; font-size: 12.5px; color: var(--muted); }
.mpts-pids summary { cursor: pointer; width: max-content; }
.mpts-pid-fields { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 6px 0 4px; }
.mpts-pid-fields label { display: flex; gap: 6px; align-items: center; margin: 0; font-weight: 600; color: var(--muted); }
.mpts-pid-fields input { width: 80px; }
@media (max-width: 720px) {
  .mpts-form .form-grid { grid-template-columns: 1fr !important; }
  .mpts-row { grid-template-columns: 1fr 1fr; }
  .mpts-row-head { display: none; }
}
/* playout schedule editor */
.notice { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px; margin: 0 0 12px; font-size: 13.5px; }
.notice.warn { background: var(--warn-soft); border-color: var(--warn-border); }
.notice.bad { background: var(--danger-soft); border-color: var(--danger-border); }
.notice .plain-list { margin-top: 4px; }
.pl-days { display: inline-flex; flex-wrap: wrap; gap: 3px; }
.pl-day { font: inherit; font-size: 11.5px; font-weight: 600; width: 28px; height: 26px; padding: 0; border: 1px solid var(--border-strong); border-radius: 6px; background: var(--surface); color: var(--muted); cursor: pointer; }
.pl-day[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-strong); border-color: var(--accent-border); }
.onair-skip { display: flex; gap: 8px; margin-top: 10px; align-items: center; flex-wrap: wrap; }
.preview { position: relative; background: #0b1220; border-radius: var(--radius) var(--radius) 0 0; aspect-ratio: 16 / 9; overflow: hidden; }
.preview video { width: 100%; height: 100%; object-fit: contain; display: block; background: #0b1220; }
.preview .overlay { position: absolute; inset: 0; display: grid; place-items: center; color: #cbd5e1; font-size: 13px; pointer-events: none; }
.preview-bar { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 12px; border-top: 1px solid var(--border); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.kv dd small { color: var(--muted); }
.callout { border: 1px solid var(--border); border-left-width: 4px; border-radius: var(--radius-sm); background: var(--surface); padding: 12px 14px; margin-bottom: 16px; }
.callout p { margin: 0 0 8px; }
.callout .row { display: flex; gap: 8px; flex-wrap: wrap; }
.callout.danger { border-color: var(--danger-border); border-left-color: var(--danger); background: var(--danger-tint); }
.callout.warn { border-color: var(--warn-border); border-left-color: #f59e0b; background: var(--warn-tint); }
.callout.info { border-color: var(--info-border); border-left-color: var(--info); background: var(--info-tint); }
.callout.ok { border-color: var(--ok-border); border-left-color: #22c55e; background: var(--ok-tint); }
.notes { margin: 0; padding-left: 18px; color: var(--muted); }
.notes li { margin: 2px 0; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty h2 { color: var(--text); font-size: 17px; margin-bottom: 6px; }
.empty .settings { text-align: left; max-width: 640px; margin: 18px auto 0; }
.fineprint { color: var(--muted); font-size: 12.5px; margin: 10px 2px 0; }

/* ---------- attention + lists ---------- */
.attn { list-style: none; margin: 0; padding: 0; }
.attn li { display: flex; gap: 10px; align-items: flex-start; padding: 11px 16px; border-bottom: 1px solid var(--border); }
.attn li:last-child { border-bottom: 0; }
.attn .lvl { flex: none; width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; background: var(--faint); }
.attn .lvl.bad { background: #ef4444; } .attn .lvl.warn { background: #f59e0b; } .attn .lvl.info { background: #38bdf8; }
.attn .body { min-width: 0; flex: 1; }
.attn .body a { font-weight: 600; }
.allgood { display: flex; align-items: center; gap: 10px; padding: 16px; color: var(--ok); font-weight: 600; }
.row-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.row-item:last-child { border-bottom: 0; }
.row-item .grow { flex: 1; min-width: 160px; display: flex; align-items: center; gap: 10px; }
.row-actions { display: flex; align-items: center; gap: 6px; }
.row-actions .btn { white-space: nowrap; }
.row-actions label { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
table.data td select { width: auto; min-width: 9em; }
.row-confirm { flex-basis: 100%; background: var(--danger-soft); border: 1px solid var(--danger-border); border-radius: var(--radius-sm); padding: 10px 12px; }
.row-confirm .row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.key { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.inline-form input { flex: 1 1 240px; }

.evt-time { color: var(--muted); white-space: nowrap; }
.data tr.day-row th { background: var(--surface); color: var(--text); text-transform: none; letter-spacing: 0; font-size: 12.5px; padding-top: 14px; }
.lvl-pill { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--faint); margin-right: 8px; }
.lvl-pill.good { background: #22c55e; } .lvl-pill.warn { background: #f59e0b; } .lvl-pill.bad { background: #ef4444; }

/* ---------- forms in cards ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 2fr auto; gap: 10px; align-items: end; }
.form-grid label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; }
.keypick { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.keypick select { width: auto; min-width: 200px; }
.field { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.field .name { color: var(--muted); font-weight: 600; font-size: 13px; }
.field code { display: block; padding: 7px 9px; overflow-x: auto; white-space: nowrap; }

/* ---------- media + playout ---------- */
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 28px 16px; border: 2px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface-2); cursor: pointer; }
.dropzone .icon { width: 28px; height: 28px; color: var(--accent); }
.dropzone:hover, .dropzone:focus-visible, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); outline: none; }
.upload-list { display: grid; gap: 14px; }
.upload-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.upload-head strong { overflow-wrap: anywhere; }
.upload-head .head-actions { margin-left: auto; }
.upload-row .meter { margin-top: 6px; }
.media-name { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.media-table td.name { min-width: 190px; }
a.pill { text-decoration: none; }
a.pill:hover { filter: brightness(0.95); }
pre.code { font-family: var(--mono); font-size: 13px; line-height: 1.6; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; overflow-x: auto; }
.plain-list { margin: 0; padding-left: 18px; }
details.err-detail { margin-top: 4px; font-size: 12.5px; color: var(--muted); }
details.err-detail summary { cursor: pointer; }
details.err-detail code { display: block; margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.plain-list li { margin: 2px 0; overflow-wrap: anywhere; }

/* ---------- toasts ---------- */
.toasts { position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); display: grid; gap: 8px; z-index: 50; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--toast); color: #fff; padding: 10px 14px; border-radius: var(--radius-sm); box-shadow: 0 6px 20px rgba(15, 23, 42, 0.25); font-weight: 500; }
.toast.error { background: #991b1b; }
.toast.good { background: #14532d; }
