/* Detail Page Redesign - Immersive Layout */

body.detail-page-body {
    background-color: #141414;
    color: #fff;
    margin: 0;
    padding: 0;
}

/* Back Button Overlay */
.back-arrow-container {
    position: fixed;
    top: 30px;
    left: 4%;
    z-index: 1000;
}

.back-btn {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s;
}

.back-btn:hover {
    transform: scale(1.1);
}

/* Immersive Hero */
.detail-hero {
    position: relative;
    width: 100%;
    min-height: 100vh;
    /* Full screen height */
    background-size: cover;
    background-position: center top;
    display: flex;
    align-items: center;
    /* Vertically center content if needed, commonly Netflix aligns bottom-left */
}

/* Gradient Overlay - Crucial for readability */
.detail-hero::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(to right,
            rgba(0, 0, 0, 0.9) 0%,
            rgba(0, 0, 0, 0.6) 40%,
            rgba(0, 0, 0, 0) 100%),
        linear-gradient(to top,
            #141414 0%,
            rgba(20, 20, 20, 0) 50%);
    z-index: 1;
}

.detail-content {
    position: relative;
    z-index: 10;
    padding-left: 4%;
    padding-right: 4%;
    /* Add right padding */
    width: 100%;
    /* expanded from max-width */
    max-width: 1400px;
    /* Limit for large screens */
    padding-top: 100px;
    padding-bottom: 50px;
    display: flex;
    /* Enable Flexbox */
    gap: 40px;
    /* Space between columns */
    align-items: flex-end;
    /* Align bottom like Netflix typically does, or center? User said "Left Title... Right Iframe". Let's try align-items: center or flex-start */
    flex-wrap: wrap;
}

.detail-col-left {
    flex: 1;
    min-width: 300px;
    max-width: 650px;
}

.detail-col-right {
    flex: 1;
    min-width: 300px;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.detail-title {
    font-size: 3.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    line-height: 1.1;
}

.detail-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 1.1rem;
    color: #bcbcbc;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.match-score {
    color: #46d369;
    /* Netflix "Match" green */
    font-weight: bold;
}

.detail-overview {
    font-size: 1.1rem;
    line-height: 1.5;
    margin-bottom: 2rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

.detail-actions {
    display: flex;
    flex-direction: row;
    /* Vertical alignment */
    gap: 15px;
    margin-bottom: 2rem;
    max-width: 900px;
}

.btn-hero {
    padding: 0.8rem 2rem;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 4px;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Center text */
    gap: 10px;
    width: 100%;
    /* Full width */
    transition: transform 0.2s, background-color 0.2s;
}

/* Player Styles - Integrated */
.hero-player-container {
    margin-top: 20px;
    position: relative;
    width: 100%;
    max-width: 100%;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
    display: none;
    /* Hidden by default, toggled or shown based on user pref? */
}

/* If the user wants the "iframe with play button" visible immediately, 
   we might need to show a "Poster" that clicks to play. */
.player-placeholder {
    position: relative;
    cursor: pointer;
    border-radius: 10px;
    overflow: hidden;
    margin-top: 20px;
    max-width: 400px;
    /* Limit size in the content area */
}

.player-placeholder img {
    width: 100%;
    height: auto;
    opacity: 0.8;
    transition: opacity 0.3s;
}

.player-placeholder:hover img {
    opacity: 1;
}

.play-icon-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(229, 9, 20, 0.8);
    /* Netflix Red */
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s;
}

.player-placeholder:hover .play-icon-overlay {
    transform: translate(-50%, -50%) scale(1.1);
}

.btn-play-hero {
    background-color: white;
    color: black;
}

.btn-play-hero:hover {
    background-color: rgba(255, 255, 255, 0.75);
}

.btn-secondary-hero {
    background-color: rgba(109, 109, 110, 0.7);
    color: white;
}

.btn-secondary-hero:hover {
    background-color: rgba(109, 109, 110, 0.4);
}

/* Cast & Info Grid below fold */
.detail-body {
    padding: 0 4% 50px 4%;
    background-color: #141414;
    position: relative;
    z-index: 10;
}

.section-header {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
    margin-top: 3rem;
    border-left: 3px solid #e50914;
    padding-left: 10px;
}

/* Cast Cards */
.cast-grid {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 15px;
    padding-bottom: 20px;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.cast-grid::-webkit-scrollbar {
    display: none;
}

.cast-card {
    flex: 0 0 140px;
    background: #1f1f1f;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s;
}

.cast-card:hover {
    transform: translateY(-5px);
    background: #2f2f2f;
}

.cast-img-wrapper {
    width: 100%;
    height: 175px;
    overflow: hidden;
}

.cast-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.placeholder-cast {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #333;
    color: #666;
    font-size: 3rem;
}

.cast-info {
    padding: 10px;
}

.cast-name {
    font-weight: 700;
    font-size: 0.9rem;
    line-height: 1.2;
    margin-bottom: 4px;
    color: #fff;
}

.cast-character {
    font-size: 0.8rem;
    color: #aaa;
    line-height: 1.2;
}

/* Mobile responsive adjustments */
/* Mobile responsive adjustments */
@media (max-width: 768px) {

    /* Hero Adjustments */
    .detail-hero {
        min-height: 85vh;
        /* Taller hero on mobile for immersive feel */
        background-position: center center;
        align-items: flex-end;
        /* Align content to bottom */
        padding-bottom: 20px;
    }

    /* Ensure the gradient is strong enough for text legibility over any image */
    .detail-hero::before {
        background: linear-gradient(to top, #141414 10%, rgba(20, 20, 20, 0.9) 40%, rgba(20, 20, 20, 0.4) 80%, rgba(0, 0, 0, 0.6) 100%);
    }

    .detail-content {
        padding-top: 60px;
        padding-left: 5%;
        padding-right: 5%;
        padding-bottom: 20px;
        width: 100%;
        gap: 20px;
    }

    .detail-col-left {
        max-width: 100%;
        min-width: 100%;
    }

    .detail-title {
        font-size: 2.5rem;
        margin-bottom: 1rem;
        line-height: 1.1;
    }

    .detail-meta {
        flex-wrap: wrap;
        font-size: 0.95rem;
        margin-bottom: 1.5rem;
        gap: 12px;
    }

    .detail-overview {
        font-size: 1rem;
        /* Better reading experience for short summaries */
        margin-bottom: 2rem;
        display: -webkit-box;
        /* Truncate overview if too long */
        -webkit-box-orient: vertical;
        overflow: hidden;
        color: #ddd;
    }

    .detail-actions {
        flex-direction: row;
        /* Side by side buttons */
        flex-wrap: wrap;
        width: 100%;
        justify-content: center;
        gap: 12px;
        margin-bottom: 20px;
    }

    .btn-hero {
        width: auto;
        flex: 1 1 45%;
        /* Buttons take ~half width */
        font-size: 1rem;
        padding: 12px 10px;
    }

    .genres {
        /* justify-content: center; */
        display: flex;
        flex-wrap: wrap;
    }

    .keywords {
        /* justify-content: center; */
        display: flex;
        flex-wrap: wrap;
        /* display: none; */
        /* Hide keywords on mobile to reduce clutter? Or keep? Let's hide for cleaner look. */
    }

    /* Episode Row Mobile Styles */
    .episode-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 15px 0;
        /* Removing side padding to use full width */
        border-bottom: 1px solid #333;
    }

    .ep-img-wrapper {
        flex: 0 0 auto;
        width: 100%;
        height: auto;
        aspect-ratio: 16/9;
        /* Standard video ratio */
        max-width: 100%;
    }

    .ep-index {
        display: none;
        /* Hide index number on mobile to save space */
    }

    .ep-meta {
        width: 100%;
    }

    .ep-header {
        flex-direction: row;
        /* Keep title and duration on same line if possible */
        justify-content: space-between;
        align-items: flex-start;
        margin-bottom: 8px;
    }

    .ep-title {
        font-size: 1.1rem;
        line-height: 1.3;
    }

    .ep-overview {
        font-size: 0.9rem;
        color: #bbb;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* Section Headers */
    .section-header {
        font-size: 1.3rem;
        margin-top: 2rem;
        border-left: 4px solid #e50914;
        padding-left: 12px;
    }

    /* Recommendations Grid */
    .row.mt-5>div {
        margin-bottom: 20px;
        /* Space out stacked items */
    }
}

/* Netflix-like Episodes List */
.eposomes-container {
    padding-top: 20px;
}

.episode-row {
    display: flex;
    align-items: center;
    /* Center vertically specifically */
    gap: 20px;
    /* Space between image and text */
    padding: 15px;
    border-bottom: 1px solid #333;
    /* Separator line */
    transition: background-color 0.2s;
    cursor: pointer;
    border-radius: 4px;
    /* Slight rounding on hover */
}

.episode-row:hover {
    background-color: #333;
    /* Lighter background on hover */
}

.ep-index {
    font-size: 1.5rem;
    color: #d2d2d2;
    font-weight: 500;
    min-width: 30px;
    /* specific width for alignment */
    text-align: center;
}

.ep-img-wrapper {
    position: relative;
    flex: 0 0 160px;
    /* Fixed width for thumbnail */
    height: 90px;
    overflow: hidden;
    border-radius: 4px;
}

.ep-img-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Crop if aspect ratio differs */
}

.ep-meta {
    flex: 1;
    /* Take remaining space */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.ep-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.ep-title {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    margin: 0;
}

.ep-duration {
    font-size: 0.9rem;
    color: #aaa;
}

.ep-overview {
    font-size: 0.85rem;
    color: #ccc;
    line-height: 1.4;
    margin: 0;
}

.play-icon-small {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid #fff;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    /* Hidden by default */
    transition: opacity 0.2s;
}

.episode-row:hover .play-icon-small {
    opacity: 1;
    /* Show on hover */
}

/* Upcoming Episode Overlay */
.ep-upcoming-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
    text-align: center;
    padding: 8px;
    z-index: 5;
    transition: background-color 0.3s;
}

.ep-upcoming-overlay i {
    font-size: 1rem;
    margin-bottom: 5px;
    color: #e50914;
}

.episode-item.upcoming {
    cursor: default;
    pointer-events: none;
    opacity: 0.8;
}

.episode-item.upcoming:hover {
    background-color: transparent !important;
}

.upcoming-label {
    display: block;
    text-transform: uppercase;
    font-size: 0.65rem;
    letter-spacing: 1px;
    margin-bottom: 2px;
    opacity: 0.8;
}
