:root {
    --bg-dark: #121212;
    --bg-panel: #1e1e1e;
    --border-color: #333;
    --text-main: #e0e0e0;
    --text-muted: #888;
    --accent-color: #0d6efd;
    --success-color: #198754;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --font-ui: 'Inter', sans-serif;
    --font-mono: 'Roboto Mono', monospace;
}

.light-mode {
    --bg-dark: #f0f2f5;
    --bg-panel: #ffffff;
    --border-color: #ddd;
    --text-main: #333;
    --text-muted: #666;
    --accent-color: #007bff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-ui);
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.hidden {
    display: none !important;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-dark);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Top Bar */
.top-bar {
    height: 60px;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    flex-shrink: 0;
}

.logo {
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: -1px;
}

.highlight {
    color: var(--accent-color);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.btn-feed-header {
    padding: 0.6rem 1.2rem;
    background: linear-gradient(135deg, var(--success-color), #1a8a3e);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.4);
}

.btn-feed-header:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.5);
}

.btn-feed-header:active {
    transform: translateY(0);
}

.clock-display {
    text-align: right;
}

.clock-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.time-readout {
    font-family: var(--font-mono);
    font-size: 1.8rem;
    font-weight: 700;
    letter-spacing: 1px;
    color: var(--text-main);
}

/* OBS Connection Indicator */
.obs-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.obs-indicator:hover {
    background: rgba(255, 255, 255, 0.1);
}

.obs-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: #dc3545;
    /* Red = disconnected */
    box-shadow: 0 0 5px currentColor;
}

.obs-indicator.connected .obs-dot {
    background-color: #28a745;
    /* Green = connected */
    animation: pulse-obs 2s ease-in-out infinite;
}

.obs-indicator.connecting .obs-dot {
    background-color: #ffc107;
    /* Yellow = connecting */
    animation: pulse-obs 1s ease-in-out infinite;
}

@keyframes pulse-obs {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Stream Status Badges */
.stream-badge {
    display: inline-block;
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 4px;
    vertical-align: middle;
    text-transform: uppercase;
}

.stream-badge.off {
    background: #444;
    color: #888;
}

.stream-badge.conn {
    background: #FFC107;
    color: #000;
    animation: pulse-live 1s infinite;
}

.stream-badge.buf {
    background: #17a2b8;
    color: #fff;
}

.stream-badge.rdy {
    background: #4CAF50;
    color: #fff;
}

.stream-badge.live {
    background: #FF5252;
    color: #fff;
    animation: pulse-live 1s infinite;
}

.stream-badge.err {
    background: #dc3545;
    color: #fff;
}

/* Status indicator colors for stream states */
.status-indicator.disconnected {
    background-color: #444;
}

.status-indicator.connecting {
    background-color: #FFC107;
    animation: pulse-live 1s infinite;
}

.status-indicator.buffering {
    background-color: #17a2b8;
}

.status-indicator.ready {
    background-color: #4CAF50;
}

.status-indicator.stream-live {
    background-color: #FF5252;
    box-shadow: 0 0 8px #FF5252;
    animation: pulse-live 1s infinite;
}

.status-indicator.error {
    background-color: #dc3545;
}

.obs-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.settings-btn {
    font-size: 1.5rem;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0.5rem;
}

/* Main Content Layout */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
    /* For absolute positioning of drawer */
}

/* Sidebar Strip (Far Left) */
.sidebar-strip {
    width: 40px;
    background-color: #1a1a1a;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 1rem;
    z-index: 200;
}

.sidebar-tab {
    cursor: pointer;
    padding: 1rem 0;
    color: var(--text-muted);
    transition: color 0.2s, background-color 0.2s;
    width: 100%;
    text-align: center;
}

.sidebar-tab:hover,
.sidebar-tab.active {
    color: var(--accent-color);
    background-color: rgba(255, 255, 255, 0.05);
}

.vertical-text {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 1px;
}

/* Library Drawer (Slide-out from left, over Playlist) */
.library-drawer {
    position: absolute;
    top: 0;
    left: 40px;
    /* Width of strip */
    width: 0;
    /* Hidden by default */
    height: 100%;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border-color);
    overflow: hidden;
    transition: width 0.3s ease;
    z-index: 150;
    /* Above playlist */
    display: flex;
    flex-direction: column;
}

.library-drawer.open {
    width: 300px;
    /* Fixed width when open */
    box-shadow: 5px 0 15px rgba(0, 0, 0, 0.5);
}

/* Contingency Drawer (shares library-drawer styling) */
.contingency-drawer .panel-header {
    background: linear-gradient(135deg, var(--danger-color), #a03040);
}

.contingency-drawer .panel-header h3 {
    color: white;
}

/* Playlist Section - Pushed by strip */
.playlist-section {
    flex: 2;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    overflow: hidden;
    /* transition: margin-left 0.3s ease; */
}

/* Channel Bug Overlay - Ensure visibility */
.bug-overlay {
    position: absolute;
    z-index: 1000 !important;
    pointer-events: none;
    transition: opacity 0.3s ease;
    width: 10%;
    /* Relative to monitor size */
    max-width: 150px;
}

.bug-overlay img {
    width: 100%;
    height: auto;
    display: block;
}

.bug-overlay.top-left {
    top: 2%;
    left: 2%;
}

.bug-overlay.top-right {
    top: 2%;
    right: 2%;
}

.bug-overlay.bottom-left {
    bottom: 10px;
    left: 10px;
    margin: 0;
    padding: 0;
}

.bug-overlay.bottom-right {
    bottom: 10px;
    right: 10px;
    margin: 0;
    padding: 0;
}

/* GFX Overlay - Full frame graphics layer */
.gfx-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50 !important;
    /* Behind bug (1000) and emergency slate, in front of video (1) */
    pointer-events: none;
    opacity: 0;
    overflow: hidden;
}

.gfx-overlay img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* GFX Transition: Fade */
.gfx-overlay.fade-in {
    animation: gfxFadeIn var(--gfx-duration, 1s) ease-in-out forwards;
}

.gfx-overlay.fade-out {
    animation: gfxFadeOut var(--gfx-duration, 1s) ease-in-out forwards;
}

@keyframes gfxFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes gfxFadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
    }
}

/* GFX Transition: Wipe Left */
.gfx-overlay.wipe-left-in {
    opacity: 1;
    animation: gfxWipeLeftIn var(--gfx-duration, 1s) ease-in-out forwards;
}

.gfx-overlay.wipe-left-out {
    opacity: 1;
    animation: gfxWipeLeftOut var(--gfx-duration, 1s) ease-in-out forwards;
}

@keyframes gfxWipeLeftIn {
    from {
        clip-path: inset(0 100% 0 0);
    }

    to {
        clip-path: inset(0 0 0 0);
    }
}

@keyframes gfxWipeLeftOut {
    from {
        clip-path: inset(0 0 0 0);
    }

    to {
        clip-path: inset(0 100% 0 0);
    }
}

/* GFX Transition: Wipe Right */
.gfx-overlay.wipe-right-in {
    opacity: 1;
    animation: gfxWipeRightIn var(--gfx-duration, 1s) ease-in-out forwards;
}

.gfx-overlay.wipe-right-out {
    opacity: 1;
    animation: gfxWipeRightOut var(--gfx-duration, 1s) ease-in-out forwards;
}

@keyframes gfxWipeRightIn {
    from {
        clip-path: inset(0 0 0 100%);
    }

    to {
        clip-path: inset(0 0 0 0);
    }
}

@keyframes gfxWipeRightOut {
    from {
        clip-path: inset(0 0 0 0);
    }

    to {
        clip-path: inset(0 0 0 100%);
    }
}

/* GFX Transition: Wipe Up */
.gfx-overlay.wipe-up-in {
    opacity: 1;
    animation: gfxWipeUpIn var(--gfx-duration, 1s) ease-in-out forwards;
}

.gfx-overlay.wipe-up-out {
    opacity: 1;
    animation: gfxWipeUpOut var(--gfx-duration, 1s) ease-in-out forwards;
}

@keyframes gfxWipeUpIn {
    from {
        clip-path: inset(100% 0 0 0);
    }

    to {
        clip-path: inset(0 0 0 0);
    }
}

@keyframes gfxWipeUpOut {
    from {
        clip-path: inset(0 0 0 0);
    }

    to {
        clip-path: inset(100% 0 0 0);
    }
}

/* GFX Transition: Wipe Down */
.gfx-overlay.wipe-down-in {
    opacity: 1;
    animation: gfxWipeDownIn var(--gfx-duration, 1s) ease-in-out forwards;
}

.gfx-overlay.wipe-down-out {
    opacity: 1;
    animation: gfxWipeDownOut var(--gfx-duration, 1s) ease-in-out forwards;
}

@keyframes gfxWipeDownIn {
    from {
        clip-path: inset(0 0 100% 0);
    }

    to {
        clip-path: inset(0 0 0 0);
    }
}

@keyframes gfxWipeDownOut {
    from {
        clip-path: inset(0 0 0 0);
    }

    to {
        clip-path: inset(0 0 100% 0);
    }
}

/* GFX Drawer Styling */
.gfx-drawer .panel-header {
    background: linear-gradient(135deg, #6a11cb, #2575fc);
}

.gfx-drawer .panel-header h3 {
    color: white;
}

.btn-gfx-on {
    background-color: var(--success-color);
    color: white;
    border: none;
    padding: 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.2s;
}

.btn-gfx-on:hover {
    filter: brightness(1.1);
}

.btn-gfx-off {
    background-color: var(--danger-color);
    color: white;
    border: none;
    padding: 0.5rem;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.2s;
}

.btn-gfx-off:hover {
    filter: brightness(1.1);
}

/* Commercial Breaks Drawer Styling */
.commercials-drawer .panel-header {
    background: linear-gradient(135deg, #ffc107, #ff9800);
}

.commercials-drawer .panel-header h3 {
    color: #000;
}

/* Commercial Time Table */
.commercial-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.commercial-table th,
.commercial-table td {
    padding: 6px 8px;
    text-align: center;
    border-bottom: 1px solid #333;
}

.commercial-table th {
    background: #1a1a1a;
    color: #888;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
}

.commercial-table td {
    font-family: var(--font-mono);
    color: var(--text-main);
}

.commercial-table tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.commercial-table tr.has-content {
    background: rgba(255, 193, 7, 0.1);
}

.commercial-table .scheduled-col {
    color: #ffc107;
}

.commercial-table .played-col {
    color: #4CAF50;
}

.commercial-table .played-col.partial {
    color: #ff9800;
}

.commercial-table .hour-col {
    font-weight: 600;
    color: #888;
}

.panel-header {
    height: 40px;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1rem;
    flex-shrink: 0;
}

.panel-header h2,
.panel-header h3 {
    font-size: 0.9rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
}

.playlist-tools {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-icon {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 28px;
    height: 28px;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background-color: var(--border-color);
}

.separator {
    width: 1px;
    height: 20px;
    background-color: var(--border-color);
    margin: 0 0.5rem;
}

/* Playlist Grid */
.playlist-header-row {
    display: grid;
    grid-template-columns: 36px 100px 100px 100px 60px 25px 1fr 100px 50px 50px;
    padding: 0.5rem;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    gap: 0.75rem;
    flex-shrink: 0;
}

.playlist-container {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.playlist-item {
    display: grid;
    grid-template-columns: 36px 100px 100px 100px 60px 25px 1fr 100px 50px 50px;
    gap: 0.75rem;
    padding: 0.5rem;
    border-left: 3px solid transparent;
    cursor: pointer;
    user-select: none;
    align-items: center;
    font-size: 0.85rem;
}

.playlist-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

/* GENERIC SELECTED ITEM (Not Playing): White Background with Black Text */
.playlist-item.selected {
    background-color: #ffffff !important;
    color: #000000 !important;
    border-left: 3px solid #6496ff !important;
    /* Keep blue accent border to distinguish from others? Or make it black/white? keeping blue for now so you know its selection */
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.playlist-item.selected * {
    color: #000000 !important;
}

/* CUED ITEM: Amber/Yellow with Black Text */
.playlist-item.cued {
    background-color: #ffc107 !important;
    /* Amber */
    color: #000000 !important;
    border-left: 4px solid #cc9a06 !important;
}

.playlist-item.cued * {
    color: #000000 !important;
    border-color: rgba(0, 0, 0, 0.2) !important;
}

/* SELECTED CUED ITEM: White Background with Dark Amber Text */
.playlist-item.selected.cued {
    background-color: #ffffff !important;
    color: #b38600 !important;
    /* Darker amber for readability on white */
    border-left: 4px solid #ffc107 !important;
}

.playlist-item.selected.cued * {
    color: #b38600 !important;
    border-color: rgba(179, 134, 0, 0.2) !important;
}

/* PLAYING ITEM: Red Background with Black Text */
.playlist-item.playing {
    background-color: #dc3545 !important;
    color: #000000 !important;
    border-left: 4px solid #ff0000 !important;
}

.playlist-item.playing * {
    color: #000000 !important;
}

/* SELECTED PLAYING ITEM: White Background with Red Text */
.playlist-item.selected.playing {
    background-color: #ffffff !important;
    color: #dc3545 !important;
    border-left: 4px solid #dc3545 !important;
}

.playlist-item.selected.playing * {
    color: #dc3545 !important;
}

.playlist-item.done {
    opacity: 0.5;
}

.playlist-item.skipped {
    opacity: 0.4;
    text-decoration: line-through;
    color: #999;
}

/* Type Colors (Vertical Bar + Background) */
/* Type Colors (Vertical Bar + Background) */
.playlist-item[data-type="CLIP"] {
    border-left-color: #007bff;
    background-color: rgba(0, 123, 255, 0.25);
}

.playlist-item[data-type="COMM"] {
    border-left-color: #ffc107;
    background-color: rgba(255, 193, 7, 0.25);
}

.playlist-item[data-type="PROMO"] {
    border-left-color: #28a745;
    background-color: rgba(40, 167, 69, 0.25);
}

.playlist-item[data-type="IDENT"] {
    border-left-color: #dc3545;
    background-color: rgba(220, 53, 69, 0.25);
}

.playlist-item[data-type="LIVE"] {
    border-left-color: #ff00ff;
    background-color: rgba(255, 0, 255, 0.25);
}

.playlist-item[data-type="IMAGE"] {
    border-left-color: #17a2b8;
    background-color: rgba(23, 162, 184, 0.25);
}

.col-time,
.col-dur {
    font-family: var(--font-mono);
}

.col-dur:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.col-opts {
    font-weight: 600;
    color: var(--warning-color);
    font-size: 0.75rem;
}

.col-epg {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.col-sec {
    display: flex;
    gap: 4px;
    align-items: center;
}

/* Status Badges */
.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background-color: #444;
}

.status-indicator.playing {
    background-color: var(--success-color);
    box-shadow: 0 0 5px var(--success-color);
}

.status-indicator.cued {
    background-color: #17a2b8;
    /* Cyan - clearly different from green */
    box-shadow: 0 0 8px #17a2b8;
    animation: pulse-cue 1.5s ease-in-out infinite;
}

@keyframes pulse-cue {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

.status-indicator.hold {
    background-color: var(--warning-color);
    box-shadow: 0 0 8px var(--warning-color);
    animation: pulse-hold 2s ease-in-out infinite;
}

.status-indicator.loop {
    background-color: #17a2b8;
    /* Cyan */
    box-shadow: 0 0 8px #17a2b8;
}

@keyframes pulse-hold {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.status-indicator.error {
    background-color: var(--danger-color);
}

.status-indicator.ready {
    background-color: #ffffff;
    /* White for ready items */
    box-shadow: 0 0 3px rgba(255, 255, 255, 0.5);
}

.status-indicator.done {
    background-color: #666;
    /* Grey for done items */
}

/* Sidebar */
.sidebar-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-panel);
    min-width: 400px;
    max-width: 500px;
    border-left: 1px solid var(--border-color);
}

.monitor-panel-group {
    display: flex;
    gap: 0.5rem;
    padding: 0.5rem;
    background-color: black;
    border-bottom: 1px solid var(--border-color);
}

/* Remove Preview Monitor */
#preview-monitor-panel {
    display: none !important;
}

.monitor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.monitor-label {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.7rem;
    color: var(--danger-color);
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.monitor-screen {
    width: 100%;
    aspect-ratio: 16/9;
    background-color: #000;
    border: 1px solid #333;
    position: relative;
    overflow: hidden;
}

/* Transport Controls */
.control-panel {
    padding: 0.5rem 1rem;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.transport-row {
    display: flex;
    gap: 0.5rem;
}

.btn-transport {
    flex: 1;
    padding: 1rem;
    border: none;
    border-radius: 4px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    text-transform: uppercase;
    transition: filter 0.2s;
}

.btn-transport:hover {
    filter: brightness(1.1);
}

.btn-take {
    background-color: var(--success-color);
    color: white;
}

.btn-hold {
    background-color: var(--warning-color);
    color: #121212;
}

.btn-hold.active {
    background-color: #ff9900;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

.btn-emergency {
    background-color: var(--danger-color);
    color: white;
    font-size: 0.9rem;
    padding: 0.75rem;
}

/* Crawl */
.crawl-panel {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.crawl-controls {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.crawl-actions {
    display: flex;
    gap: 0.5rem;
}

.crawl-actions button {
    flex: 1;
    padding: 0.5rem;
}

#crawl-select,
#crawl-input {
    width: 100%;
    padding: 0.5rem;
    background: var(--bg-dark);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

/* Media Library */
.library-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.library-container {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
    background-color: var(--bg-dark);
}

.library-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: grab;
    user-select: none;
}

.library-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.lib-icon {
    font-size: 1.2rem;
}

.lib-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
}

.lib-dur {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.library-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 600px;
    max-width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.modal-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 1rem;
    overflow-y: auto;
}

.setting-group {
    margin-bottom: 1.5rem;
}

.setting-group h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
    padding-bottom: 0.25rem;
}

.setting-row {
    margin-bottom: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.setting-row select {
    padding: 0.5rem;
    background: var(--bg-dark);
    color: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.settings-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.settings-actions-grid button {
    padding: 0.8rem;
    cursor: pointer;
    background: var(--bg-dark);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.settings-actions-grid button:hover {
    background: var(--border-color);
}

.upload-btn {
    width: 100%;
    padding: 0.5rem;
    background: none;
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
    cursor: pointer;
}

.upload-btn:hover {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.btn-danger {
    background-color: rgba(220, 53, 69, 0.1) !important;
    color: var(--danger-color) !important;
    border-color: var(--danger-color) !important;
}

.btn-danger:hover {
    background-color: var(--danger-color) !important;
    color: white !important;
}

/* Context Menu */
.context-menu {
    position: fixed;
    background-color: var(--bg-panel);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 5000;
    min-width: 180px;
    border-radius: 4px;
}

.context-menu-item {
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.context-menu-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.context-menu-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 2px 0;
}

.context-menu-item .shortcut {
    float: right;
    opacity: 0.5;
    font-size: 0.8em;
}

/* Helper */
.btn-xs {
    padding: 2px 6px;
    font-size: 0.7rem;
    background: #333;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
}

.full-width {
    width: 100%;
}

.full-width-input {
    width: 100%;
    padding: 8px;
    background-color: #2a2a2a;
    border: 1px solid #444;
    color: #fff;
    border-radius: 4px;
}

.col-sec {
    display: flex;
    justify-content: center;
    align-items: center;
}

.sec-badge {
    font-size: 0.7rem;
    padding: 2px 4px;
    background: #444;
    border-radius: 3px;
    color: #ccc;
    cursor: pointer;
}

.sec-badge.active-bug {
    background: var(--accent-color);
    color: white;
}

/* Emergency Slate */
.emergency-slate {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #000;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    z-index: 100;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* Crawl Overlay - Synced with output.html */
.crawl-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 40px;
    background: rgba(0, 0, 0, 0.8);
    overflow: hidden;
    z-index: 50;
    display: none;
    align-items: center;
    border-top: 1px solid #444;
    border-bottom: 1px solid #444;
}

.crawl-overlay:not(.hidden) {
    display: flex;
}

.crawl-text {
    padding-left: 100%;
    display: inline-block;
    white-space: nowrap;
    font-size: 1.2rem;
    font-weight: bold;
    color: #ffc107;
    animation: scroll-left 18s linear infinite;
    /* 20% slower than 15s */
}

@keyframes scroll-left {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-100%);
    }
}

/* Channel Bug Overlay */
.bug-overlay {
    position: absolute;
    z-index: 70;
    /* Highest layer - above everything */
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.bug-overlay img {
    display: block;
    max-width: 200px;
    max-height: 200px;
    object-fit: contain;
}

/* Override for fullscreen bugs - no size limits */
.bug-overlay.fullscreen-bug img {
    max-width: none;
    max-height: none;
}

/* Bug Position Presets */
.bug-overlay.top-left {
    top: 20px;
    left: 20px;
}

.bug-overlay.top-right {
    top: 20px;
    right: 20px;
}

.bug-overlay.bottom-left {
    bottom: 80px;
    /* Above crawl */
    left: 20px;
}

.bug-overlay.bottom-right {
    bottom: 80px;
    /* Above crawl */
    right: 20px;
}

.bug-overlay.center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.bug-overlay.fullscreen-bug {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-width: none;
}

.bug-overlay.fullscreen-bug img {
    width: 100%;
    height: 100%;
    object-fit: fill;
    /* Fill exactly - the image is pre-positioned at 1920x1080 with alpha */
}

/* Accordion Panels */
.accordion-panel {
    border-bottom: 1px solid var(--border-color);
}

.accordion-trigger {
    cursor: pointer;
    position: relative;
}

.accordion-arrow {
    transition: transform 0.3s ease;
    font-size: 0.8rem;
    margin-left: auto;
}

.accordion-panel.collapsed .accordion-content {
    display: none;
}

.accordion-panel.collapsed .accordion-arrow {
    transform: rotate(-90deg);
}

.accordion-content {
    display: block;
    padding: 0.25rem 0.5rem;
    max-height: 150px;
    overflow-y: auto;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

/* Slate List */
.slate-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.slate-item {
    aspect-ratio: 16/9;
    background-size: cover;
    background-position: center;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    transition: border-color 0.2s;
}

.slate-item:hover {
    border-color: var(--accent-color);
}

.slate-item-delete {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Secondary Event Badge */
.sec-badge {
    display: inline-block;
    background: var(--accent-color);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 0.5rem;
}

/* Bug Library Items in Modal */
.bug-lib-item {
    width: 100%;
    aspect-ratio: 1;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-color: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.1s;
}

.bug-lib-item:hover {
    border-color: var(--accent-color);
    transform: scale(1.05);
}

.bug-lib-item.selected {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px var(--accent-color);
}

.bug-lib-item.add-new {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
}

.bug-lib-item.add-new:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--accent-color);
}

/* Live Stream Status Animation */
@keyframes pulse-live {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes pulse-cue {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 5px #17a2b8;
    }

    50% {
        opacity: 0.7;
        box-shadow: 0 0 10px #17a2b8;
    }
}

@keyframes pulse-obs {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Sidebar Tab Styles */
.sidebar-tab:hover {
    background: var(--border-color);
    cursor: pointer;
}

/* Segment Column */
.col-seg {
    width: 32px;
    min-width: 32px;
    max-width: 32px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* Column Width Fixes - Prevent Header Wrapping */
.col-status {
    width: 36px;
    min-width: 36px;
    max-width: 36px;
}

.col-time {
    width: 90px;
    min-width: 90px;
    max-width: 90px;
}

.col-dur {
    width: 80px;
    min-width: 80px;
    max-width: 80px;
}

.col-type {
    width: 60px;
    min-width: 60px;
    max-width: 60px;
}

.col-title {
    flex: 1;
    min-width: 150px;
}

.col-sec {
    width: 50px;
    min-width: 50px;
    max-width: 50px;
}

.col-opts {
    width: 50px;
    min-width: 50px;
    max-width: 50px;
}

/* Enhanced Drag and Drop Visuals */
.playlist-item.drag-over-top {
    box-shadow: 0 -2px 0 0 #ffffff !important;
    z-index: 10;
    position: relative;
}

.playlist-item.drag-over-bottom {
    box-shadow: 0 2px 0 0 #ffffff !important;
    z-index: 10;
    position: relative;
}

.playlist-item[draggable='true'] {
    cursor: grab;
}

.playlist-item[draggable='true']:active {
    cursor: grabbing;
}

.playlist-item.dragging {
    opacity: 0.5;
    background: #444;
}

.btn-loop {
    background-color: #17a2b8;
    color: white;
}

.btn-loop.active {
    background-color: #138496;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5);
}

/* Context Menu Submenus */
.context-menu-item {
    position: relative;
    padding-right: 25px;
    /* Space for arrow */
}

.context-menu-item.has-submenu::after {
    content: '';
    position: absolute;
    right: 10px;
    font-size: 0.8em;
    color: #888;
}

.context-menu-submenu {
    display: none;
    position: absolute;
    top: 0;
    left: 100%;
    background: #333;
    border: 1px solid #555;
    min-width: 150px;
    box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.5);
    z-index: 10001;
}

.context-menu-item:hover>.context-menu-submenu {
    display: block;
}

/* ============================================
   LIVE FEEDS DRAWER
   ============================================ */
.live-drawer .panel-header {
    background: linear-gradient(135deg, #e91e63, #9c27b0);
}

.live-drawer .panel-header h3 {
    color: white;
}

/* Live Feed Slot Card */
.live-feed-slot {
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}

.live-feed-slot.backup-slot {
    border-left: 3px solid #666;
    opacity: 0.85;
}

.live-feed-slot.connected {
    border-color: #4CAF50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.3);
}

.live-feed-slot.connecting {
    border-color: #FFC107;
    animation: pulse-slot 1.5s infinite;
}

.live-feed-slot.error {
    border-color: #f44336;
}

@keyframes pulse-slot {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* Feed Header */
.live-feed-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.live-feed-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.live-feed-status {
    font-size: 0.7rem;
    font-weight: 600;
}

.live-feed-status[data-status="disconnected"] {
    color: #666;
}

.live-feed-status[data-status="connecting"] {
    color: #FFC107;
}

.live-feed-status[data-status="connected"] {
    color: #4CAF50;
}

.live-feed-status[data-status="error"] {
    color: #f44336;
}

/* Feed Controls */
.live-feed-controls {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.live-feed-name,
.live-feed-url {
    width: 100%;
    padding: 0.4rem 0.5rem;
    background: #0d0d0d;
    border: 1px solid #333;
    border-radius: 4px;
    color: #e0e0e0;
    font-size: 0.8rem;
}

.live-feed-name::placeholder,
.live-feed-url::placeholder {
    color: #555;
}

.live-feed-url {
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

/* Feed Action Buttons */
.live-feed-actions {
    display: flex;
    gap: 0.4rem;
    margin-top: 0.25rem;
}

.btn-live-connect {
    background: var(--success-color);
    color: white;
    flex: 1;
}

.btn-live-disconnect {
    background: var(--danger-color);
    color: white;
    flex: 1;
}

.btn-live-preview {
    background: #333;
    color: #888;
}

.btn-live-preview:not(:disabled) {
    background: #2196F3;
    color: white;
}

/* Auto-switch checkbox */
.live-auto-switch {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.7rem;
    color: #888;
    margin-top: 0.4rem;
}

.live-auto-switch input[type="checkbox"] {
    width: 14px;
    height: 14px;
}