:root {
    --bg-color: #0a0f1e;
    --primary-color: #c70039;
    --secondary-color: #007bff;
    --card-bg: rgba(10, 15, 30, 0.7);
    --text-color: #ffffff;
    --text-secondary: #b3b3b3;
    --border-color: #c70039;
    --font-body: 'Poppins', sans-serif;
    --font-heading: 'Exo 2', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    background-image: url('data:image/svg+xml,%3Csvg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"%3E%3Cg fill="%23c70039" fill-opacity="0.1"%3E%3Crect x="0" y="0" width="100" height="1"/%3E%3Crect x="0" y="0" width="1" height="100"/%3E%3C/g%3E%3C/svg%3E');
    color: var(--text-color);
    font-family: var(--font-body);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(ellipse at top, var(--primary-color), transparent), radial-gradient(ellipse at bottom, var(--secondary-color), transparent);
    background-size: 400% 400%;
    animation: aurora 10s ease infinite alternate;
    opacity: 0.1;
    z-index: -1;
}

@keyframes aurora {
    from {
        transform: translateX(-50%);
    }
    to {
        transform: translateX(50%);
    }
}

header .navbar {
    font-family: var(--font-heading);
    width: 100%;
    padding: 10px;
    height: 7vh;
    background: rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 17px;
    border-bottom: 1px solid var(--border-color);
    height: 8vh;
    text-shadow: 0 0 10px var(--primary-color);
}

.herotitle {
    text-align: center;
    margin-top: 40px;
    font-size: 40px;
    font-weight: bold;
    color: var(--text-color);
    width: 100%;
    font-family: var(--font-heading);
}

.hero-text {
    color: var(--primary-color);
    text-shadow: 0 0 8px hsla(345, 100%, 39%, 0.7);
}

.heroTex {
    margin-top: 20px;
    font-size: 80%;
    letter-spacing: 1px;
}

.heroDetails h3 {
    padding: 5%;
    color: var(--text-secondary);
    text-align: center;
    margin-top: 20px;
    width: 100%;
    font-size: 1.25vw;
}

.main {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-grow: 1;
}

.search-box {
    margin: 40px 0;
    width: 65%;
    max-width: 800px;
    display: flex;
    align-items: center;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 50px;
    padding: 1rem 2rem;
    position: relative;
    transition: all 0.3s ease;
    box-shadow: 0 0 20px rgba(199, 0, 57, 0.5);
}

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-color);
    font-size: 18px;
    padding: 10px;
    font-family: var(--font-body);
}

.search-box:hover {
    box-shadow: 0 0 25px var(--secondary-color);
    border-color: var(--secondary-color);
}

#movies-container {
    width: 90%;
    max-width: 1400px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 30px;
    padding: 20px;
    border-radius: 15px;
    transition: background-color 0.3s ease;
    background-color: var(--card-bg);
    margin-top: 40px;
}

.movie-card {
    background-color: var(--card-bg);
    border-radius: 15px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
    position: relative;
}

.movie-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    border-color: var(--secondary-color);
}

.movie-card img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.movie-card:hover img {
    transform: scale(1.1);
}

.movie-card h3 {
    text-align: center;
    padding: 15px;
    font-size: 1.2rem;
    font-weight: bold;
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    text-shadow: 0 0 5px var(--primary-color);
}

.footer {
    width: 100%;
    background-color: transparent;
    color: var(--text-secondary);
    text-align: center;
    padding: 10px 0;
    border-top: 1px solid var(--border-color);
    margin-top: 40px;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background-color: var(--card-bg);
    border: 1px solid var(--primary-color);
    border-radius: 15px;
    max-width: 700px; /* Reduced max-width */
    width: 90%;
    max-height: 90vh;
    overflow: hidden; /* Changed from overflow-y: auto */
    position: relative;
    padding: 0; /* Remove padding to allow full control */
    box-shadow: 0 0 30px rgba(199, 0, 57, 0.4);
    transform: scale(0.95);
    transition: transform 0.3s ease;
    display: flex; /* Use flexbox for the layout */
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-poster-container {
    flex: 0 0 250px; /* Fixed width for the poster container */
    position: relative;
}

#modal-poster {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-top-left-radius: 15px;
    border-bottom-left-radius: 15px;
}

.modal-details-container {
    padding: 30px;
    display: flex;
    flex-direction: column;
    overflow-y: auto; /* Allow details to scroll if they overflow */
}

#modal-title {
    font-family: var(--font-heading);
    font-size: 2.2rem;
    margin-bottom: 15px;
    color: var(--primary-color);
    line-height: 1.2;
}

#modal-release-date, #modal-rating, #modal-genres {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

#modal-overview {
    font-size: 1rem;
    line-height: 1.7;
    margin-top: 20px;
    flex-grow: 1; /* Allow overview to take up available space */
}


#streaming-modal .modal-content {
    max-width: 95vw;
    width: 95%;
    height: 95vh;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.video-container {
    flex-grow: 1;
    position: relative;
}

#streaming-iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.modal-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--primary-color);
    cursor: pointer;
    transition: color 0.3s ease, transform 0.3s ease;
    z-index: 3;
}

.modal-close-btn:hover {
    color: var(--secondary-color);
    transform: rotate(90deg);
}

#watch-now-btn {
    background-color: var(--primary-color);
    color: var(--text-color);
    border: none;
    border-radius: 5px;
    padding: 12px 25px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    margin-top: 25px;
    align-self: flex-start; /* Align button to the left */
}

#watch-now-btn:hover {
    background-color: var(--secondary-color);
}

/* Episode Selection Modal Styles */
#episode-selection-modal .modal-content {
    max-height: 80vh;
    display: block; /* Revert to block for this modal */
    padding: 25px;
    overflow: hidden; /* Revert */
}

.season-selection {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.season-selection label {
    font-size: 1.2rem;
    font-weight: bold;
}

#season-select {
    background-color: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 8px;
    font-size: 1rem;
}

#episodes-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
    max-height: 60vh;
    overflow-y: auto;
    padding-right: 10px; /* For scrollbar */
}

.episode-item {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid transparent;
    transition: border-color 0.3s ease;
}

.episode-item:hover {
    border-color: var(--secondary-color);
}

.episode-item span {
    flex-grow: 1;
    margin-right: 15px;
}

.stream-btn {
    background-color: var(--primary-color);
    color: var(--text-color);
    border: none;
    border-radius: 5px;
    padding: 8px 15px;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.stream-btn:hover {
    background-color: var(--secondary-color);
}

@media (max-width: 768px) {
    .herotitle {
        font-size: 30px;
    }

    .heroDetails h3 {
        font-size: 1rem;
    }

    .search-box {
        width: 90%;
    }

    #movies-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .modal-content {
        flex-direction: column;
        max-height: 85vh;
        width: 95%;
    }

    .modal-poster-container {
        flex: 0 0 150px; /* Adjust height for smaller screens */
    }

    #modal-poster {
        width: 50%;
        border-bottom-left-radius: 0;
        border-top-right-radius: 15px;
    }

    .episode-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .stream-btn {
        width: 100%;
        text-align: center;
    }

    .modal-details-container {
        padding: 20px;
    }

    #modal-title {
        font-size: 1.8rem;
    }

    #modal-overview {
        font-size: 0.9rem;
    }

    #watch-now-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    #movies-container {
        grid-template-columns: repeat(2, 1fr);
    }
}