@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;600;800&display=swap');

:root {
    --primary: #E50914; --primary-hover: #f40612;
    --bg: #0b0b0c; --bg-panel: #18181b; --bg-glass: rgba(24, 24, 27, 0.7);
    --text: #f1f1f1; --text-muted: #a1a1aa; --border: #27272a;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', sans-serif; background-color: var(--bg); color: var(--text); overflow-x: hidden; }

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* NAVBAR - Professional Netflix Gradient */
nav { display: flex; justify-content: space-between; align-items: center; padding: 20px 4%; background: linear-gradient(to bottom, rgba(0,0,0,0.8) 0%, transparent 100%); position: fixed; width: 100%; z-index: 1000; transition: background 0.4s ease; }
nav.scrolled { background: var(--bg); border-bottom: none; }
.logo { font-size: 26px; color: var(--primary); font-weight: 800; letter-spacing: 1px; cursor: pointer; }
.logo b { color: var(--text); }
.nav-links { display: flex; align-items: center; gap: 20px; }
.nav-links span { color: var(--text-muted); font-size: 14px; font-weight: 600; }
.nav-links a, .nav-links button { color: var(--text); text-decoration: none; font-weight: 600; background: none; border: none; cursor: pointer; font-size: 14px; transition: color 0.2s; }
.nav-links button:hover, .nav-links a:hover { color: var(--text-muted); }

/* TOAST NOTIFICATIONS (Working Code Preserved) */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 99999; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 16px 24px; background: var(--bg-panel); border-left: 4px solid var(--primary); color: white; border-radius: 6px; box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5); animation: slideIn 0.3s forwards, fadeOut 0.3s 3s forwards; font-size: 14px; font-weight: 600; }
.toast.success { border-color: #22c55e; }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; transform: translateY(-10px); } }

/* BUTTONS & INPUTS */
.btn { padding: 12px 28px; border: none; font-size: 1.1rem; font-weight: 600; border-radius: 4px; cursor: pointer; transition: 0.2s; display: inline-flex; align-items: center; gap: 12px; }
.btn-white { background: white; color: black; }
.btn-white:hover { background: rgba(255,255,255,0.75); transform: scale(1.02); }
.btn-gray { background: rgba(109, 109, 110, 0.7); color: white; }
.btn-gray:hover { background: rgba(109, 109, 110, 0.4); transform: scale(1.02); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }

input { width: 100%; padding: 16px; margin-bottom: 15px; background: rgba(0,0,0,0.5); border: 1px solid var(--border); color: white; border-radius: 6px; font-size: 15px; transition: border 0.3s; }
input:focus { outline: none; border-color: var(--text-muted); background: rgba(0,0,0,0.7); }

/* AUTH PAGE (Working Code Preserved) */
.auth-container { height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(rgba(0,0,0,0.6), rgba(0,0,0,0.8)), url('https://assets.nflxext.com/ffe/siteui/vlv3/ab180a27-b661-44d7-a6d9-940cb32f2f4a/7fb62e44-31fd-4e1c-bba3-11f26fdbbc00/US-en-20231009-popsignuptwoweeks-perspective_alpha_website_large.jpg') center/cover; }
.auth-box { background: var(--bg-glass); backdrop-filter: blur(10px); padding: 60px 50px; border-radius: 12px; width: 100%; max-width: 450px; border: 1px solid var(--border); box-shadow: 0 25px 50px -12px rgba(0,0,0,0.8); }
.auth-box h2 { margin-bottom: 30px; font-size: 32px; font-weight: 800; }
.auth-box p { margin-top: 20px; color: var(--text-muted); cursor: pointer; text-align: left; font-size: 14px; transition: color 0.2s; }
.auth-box p:hover { color: white; text-decoration: underline; }

/* APP HERO - Adjusted to 78vh for Content Peeking */
.hero { 
    height: 78vh; 
    display: flex; 
    align-items: center; 
    padding: 0 4%; 
    background-size: cover; 
    background-position: center; 
    /* Dual Gradient: Side fade for text + Bottom fade for catalog transition */
    box-shadow: inset 400px 0 200px -100px var(--bg), inset 0 -150px 100px -50px var(--bg); 
    transition: background 0.8s ease;
}
.hero-content { max-width: 40%; z-index: 10; margin-top: 20px; }
.hero h1 { font-size: 4rem; font-weight: 800; line-height: 1.1; margin-bottom: 15px; text-shadow: 2px 2px 4px rgba(0,0,0,0.5); }
.hero p { font-size: 1.2rem; margin-bottom: 25px; color: #f1f1f1; text-shadow: 1px 1px 3px rgba(0,0,0,0.8); line-height: 1.4; font-weight: 400; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.hero-btns { display: flex; gap: 12px; }

/* CATALOG ROW - The "Netflix Fold" */
.catalog-section { 
    padding: 0 4%; 
    margin-top: -100px; /* Pulls content up to peak into the Hero area */
    position: relative; 
    z-index: 20; 
}
.catalog-section h3 { margin-bottom: 15px; font-size: 1.4rem; font-weight: 600; color: #e5e5e5; }


/* MULTI-ROW CATALOG GRID - UX Improved */
.grid { 
    display: flex; 
    flex-wrap: wrap; /* Allows items to flow onto the next row */
    gap: 20px 1.25%; /* 20px vertical gap, 1.25% horizontal gap */
    padding: 20px 0 60px 0; 
}

/* Netflix Card Hover Effect - UX Improved */
.card { 
    width: 19%; /* Exactly 5 cards per row */
    aspect-ratio: 16/9; 
    border-radius: 4px; 
    overflow: visible; 
    cursor: pointer; 
    transition: transform 0.3s cubic-bezier(0.5, 0, 0.1, 1), box-shadow 0.3s ease; 
    position: relative; 
    transform-origin: center;
}

.card:hover { 
    transform: scale(1.05); /* Reduced from 1.2 to prevent screen clipping */
    z-index: 100; 
    box-shadow: 0 10px 25px rgba(0,0,0,0.8); 
}

.card img { width: 100%; height: 100%; object-fit: cover; border-radius: 4px; }


.card-meta {
    position: absolute;
    bottom: 0; width: 100%;
    padding: 10px;
    background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
    border-bottom-left-radius: 4px; border-bottom-right-radius: 4px;
    display: flex; justify-content: space-between; align-items: center;
    opacity: 0; transition: opacity 0.3s ease;
}
.card:hover .card-meta { opacity: 1; }
.card-title { font-size: 12px; font-weight: 700; color: white; }

/* PLAYER MODAL - UX Improved with Fade Transition */
#player-modal { 
    position: fixed; inset: 0; background: black; z-index: 9999; 
    visibility: hidden; 
    opacity: 0; 
    transition: visibility 0s 0.4s, opacity 0.4s ease-in-out; 
}
#player-modal.active { 
    visibility: visible; 
    opacity: 1; 
    transition: opacity 0.4s ease-in-out; 
}

.back-nav {
    position: absolute; top: 40px; left: 40px;
    display: flex; align-items: center; gap: 12px;
    color: white; font-size: 1.1rem; font-weight: 600;
    z-index: 10001; cursor: pointer;
    opacity: 0.85; transition: all 0.2s ease;
    padding: 12px 24px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px); /* Netflix-style glass effect over the video */
}
.back-nav:hover { 
    opacity: 1; 
    background: var(--primary); /* Button fills with red */
    color: white; 
    transform: scale(1.03); /* Subtle pop effect */
}

#video-container { width: 100%; height: 100%; }
#secure-video { width: 100%; height: 100%; }

/* SHAKA UI CUSTOM THEME - Netflix Red */
.shaka-video-container .shaka-range-element { color: var(--primary) !important; }
.shaka-video-container .shaka-play-button-container button { color: white !important; }
.shaka-video-container .shaka-current-time { font-weight: 700; color: white; }

/* ADMIN LAYOUT (Working Code Preserved) */
.admin-layout { display: flex; height: 100vh; padding-top: 70px; background: var(--bg); }
.sidebar { width: 260px; background: var(--bg-panel); padding: 30px 20px; border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 15px; }
.sidebar a { color: var(--text-muted); text-decoration: none; padding: 12px 15px; border-radius: 6px; transition: 0.2s; font-weight: 600; display: block; }
.sidebar a:hover, .sidebar a.active { background: rgba(255,255,255,0.05); color: white; }
.main-content { flex: 1; padding: 40px 5%; overflow-y: auto; }
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }

/* ADMIN TABLES (Working Code Preserved) */
.table-container { background: var(--bg-panel); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 16px 20px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: rgba(0,0,0,0.2); color: var(--text-muted); font-weight: 600; text-transform: uppercase; font-size: 12px; letter-spacing: 1px; }
tr:hover td { background: rgba(255,255,255,0.02); }
.badge { padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.admin { background: rgba(229, 9, 20, 0.2); color: var(--primary); }
.badge.user { background: rgba(255,255,255,0.1); color: var(--text-muted); }

/* TOGGLE SWITCH UI (Working Code Preserved) */
.switch { position: relative; display: inline-block; width: 50px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(255,255,255,0.2); transition: .3s; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 4px; bottom: 4px; background-color: white; transition: .3s; }
input:checked + .slider { background-color: var(--primary); }
input:checked + .slider:before { transform: translateX(24px); }
.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

/* Custom Admin Dropdowns */
.custom-select {
    width: 250px;
    padding: 12px;
    background: rgba(0,0,0,0.5);
    border: 1px solid var(--border);
    color: white;
    border-radius: 6px;
    font-size: 14px;
    font-family: 'Inter', sans-serif;
    outline: none;
    cursor: pointer;
    transition: border 0.3s;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a1a1aa' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 15px center;
    background-size: 15px;
}
.custom-select:focus { border-color: var(--primary); }
.custom-select option { background: var(--bg-panel); color: white; padding: 10px; }

/* ==========================================================================
   POLYCIPHER - ENTERPRISE TELEMETRY OVERLAY OVERRIDES
   ========================================================================== */

/* 1. Prevent the statistics overlay from ever being hidden by standard z-index stacking */
.shaka-statistics-container {
    z-index: 10005 !important;
}

/* 2. When Shaka is inactive, keep the parent controls container visible so the stats stay on screen */
.shaka-controls-container:has(.shaka-statistics-container)[style*="opacity: 0"],
.shaka-controls-container:has(.shaka-statistics-container)[style*="opacity:0"] {
    opacity: 1 !important;
    background: transparent !important; /* Ensure the background shadow gradient still fades out */
}

/* 3. Manually fade out all OTHER controls (Timeline, Seekbar, Play Buttons) when the player is idle */
.shaka-controls-container:has(.shaka-statistics-container)[style*="opacity: 0"] > :not(.shaka-statistics-container),
.shaka-controls-container:has(.shaka-statistics-container)[style*="opacity:0"] > :not(.shaka-statistics-container) {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.3s ease-in-out !important;
}


/* ==========================================================================
   CHOOSE YOUR POSITION: Copy/Paste ONE of these blocks below
   ========================================================================== */

/* OPTION A: TOP-LEFT POSITION (Recommended to clear right-side settings) */

.shaka-statistics-container {
    top: 100px !important;
    left: 40px !important;
    right: auto !important;
    bottom: auto !important;
}


/*
.shaka-statistics-container {
    bottom: 80px !important; 
    right: 70px !important;
    top: auto !important;
    left: auto !important;
}
*/

/* OPTION B: VISUAL STYLING (Matches your cinematic black/red theme) */
.shaka-statistics-container {
    background: rgba(11, 11, 12, 0.85) !important;       /* Dark glass theme */
    border: 1px solid rgba(229, 9, 20, 0.2) !important;   /* Subtle red border */
    border-radius: 8px !important;
    font-family: 'Inter', sans-serif !important;
    font-size: 11px !important;
    padding: 14px !important;
    color: #f1f1f1 !important;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5) !important;
}

/* ==========================================================================
   POLYCIPHER - ENTERPRISE TELEMETRY OVERRIDES
   ========================================================================== */

/* 1. Prevent the statistics overlays from ever being hidden by standard z-index stacking */
.shaka-statistics-container {
    z-index: 10005 !important;
}
#polycipher-telemetry {
    z-index: 10006 !important;
}

/* 2. Prevent parent container from hiding if EITHER stats or the telemetry card is active */
.shaka-controls-container:has(.shaka-statistics-container, #polycipher-telemetry)[style*="opacity: 0"],
.shaka-controls-container:has(.shaka-statistics-container, #polycipher-telemetry)[style*="opacity:0"] {
    opacity: 1 !important;
    background: transparent !important; /* Let standard background shadow fade out naturally */
}

/* 3. Manually fade out all OTHER control elements when the player is idle */
.shaka-controls-container:has(.shaka-statistics-container, #polycipher-telemetry)[style*="opacity: 0"] > :not(.shaka-statistics-container, #polycipher-telemetry),
.shaka-controls-container:has(.shaka-statistics-container, #polycipher-telemetry)[style*="opacity:0"] > :not(.shaka-statistics-container, #polycipher-telemetry) {
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.3s ease-in-out !important;
}

/* Red pulsing live dot animation for the Telemetry Card */
@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}