/* Adminsidorna (body.tabler): Tabler (public/vendor/tabler) i ljust tema med
   svart som primärfärg, och de delade komponenterna (layoutkort, mediarad,
   grafik, väljare) i samma ljusa tema. Studion och editorn använder app.css. */
body.tabler {
  --tblr-primary: #111111;
  --tblr-primary-rgb: 17, 17, 17;
  --tblr-primary-darken: #000000;
  --tblr-primary-fg: #ffffff;
  --tblr-link-color: #111111;
  --tblr-link-color-rgb: 17, 17, 17;
  --tblr-link-hover-color: #000000;
  /* Variablerna som komponenterna i app.css använder, i ljust tema. */
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-2: #f1f3f6;
  --line: #dce1e7;
  --text: #182433;
  --muted: #667382;
  --accent: #111111;
  --rec: #d63939;
  --ok: #2fb344;
  --talk: #f59f00;
  --radius: 8px;
}
body.tabler .btn-primary { --tblr-btn-bg: #111; --tblr-btn-border-color: #111; --tblr-btn-hover-bg: #000; --tblr-btn-hover-border-color: #000; --tblr-btn-active-bg: #000; --tblr-btn-color: #fff; --tblr-btn-hover-color: #fff; }
body.tabler .nav-link.active, body.tabler .navbar .nav-link.active { font-weight: 600; }
body.tabler .hidden { display: none !important; }
body.tabler .muted { color: var(--tblr-secondary); }
body.tabler .small { font-size: .8125rem; }
body.tabler .row-click { cursor: pointer; }
body.tabler .table td.actions { width: 1%; white-space: nowrap; text-align: right; }
body.tabler .table td.actions .btn-icon { margin-left: 2px; }
body.tabler .avatar-list .avatar { font-size: .7rem; }
body.tabler .error, body.tabler .text-danger-soft { color: var(--tblr-danger); }
body.tabler .modal-backdrop { z-index: 1040; }
body.tabler .modal.d-block { overflow-y: auto; }
body.tabler .page-header .btn-list { flex-wrap: nowrap; }
body.tabler .search-input { min-width: 240px; }

/* Delade komponenter: knappar utan Tablers klasser. */
body.tabler .layout-card, body.tabler .media-show, body.tabler .media-mode, body.tabler .media-add,
body.tabler .media-end, body.tabler .picker-item, body.tabler .mode-switch button {
  display: inline-flex; align-items: center; font: inherit; color: inherit; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg); border-radius: 6px; padding: 4px 8px;
}
body.tabler .layout-card { border-width: 2px; flex-direction: column; align-items: flex-start; }
body.tabler .layout-picker-small .layout-card { flex-direction: row; align-items: center; }
body.tabler .layout-picker { display: flex; }
body.tabler .layout-picker-large .layout-card { flex: 1 1 260px; }
body.tabler .layout-card.selected, body.tabler .media-mode.selected, body.tabler .mode-switch button.selected { border-color: var(--accent); }
body.tabler .layout-card.selected { background: rgba(0, 0, 0, .04); }
body.tabler .media-mode.selected, body.tabler .mode-switch button.selected { background: var(--accent); color: #fff; }
body.tabler .media-end.hold { border-color: var(--accent); }
/* Produktionens modal: samma höjd på alla flikar. */
body.tabler .modal-xl .modal-body { min-height: 60vh; }
body.tabler .media-show { border: 0; padding: 0; background: none; flex-direction: column; align-items: stretch; gap: 4px; }
body.tabler .media-item { border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; flex-direction: column; gap: 4px; width: 132px; position: relative; }
body.tabler .media-add { flex-direction: column; justify-content: center; width: 110px; border-style: dashed; color: var(--muted); }
body.tabler .media-thumb { position: relative; display: flex; align-items: center; justify-content: center; aspect-ratio: 16 / 9; background: #f1f3f6; border-radius: 4px; overflow: hidden; }
body.tabler .media-del { position: absolute; top: 2px; right: 2px; width: 22px; height: 22px; align-items: center; justify-content: center; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; display: none; z-index: 2; }
body.tabler .media-dur, body.tabler .media-live { position: absolute; bottom: 3px; font-size: 11px; padding: 0 4px; border-radius: 3px; background: rgba(0,0,0,.65); color: #fff; }
body.tabler .media-role { font-size: 12px; padding: 2px 4px; border: 1px solid var(--line); border-radius: 4px; background: #fff; }
body.tabler .graphic-slot { display: flex; gap: 12px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 10px; flex: 1 1 320px; }
body.tabler .graphic-preview { flex: 0 0 120px; height: 68px; border-radius: 6px; overflow: hidden; display: flex; align-items: center; justify-content: center; background: #f1f3f6; }
body.tabler .graphic-logo { background: repeating-conic-gradient(#e6e8eb 0 25%, #f6f7f9 0 50%) 0 0 / 16px 16px; }
body.tabler .picker-item { flex-direction: column; align-items: stretch; padding: 6px; }
body.tabler .modal-overlay { position: fixed; inset: 0; background: rgba(24, 36, 51, .45); display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; z-index: 1060; }
body.tabler .modal-overlay > .modal { display: flex; position: static; background: #fff; border-radius: 8px; padding: 18px; width: min(860px, 100%); max-height: 86vh; overflow: auto; flex-direction: column; gap: 12px; height: auto; box-shadow: 0 10px 30px rgba(0,0,0,.2); }
body.tabler .modal-overlay .modal-head { display: flex; justify-content: space-between; align-items: center; }
body.tabler .toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #111; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 2000; display: block; opacity: 1; width: auto; max-width: 90vw; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
body.tabler .check { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
/* De delade komponenterna använder .row som en enkel rad (som i app.css), inte
   Bootstraps rutnät; adminsidorna använder Tablers d-flex och .form-grid. */
body.tabler .row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
body.tabler .row > * { width: auto; max-width: none; padding: 0; margin-top: 0; flex-shrink: 1; }
body.tabler .form-grid { display: grid; gap: 12px 16px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
body.tabler .form-grid .span-all { grid-column: 1 / -1; }

/* Ur app.css (samma komponenter som i studion), med ljusa variabler ovan. */
@media (max-width: 700px) { .room.layout-fill:not(.staged) .grid { grid-template-columns: 1fr 1fr; } }
.layout-picker { display: flex; gap: 10px; flex-wrap: wrap; }
.layout-card {
  flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 10px; background: var(--bg); border: 2px solid var(--line); border-radius: 10px; text-align: left;
}
.layout-card:hover { border-color: var(--muted); }
.layout-card.selected { border-color: var(--accent); background: rgba(0, 0, 0, .04); }
.layout-sketches { display: flex; gap: 16px; }
.layout-screen { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.layout-frame {
  padding: 3px; background: #5b6572; border-radius: 6px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
}
.layout-card.selected .layout-frame { background: var(--accent); }
.layout-sketch { display: block; border-radius: 3px; }
.layout-count { font-size: 11px; color: var(--muted); }
.layout-title { font-weight: 600; }
.layout-desc { font-size: 12px; color: var(--muted); max-width: 300px; }
.layout-picker-large .layout-card { flex: 1 1 300px; }
.layout-picker-large .layout-sketch { width: 144px; height: 81px; }
.layout-picker-small .layout-card { flex-direction: row; align-items: center; padding: 4px 8px 4px 4px; border-width: 1px; font-size: 13px; }
.layout-picker-small .layout-card.selected { box-shadow: 0 0 0 1px var(--accent); }
.layout-picker-small .layout-sketch { width: 48px; height: 27px; border-radius: 2px; }
.layout-picker-small .layout-frame { padding: 2px; border-radius: 4px; box-shadow: none; }
.layout-picker.disabled { opacity: .5; pointer-events: none; }
.flerbild { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.flerbild-label { font-size: 13px; }
.media-bar { border-top: 1px solid var(--line); background: var(--panel); padding: 8px 12px; }
.media-strip { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.media-list { display: flex; gap: 8px; }
.media-add {
  flex: 0 0 auto; width: 120px; height: 92px; justify-content: center; text-align: center;
  border-style: dashed; font-size: 13px; color: var(--muted);
}
.media-item {
  position: relative; flex: 0 0 auto; width: 128px; padding: 4px; flex-direction: column; align-items: stretch; gap: 3px;
  background: var(--bg); border: 2px solid var(--line); border-radius: 8px;
}
.media-item.active { border-color: var(--rec); }
.media-item.uploading { opacity: .7; cursor: default; }
.media-thumb {
  position: relative; display: flex; align-items: center; justify-content: center;
  aspect-ratio: 16 / 9; background: #000; border-radius: 4px; overflow: hidden;
}
.media-thumb img { width: 100%; height: 100%; object-fit: contain; }
.media-dur, .media-live {
  position: absolute; bottom: 3px; font-size: 11px; padding: 0 5px; border-radius: 4px; background: rgba(0, 0, 0, .7);
}
.media-dur { right: 3px; }
.media-live { left: 3px; background: var(--rec); color: #fff; font-weight: 600; }
.media-progress { font-size: 12px; color: var(--muted); }
.media-name { font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.media-del {
  position: absolute; top: 0; right: 0; width: 22px; height: 22px; display: none; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, .75); border-radius: 0 6px 0 6px; color: #ff8080; font-size: 16px;
}
.media-item:hover .media-del { display: flex; }
.media-player { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.media-title { font-weight: 600; max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-video-controls { flex: 1; flex-wrap: nowrap; }
.media-seek { flex: 1; min-width: 120px; padding: 0; accent-color: var(--accent); }
.media-time { font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.media-section { margin-top: 10px; }
.media-toggle { background: none; border: 0; padding: 2px 0; color: var(--muted); font-size: 13px; }
.media-toggle:hover { color: var(--text); }
.media-section-body { margin-top: 6px; }
.media-hint { font-size: 12px; margin-top: 4px; }
.mode-switch { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.mode-switch button { border: 0; border-radius: 0; background: var(--bg); }
.mode-switch button + button { border-left: 1px solid var(--line); }
.mode-switch button.selected { background: var(--accent); color: #fff; }
.graphics { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 12px; }
.graphic-slot {
  flex: 1 1 320px; display: flex; gap: 10px; align-items: center; padding: 8px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
}
.graphic-preview {
  flex: 0 0 auto; width: 128px; aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center;
  background: #000; border-radius: 4px; overflow: hidden; font-size: 12px;
}
.graphic-preview img { width: 100%; height: 100%; object-fit: cover; }
.graphic-logo { background: repeating-conic-gradient(#3a3f47 0 25%, #2a2e35 0 50%) 0 0 / 16px 16px; }
.graphic-logo img { object-fit: contain; padding: 6px; }
.graphic-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.graphic-info .muted { font-size: 12px; }
.graphic-status { font-size: 12px; }
.media-item { display: flex; }
.media-show {
  display: flex; flex-direction: column; align-items: stretch; gap: 3px; padding: 0;
  background: none; border: 0; color: inherit; text-align: left;
}
.media-show:hover .media-thumb { outline: 2px solid var(--muted); }
.media-modes { display: flex; gap: 4px; }
.media-mode {
  flex: 1; justify-content: center; padding: 3px 0; background: var(--panel-2); border-radius: 5px;
}
.media-mode svg { width: 28px; height: 16px; display: block; }
.media-mode .mi-frame { fill: none; stroke: var(--muted); }
.media-mode .mi-media { fill: var(--muted); }
.media-mode .mi-person { fill: var(--muted); opacity: .6; }
.media-mode.selected { background: var(--accent); border-color: var(--accent); }
.media-mode.selected .mi-frame { stroke: #fff; }
.media-mode.selected .mi-media, .media-mode.selected .mi-person { fill: #fff; }
.media-end { justify-content: center; padding: 2px 4px; font-size: 11px; background: var(--panel-2); color: var(--muted); border-radius: 5px; }
.media-end.hold { color: var(--text); border-color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 2px; background: var(--panel-2); border: 1px solid var(--line); border-radius: 99px; padding: 2px 4px 2px 10px; font-size: 13px; }
.chip-note { color: var(--talk); font-size: 12px; }
.chip-x { border: 0; background: transparent; color: var(--muted); padding: 0 6px; font-size: 15px; line-height: 1; }
.chip-x:hover { color: #ff8080; }
.media-adds { display: flex; flex-direction: column; gap: 6px; flex: 0 0 auto; }
.media-adds .media-add { height: 43px; }
.media-role { font-size: 11px; padding: 2px 4px; width: 100%; }
.media-item[draggable="true"] { cursor: grab; }
.media-item.role-intro { border-color: #3b82f6; }
.media-item.role-outro { border-color: #8b5cf6; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.picker-item { display: flex; flex-direction: column; gap: 4px; align-items: stretch; padding: 6px; text-align: left; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.picker-item:hover { border-color: var(--accent); }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; }
.tag-list { display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); cursor: pointer; }
.tag.selected { background: var(--accent); color: #fff; border-color: var(--accent); }
body.tabler .lib-thumb { position: relative; display: flex; align-items: center; justify-content: center; width: 96px; aspect-ratio: 16 / 9; border-radius: 4px; overflow: hidden; background: #f1f3f6; color: var(--muted); }
body.tabler .lib-thumb img { width: 100%; height: 100%; object-fit: cover; }
body.tabler .cursor-pointer { cursor: pointer; }
body.tabler .empty-title { font-size: 1rem; font-weight: 500; }
body.tabler .empty-icon { font-size: 2rem; color: var(--muted); }
/* Förhandsvisning i modal: hela bilden syns, liggande eller stående, utan att
   modalen behöver rullas (sidhuvud, val och marginaler räknas bort). */
body.tabler .preview-media { display: block; width: auto; height: auto; max-width: 100%; max-height: calc(100vh - 260px); margin: 0 auto; background: #000; border-radius: 6px; object-fit: contain; }
/* Menyn har sin höjd från början, så att sidan inte hoppar när den ritas. */
body.tabler #topbar { min-height: 56px; }
/* Biblioteket: flikar ovanför kortet. */
body.tabler .card-tabbed { border-top-left-radius: 0; }
body.tabler .lib-tabs .nav-link.active { background: #fff; }
/* Grafikeditorn */
body.tabler .gfx-editor { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; }
@media (max-width: 1000px) { body.tabler .gfx-editor { grid-template-columns: 1fr; } }
body.tabler .gfx-canvas { width: 100%; aspect-ratio: 16 / 9; border-radius: 6px; cursor: move; touch-action: none;
  background: linear-gradient(135deg, #3b4656, #1c232d); box-shadow: inset 0 0 0 1px rgba(0,0,0,.1); }
body.tabler .gfx-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
body.tabler .gfx-layers { max-height: 220px; overflow-y: auto; }
body.tabler .gfx-layers .list-group-item.active { background: rgba(0,0,0,.05); color: inherit; border-color: var(--line); }
body.tabler .gfx-checker { background: linear-gradient(135deg, #3b4656, #1c232d); }
body.tabler .gfx-thumb { width: 100%; height: 100%; }
body.tabler .gfx-value { width: auto; min-width: 200px; flex: 1 1 200px; }
body.tabler .gfx-name { width: 160px; }

/* Körlistan (public/js/rundown.js); samma i studion och översikten. */
.rd-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.rd-row {
  display: flex; align-items: center; gap: 10px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel-2); min-height: 44px;
}
.rd-num { width: 22px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 12px; }
.rd-thumb { flex: 0 0 auto; width: 56px; height: 32px; border-radius: 4px; overflow: hidden; background: #000; color: #fff; display: flex; align-items: center; justify-content: center; font-size: 16px; }
.rd-thumb img { width: 100%; height: 100%; object-fit: cover; }
.rd-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rd-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rd-sub { font-size: 12px; color: var(--muted); }
.rd-note { max-width: 320px; padding: 2px 6px; font-size: 12px; }
.rd-actions { display: flex; gap: 2px; opacity: .5; }
.rd-row:hover .rd-actions { opacity: 1; }
.rd-btn { padding: 3px 6px; }
.rd-row.missing .rd-name { color: var(--rec); font-weight: 400; }
.rd-empty { color: var(--muted); font-size: 13px; padding: 8px 4px; }
.rd-add { display: flex; gap: 8px; margin-top: 8px; }
.rd-add-select { flex: 1; min-width: 0; max-width: 420px; }
/* Studion: utlagda nedtonade, nästa markerad, klick laddar raden. */
.rundown-bar .rd-row { cursor: pointer; }
.rd-row.done { opacity: .45; }
.rd-row.next { border-color: #3b82f6; box-shadow: inset 4px 0 0 #3b82f6; background: rgba(59, 130, 246, .14); }
.rd-row.onair { border-color: var(--rec); box-shadow: inset 4px 0 0 var(--rec); background: rgba(229, 72, 77, .18); }
.rd-head { display: flex; align-items: center; gap: 10px 20px; flex-wrap: wrap; margin-bottom: 8px; }
.rd-label { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-right: 6px; }
.rd-onair, .rd-next { display: flex; align-items: center; gap: 6px; min-width: 0; }
.rd-pill { font-size: 12px; padding: 2px 8px; border-radius: 10px; background: var(--rec); color: #fff; white-space: nowrap; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.rd-pill.live { background: var(--rec); }
.rd-next-name { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 360px; }
.rd-buttons { display: flex; gap: 8px; margin-left: auto; }
.rd-end { flex: 0 0 auto; width: auto; max-width: 280px; padding: 2px 28px 2px 8px; font-size: 12px; background-position: right 6px center; }

/* Inbjudna gäster (guests.js). */
.gl-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.gl-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.gl-name { flex: 1; min-width: 0; }
.gl-actions { display: flex; gap: 4px; }
.gl-add { display: flex; gap: 8px; margin-top: 10px; }
.gl-add input { flex: 1; max-width: 420px; }
.gl-empty { color: var(--muted); font-size: 13px; padding: 6px 2px; }

/* Scener (scenes.js). */
.sc-list { display: flex; flex-direction: column; gap: 8px; }
.sc-card { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2); }
.sc-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sc-name { flex: 1 1 200px; min-width: 0; }
.sc-layout { width: auto; }
.sc-actions { display: flex; gap: 4px; margin-left: auto; }
.sc-all, .modal .sc-all { display: inline-flex; flex-direction: row; align-items: center; gap: 6px; font-size: 13px; color: var(--text); }
.sc-focus, .sc-addperson { width: auto; max-width: 260px; }
.sc-chip { display: inline-flex; align-items: center; gap: 2px; padding: 2px 4px 2px 10px; border-radius: 14px; background: var(--bg); border: 1px solid var(--line); font-size: 13px; }
.sc-chip.focus { border-color: var(--accent); }
.sc-chip .btn { padding: 0 4px; border: 0; background: none; }
.sc-add { margin-top: 8px; }
.sc-empty { color: var(--muted); font-size: 13px; padding: 6px 2px; }
.sc-all input { width: auto; margin: 0; }
