/* Basic Resets */
body {
    margin: 0;
    font-family: Arial, sans-serif;
    background-color: #1a1a1a;
    color: #f0f0f0;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden; /* Hide scrollbar during loading */
}

/* Loading Screen */
#loadingScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    color: white;
    font-size: 1.2em;
    transition: opacity 0.5s ease-out;
}

.spinner {
    border: 8px solid rgba(255, 255, 255, 0.3);
    border-top: 8px solid #007bff;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Popup Overlay */
#popupOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1010; /* Above loading screen */
}

.popupBox {
    background-color: #2c2c2c;
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
    max-width: 400px;
    width: 90%;
}

.popupBox h2 {
    color: #007bff;
    margin-top: 0;
    margin-bottom: 15px;
}

.popupBox p {
    margin-bottom: 25px;
    line-height: 1.6;
}

#acceptButton {
    background-color: #007bff;
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.1em;
    transition: background-color 0.3s ease;
}

#acceptButton:hover {
    background-color: #0056b3;
}

/* Main Container */
.container {
    display: flex;
    max-width: 1200px;
    width: 100%;
    background-color: #222;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    display: none; /* Hidden by default, shown after popup */
    height: 90vh; /* Make container take up more vertical space */
}

.video-container {
    flex: 3; /* Takes up 3 parts of the space */
    position: relative;
    padding-bottom: 40%; /* Adjust for 16:9 aspect ratio (height is 9/16 of width) */
    height: 0;
    background-color: #000;
}

#videoPlayer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Shaka Player UI elements will overlay this video element */
}

#fallbackMessage {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: #ccc;
    font-size: 1.1em;
    background-color: rgba(0, 0, 0, 0.7);
    padding: 20px;
    border-radius: 5px;
}

.sidebar {
    flex: 1; /* Takes up 1 part of the space */
    background-color: #2c2c2c;
    padding: 20px;
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Enable scrolling for content */
    max-height: 100%; /* Sidebar fills its container height */
}

.movie-info-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #444;
}

#movie-title {
    color: #007bff;
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.8em;
}

#movie-overview {
    font-size: 0.95em;
    line-height: 1.6;
    color: #ccc;
    margin-bottom: 15px;
}

.movie-meta-data span {
    display: block;
    font-size: 0.85em;
    color: #aaa;
    margin-bottom: 5px;
}

.list-container {
    flex-grow: 1;
    /* Styles for upcoming movie list could go here */
}

/* --- M3U Input Section Styles --- */
.m3u-input-section {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid #444;
    text-align: center;
}

.m3u-input-section h3 {
    color: #007bff;
    margin-top: 0;
    margin-bottom: 15px;
}

.m3u-input-section input[type="text"] {
    width: calc(100% - 20px);
    padding: 10px;
    margin-bottom: 10px;
    border: 1px solid #555;
    border-radius: 5px;
    background-color: #3a3a3a;
    color: #f0f0f0;
}

.m3u-input-section .input-buttons {
    display: flex;
    gap: 10px; /* Space between buttons */
    justify-content: center;
    margin-top: 5px;
}

.m3u-input-section button,
.custom-file-upload {
    background-color: #007bff;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.3s ease;
    flex-grow: 1; /* Make buttons fill available space */
}

.m3u-input-section button:hover,
.custom-file-upload:hover {
    background-color: #0056b3;
}

/* Hide the default file input, the label acts as a button */
input[type="file"] {
    display: none;
}

/* Playlist Controls (Search and Filter) */
.playlist-controls {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: 10px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #444;
}

#playlistSearchInput,
#playlistGroupFilter {
    flex-grow: 1;
    padding: 8px;
    border: 1px solid #555;
    border-radius: 5px;
    background-color: #3a3a3a;
    color: #f0f0f0;
    font-size: 0.9em;
    min-width: 120px; /* Ensure inputs aren't too small */
}

#playlistGroupFilter {
    cursor: pointer;
}

.movie-list .playlist-group-title {
    background-color: #4a4a4a;
    color: #fff;
    padding: 8px 10px;
    margin-top: 15px;
    margin-bottom: 5px;
    border-radius: 4px;
    font-weight: bold;
    font-size: 1em;
    cursor: pointer; /* To indicate it's collapsible */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.movie-list .playlist-group-title::after {
    content: '▼'; /* Down arrow */
    margin-left: 5px;
    transition: transform 0.2s;
}

.movie-list .playlist-group-title.collapsed::after {
    content: '►'; /* Right arrow */
    transform: rotate(0deg);
}

.movie-list .playlist-group-content {
    display: block; /* Show by default */
}

.movie-list .playlist-group-content.hidden {
    display: none;
}


.movie-list .playlist-item {
    background-color: #3a3a3a;
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
}

.movie-list .playlist-item:hover {
    background-color: #4a4a4a;
}

.movie-list .playlist-item.active {
    background-color: #0056b3; /* Highlight active item */
    border: 1px solid #007bff;
}

.movie-list .playlist-item .item-logo {
    width: 30px; /* Larger logo for better visibility */
    height: 30px;
    object-fit: contain;
    margin-right: 10px;
    border-radius: 3px;
    flex-shrink: 0; /* Prevent shrinking */
}

.movie-list .playlist-item .item-icon {
    width: 30px;
    height: 30px;
    background-color: #007bff;
    border-radius: 3px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    font-size: 0.9em;
    font-weight: bold;
    margin-right: 10px;
    flex-shrink: 0;
}

.movie-list .playlist-item .item-title {
    flex-grow: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.95em;
}


/* Responsive Design */
@media (max-width: 768px) {
    body {
        min-height: auto; /* Allow body to shrink */
        padding: 10px; /* Add some padding */
    }
    .container {
        flex-direction: column;
        margin: 0;
        height: auto; /* Allow container to adjust height */
    }

    .video-container {
        padding-bottom: 56.25%; /* Standard 16:9 for smaller screens */
        width: 100%;
    }

    .sidebar {
        max-height: 50vh; /* Limit sidebar height on smaller screens */
        border-top: 1px solid #444;
        padding-top: 15px;
        flex-shrink: 0; /* Prevent sidebar from shrinking excessively */
    }

    .popupBox {
        margin: 0 20px;
    }

    .m3u-input-section .input-buttons {
        flex-direction: column; /* Stack buttons vertically */
    }

    #playlistSearchInput,
    #playlistGroupFilter {
        min-width: unset; /* Remove min-width for better responsiveness */
        width: 100%; /* Make them full width */
    }
}