
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: none;
    justify-content: center;
    align-items: flex-start; /* Align to top to allow scrolling */
    padding-top: 30px;
    overflow-y: auto; /* Enable scrolling for overlay */
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.show {
    display: flex;
    opacity: 1;
}

/* Modal Window */
.modal-content {
    background-color: #181818;
    width: 95%;
    max-width: 850px;
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0,0,0,0.9);
    position: relative;
    color: #fff;
    margin-bottom: 50px; /* Space at bottom */
    overflow: hidden; /* Hide overflow from banner */
    transform: scale(0.95);
    transition: transform 0.3s ease;
}

.modal-overlay.show .modal-content {
    transform: scale(1);
}

/* Close Button */
.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #181818;
    color: #fff;
    border: none;
    font-size: 20px;
    cursor: pointer;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background-color: #333;
}

/* Video Player Section (Banner) */
.modal-video-section {
    display: none;
    width: 100%;
    position: relative;
    background: #000;
}

.video-player-container {
    width: 100%;
    aspect-ratio: 16 / 9;
    position: relative;
}

/* Gradient overlay on video bottom */
.video-player-container::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 30%;
    background: linear-gradient(to top, #181818, transparent);
    pointer-events: none;
}

.modal-trailer-iframe {
    width: 100%;
    height: 100%;
}

/* Modal Details (2 Column Layout) */
.modal-details-section {
    padding: 0 40px 40px;
}

.details-content {
    display: grid;
    grid-template-columns: 2fr 1fr; /* Left (Info) vs Right (Cast/Credits) */
    gap: 30px;
}

/* Left Column */
.modal-movie-title {
    font-size: 0; /* Hidden, likely shown in video or we recreate it? Standard Netflix shows title in video. */
    display: none;
}

/* Metadata Row */
.movie-metadata {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    font-size: 16px;
}

.movie-match {
    color: #46d369; /* Green Match */
    font-weight: 700;
}

.movie-year {
    color: #bcbcbc;
}

.movie-age {
    border: 1px solid #bcbcbc;
    padding: 0 4px;
    font-size: 12px;
    color: #bcbcbc;
}

.movie-hd {
    border: 1px solid rgba(255,255,255,0.4);
    border-radius: 3px;
    padding: 0 5px;
    font-size: 11px;
    color: #bcbcbc;
}

.modal-movie-overview {
    font-size: 16px;
    line-height: 1.8; /* increased further for readability */
    color: #fff;
}

/* Right Column */
.cast-section {
    font-size: 16px;
    line-height: 1.8; /* slightly increased line spacing */
    margin-top: 6px; /* small nudge downward to separate from overview */
}

.cast-label {
    color: #777;
    margin-right: 5px;
}

.cast-value {
    color: #dddddd;
    margin-bottom: 15px;
    display: block;
    font-size: 15px; /* restore clearer size for cast/genres */
    line-height: 1.75;
}

.cast-value span {
    cursor: pointer;
}
.cast-value span:hover {
    text-decoration: underline;
}

.cast-label {
    font-size: 14px; /* ensure label stands out */
}

/* Episodes area stretches to modal edges */
.episodes-section {
    margin-top: 20px;
    width: calc(100% + 80px); /* counter modal padding (40px each side) */
    margin-left: -40px;
    padding: 0 40px; /* internal padding so content doesn't touch the absolute edge */
    box-sizing: border-box;
    grid-column: 1 / -1; /* span full width of the grid */
}

.episodes-header {
    font-weight: 700;
    margin-bottom: 10px;
    font-size: 16px;
    color: #fff;
}

.episodes-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.episode-item {
    width: 100%;
    background: #0f0f0f;
    border-radius: 8px;
    padding: 10px;
    display: flex; /* horizontal layout inside each episode */
    gap: 14px;
    align-items: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.6);
}

.episode-number {
    min-width: 28px;
    color: #bdbdbd;
    font-weight: 700;
    margin-right: 6px;
}

.episode-thumbnail {
    width: 160px;
    height: 90px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
}

.episode-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    flex: 1;
}

.episode-title {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
}

.episode-desc {
    font-size: 13px;
    color: #cfcfcf;
    margin-top: 6px;
    line-height: 1.6;
}

.episode-duration {
    font-size: 12px;
    color: #9b9b9b;
    margin-top: 6px;
}

/* Responsive */
@media (max-width: 768px) {
    .details-content {
        grid-template-columns: 1fr;
    }
    .modal-details-section {
        padding: 20px;
    }
    .episodes-section {
        width: 100%;
        margin-left: 0;
        padding: 0;
    }
    .episode-thumbnail {
        width: 120px;
        height: 68px;
    }
}
