:root {
    --primary-color: #e50914;
    --accent-color: #6a11cb;
    --bg-color: #080808;
    --surface-color: #141414;
    --card-bg: #1f1f1f;
    --text-primary: #ffffff;
    --text-secondary: #a3a3a3;
    --glass-bg: rgba(20, 20, 20, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --font-heading: 'Inter', sans-serif;
    --font-body: 'Inter', sans-serif;
    --sidebar-width: 280px;
    --header-height: 80px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    font-family: var(--font-body);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
    -webkit-font-smoothing: antialiased;
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
    background: linear-gradient(-45deg, #050505, #100514, #050505, #000000);
    background-size: 400% 400%;
    animation: gradientBG 20s ease infinite;
}

@keyframes gradientBG {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

/* Utilities */
.hidden {
    display: none !important;
}

/* FIX: Opacity 1 by default to prevent black screen */
.screen {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    opacity: 1;
    /* Changed from 0 */
    pointer-events: all;
    /* Changed to allow interaction immediately */
    /* Removed transition for safety */
}

/* ---------------- LOGIN SCREEN ---------------- */
#login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #000;
    /* Using a reliable color fallback */
    background-image: url('https://assets.nflxext.com/ffe/siteui/vlv3/f8fb166f-297d-4db5-9e69-02ebcb79222c/83b5b3a4-8f0b-46ce-8e07-6b0870335e67/BR-pt-20250106-TRIFECTA-perspective_227848d2-45e0-47b2-840a-9d6fb551e186_large.jpg');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

#login-container::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle, rgba(0, 0, 0, 0.4) 0%, rgba(0, 0, 0, 0.95) 100%);
}

.login-card {
    position: relative;
    width: 450px;
    padding: 60px 50px;
    background: rgba(0, 0, 0, 0.75);
    border-radius: 8px;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
    text-align: left;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.login-card h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 30px;
    color: #fff;
    text-align: center;
}

.login-card p {
    color: var(--text-secondary);
    margin-bottom: 20px;
    text-align: center;
    font-size: 0.95rem;
}

.input-group {
    position: relative;
    margin-bottom: 20px;
}

.input-group i {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
    transition: color 0.3s;
}

.input-group input {
    width: 100%;
    padding: 16px 20px 16px 45px;
    background: #333;
    border: none;
    border-radius: 4px;
    color: #fff;
    font-size: 1rem;
    outline: none;
    transition: background 0.3s;
}

.input-group input:focus {
    background: #444;
}

.input-group input:focus+i {
    color: #fff;
}

#login-btn {
    width: 100%;
    padding: 16px;
    background: var(--primary-color);
    border: none;
    border-radius: 4px;
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    margin-top: 20px;
    transition: background 0.3s;
}

#login-btn:hover {
    background: #f40612;
}

.options {
    margin-top: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #b3b3b3;
    font-size: 0.85rem;
}

#error-message {
    margin-top: 20px;
    color: #e87c03;
    font-size: 0.9rem;
    text-align: center;
}

/* ---------------- DASHBOARD ---------------- */
#dashboard-container {
    display: flex;
    background-color: var(--bg-color);
}

.sidebar {
    width: var(--sidebar-width);
    background: #000;
    display: flex;
    flex-direction: column;
    padding: 30px 20px;
    border-right: 1px solid #1a1a1a;
    z-index: 5;
}

.logo-area {
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 50px;
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: -1px;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.nav-links li {
    padding: 14px 20px;
    border-radius: 8px;
    cursor: pointer;
    color: #808080;
    font-weight: 500;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.3s ease;
}

.nav-links li:hover,
.nav-links li.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.nav-links li.active {
    font-weight: 700;
    border-left: 3px solid var(--primary-color);
}

.nav-links li i {
    font-size: 1.2rem;
    width: 24px;
    text-align: center;
}

.bottom-link {
    margin-top: auto;
    color: #e50914 !important;
}

.bottom-link:hover {
    background: rgba(229, 9, 20, 0.1) !important;
}

.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: linear-gradient(to bottom, #141414 0%, #080808 100%);
}

.top-bar {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    background: transparent;
    position: sticky;
    top: 0;
    z-index: 10;
}

.search-bar {
    position: relative;
    width: 350px;
}

.search-bar input {
    width: 100%;
    padding: 12px 20px 12px 45px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: #fff;
    outline: none;
    font-size: 0.9rem;
    transition: border-color 0.3s, background 0.3s;
}

.search-bar input:focus {
    border-color: #fff;
    background: rgba(0, 0, 0, 0.8);
}

.search-bar i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #aaa;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    cursor: pointer;
}

.user-profile i {
    font-size: 1.8rem;
    color: #aaa;
}

/* ---------------- CONTENT GRID ---------------- */
.grid-container {
    padding: 20px 40px 60px 40px;
    overflow-y: auto;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;

    scrollbar-width: thin;
    scrollbar-color: #333 #141414;
}

/* Poster Card Style */
.card-item {
    position: relative;
    background-color: var(--card-bg);
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s, z-index 0s;
    /* Aspect Ratio Hack (2:3) -> 150% height */
    width: 100%;
    height: 0;
    padding-top: 150%;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.card-item.channel-card {
    /* 16:9 -> 56.25% height */
    padding-top: 56.25%;
}

.card-item:hover {
    transform: scale(1.1);
    z-index: 10;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    /* Highlighting border */
    outline: 2px solid #fff;
}

.card-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: opacity 0.3s;
}

.card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 20px 10px 10px 10px;
    background: linear-gradient(to top, rgba(0, 0, 0, 1) 10%, transparent);
    opacity: 1;
    transition: opacity 0.3s;
}

.card-title {
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

/* Loading */
.loading-spinner {
    grid-column: 1 / -1;
    text-align: center;
    padding: 50px;
    font-size: 1.2rem;
    color: #666;
}

/* ---------------- PLAYER OVERLAY ---------------- */
#player-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease;
}

#player-overlay:not(.hidden) {
    opacity: 1;
    pointer-events: all;
}

#close-player {
    position: absolute;
    top: 30px;
    right: 30px;
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s;
    z-index: 1002;
    display: flex;
    align-items: center;
    justify-content: center;
}

#close-player:hover {
    background: #fff;
    color: #000;
    border-color: #fff;
    transform: rotate(90deg);
}

.video-wrapper {
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

video {
    width: 100%;
    height: 100%;
    outline: none;
    cursor: pointer;
}

/* Custom Controls */
.video-wrapper {
    position: relative;
    /* Anchor for absolute controls */
    background: #000;
}

.custom-controls {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    opacity: 0;
    transition: opacity 0.3s;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), transparent 30%, transparent 70%, rgba(0, 0, 0, 0.9));
}

.video-wrapper:hover .custom-controls,
.custom-controls.active {
    opacity: 1;
}

.controls-top {
    padding: 20px;
    font-size: 1.2rem;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
}

.controls-center {
    display: flex;
    justify-content: center;
    align-items: center;
}

#big-play-btn {
    background: rgba(0, 0, 0, 0.5);
    border: 3px solid #fff;
    color: #fff;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    font-size: 2rem;
    cursor: pointer;
    backdrop-filter: blur(5px);
    transition: transform 0.2s, background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#big-play-btn:hover {
    transform: scale(1.1);
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.controls-bottom {
    padding: 20px;
}

.progress-container {
    width: 100%;
    height: 5px;
    background: rgba(255, 255, 255, 0.3);
    cursor: pointer;
    border-radius: 5px;
    margin-bottom: 15px;
    /* Separation from buttons */
    position: relative;
    transition: height 0.2s;
}

.progress-container:hover {
    height: 10px;
}

.progress-bar {
    height: 100%;
    background: var(--primary-color);
    width: 0%;
    border-radius: 5px;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 15px;
    height: 15px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.progress-container:hover .progress-bar::after {
    transform: translateY(-50%) scale(1);
}

.buttons-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.left-controls,
.right-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.custom-controls button {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.2rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.custom-controls button:hover {
    background: rgba(255, 255, 255, 0.1);
}

.volume-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.volume-container:hover input {
    width: 80px;
    opacity: 1;
}

#volume-slider {
    width: 0px;
    transition: width 0.3s, opacity 0.3s;
    opacity: 0;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.time-display {
    font-size: 0.9rem;
    font-family: monospace;
}