* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
}

/* Default pages scroll normally; rundown page will override via body class */

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
}

/* Rundown-only layout: lock to viewport, internal scrolling */
body.rundown-page .container {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: #2c3e50;
    color: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.header-left {
    flex: 1;
}

.header-right {
    flex-shrink: 0;
}

header h1 {
    font-size: 24px;
    margin-bottom: 15px;
}

/* Digital Clock - LCD Broadcast Studio Style */
.digital-clock {
    background: linear-gradient(135deg, #1a1a1a 0%, #0a0a0a 100%);
    border: 2px solid #333;
    border-radius: 6px;
    padding: 12px 20px;
    box-shadow: 
        inset 0 2px 4px rgba(0, 0, 0, 0.5),
        0 2px 8px rgba(0, 0, 0, 0.3);
    position: relative;
    min-width: 180px;
}

.digital-clock::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        repeating-linear-gradient(
            0deg,
            transparent,
            transparent 2px,
            rgba(255, 0, 0, 0.03) 2px,
            rgba(255, 0, 0, 0.03) 4px
        );
    border-radius: 4px;
    pointer-events: none;
}

.clock-time {
    font-family: 'Courier New', 'Lucida Console', 'Monaco', 'Consolas', monospace;
    font-size: 32px;
    font-weight: bold;
    color: #ff0000;
    letter-spacing: 2px;
    display: block;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    text-align: center;
    line-height: 1.2;
}

.status-bar {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.status-item {
    display: flex;
    gap: 8px;
}

.status-label {
    font-weight: 600;
    opacity: 0.8;
}

.status-value {
    font-weight: 400;
}

.status-value.connected {
    color: #2ecc71;
}

.status-value.disconnected {
    color: #e74c3c;
}

.status-value.running {
    color: #2ecc71;
}

.status-value.stopped {
    color: #95a5a6;
}

body.rundown-page .main-content {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    flex: 1 1 auto;
    min-height: 0; /* allow children to shrink and scroll */
    overflow: hidden; /* prevent page scroll */
}

.sidebar {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    max-height: 100%;
    overflow: auto; /* its own scroll */
    display: flex;
    flex-direction: column;
}

.sidebar-section {
    margin-bottom: 30px;
}

.sidebar-section:last-child {
    margin-bottom: 0;
}

.sidebar-section h2 {
    font-size: 18px;
    margin-bottom: 15px;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 8px;
}

.inputs-list {
    max-height: 400px;
    overflow-y: auto;
}

.input-item {
    padding: 10px;
    margin-bottom: 8px;
    background: #f8f9fa;
    border-radius: 4px;
    border-left: 3px solid #3498db;
    cursor: pointer;
    transition: all 0.2s;
}

.input-item:hover {
    background: #e9ecef;
    transform: translateX(2px);
}

.input-item.active {
    border-left-color: #e74c3c;
    background: #fff5f5;
}

.input-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.input-number {
    font-weight: 600;
    color: #3498db;
}

.input-type {
    font-size: 12px;
    color: #7f8c8d;
    background: #ecf0f1;
    padding: 2px 6px;
    border-radius: 3px;
}

.input-title {
    font-size: 14px;
    color: #2c3e50;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.input-duration {
    font-size: 11px;
    color: #95a5a6;
    margin-top: 4px;
}

.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.command-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.command-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.command-group label {
    min-width: 80px;
    font-size: 14px;
}

.rundown-area {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    min-height: 0; /* allow inner container to scroll */
}

.rundown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #ecf0f1;
    gap: 15px;
}

.rundown-header h2 {
    margin: 0;
    flex: 1;
    font-size: 20px;
    color: #2c3e50;
}

.rundown-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.button-separator {
    width: 1px;
    height: 30px;
    background: #bdc3c7;
    margin: 0 5px;
}

.rundown-table-container {
    overflow: auto; /* vertical + horizontal scroll inside panel */
    flex: 1 1 auto;
    min-height: 0;
}

.rundown-table {
    width: 100%;
    border-collapse: collapse;
}

.rundown-table th {
    background: #34495e;
    color: white;
    padding: 12px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
}

.rundown-table td {
    padding: 12px;
    border-bottom: 1px solid #ecf0f1;
}

.rundown-table tbody tr {
    transition: background 0.2s;
}

.rundown-table tbody tr:hover {
    background: #f8f9fa;
}

.rundown-table tbody tr.active {
    background: #fff3cd;
}

.rundown-table tbody tr.completed {
    opacity: 0.6;
}

.empty-state {
    text-align: center;
    color: #95a5a6;
    padding: 40px !important;
}

.event-time {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    padding: 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.event-time:hover {
    background: #f0f0f0;
}

.event-time .time-display {
    display: inline;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
    color: #3498db;
}

/* Time Edit Popup */
.time-edit-popup {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    justify-content: center;
    align-items: center;
}

.time-edit-popup-content {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.time-edit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: #2c3e50;
    color: white;
    border-radius: 8px 8px 0 0;
}

.time-edit-header h4 {
    margin: 0;
    font-size: 16px;
}

.time-edit-close {
    color: white;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.time-edit-close:hover {
    color: #ecf0f1;
}

.time-edit-body {
    padding: 20px;
}

.time-edit-body .form-group {
    margin-bottom: 0;
}

.time-edit-body .form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #2c3e50;
}

.time-edit-body .form-group input[type="time"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    font-family: 'Courier New', monospace;
}

.time-edit-footer {
    padding: 15px 20px;
    border-top: 1px solid #ecf0f1;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #7f8c8d;
    font-style: italic;
}

.column-hint {
    font-size: 10px;
    font-weight: normal;
    opacity: 0.6;
    font-style: italic;
}

/* Duration option wrapper */
.duration-option-wrapper {
    border: 2px solid #3498db;
    border-radius: 6px;
    padding: 12px;
    background: #f8f9fa;
    margin-top: 10px;
}

.duration-option-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 0;
}

.duration-option-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.event-type {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 4px;
    display: inline-block;
}

.event-type.input {
    background: #3498db;
    color: white;
}

.event-type.command {
    background: #9b59b6;
    color: white;
}

.event-input {
    font-weight: 600;
}

.event-transition {
    font-size: 12px;
    color: #7f8c8d;
}

.event-duration {
    font-family: 'Courier New', monospace;
    font-size: 12px;
    color: #7f8c8d;
}

.event-title {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.action-buttons {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
}

.action-buttons .btn {
    padding: 4px 8px;
    font-size: 11px;
    min-width: auto;
}

.action-buttons .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn.active {
    box-shadow: 
        0 0 10px rgba(52, 152, 219, 0.5),
        0 0 20px rgba(52, 152, 219, 0.3),
        inset 0 2px 4px rgba(255, 255, 255, 0.2);
    border: 2px solid #3498db;
}

.btn-success.active {
    box-shadow: 
        0 0 15px rgba(46, 204, 113, 0.8),
        0 0 30px rgba(46, 204, 113, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.3);
    border: 2px solid #27ae60;
    transform: scale(1.02);
}

.btn-danger.active {
    box-shadow: 
        0 0 15px rgba(231, 76, 60, 0.8),
        0 0 30px rgba(231, 76, 60, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.3);
    border: 2px solid #c0392b;
    transform: scale(1.02);
}

.btn-primary {
    background: #3498db;
    color: white;
}

.btn-primary:hover {
    background: #2980b9;
}

.btn-success {
    background: #1e7e4a;
    color: white;
    opacity: 0.7;
}

.btn-success:hover {
    background: #27ae60;
    opacity: 0.9;
}

.btn-success.active {
    background: #2ecc71;
    opacity: 1;
}

.btn-danger {
    background: #8b2635;
    color: white;
    opacity: 0.7;
}

.btn-danger:hover {
    background: #c0392b;
    opacity: 0.9;
}

.btn-danger.active {
    background: #e74c3c;
    opacity: 1;
}

.btn-secondary {
    background: #7f8c8d;
    color: white;
    opacity: 0.7;
}

.btn-secondary:hover {
    background: #95a5a6;
    opacity: 0.9;
}

.btn-secondary.active {
    background: #95a5a6;
    opacity: 1;
    box-shadow: 
        0 0 15px rgba(149, 165, 166, 0.8),
        0 0 30px rgba(149, 165, 166, 0.4),
        inset 0 2px 4px rgba(255, 255, 255, 0.3);
    border: 2px solid #95a5a6;
    transform: scale(1.02);
}

.btn-warning {
    background: #f39c12;
    color: white;
}

.btn-warning:hover {
    background: #d68910;
}

.btn-secondary {
    background: #95a5a6;
    color: white;
}

.btn-secondary:hover {
    background: #7f8c8d;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 12px;
}

/* Ensure small buttons also get active styles */
.btn-sm.active {
    box-shadow: inherit;
    border: inherit;
    transform: inherit;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    overflow: auto;
}

.modal-content {
    background-color: white;
    margin: 50px auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #2c3e50;
    color: white;
    border-radius: 8px 8px 0 0;
}

.modal-header h3 {
    margin: 0;
}

.close {
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 20px;
}

.close:hover {
    color: #ecf0f1;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 20px;
    border-top: 1px solid #ecf0f1;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #2c3e50;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

/* Time input group */
.time-input-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.time-input-group input[type="time"] {
    flex: 0 0 auto;
    width: 150px;
}

.time-input-separator {
    color: #7f8c8d;
    font-size: 12px;
}

#time-mode-indicator {
    background: #ecf0f1;
    border-radius: 4px;
    padding: 2px 6px;
}

/* Command dropdown */
.command-select-wrapper {
    position: relative;
}

.command-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #bdc3c7;
    border-radius: 4px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: none;
}

.command-item {
    padding: 10px;
    cursor: pointer;
    border-bottom: 1px solid #ecf0f1;
    transition: background 0.2s;
}

.command-item:hover {
    background: #f8f9fa;
}

.command-item:last-child {
    border-bottom: none;
}

.command-item strong {
    display: block;
    color: #2c3e50;
    margin-bottom: 4px;
}

.command-category {
    font-size: 11px;
    color: #7f8c8d;
    background: #ecf0f1;
    padding: 2px 6px;
    border-radius: 3px;
    margin-left: 8px;
}

.command-desc {
    font-size: 12px;
    color: #7f8c8d;
    margin-top: 4px;
}

.command-description {
    margin-top: 8px;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 13px;
    color: #2c3e50;
}

.params-hint {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #7f8c8d;
}

/* Drag and Drop */
.input-item.dragging {
    opacity: 0.5;
    border: 2px dashed #3498db;
}

.input-item[draggable="true"] {
    cursor: move;
}

.input-item[draggable="true"]:hover {
    background: #e9ecef;
}

/* Drop zone styles */
.drop-row {
    height: 60px;
}

.drop-zone-cell {
    padding: 0 !important;
    height: 100%;
    position: relative;
}

.drop-zone-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed #bdc3c7;
    border-radius: 4px;
    color: #95a5a6;
    font-size: 14px;
    transition: all 0.2s;
}

/* Always-visible drop footer below table */
.rundown-drop-footer {
    margin-top: 12px;
    flex: 0 0 64px;
}

.rundown-drop-footer-inner {
    height: 100%;
    border: 2px dashed #bdc3c7;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #95a5a6;
    transition: all 0.2s;
}

.rundown-drop-footer.dragover .rundown-drop-footer-inner {
    border-color: #3498db;
    background: #ebf5fb;
    color: #3498db;
    border-width: 3px;
}

.drop-row.drop-target .drop-zone-placeholder {
    border-color: #3498db;
    background: #ebf5fb;
    color: #3498db;
    border-width: 3px;
}

tr.drop-target {
    background: #fff3cd !important;
}

tr.drop-target td {
    border-color: #ffc107;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}

@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
    }
}

