/* Playout / Master Control (MCR) page styles — redesigned. */

/* ── Page header ─────────────────────────────────────────────────────────────── */
.po-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-1);
  gap: 16px;
  flex-wrap: wrap;
}
.po-head-left { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.po-head-title {
  font-size: 15px; font-weight: 700; color: var(--text-1);
  letter-spacing: 0.02em; white-space: nowrap;
}
.po-clock {
  font-size: 22px; font-weight: 700; color: var(--text-1);
  letter-spacing: 0.05em; min-width: 90px; text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Channel tab bar ─────────────────────────────────────────────────────────── */
.po-channels-bar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.po-chan-tab {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 5px 12px; border-radius: 8px;
  background: var(--bg-2); border: 1px solid var(--border);
  color: var(--text-2); font-size: 13px; cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.po-chan-tab:hover { background: var(--bg-3); color: var(--text-1); }
.po-chan-tab.active {
  background: var(--accent-soft); color: var(--accent-text);
  border-color: var(--accent-soft-2);
}
.po-chan-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-3); flex-shrink: 0;
  transition: background 0.3s, box-shadow 0.3s;
}
.po-chan-dot.live {
  background: var(--danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent);
  animation: po-pulse 2s ease-in-out infinite;
}
@keyframes po-pulse {
  0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent); }
  50%       { box-shadow: 0 0 0 6px color-mix(in srgb, var(--danger) 10%, transparent); }
}

/* ── Page layout ─────────────────────────────────────────────────────────────── */
.po-page { display: flex; flex-direction: column; gap: 0; padding: 0; }
.po-root { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; }

.po-empty {
  text-align: center; padding: 48px 0;
  display: flex; flex-direction: column; gap: 12px; align-items: center;
}

/* ── Top row: PGM + right rail ───────────────────────────────────────────────── */
.po-top {
  display: grid;
  grid-template-columns: minmax(0, 960px) 300px;
  gap: 12px;
  align-items: start;
}
@media (max-width: 960px) {
  .po-top { grid-template-columns: 1fr; }
}

/* ── PGM monitor column ──────────────────────────────────────────────────────── */
.po-pgm-col {
  display: flex; flex-direction: column; gap: 8px;
}

/* ── Screen ──────────────────────────────────────────────────────────────────── */
.po-pgm {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  display: flex; flex-direction: column;
}
.po-screen {
  position: relative;
  background: #0a0a0a;
  aspect-ratio: 16 / 9;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.po-monitor-video {
  width: 100%; height: 100%; object-fit: contain; display: block;
}
.po-onair-badge {
  position: absolute; top: 10px; left: 10px;
  background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 800; letter-spacing: 0.12em;
  padding: 3px 8px; border-radius: 4px;
  animation: po-onair-blink 2s step-end infinite;
  z-index: 2;
}
@keyframes po-onair-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}
.po-screen-offline {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: rgba(0,0,0,0.7); color: var(--text-3); font-size: 13px;
}
.po-screen-offline-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--text-3);
}
.po-tc-overlay {
  position: absolute; bottom: 8px; left: 10px;
  font-size: 12px; color: rgba(255,255,255,0.7);
  letter-spacing: 0.06em; font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
  pointer-events: none; z-index: 2;
}
.po-meters-wrap {
  position: absolute; right: 10px; bottom: 8px;
  display: flex; align-items: flex-end;
  z-index: 2;
}
.po-vu-meter { display: block; }

/* Clip progress bar (below video) */
.po-clip-progress {
  height: 3px; background: var(--bg-3); flex-shrink: 0;
}
.po-clip-progress-fill {
  height: 100%; background: var(--danger);
  transition: width 0.1s linear;
}

/* Monitor metadata footer */
.po-monitor-meta {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  font-size: 11px; min-height: 32px;
}
.po-monitor-clip-name {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--text-1);
}
.po-monitor-right {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0; color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.po-clip-pos  { color: var(--text-2); }
.po-clip-remain { color: var(--warning); }

/* ── Transport bar ───────────────────────────────────────────────────────────── */
.po-transport {
  display: flex; align-items: center;
  padding: 8px 10px;
  background: var(--bg-1); border: 1px solid var(--border); border-radius: 10px;
}
.po-transport-group { display: flex; align-items: center; gap: 4px; }
.po-trans-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 7px 12px; border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg-2); color: var(--text-1);
  cursor: pointer; font-size: 13px;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
  white-space: nowrap;
}
.po-trans-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.po-trans-btn:not(:disabled):hover { background: var(--bg-3); }
.po-trans-btn:not(:disabled):active { background: var(--bg-4, var(--bg-3)); }
.po-trans-play {
  background: color-mix(in srgb, var(--accent) 15%, var(--bg-2));
  border-color: var(--accent-soft-2);
  color: var(--accent-text);
  font-weight: 600;
}
.po-trans-play:not(:disabled):hover {
  background: color-mix(in srgb, var(--accent) 25%, var(--bg-2));
}
.po-trans-stop {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
}
.po-trans-stop:not(:disabled):hover {
  background: color-mix(in srgb, var(--danger) 10%, var(--bg-2));
}
.po-trans-icon { font-size: 14px; line-height: 1; }
.po-trans-label { font-size: 12px; }

/* ── Right rail ──────────────────────────────────────────────────────────────── */
.po-rail {
  display: flex; flex-direction: column; gap: 10px;
}

/* Generic card */
.po-card {
  background: var(--bg-1); border: 1px solid var(--border); border-radius: 10px;
  overflow: hidden;
}
.po-card-head {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; border-bottom: 1px solid var(--border);
}

/* Channel card */
.po-channel-card {}
.po-channel-actions { display: flex; gap: 6px; align-items: center; margin-left: auto; }
.po-channel-meta {
  padding: 8px 12px; font-size: 11px;
  display: flex; align-items: center; gap: 8px;
}
.po-restart-badge {
  font-size: 10px; color: var(--warning); font-weight: 600;
}

/* Now Playing card */
.po-nowplaying-card {}
.po-nowplaying-pos { margin-left: auto; font-size: 11px; }
.po-nowplaying-empty { padding: 16px 12px; font-size: 12px; }
.po-nowplaying-name {
  padding: 8px 12px 6px;
  font-size: 13px; font-weight: 600; color: var(--text-1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.po-nowplaying-progress { padding: 0 12px 8px; }
.po-nowplaying-bar {
  height: 4px; background: var(--bg-3); border-radius: 2px; overflow: hidden;
  margin-bottom: 4px;
}
.po-nowplaying-fill {
  height: 100%; background: var(--danger); border-radius: 2px;
  transition: width 0.5s linear;
}
.po-nowplaying-times {
  display: flex; justify-content: space-between; font-size: 10px;
}
.po-nowplaying-elapsed { color: var(--text-2); }
.po-nowplaying-remain  { color: var(--text-3); }
.po-nowplaying-next {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-top: 1px solid var(--border);
  font-size: 11px;
}
.po-nowplaying-next-name {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* SCTE-35 card */
.po-scte-card {}
.po-scte-stub-badge {
  margin-left: auto;
  font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--warning); background: color-mix(in srgb, var(--warning) 15%, transparent);
  padding: 2px 5px; border-radius: 3px;
}
.po-scte-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
.po-scte-row { display: flex; gap: 6px; flex-wrap: wrap; }
.po-fire {
  flex: 1; min-width: 0;
  padding: 6px 10px; border-radius: 7px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.03em;
  cursor: pointer; border: 1px solid transparent;
  transition: background 0.12s, opacity 0.12s;
  white-space: nowrap;
}
.po-fire:disabled { opacity: 0.35; cursor: not-allowed; }
.po-fire.amber {
  background: color-mix(in srgb, #f59e0b 18%, var(--bg-2));
  border-color: color-mix(in srgb, #f59e0b 40%, transparent);
  color: #f59e0b;
}
.po-fire.amber:not(:disabled):hover {
  background: color-mix(in srgb, #f59e0b 28%, var(--bg-2));
}
.po-fire.in {
  background: color-mix(in srgb, #22c55e 18%, var(--bg-2));
  border-color: color-mix(in srgb, #22c55e 40%, transparent);
  color: #22c55e;
}
.po-fire.in:not(:disabled):hover {
  background: color-mix(in srgb, #22c55e 28%, var(--bg-2));
}
.po-fire.out {
  background: color-mix(in srgb, var(--danger) 18%, var(--bg-2));
  border-color: color-mix(in srgb, var(--danger) 40%, transparent);
  color: var(--danger);
}
.po-fire.out:not(:disabled):hover {
  background: color-mix(in srgb, var(--danger) 28%, var(--bg-2));
}
.po-scte-last {
  font-size: 10px; color: var(--text-3); margin-top: 2px;
}

/* Rail quick-actions */
.po-rail-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.po-rail-action-btn { flex: 1; text-align: center; }

/* ── Section label ───────────────────────────────────────────────────────────── */
.po-section-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-3); font-weight: 600;
}

/* ── Media bin ───────────────────────────────────────────────────────────────── */
.po-bin {
  display: flex; flex-direction: column;
  min-height: 180px; max-height: 280px;
  border-radius: 10px; overflow: hidden;
  background: var(--bg-1); border: 1px solid var(--border);
}
.po-bin-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
}
.po-bin-list { overflow-y: auto; flex: 1; }
.po-bin-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 7px 12px; border-bottom: 1px solid var(--border);
  cursor: grab; user-select: none;
}
.po-bin-item:hover { background: var(--bg-3); }
.po-bin-item:active { cursor: grabbing; }
.po-bin-name {
  font-size: 13px; color: var(--text-1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Playlist ─────────────────────────────────────────────────────────────────── */
.po-playlist {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
  min-height: 100px;
}
.po-playlist-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
}
.po-drop-err { font-size: 11px; color: var(--danger); }
.po-playlist-empty { padding: 24px 12px; text-align: center; color: var(--text-3); font-size: 13px; }

.po-pl-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px 13px;
  border-bottom: 1px solid var(--border);
  cursor: grab; user-select: none;
  transition: background 0.1s;
}
.po-pl-item:last-child { border-bottom: none; }
.po-pl-item:hover { background: var(--bg-3); }
.po-pl-item:active { cursor: grabbing; }
.po-pl-item--active {
  background: color-mix(in srgb, var(--danger) 8%, transparent);
  border-left: 3px solid var(--danger);
}
.po-pl-item--active:hover {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}
.po-pl-index {
  width: 22px; text-align: center; font-family: var(--font-mono);
  font-size: 12px; color: var(--text-3); flex-shrink: 0;
}
.po-pl-onair { color: var(--danger); font-size: 11px; }
.po-pl-name {
  flex: 1; font-size: 13px; color: var(--text-1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.po-pl-dur {
  font-size: 11px; color: var(--text-3); flex-shrink: 0;
  min-width: 40px; text-align: right;
  font-variant-numeric: tabular-nums;
}
.po-pl-badge { flex-shrink: 0; }

/* Staging progress bar */
.po-staging-bar {
  position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
}
.po-staging-bar--pending  { background: var(--text-3); opacity: 0.25; }
.po-staging-bar--staging  {
  background: linear-gradient(90deg, transparent 0%, var(--warning) 50%, transparent 100%);
  background-size: 200% 100%;
  animation: po-staging-sweep 1.4s linear infinite;
}
.po-staging-bar--ready    { background: var(--success); opacity: 0.8; }
.po-staging-bar--error    { background: var(--danger); }
@keyframes po-staging-sweep {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Timeline ─────────────────────────────────────────────────────────────────── */
.po-tl {
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
  padding-bottom: 4px;
}
.po-tl-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
}
.po-tl-empty {
  padding: 20px 12px; text-align: center; font-size: 12px; color: var(--text-3);
}
.po-tl-track-wrap {
  position: relative; padding: 10px 12px 28px;
}
.po-tl-playhead {
  position: absolute; top: 10px; bottom: 28px;
  width: 2px; background: var(--danger);
  z-index: 3; transform: translateX(-50%);
  pointer-events: none;
}
.po-tl-playhead::before {
  content: '';
  position: absolute; top: -4px; left: 50%; transform: translateX(-50%);
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid var(--danger);
}
.po-tl-track {
  display: flex; height: 44px;
  border-radius: 6px; overflow: hidden;
  background: var(--bg-3);
  gap: 1px;
}
.po-tl-clip {
  position: relative; display: flex;
  flex-direction: column; justify-content: center;
  padding: 4px 6px; min-width: 0; overflow: hidden;
  background: color-mix(in srgb, var(--clip-color, #3b82f6) 20%, var(--bg-2));
  border-left: 2px solid var(--clip-color, #3b82f6);
  cursor: default; transition: background 0.15s;
}
.po-tl-clip:hover {
  background: color-mix(in srgb, var(--clip-color, #3b82f6) 30%, var(--bg-2));
}
.po-tl-clip--active {
  background: color-mix(in srgb, var(--clip-color, #3b82f6) 35%, var(--bg-2));
  border-left-color: var(--clip-color, #3b82f6);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--clip-color, #3b82f6) 50%, transparent);
}
.po-tl-clip-name {
  font-size: 10px; font-weight: 600; color: var(--text-1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.po-tl-clip-dur {
  font-size: 9px; color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.po-tl-staging-dot {
  position: absolute; top: 3px; right: 4px;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--warning);
  animation: po-staging-sweep 1s ease-in-out infinite alternate;
}
.po-tl-error-dot {
  position: absolute; top: 3px; right: 4px;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--danger);
}
/* Time ruler */
.po-tl-ruler {
  position: absolute; bottom: 4px; left: 12px; right: 12px; height: 18px;
}
.po-tl-ruler-mark {
  position: absolute; font-size: 9px; color: var(--text-3);
  transform: translateX(-50%);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* ── As-run drawer ────────────────────────────────────────────────────────────── */
.po-drawer-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,0.4);
  z-index: 90; backdrop-filter: blur(2px);
}
.po-drawer {
  position: fixed; right: 0; top: 0; bottom: 0;
  width: 420px; max-width: 95vw;
  background: var(--bg-1); border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 91;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -4px 0 24px rgba(0,0,0,0.2);
}
.po-drawer--open { transform: translateX(0); }
.po-drawer-head {
  display: flex; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 4px;
}
.po-drawer-close { margin-left: auto; }
.po-drawer-body { flex: 1; overflow-y: auto; padding: 12px 16px; }

/* ── As-run table (shared by drawer) ─────────────────────────────────────────── */
.po-asrun-table {
  width: 100%; border-collapse: collapse; font-size: 12px;
}
.po-asrun-table th {
  text-align: left; font-weight: 600; color: var(--text-3);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 4px 8px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg-1);
}
.po-asrun-table td {
  padding: 5px 8px; border-bottom: 1px solid var(--border);
  color: var(--text-1); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; max-width: 200px;
}
.po-asrun-table tr:last-child td { border-bottom: none; }
.po-asrun-result {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
}
.po-asrun-played  { color: var(--success); }
.po-asrun-skipped { color: var(--warning); }
.po-asrun-error   { color: var(--danger); }

/* ── Utility overrides ───────────────────────────────────────────────────────── */
.btn.xs { padding: 2px 8px; font-size: 11px; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.field-input.sm { padding: 5px 8px; font-size: 12px; }

/* Downloads modal section header (preserved from original) */
.downloads-section-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--text-3);
  padding-bottom: 8px; border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

/* ── SCTE-35 additions (timeline marker + active-break line) ──────────────── */
.po-tl-scte-marker {
  position: absolute; top: 10px; bottom: 28px;
  width: 0; border-left: 2px dashed #f59e0b;
  z-index: 2; transform: translateX(-50%);
  pointer-events: none;
}
.po-tl-scte-marker::before {
  content: 'AD'; position: absolute; top: -2px; left: 2px;
  font-size: 8px; font-weight: 800; letter-spacing: 0.06em; color: #f59e0b;
}
.po-scte-active {
  padding: 6px 8px; border-radius: 6px;
  background: color-mix(in srgb, #f59e0b 14%, transparent);
  border: 1px solid color-mix(in srgb, #f59e0b 35%, transparent);
}
