/* CSS Variables for colors */
:root {
    --main-bg-color: #333; /* Dark background */
    --text-color: #fff;
    --button-bg-color: #004080;
    --button-hover-bg-color: #003366;
    --modal-bg-color: rgba(0,0,0,0.5);
}

/* Apply box-sizing to all elements */
* {
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: var(--main-bg-color);
    color: var(--text-color);
    margin: 0;
}

/* Hide the main content initially */
#mainContent {
    display: none;
}

/* TV Wall Container */
.tv-wall {
    position: fixed; /* Cover the entire viewport */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    overflow: hidden;
    z-index: -1; /* Place it behind other content */
}

/* Individual TV Styles */
.tv {
    flex: 1;
    aspect-ratio: 9 / 16; /* Vertical aspect ratio */
    margin: 10px;
    border: 8px solid #000;
    border-radius: 12px;
    overflow: hidden;
    background-color: #000;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.5);
}

.tv video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Content Container */
.content-container {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 900px;
    width: 90%;
    padding: 40px 20px;
    background-color: rgba(0, 0, 0, 0.7); /* Semi-transparent background */
    border-radius: 8px;
    text-align: center;
    z-index: 1; /* Place it above the TV wall */
}

h1 {
    font-size: 32px;
    margin-bottom: 20px;
}

p {
    font-size: 22px;
    margin: 20px 0;
}

select, input[type="url"] {
    width: 100%;
    padding: 15px;
    margin: 10px 0;
    font-size: 22px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

button {
    padding: 15px 25px;
    font-size: 18px;
    background-color: var(--button-bg-color);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

button:hover {
    background-color: var(--button-hover-bg-color);
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 3; /* Higher than other content */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-bg-color);
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.modal-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    max-width: 400px;
    width: 100%;
    text-align: center;
    color: #000;
}

.modal-buttons {
    margin-top: 20px;
    display: flex;
    justify-content: center;
}

.modal-buttons button {
    margin: 0 10px;
}

.close-btn {
    background-color: var(--button-bg-color);
    color: #fff;
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.close-btn:hover {
    background-color: var(--button-hover-bg-color);
}

.modal-input {
    width: 100%;
    padding: 12px;
    margin: 20px 0;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* Password Overlay */
#passwordOverlay .modal-content {
    max-width: 300px;
    width: 100%;
}

/* Video Editor Modal Styles */
.video-editor-modal {
    z-index: 4; /* Higher than regular modals */
}

.video-editor-modal-content {
    max-width: 90%;
    width: 1000px;
    max-height: 90vh;
    padding: 0;
    text-align: left;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.video-editor-header {
    padding: 20px;
    border-bottom: 2px solid #e0e0e0;
    background-color: #f5f5f5;
}

.video-editor-header h2 {
    margin: 0;
    color: #333;
    font-size: 24px;
}

.video-editor-table-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    max-height: calc(90vh - 200px);
}

/* Mobile container - only used in mobile view */
.video-editor-mobile-container {
    display: none;
}

.video-editor-table {
    width: 100%;
    border-collapse: collapse;
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.video-editor-table thead {
    background-color: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
}

.video-editor-table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: #333;
    border-bottom: 2px solid #dee2e6;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.video-editor-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #e9ecef;
    vertical-align: middle;
}

.video-editor-table tbody tr {
    transition: background-color 0.2s;
}

.video-editor-table tbody tr:hover {
    background-color: #f8f9fa;
}

.video-editor-table tbody tr:last-child td {
    border-bottom: none;
}

.order-header {
    width: 100px;
    text-align: center;
}

.title-header {
    width: 30%;
}

.url-header {
    width: 50%;
}

.actions-header {
    width: 80px;
    text-align: center;
}

.order-cell {
    text-align: center;
}

.order-cell .move-btn {
    background-color: #6c757d;
    color: #fff;
    border: none;
    padding: 4px 8px;
    margin: 0 2px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    min-width: 30px;
    transition: background-color 0.2s;
}

.order-cell .move-btn:hover:not(:disabled) {
    background-color: #5a6268;
}

.order-cell .move-btn:disabled {
    background-color: #c6c8ca;
    cursor: not-allowed;
    opacity: 0.5;
}

.title-cell,
.url-cell {
    padding: 4px 12px;
}

.editable-input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.editable-input:focus {
    outline: none;
    border-color: #004080;
    box-shadow: 0 0 0 2px rgba(0, 64, 128, 0.1);
}

.actions-cell {
    text-align: center;
}

.delete-btn {
    background-color: #dc3545;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    font-weight: bold;
    line-height: 1;
    transition: background-color 0.2s;
    min-width: 32px;
}

.delete-btn:hover {
    background-color: #c82333;
}

.video-editor-footer {
    padding: 20px;
    border-top: 2px solid #e0e0e0;
    background-color: #f5f5f5;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.add-video-btn {
    background-color: #28a745;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.2s;
}

.add-video-btn:hover {
    background-color: #218838;
}

.video-editor-actions {
    display: flex;
    gap: 10px;
}

.cancel-btn {
    background-color: #6c757d;
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.2s;
}

.cancel-btn:hover {
    background-color: #5a6268;
}

.save-btn {
    background-color: var(--button-bg-color);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background-color 0.2s;
}

.save-btn:hover:not(:disabled) {
    background-color: var(--button-hover-bg-color);
}

.save-btn:disabled {
    background-color: #c6c8ca;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Edit Video List Gear Icon Button - Fixed Bottom Right */
.edit-videos-gear-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    background-color: rgba(108, 117, 125, 0.9);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
    z-index: 2;
    padding: 0;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.edit-videos-gear-btn:hover {
    background-color: rgba(90, 98, 104, 0.95);
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
}

.edit-videos-gear-btn:active {
    transform: scale(0.95);
}

.edit-videos-gear-btn svg {
    width: 24px;
    height: 24px;
    pointer-events: none;
}

/* Media Queries for Responsiveness */
@media (max-width: 768px) {
    /* Adjust the content container for mobile */
    .content-container {
        width: 90%;
        padding: 30px 15px;
    }

    h1 {
        font-size: 24px;
    }

    select, input[type="url"] {
        padding: 12px;
        font-size: 16px;
    }

    button {
        padding: 15px 25px;
        font-size: 20px;
    }

    /* Hide the second and third TVs */
    .tv:nth-child(2),
    .tv:nth-child(3) {
        display: none;
    }

    /* Adjust TV size */
    .tv {
        margin: 0;
        width: 100%;
        height: 100%;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }

    /* Adjust the TV wall to ensure the background video fills the screen */
    .tv-wall {
        flex-direction: column;
    }

    /* Video Editor Mobile Styles - Brand New Mobile-First Design */
    .video-editor-modal-content {
        max-width: 100%;
        width: 100%;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
        padding: 0;
        display: flex;
        flex-direction: column;
        background-color: #f8f9fa;
    }

    /* Hide desktop table on mobile */
    .video-editor-table-container {
        display: none;
    }

    /* Mobile Header */
    .mobile-editor-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        background-color: #fff;
        border-bottom: 1px solid #e9ecef;
        position: sticky;
        top: 0;
        z-index: 100;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }

    .mobile-editor-header h2 {
        margin: 0;
        font-size: 20px;
        font-weight: 600;
        color: #212529;
        flex: 1;
        text-align: center;
    }

    .mobile-close-btn {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: none;
        border: none;
        color: #6c757d;
        cursor: pointer;
        border-radius: 8px;
        transition: all 0.2s;
        padding: 0;
    }

    .mobile-close-btn:active {
        background-color: #f8f9fa;
        transform: scale(0.95);
    }

    /* Mobile Content Area */
    .mobile-editor-content {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 12px;
    }

    .mobile-video-list {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    /* Mobile Video Item */
    .mobile-video-item {
        background-color: #fff;
        border-radius: 12px;
        padding: 16px;
        display: flex;
        flex-direction: column;
        gap: 12px;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
        border: 1px solid #e9ecef;
        transition: all 0.2s;
    }

    .mobile-video-item:active {
        transform: scale(0.98);
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    }

    /* Header Row with Drag Handle and Delete */
    .mobile-video-header-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    /* Drag Handle */
    .mobile-video-drag-handle {
        display: flex;
        align-items: center;
        color: #adb5bd;
        flex-shrink: 0;
    }

    /* Video Content */
    .mobile-video-content {
        display: flex;
        flex-direction: column;
        gap: 10px;
        width: 100%;
    }

    /* Mobile Inputs */
    .mobile-input-title,
    .mobile-input-url {
        width: 100%;
        padding: 12px 14px;
        border: 2px solid #e9ecef;
        border-radius: 8px;
        font-size: 16px;
        font-family: inherit;
        background-color: #fff;
        color: #212529;
        transition: all 0.2s;
        -webkit-appearance: none;
        appearance: none;
        box-sizing: border-box;
    }

    .mobile-input-title {
        font-weight: 500;
        font-size: 16px;
    }

    .mobile-input-url {
        font-size: 15px;
        color: #495057;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
        width: 100%;
    }

    .mobile-input-title:focus,
    .mobile-input-url:focus {
        outline: none;
        border-color: #004080;
        box-shadow: 0 0 0 3px rgba(0, 64, 128, 0.1);
    }

    .mobile-input-title::placeholder,
    .mobile-input-url::placeholder {
        color: #adb5bd;
    }

    /* Mobile Actions */
    .mobile-video-actions {
        display: flex;
        flex-direction: row;
        gap: 8px;
        justify-content: flex-start;
    }

    .mobile-move-up-btn,
    .mobile-move-down-btn {
        width: 44px;
        height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s;
        padding: 0;
        background-color: #f8f9fa;
    }

    .mobile-delete-btn {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s;
        padding: 0;
        background-color: transparent;
    }

    .mobile-move-up-btn {
        color: #004080;
    }

    .mobile-move-up-btn:active:not(:disabled) {
        background-color: #e7f3ff;
        transform: scale(0.95);
    }

    .mobile-move-down-btn {
        color: #004080;
    }

    .mobile-move-down-btn:active:not(:disabled) {
        background-color: #e7f3ff;
        transform: scale(0.95);
    }

    .mobile-move-up-btn:disabled,
    .mobile-move-down-btn:disabled {
        color: #adb5bd;
        cursor: not-allowed;
        opacity: 0.5;
    }

    .mobile-delete-btn {
        color: #dc3545;
    }

    .mobile-delete-btn:active {
        background-color: #fee;
        transform: scale(0.95);
    }

    /* Empty State */
    .mobile-empty-state {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 60px 20px;
        text-align: center;
    }

    .mobile-empty-icon {
        font-size: 64px;
        margin-bottom: 16px;
        opacity: 0.5;
    }

    .mobile-empty-title {
        font-size: 20px;
        font-weight: 600;
        color: #212529;
        margin: 0 0 8px 0;
    }

    .mobile-empty-text {
        font-size: 16px;
        color: #6c757d;
        margin: 0;
    }

    /* Mobile Footer */
    .mobile-editor-footer {
        padding: 16px 20px;
        background-color: #fff;
        border-top: 1px solid #e9ecef;
        display: flex;
        flex-direction: column;
        gap: 12px;
        position: sticky;
        bottom: 0;
        box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.05);
    }

    .mobile-add-btn {
        width: 100%;
        padding: 16px;
        background: linear-gradient(135deg, #28a745 0%, #218838 100%);
        color: #fff;
        border: none;
        border-radius: 12px;
        font-size: 16px;
        font-weight: 600;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        transition: all 0.2s;
        box-shadow: 0 2px 8px rgba(40, 167, 69, 0.3);
    }

    .mobile-add-btn:active {
        transform: scale(0.98);
        box-shadow: 0 1px 4px rgba(40, 167, 69, 0.3);
    }

    .mobile-footer-actions {
        display: flex;
        gap: 10px;
    }

    .mobile-cancel-btn,
    .mobile-save-btn {
        flex: 1;
        padding: 14px;
        border: none;
        border-radius: 10px;
        font-size: 16px;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s;
    }

    .mobile-cancel-btn {
        background-color: #f8f9fa;
        color: #6c757d;
        border: 2px solid #e9ecef;
    }

    .mobile-cancel-btn:active {
        background-color: #e9ecef;
        transform: scale(0.98);
    }

    .mobile-save-btn {
        background: linear-gradient(135deg, #004080 0%, #003366 100%);
        color: #fff;
        box-shadow: 0 2px 6px rgba(0, 64, 128, 0.3);
    }

    .mobile-save-btn:active:not(:disabled) {
        transform: scale(0.98);
        box-shadow: 0 1px 3px rgba(0, 64, 128, 0.3);
    }

    .mobile-save-btn:disabled {
        background: #e9ecef;
        color: #adb5bd;
        cursor: not-allowed;
        box-shadow: none;
        opacity: 0.6;
    }

    /* Edit gear button mobile adjustments */
    .edit-videos-gear-btn {
        width: 56px;
        height: 56px;
        bottom: 15px;
        right: 15px;
    }

    .edit-videos-gear-btn svg {
        width: 24px;
        height: 24px;
    }
}

@media (max-width: 576px) {
    /* Further adjustments for smaller screens */
    h1 {
        font-size: 26px;
    }

    .content-container {
        padding: 20px 10px;
    }
}
