/* ── Producer Layout ── */

/* Full-viewport producer app (uses BlankLayout — no navbar/footer) */
.producer-layout {
    display: flex;
    flex-direction: column;
    background: #1a1a2e;
    color: #e0e0e0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
}

/* Exit button — top-left corner, away from live controls */
.producer-exit {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 10;
    font-size: 0.7rem;
    font-weight: 600;
    text-decoration: none;
    color: #8888aa;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
}

.producer-exit:hover {
    background: rgba(255,255,255,0.15);
    color: #fff;
}

/* ── Single preview (normal mode) ── */
.single-preview {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
    container-type: size;
}

/* Largest 16:9 box that fits the available space.
   cqw/cqh from the size-container give reliable dimensions
   without flex cross-size ambiguity.
   Pick the smaller constraint: full width vs full height. */
.single-preview .preview-wrapper {
    --w-limited: min(100cqw, 1200px);
    --h-limited: calc(100cqh * 16 / 9);
    width:  min(var(--w-limited), var(--h-limited));
    height: min(calc(var(--w-limited) * 9 / 16), 100cqh);
    flex: 0 0 auto;
}

/* ── Source add form + list ── */
.source-add-form {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-bottom: 6px;
    flex-shrink: 0;
}

.source-add-form select,
.source-add-form input {
    background: #0a0a1a;
    color: #e0e0e0;
    border: 1px solid #2a2a4a;
    flex: 1;
    min-width: 0;
    font-size: 0.7rem;
    padding: 2px 4px;
    height: 26px;
}

.source-add-form .btn {
    flex-shrink: 0;
    height: 26px;
    line-height: 1;
}

.source-edit-form {
    padding: 3px 8px 4px;
    background: #111;
    border-left: 2px solid #f0ad4e;
    border-bottom: 1px solid #1e2a44;
}

.source-edit-form select {
    background: #0a0a1a;
    color: #e0e0e0;
    border: 1px solid #2a2a4a;
    font-size: 0.65rem;
    height: 24px;
    width: 100%;
}

.source-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.source-list-item {
    font-size: 0.7rem;
    padding: 3px 8px;
    background: #0a0a1a;
    color: #d0d0e0;
    border-left: 2px solid #4d8dff;
    border-bottom: 1px solid #1e2a44;
    display: flex;
    align-items: center;
    gap: 4px;
}

.source-label {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.source-remove-btn {
    background: none;
    border: none;
    color: #555;
    cursor: pointer;
    font-size: 0.6rem;
    padding: 0 2px;
    line-height: 1;
    flex-shrink: 0;
}

.source-remove-btn:hover { color: #e63946; }

.source-list-item.stale { border-left-color: #f0ad4e; }
.source-stale-badge { color: #f0ad4e; font-size: 0.7rem; flex-shrink: 0; cursor: help; }

.scene-setting {
    margin-bottom: 8px;
}

.scene-setting select {
    background: #0a0a1a;
    color: #e0e0e0;
    border: 1px solid #2a2a4a;
    font-size: 0.7rem;
    height: 26px;
}

.source-list-item.satellite {
    border-left-color: #17a2b8;
}

.source-list-item.satellite.offline {
    border-left-color: #6c757d;
    color: #9fb0c7;
}

.source-status-badge {
    font-size: 0.6rem;
    line-height: 1;
    padding: 2px 6px;
    border-radius: 999px;
    border: 1px solid transparent;
    flex-shrink: 0;
}

.source-status-badge.online {
    color: #9ff0c1;
    background: rgba(76, 205, 123, 0.14);
    border-color: rgba(76, 205, 123, 0.3);
}

.source-status-badge.offline {
    color: #c9d4e3;
    background: rgba(108, 117, 125, 0.18);
    border-color: rgba(201, 212, 227, 0.2);
}

.preview-wrapper {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    border-radius: 6px;
    overflow: hidden;
    position: relative;
}

/* Inner frame: largest 16:9 box that fits the wrapper.
   width:100% + aspect-ratio derives height; max-height:100% clamps when
   the wrapper is shorter than 16:9. overflow:hidden clips sub-pixel rounding. */
.preview-frame {
    position: relative;
    aspect-ratio: 16/9;
    width: 100%;
    max-height: 100%;
    overflow: hidden;
}

#compositor-canvas {
    width: 100%;
    height: 100%;
    display: block;
    background: #000;
}

/* Overlay design layered on top of the canvas */
.preview-overlay {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
    container-type: size;
}

/* Override overlay.css's position:fixed so the overlay fits within the
   producer preview frame instead of covering the entire viewport.
   Render at native 1920×1080 and scale down with container-query-based
   inline size so text and elements maintain correct proportions. */
.preview-overlay .overlay-root {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transform: none !important;
}

.preview-overlay .overlay-stage {
    width: 100% !important;
    height: 100% !important;
    --stageH: 100cqh;
}


/* ── Bottom toolbar ── */
.producer-toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 6px 10px;
    background: #16213e;
    border-top: 1px solid #2a2a4a;
    flex-shrink: 0;
    font-size: 0.8rem;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.toolbar-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #8888aa;
    font-weight: 600;
}

.toolbar-sep {
    width: 1px;
    height: 20px;
    background: #2a2a4a;
}

.dest-toggle {
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ── Studio Mode ── */

/* Preview row: Preview | CUT | Program */
.studio-previews {
    display: flex;
    flex: 1;
    min-height: 0;
    gap: 4px;
    padding: 6px 6px 0;
    align-items: center;
}

.studio-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.studio-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 2px 8px;
    color: #4d8dff;
    flex-shrink: 0;
}

.studio-label.program-label {
    color: #e63946;
}

/* Red border on program preview */
.studio-panel.program .preview-wrapper {
    border: 2px solid #e63946;
    border-radius: 6px;
}

/* CUT button between previews */
.studio-transition {
    display: flex;
    align-items: center;
    padding: 0 4px;
    flex-shrink: 0;
}

/* Controls strip — shared between studio and normal mode */
.producer-controls {
    display: flex;
    gap: 12px;
    padding: 6px 8px;
    background: #16213e;
    border-top: 1px solid #2a2a4a;
    flex-shrink: 0;
    overflow-x: auto;
    align-items: stretch;
    max-height: 220px;
}

.producer-controls .control-group {
    min-width: 0;
    overflow-y: auto;
}

.producer-controls .control-group {
    flex: 1 1 0;
}

.control-group h5 {
    margin: 0 0 6px 0;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #8888aa;
    font-weight: 600;
}

/* Scene buttons stacked vertically with color-coded left border */
.scene-stack {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.scene-stack .btn {
    width: 100%;
    text-align: left;
    font-size: 0.75rem;
    padding: 4px 8px;
    border-left: 3px solid transparent;
    background: #0a0a1a;
    color: #e0e0e0;
    border-top: 1px solid #2a2a4a;
    border-right: 1px solid #2a2a4a;
    border-bottom: 1px solid #2a2a4a;
    border-radius: 4px;
}

.scene-stack .btn:hover {
    background: #1e2a44;
}

.scene-stack .btn.is-program {
    border-left-color: #e63946;
    background: #2a1520;
}

.scene-stack .btn.is-preview,
.scene-stack .btn.is-active {
    border-left-color: #4d8dff;
    background: #1a2540;
}

/* CUT button */
.btn-cut {
    background: #f0ad4e;
    color: #000;
    font-weight: 700;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    padding: 6px 12px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-cut:hover {
    background: #ec971f;
}

/* ── Audio mixer (compact) ── */
.audio-tracks {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mixer-track-compact {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 3px 0;
    border-bottom: 1px solid #1e2a44;
}

.mixer-track-header {
    display: flex;
    align-items: center;
    gap: 4px;
}

.mixer-track-compact .track-label {
    font-size: 0.6rem;
    color: #8888aa;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mute-btn {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    border-radius: 3px;
    border: 1px solid #2a2a4a;
    background: transparent;
    color: #e0e0e0;
    cursor: pointer;
    font-size: 0.55rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.mute-btn:hover { background: #1e2a44; }

.mixer-track-compact.muted .mute-btn {
    background: #e63946;
    border-color: #e63946;
    color: #fff;
}

.vu-meter {
    width: 100%;
    height: 8px;
    border-radius: 2px;
    background: #0a0a1a;
}

.vol-slider {
    width: 100%;
    accent-color: #4d8dff;
    height: 12px;
}

.mixer-track-compact.muted .vol-slider { opacity: 0.35; }

/* Preview canvas in studio mode */
#compositor-canvas-preview {
    width: 100%;
    height: 100%;
    display: block;
    background: #000;
}

/* ── Commentary Layout ── */
.commentary-layout {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #1a1a2e;
    color: #e0e0e0;
}

.board-feed {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    position: relative;
}

.board-feed video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.join-overlay,
.connecting-overlay,
.error-overlay {
    text-align: center;
    padding: 2rem;
}

.commentary-controls {
    padding: 12px 16px;
    background: #16213e;
    border-top: 1px solid #2a2a4a;
    display: flex;
    align-items: center;
    gap: 16px;
}

.mic-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ── Source Slot Cards ── */
.sources-group {
    min-width: 200px !important;
}

.slot-cards {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
}

.slot-card {
    background: #0a0a1a;
    border: 1px solid #2a2a4a;
    border-radius: 4px;
    padding: 5px 8px;
}

.slot-card.bound {
    border-color: #2d6a4f;
}

.slot-card-header {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-bottom: 4px;
}

.slot-card-indicator {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.slot-card.bound .slot-card-indicator {
    background: #4ccd7b;
}

.slot-card.unbound .slot-card-indicator {
    background: #555;
}

.slot-card.selected {
    border-color: #0096ff;
    box-shadow: 0 0 4px rgba(0,150,255,0.3);
}

.slot-card-name {
    font-size: 0.72rem;
    font-weight: 600;
    color: #d0d0e0;
    text-transform: capitalize;
    flex-grow: 1;
}

.st-reset-btn {
    font-size: 0.65rem;
    padding: 0 4px;
    line-height: 1;
    color: #888;
    border: none;
    background: none;
}

.st-reset-btn:hover { color: #e63946; }

.slot-transform-info {
    display: flex;
    gap: 6px;
    font-size: 0.6rem;
    color: #6b7280;
    margin-top: 3px;
}

.slot-card-select {
    background: #0f1629 !important;
    color: #e0e0e0 !important;
    border: 1px solid #2a2a4a !important;
    font-size: 0.7rem !important;
    padding: 2px 6px !important;
    width: 100%;
}

.slot-empty-hint {
    font-size: 0.65rem;
    color: #666;
    font-style: italic;
    margin-bottom: 6px;
}
.sources-loading {
    color: #8ab4f8;
    animation: pulse-loading 1.5s ease-in-out infinite;
}
@keyframes pulse-loading {
    0%, 100% { opacity: .5; }
    50% { opacity: 1; }
}

.cameras-section {
    border-top: 1px solid #1e2a44;
    padding-top: 6px;
    margin-top: 2px;
}

.cameras-header {
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    margin-bottom: 4px;
}

/* ── Destination management panel ── */
.dest-panel {
    background: #0f1629;
    border-top: 1px solid #2a2a4a;
    padding: 8px 10px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.dest-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.75rem;
    font-weight: 600;
    color: #8888aa;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.dest-row {
    display: flex;
    gap: 6px;
    align-items: center;
}

.dest-input {
    background: #0a0a1a !important;
    color: #e0e0e0 !important;
    border: 1px solid #2a2a4a !important;
    font-size: 0.75rem !important;
}

.dest-input.dest-platform { max-width: 100px; }
.dest-input.dest-url { flex: 1; }
.dest-input.dest-key { max-width: 200px; }

.dest-header-row {
    padding-bottom: 2px;
}

.dest-col-header {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #8888aa;
    padding: 0 4px;
}

.dest-col-header.dest-platform { max-width: 100px; width: 100px; }
.dest-col-header.dest-url { flex: 1; }
.dest-col-header.dest-key { max-width: 200px; width: 200px; }
.dest-col-header.dest-action { width: 32px; }
