/* --- Global Styles & Polished Theme --- */
:root { --primary-red: #E50914; --dark-bg: #0c0c0c; --medium-bg: #181818; --light-text: #ffffff; --dark-text: #8c8c8c; --font-title: 'Bebas Neue', cursive; --font-body: 'Poppins', sans-serif; --text-shadow: 0px 2px 4px rgba(0, 0, 0, 0.5); }
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font-body); background-color: var(--dark-bg); color: var(--light-text); overflow: hidden; }

/* --- Main Layout --- */
.app-container { display: flex; height: 100vh; }
.main-content { flex-grow: 1; overflow-y: auto; position: relative; }
.main-content::-webkit-scrollbar { display: none; }
.main-content { -ms-overflow-style: none; scrollbar-width: none; }

/* --- Sidebar Styles --- */
.sidebar { width: 100px; background-color: #000; padding: 2rem 0; flex-shrink: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 10; gap: 2rem; transition: all 0.3s ease; }
.sidebar-logo { width: 50px; height: auto; margin-bottom: 2rem; }
.nav-links { list-style-type: none; display: flex; flex-direction: column; gap: 1.5rem; }
.nav-item { color: var(--dark-text); display: flex; justify-content: center; align-items: center; padding: 1rem; border-radius: 50%; transition: all 0.3s ease; }
.nav-item svg { width: 28px; height: 28px; }
.nav-item:hover, .nav-item.active { color: var(--light-text); background-color: var(--medium-bg); }

/* --- Hero Section Styles --- */
.hero { display: flex; position: relative; height: 65vh; width: 100%; flex-direction: column; justify-content: flex-end; padding: 4rem; }
.hero-bg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; }
.hero-bg img { width: 100%; height: 100%; object-fit: cover; object-position: center 20%; opacity: 0; transition: opacity 0.5s ease-in-out; }
.hero-gradient { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(to top, rgba(12,12,12,1) 15%, rgba(12,12,12,0.7) 30%, transparent 60%); z-index: 2; }
.hero-content { position: relative; z-index: 3; max-width: 45%; opacity: 0; transform: translateY(20px); transition: opacity 0.5s ease 0.2s, transform 0.5s ease 0.2s; }
#hero-title { font-family: var(--font-title); font-size: 4.5rem; letter-spacing: 2px; text-shadow: var(--text-shadow); line-height: 1.1; margin-bottom: 1rem; }
.hero-meta { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; font-size: 1rem; color: #c7c7c7; margin-bottom: 1rem; text-shadow: var(--text-shadow); }
.hero-meta .genre-tag { background-color: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 255, 255, 0.2); padding: 0.2rem 0.6rem; border-radius: 20px; font-size: 0.8rem; }
#hero-description { font-size: 1rem; line-height: 1.6; text-shadow: var(--text-shadow); margin-bottom: 1.5rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hero-button { background-color: var(--primary-red); color: var(--light-text); border: none; padding: 0.8rem 2rem; font-size: 1.2rem; font-weight: 500; border-radius: 5px; cursor: pointer; transition: all 0.2s ease; }

/* --- Content Rows & Posters --- */
.content-rows { padding: 0 4rem; position: relative; z-index: 5; }
.movie-row { margin-bottom: 3rem; }
.row-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.row-title { font-family: var(--font-title); font-size: 2rem; letter-spacing: 1px; margin-bottom: 0; }
.view-all-link { color: var(--dark-text); text-decoration: none; font-size: 1rem; transition: color 0.2s ease; cursor: pointer; }
.view-all-link:hover, .view-all-link:focus-visible { color: var(--light-text); outline: none; }
.poster-list { display: flex; overflow-x: auto; overflow-y: hidden; padding-bottom: 1rem; }
.poster-list::-webkit-scrollbar { display: none; }
.poster-list { -ms-overflow-style: none; scrollbar-width: none; }
.poster { position: relative; flex: 0 0 190px; margin-right: 12px; cursor: pointer; transition: transform 0.3s ease, filter 0.3s ease; border-radius: 5px; overflow: hidden; }
.poster img { width: 100%; height: auto; display: block; }
.poster:hover { filter: brightness(1.1); }

/* --- Focus & Active States --- */
a:focus, button:focus, input:focus { outline: none; }
.nav-item:focus-visible, .season-item:focus-visible, .settings-btn:focus-visible, .modal-btn:focus-visible { outline: 2px solid var(--primary-red); }
.poster:focus-visible, .search-item:focus-visible, .grid-poster:focus-visible { outline: 4px solid white; transform: scale(1.05); }
.hero-button:hover, .hero-button:focus-visible { background-color: #fff; color: #000; transform: scale(1.05); outline: none; }
.episode-item:focus-visible { background-color: rgba(229, 9, 20, 0.2); }
.episode-item:focus-visible span, .episode-item:focus-visible h3 { color: white; }

/* --- Settings Modal --- */
.settings-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.85); z-index: 1600; align-items: center; justify-content: center; opacity: 0; transition: opacity 0.3s ease; }
.settings-modal.active { display: flex; opacity: 1; }
.settings-content { position: relative; background-color: var(--medium-bg); padding: 3rem; border-radius: 10px; width: 90%; max-width: 500px; display: flex; flex-direction: column; gap: 2rem; }
.settings-content h2 { font-family: var(--font-title); font-size: 2.5rem; letter-spacing: 1px; text-align: center; margin-bottom: 1rem; }
.close-settings-btn { position: absolute; top: 1rem; right: 1rem; background: none; border: none; color: var(--dark-text); font-size: 2rem; cursor: pointer; }
.setting-item { display: flex; justify-content: space-between; align-items: center; font-size: 1.1rem; }
.setting-item p { color: #aaa; font-size: 1rem; }
.settings-btn { background-color: #333; color: white; border: none; padding: 0.7rem 1.5rem; border-radius: 5px; cursor: pointer; transition: background-color 0.2s ease; }
.settings-btn:hover { background-color: #444; }
.toggle-switch { position: relative; display: inline-block; width: 60px; height: 34px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #333; transition: .4s; border-radius: 34px; }
.slider:before { position: absolute; content: ""; height: 26px; width: 26px; left: 4px; bottom: 4px; background-color: white; transition: .4s; border-radius: 50%; }
input:checked + .slider { background-color: var(--primary-red); }
input:focus-visible + .slider { box-shadow: 0 0 1px var(--primary-red); outline: 2px solid var(--primary-red); }
input:checked + .slider:before { transform: translateX(26px); }
.settings-actions { margin-top: 1rem; }
.save-btn { width: 100%; background-color: var(--primary-red); font-size: 1.1rem; padding: 0.8rem; }
.save-btn:hover { background-color: #ff1f2c; }

/* --- TV Details Modal --- */
.details-modal, .confirmation-modal { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: #000; z-index: 1500; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease; }
.details-modal.active, .confirmation-modal.active { display: flex; opacity: 1; visibility: visible; }
.confirmation-modal { z-index: 1700; background-color: rgba(0, 0, 0, 0.85); align-items: center; justify-content: center; }
.modal-content-box { position: relative; background-color: var(--medium-bg); padding: 3rem; border-radius: 10px; width: 90%; max-width: 500px; display: flex; flex-direction: column; gap: 2rem; }
.modal-content-box h2 { font-family: var(--font-title); font-size: 2.5rem; letter-spacing: 1px; text-align: center; margin-bottom: 1rem; }
#confirmation-message { text-align: center; color: #c7c7c7; margin-bottom: 1rem; }
.confirmation-buttons { display: flex; justify-content: center; gap: 1rem; }
.modal-btn { border: none; padding: 0.7rem 2rem; border-radius: 5px; cursor: pointer; font-size: 1rem; font-weight: 500; transition: background-color 0.2s ease; }
.confirm-btn { background-color: var(--primary-red); color: white; }
.confirm-btn:hover { background-color: #ff1f2c; }
.cancel-btn { background-color: #333; color: white; }
.cancel-btn:hover { background-color: #444; }
.details-modal-bg { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
.details-modal-bg img { width: 100%; height: 100%; object-fit: cover; opacity: 0.2; }
.details-modal-gradient { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: linear-gradient(to right, rgba(12,12,12,1) 50%, rgba(12,12,12,0.9) 70%, transparent 100%); }
.details-modal-content { position: relative; z-index: 2; display: flex; height: 100%; padding: 5rem; gap: 4rem; }
.close-details-btn { position: absolute; top: 2rem; right: 2rem; background: none; border: none; color: white; font-size: 2.5rem; cursor: pointer; z-index: 15; font-weight: 300; }
.details-left { flex: 0 0 300px; display: flex; align-items: center; }
.details-left h1 { font-family: var(--font-title); font-size: 7rem; line-height: 0.95; text-transform: uppercase; word-break: break-word; }
.details-right { flex: 1; display: flex; flex-direction: column; overflow-y: auto; }
.details-right::-webkit-scrollbar { display: none; }
.details-right { -ms-overflow-style: none; scrollbar-width: none; }
.details-right h2 { font-family: var(--font-title); font-size: 2.5rem; letter-spacing: 1px; margin-bottom: 1.5rem; border-bottom: 3px solid var(--primary-red); padding-bottom: 0.5rem; align-self: flex-start; }

.seasons-list { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; margin-bottom: 2rem; }
.season-item { background: none; border: none; font-family: var(--font-body); font-size: 1rem; padding: 0.2rem 0; text-align: left; cursor: pointer; transition: color 0.2s ease; color: var(--dark-text); }
.season-item.active { color: #3b82f6; font-weight: 500; }
.season-item:hover, .season-item:focus-visible { color: var(--light-text); }
.episodes-list { border-top: 1px solid #333; padding-top: 1rem; }
.episode-item { display: flex; align-items: center; padding: 1.2rem 0.5rem; border-bottom: 1px solid #2a2a2a; cursor: pointer; border-radius: 4px; transition: background-color 0.2s ease; text-decoration: none; }
.episode-item:visited h3, .episode-item:visited span { color: var(--light-text); }
.episode-item:last-child { border-bottom: none; }
.episode-item span { font-size: 1.1rem; font-weight: 700; color: var(--dark-text); margin-right: 1.5rem; transition: color 0.2s ease; flex-shrink: 0; width: 60px; }
.episode-item h3 { font-size: 1.1rem; font-weight: 400; color: #e0e0e0; transition: color 0.2s ease; }
.episode-item:hover, .episode-item:focus-visible { background-color: rgba(255, 255, 255, 0.05); }
.episode-item:hover h3, .episode-item:focus-visible h3, .episode-item:hover span, .episode-item:focus-visible span { color: white; }

.player-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: #000; z-index: 2000; opacity: 0; visibility: hidden; transition: opacity 0.3s ease, visibility 0.3s ease; }
.player-modal.active { opacity: 1; visibility: visible; }
.back-from-player { position: absolute; top: 2rem; left: 2rem; background-color: rgba(0, 0, 0, 0.5); border: none; color: white; z-index: 2010; cursor: pointer; border-radius: 50%; width: 50px; height: 50px; display: flex; align-items: center; justify-content: center; transition: background-color 0.2s ease; }
.back-from-player:hover, .back-from-player:focus-visible { background-color: rgba(255, 255, 255, 0.2); outline: none; }
.back-from-player svg { width: 28px; height: 28px; }
.player-modal .video-container { width: 100%; height: 100%; }
.search-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.95); z-index: 1800; display: none; flex-direction: column; align-items: center; padding-top: 5%; opacity: 0; transition: opacity 0.3s ease; }
.search-overlay.active { display: flex; opacity: 1; }
.close-search { position: absolute; top: 2rem; right: 2rem; background: none; border: none; color: white; font-size: 3rem; cursor: pointer; }
.search-box { width: 60%; max-width: 800px; margin-bottom: 2rem; }
#search-input { width: 100%; background: none; border: none; border-bottom: 2px solid var(--dark-text); color: white; font-size: 3rem; font-family: var(--font-title); letter-spacing: 1px; padding: 1rem 0; outline: none; text-align: center; transition: border-color 0.3s ease; }
#search-input:focus { border-bottom-color: white; }
.search-results-grid { width: 90%; max-width: 1600px; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; overflow-y: auto; padding: 1rem; }
.search-item, .grid-poster { cursor: pointer; border-radius: 5px; overflow: hidden; }
.search-item img, .grid-poster img { width: 100%; display: block; height: auto; }
.loader { display: none; position: fixed; left: 50%; top: 50%; z-index: 2500; width: 60px; height: 60px; margin: -30px 0 0 -30px; border: 8px solid #f3f3f3; border-radius: 50%; border-top: 8px solid var(--primary-red); animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* --- Grid View Overlay --- */
.grid-view-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.97); z-index: 1900; display: none; flex-direction: column; opacity: 0; transition: opacity 0.3s ease; }
.grid-view-overlay.active { display: flex; opacity: 1; }
.close-grid-view { position: absolute; top: 2rem; right: 2rem; background: none; border: none; color: white; font-size: 3rem; cursor: pointer; }
#grid-view-title { font-family: var(--font-title); font-size: 3rem; letter-spacing: 1px; padding: 2rem 0; text-align: center; color: white; flex-shrink: 0; }
.grid-view-results-grid { width: 90%; max-width: 1600px; margin: 0 auto; flex-grow: 1; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 1rem; overflow-y: auto; padding: 1rem; }

/* --- Responsive Design --- */
@media (max-width: 1200px) {
    #hero-title { font-size: 4rem; }
    .details-left h1 { font-size: 5.5rem; }
    .poster { flex: 0 0 170px; }
}

@media (max-width: 992px) {
    .sidebar { width: 80px; }
    .hero { padding: 3rem; }
    .content-rows { padding: 0 3rem; }
    #hero-title { font-size: 3.5rem; }
    .hero-content { max-width: 60%; }
    .poster { flex: 0 0 160px; }
    .details-modal-content { padding: 4rem; gap: 2rem; }
    .details-left { flex-basis: 200px; }
    .details-left h1 { font-size: 4.5rem; }
}

@media (max-width: 768px) {
    .sidebar { width: 70px; padding: 1rem 0; }
    .sidebar-logo { width: 40px; }
    .hero { padding: 2rem; height: 55vh; }
    .content-rows { padding: 0 2rem; }
    .hero-content { max-width: 80%; }
    #hero-title { font-size: 3rem; }
    #hero-description { -webkit-line-clamp: 2; }
    .hero-button { padding: 0.7rem 1.5rem; font-size: 1rem; }
    .poster { flex: 0 0 150px; }
    .row-title { font-size: 1.5rem; }

    /* Modal Adjustments */
    .details-modal-content { flex-direction: column; padding: 5rem 2rem 2rem 2rem; overflow-y: auto; }
    .details-modal-content::-webkit-scrollbar { display: none; }
    .details-modal-content { -ms-overflow-style: none; scrollbar-width: none; }
    .details-left { flex-basis: auto; align-items: flex-start; text-align: left; margin-bottom: 2rem; }
    .details-left h1 { font-size: 3.5rem; }
    .details-right { flex-grow: 1; }
    .episodes-list { padding-right: 0; }
    .close-details-btn { top: 1rem; right: 1rem; font-size: 2.5rem; }

    .search-box { width: 90%; }
    #search-input { font-size: 2rem; }
    .search-results-grid, .grid-view-results-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
}

@media (max-width: 576px) {
    body { overflow: auto; } /* Allow scrolling on mobile */
    .app-container { flex-direction: column; height: auto; min-height: 100vh; }
    .main-content { overflow-y: visible; }
    
    /* Transform sidebar to bottom nav bar */
    .sidebar { 
        order: 2;
        width: 100%;
        height: 60px;
        background-color: #000;
        padding: 0;
        flex-direction: row;
        justify-content: space-around;
        gap: 0;
        position: fixed;
        bottom: 0;
        left: 0;
        border-top: 1px solid #222;
    }
    .sidebar-logo { display: none; }
    .nav-links { flex-direction: row; gap: 0; width: 100%; justify-content: space-around; }
    .nav-item { padding: 0.5rem; width: 100%; height: 60px; border-radius: 0; }
    .nav-item svg { width: 24px; height: 24px; }
    
    .main-content { padding-bottom: 70px; } /* Add padding to avoid overlap with bottom nav */
    .hero { padding: 1.5rem; height: 50vh; }
    .content-rows { padding: 0 1.5rem; }
    .hero-content { max-width: 95%; }
    #hero-title { font-size: 2.5rem; }
    .hero-meta { font-size: 0.9rem; }
    #hero-description { display: none; } /* Hide description on smallest screens for space */
    .poster { flex: 0 0 120px; margin-right: 8px; }
    
    /* Modal Adjustments for small screens */
    .settings-content, .modal-content-box { width: 95%; padding: 2rem 1.5rem; }
    .settings-content h2, .modal-content-box h2 { font-size: 2rem; }
    .details-left h1 { font-size: 3rem; }
    .details-modal-gradient { background: linear-gradient(to top, rgba(12,12,12,1) 30%, rgba(12,12,12,0.8) 60%, transparent 90%); }
    .search-results-grid, .grid-view-results-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
    #search-input { font-size: 1.8rem; }
}