/* Base Variables & Theme Setup */
:root {
    --primary: #E50914;
    --primary-hover: #b20710;
    --bg: #0a0a0a;
    --bg-alpha: rgba(10, 10, 10, 0.9);
    --surface: #1a1a1a;
    --surface-hover: #2a2a2a;
    --text: #ffffff;
    --text-muted: #aaaaaa;
    --border: rgba(255, 255, 255, 0.1);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}
[data-theme="light"] {
    --bg: #f5f5f7;
    --bg-alpha: rgba(245, 245, 247, 0.9);
    --surface: #ffffff;
    --surface-hover: #eaeaea;
    --text: #1d1d1f;
    --text-muted: #6e6e73;
    --border: rgba(0, 0, 0, 0.1);
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Poppins', sans-serif; -webkit-tap-highlight-color: transparent; }
body { background: var(--bg); color: var(--text); overflow-x: hidden; transition: background 0.3s ease, color 0.3s ease; }
.text-primary { color: var(--primary) !important; }

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 10px; }
::-webkit-scrollbar-track { background: var(--surface); }

/* Navigation */
header {
    position: fixed; top: 0; width: 100%; z-index: 100;
    background: var(--bg-alpha); backdrop-filter: blur(15px);
    padding: 1rem 4%; display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--border); transition: 0.3s;
}
.brand { font-size: 1.6rem; font-weight: 800; color: var(--primary); display: flex; align-items: center; gap: 0.5rem; cursor: pointer; letter-spacing: -0.5px; }
.search-bar { background: var(--surface); border: 1px solid var(--border); border-radius: 30px; padding: 0.5rem 1.2rem; display: flex; align-items: center; gap: 0.8rem; width: 350px; transition: 0.3s; }
.search-bar:focus-within { border-color: var(--primary); box-shadow: 0 0 15px rgba(229,9,20,0.2); }
.search-bar input { background: none; border: none; color: var(--text); outline: none; width: 100%; font-size: 0.95rem; }
.nav-links { display: flex; gap: 1.5rem; align-items: center; }
.nav-links button { background: none; border: none; color: var(--text); font-size: 1rem; font-weight: 500; cursor: pointer; transition: 0.2s; display: flex; gap: 0.4rem; align-items: center; }
.nav-links button:hover { color: var(--primary); }

/* Mobile Bottom Nav */
.mobile-nav { display: none; position: fixed; bottom: 0; width: 100%; background: var(--bg-alpha); backdrop-filter: blur(15px); border-top: 1px solid var(--border); z-index: 100; justify-content: space-around; padding: 0.8rem 0; padding-bottom: env(safe-area-inset-bottom, 0.8rem); }
.mobile-nav button { background: none; border: none; color: var(--text-muted); font-size: 1.2rem; display: flex; flex-direction: column; align-items: center; gap: 0.3rem; cursor: pointer; transition: 0.2s; }
.mobile-nav button:hover { color: var(--primary); }
.mobile-nav span { font-size: 0.65rem; font-weight: 500; }

/* Dynamic Hero Section - Fixed Spacing */
.hero { 
    position: relative; 
    min-height: 85vh; 
    display: flex; 
    align-items: center; 
    padding: 120px 4% 100px;
    overflow: hidden; 
}
.hero-backdrop { 
    position: absolute; inset: 0; 
    background-size: cover; background-position: top center; 
    z-index: -2; transition: background-image 1s ease-in-out; 
    filter: brightness(0.7); 
}
.hero-vignette { 
    position: absolute; inset: 0; 
    background: linear-gradient(90deg, var(--bg) 0%, var(--bg-alpha) 45%, transparent 100%), 
                linear-gradient(0deg, var(--bg) 0%, transparent 30%); 
    z-index: -1; transition: background 0.3s ease;
}
.hero-content { 
    max-width: 650px; z-index: 1; 
    animation: slideUp 1s ease backwards; 
    margin-bottom: 70px;
}
.hero-badge { 
    background: rgba(229,9,20,0.15); color: var(--primary); 
    padding: 0.4rem 1rem; border-radius: 30px; 
    font-size: 0.8rem; font-weight: 700; margin-bottom: 1rem; 
    display: inline-block; border: 1px solid var(--primary); letter-spacing: 1px; 
}
.hero-title { 
    color: var(--text); 
    font-size: clamp(2.5rem, 5vw, 4rem); 
    font-weight: 800; margin-bottom: 1rem; line-height: 1.1; 
}
.hero-desc { 
    color: var(--text-muted); 
    font-size: 1.05rem; margin-bottom: 2rem; 
    display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; 
    -webkit-box-orient: vertical; overflow: hidden; 
}

.btn-primary { background: var(--primary); color: white; border: none; padding: 0.8rem 1.8rem; border-radius: 30px; font-size: 1.05rem; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 0.6rem; transition: 0.2s; box-shadow: 0 5px 20px rgba(229,9,20,0.4); white-space: nowrap; }
.btn-primary:hover { transform: translateY(-3px) scale(1.02); background: var(--primary-hover); }
.btn-secondary { background: rgba(100,100,100,0.3); backdrop-filter: blur(5px); color: var(--text); border: 1px solid var(--border); padding: 0.8rem 1.8rem; border-radius: 30px; font-size: 1.05rem; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 0.6rem; transition: 0.2s; white-space: nowrap; }
.btn-secondary:hover { background: rgba(100,100,100,0.5); transform: translateY(-3px) scale(1.02); }

/* Carousels / Rows */
.content-wrapper { padding: 0 4%; display: flex; flex-direction: column; gap: 3rem; margin-top: -80px; z-index: 10; position: relative; padding-bottom: 4rem; }
.row-header h2 { font-size: 1.4rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem; color: var(--text); }
.row-container { display: flex; gap: 1.2rem; overflow-x: auto; padding: 1rem 0 2rem; scroll-snap-type: x mandatory; scroll-behavior: smooth; }
.row-container::-webkit-scrollbar { display: none; } 

/* Grid specifically for Search and Watchlist */
.grid-container { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1.5rem; padding: 8rem 4% 4rem; }

/* Media Cards */
.card { flex: 0 0 calc(100% / 6 - 1.2rem); min-width: 160px; max-width: 220px; position: relative; border-radius: 14px; overflow: hidden; cursor: pointer; transition: 0.3s ease; scroll-snap-align: start; background: var(--surface); box-shadow: var(--shadow); animation: fadeIn 0.6s ease backwards; }
.card:hover { transform: translateY(-10px) scale(1.05); z-index: 2; box-shadow: 0 20px 40px rgba(0,0,0,0.6); }
.card-img { width: 100%; aspect-ratio: 2/3; object-fit: cover; }
.card-overlay { position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.4) 50%, transparent 100%); display: flex; flex-direction: column; justify-content: flex-end; padding: 1.2rem; opacity: 0; transition: 0.3s ease; }
.card:hover .card-overlay { opacity: 1; }
.card-rating { position: absolute; top: 10px; right: 10px; background: rgba(0,0,0,0.7); backdrop-filter: blur(8px); padding: 0.3rem 0.6rem; border-radius: 10px; font-size: 0.8rem; font-weight: 700; color: #f5c518; display: flex; align-items: center; gap: 0.3rem; border: 1px solid rgba(255,255,255,0.1); }
.play-icon-overlay { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.5); font-size: 3rem; color: white; opacity: 0; transition: 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.card:hover .play-icon-overlay { opacity: 1; transform: translate(-50%, -50%) scale(1); }

/* Detail Modal Overlay */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.85); backdrop-filter: blur(20px); z-index: 1000; display: none; opacity: 0; transition: 0.4s ease; overflow-y: auto; }
.modal-overlay.active { display: block; opacity: 1; }
.detail-modal { background: var(--bg); max-width: 1100px; margin: 3rem auto; border-radius: 24px; overflow: hidden; box-shadow: 0 30px 60px rgba(0,0,0,0.8); border: 1px solid var(--border); position: relative; transform: translateY(80px) scale(0.95); transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.modal-overlay.active .detail-modal { transform: translateY(0) scale(1); }
.modal-close { position: absolute; top: 1.5rem; right: 1.5rem; background: rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.2); color: white; width: 45px; height: 45px; border-radius: 50%; font-size: 1.4rem; cursor: pointer; z-index: 10; backdrop-filter: blur(10px); transition: 0.3s ease; }
.modal-close:hover { background: var(--primary); transform: rotate(90deg); border-color: var(--primary); }

.detail-hero { position: relative; height: 450px; }
.detail-backdrop { width: 100%; height: 100%; object-fit: cover; filter: brightness(0.7); }
.detail-hero-vignette { position: absolute; inset: 0; background: linear-gradient(to top, var(--bg) 0%, transparent 100%); }
.detail-content { padding: 0 3rem 3rem; display: flex; gap: 3rem; margin-top: -150px; position: relative; z-index: 2; }
.detail-poster { width: 240px; border-radius: 16px; box-shadow: 0 15px 40px rgba(0,0,0,0.6); aspect-ratio: 2/3; object-fit: cover; border: 1px solid var(--border); }
.detail-info { flex: 1; padding-top: 3rem; }
.detail-title { font-size: clamp(2rem, 4vw, 3rem); font-weight: 800; line-height: 1.2; margin-bottom: 1rem; color: var(--text); }
.detail-meta { display: flex; gap: 1rem; font-size: 0.95rem; color: var(--text-muted); margin-bottom: 1.5rem; align-items: center; flex-wrap: wrap; }
.badge { background: var(--surface); padding: 0.4rem 1rem; border-radius: 20px; border: 1px solid var(--border); font-weight: 500; color: var(--text); }
.badge-hd { background: var(--text); color: var(--bg); font-weight: 800; }

/* Unified Custom Select for dropdowns */
.custom-select { background: var(--surface); color: var(--text); border: 1px solid var(--border); padding: 0.8rem 1.2rem; border-radius: 12px; font-weight: 500; font-size: 0.95rem; outline: none; cursor: pointer; appearance: none; padding-right: 2.5rem; background-image: url('data:image/svg+xml;charset=US-ASCII,<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="gray" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z"/></svg>'); background-repeat: no-repeat; background-position: right 15px center; background-size: 14px; }

/* Video Player Modal (Cinematic Integrated) */
.player-overlay { position: fixed; inset: 0; background: #000; z-index: 2000; display: none; flex-direction: column; }
.player-overlay.active { display: flex; animation: fadeIn 0.4s ease; }

.player-header { position: absolute; top: 0; left: 0; right: 0; padding: 1.5rem 2.5rem; display: flex; justify-content: space-between; align-items: center; background: linear-gradient(to bottom, rgba(0,0,0,0.9), transparent); z-index: 10; transition: transform 0.4s ease, opacity 0.4s ease; }
.player-header h2 { color: #fff; font-size: 1.3rem; font-weight: 600; margin: 0; }

.server-panel { position: absolute; bottom: 0; left: 0; right: 0; padding: 1.5rem 2.5rem; background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.8) 50%, transparent); display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; z-index: 10; transition: transform 0.4s ease, opacity 0.4s ease; }
.server-panel h4 { color: #fff; margin-right: 1rem; font-weight: 500; }
.server-btn { background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2); color: #fff; padding: 0.6rem 1.2rem; border-radius: 10px; cursor: pointer; font-size: 0.9rem; font-weight: 500; transition: 0.2s; backdrop-filter: blur(5px); }
.server-btn:hover, .server-btn.active { background: var(--primary); border-color: var(--primary); color: white; }

.iframe-container { flex: 1; width: 100%; height: 100%; background: #000; }
.iframe-container iframe { width: 100%; height: 100%; border: none; }

/* Dropdowns specifically in the black player overlay */
.player-overlay .custom-select { background: rgba(30,30,30,0.8); border-color: #444; color: #fff; backdrop-filter: blur(5px); }

/* Cinematic Mode Logic */
.player-overlay.cinematic .player-header { transform: translateY(-100%); opacity: 0; pointer-events: none; }
.player-overlay.cinematic .server-panel { transform: translateY(100%); opacity: 0; pointer-events: none; }

.exit-cinematic-btn { position: absolute; bottom: 30px; right: 30px; background: rgba(229,9,20,0.9); color: white; border: none; padding: 0.8rem 1.5rem; border-radius: 30px; font-weight: 600; font-size: 1rem; cursor: pointer; z-index: 20; display: none; box-shadow: 0 5px 15px rgba(0,0,0,0.5); backdrop-filter: blur(5px); transition: 0.2s; }
.exit-cinematic-btn:hover { background: var(--primary-hover); transform: scale(1.05); }
.player-overlay.cinematic .exit-cinematic-btn { display: flex; align-items: center; gap: 0.5rem; animation: fadeIn 0.4s ease; }

/* Professional Footer */
.site-footer { background: var(--surface); border-top: 1px solid var(--border); padding: 3rem 4%; margin-top: 4rem; }
.footer-container { max-width: 1200px; margin: 0 auto; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 1.5rem; }
.footer-brand { font-size: 1.5rem; font-weight: 800; color: var(--text); display: flex; align-items: center; gap: 0.5rem; }
.footer-text { color: var(--text-muted); font-size: 0.95rem; text-align: center; flex: 1; min-width: 250px; }
.footer-credit { color: var(--text); font-weight: 500; font-size: 1rem; }

/* Utilities & Animations */
.loader-overlay { position: fixed; inset: 0; background: var(--bg-alpha); backdrop-filter: blur(10px); z-index: 9999; display: flex; justify-content: center; align-items: center; visibility: hidden; opacity: 0; transition: 0.3s; }
.loader-overlay.active { visibility: visible; opacity: 1; }
.spinner { width: 60px; height: 60px; border: 4px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 1s linear infinite; }
.toast { position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(100px); background: var(--primary); color: white; padding: 1rem 2rem; border-radius: 30px; font-weight: 600; box-shadow: 0 10px 20px rgba(229,9,20,0.4); z-index: 10000; transition: 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.toast.show { transform: translateX(-50%) translateY(0); }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(50px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pulse { 0% { transform: scale(1); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }

/* Universal Responsive Constraints */
@media (max-width: 900px) {
    .hero-title { font-size: 3rem; }
    .card { min-width: 140px; max-width: 190px; }
}

/* Mobile Adjustments */
@media (max-width: 768px) {
    header { flex-wrap: wrap; padding: 1rem 4%; }
    .nav-links { display: none; }
    .search-bar { width: 100%; order: 3; margin-top: 1rem; }
    .mobile-nav { display: flex; }
    
    .hero { min-height: 75vh; padding: 140px 4% 60px; align-items: center; } 
    .hero-content { margin-bottom: 40px; }
    .hero-title { font-size: 2.2rem; }
    .hero-desc { font-size: 0.95rem; -webkit-line-clamp: 4; line-clamp: 4; margin-bottom: 1.5rem; }
    
    .content-wrapper { margin-top: -50px; gap: 2rem; }
    .card { min-width: 130px; max-width: 170px; } 
    .row-header h2 { font-size: 1.2rem; }
    
    .detail-hero { height: 250px; }
    .detail-content { flex-direction: column; align-items: center; text-align: center; margin-top: -80px; padding: 0 1.5rem 1.5rem; }
    .detail-poster { width: 160px; margin-bottom: 1rem; }
    .detail-title { font-size: 1.8rem; }
    .modal-close { top: 1rem; right: 1rem; width: 38px; height: 38px; font-size: 1.1rem; }
    .detail-meta { justify-content: center; }
    
    .player-header { padding: 1rem; }
    .server-panel { padding: 1rem; flex-direction: column; align-items: flex-start; gap: 0.8rem; }
    #player-tv-controls { margin-left: 0 !important; width: 100%; justify-content: space-between; margin-top: 0.5rem; flex-direction: column; }
    #player-tv-controls select { width: 100%; max-width: none; }
    .exit-cinematic-btn { bottom: 85px; right: 20px; font-size: 0.9rem; padding: 0.7rem 1.2rem; }
    
    body { padding-bottom: 70px; }
    .footer-container { flex-direction: column; text-align: center; gap: 1rem; }
    .footer-text { order: 3; margin-top: 0.5rem; }
}