:root {
    --bg-color: #141414;
    /* Netflix-like dark background */
    --card-bg: #1f1f1f;
    --text-color: #ffffff;
    --text-secondary: #b3b3b3;
    --accent-color: #e50914;
    /* Netflix Red */
    --accent-hover: #f40612;
    --glass-border: rgba(255, 255, 255, 0.1);
    --font-family: 'Outfit', sans-serif;
    --modal-bg: #181818;
    --success-color: #46d369;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    min-height: 100vh;
    padding-bottom: 50px;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 4%;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7) 0%, rgba(0, 0, 0, 0) 100%);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    color: var(--accent-color);
    font-size: 1.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.nav-links {
    display: flex;
    gap: 1rem;
}

.nav-btn {
    background: transparent;
    color: var(--text-color);
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 1rem;
    padding: 0.5rem 1rem;
    transition: opacity 0.2s;
}

.nav-btn.primary {
    background-color: var(--text-color);
    color: #000;
    border-radius: 4px;
    font-weight: 600;
}

.nav-btn.primary:hover {
    background-color: #c9c9c9;
}

/* Views Management */
.view {
    display: none;
    padding: 2rem 4%;
    animation: fadein 0.3s;
}

.view.active {
    display: block;
}

.view.hidden {
    display: none;
}

@keyframes fadein {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Library View */
.section-header h2 {
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.series-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.series-card {
    background: var(--card-bg);
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
    aspect-ratio: 2/3;
    display: flex;
    flex-direction: column;
}

.series-card:hover {
    transform: scale(1.05);
    z-index: 10;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
}

.series-poster {
    flex: 1;
    background-size: cover;
    background-position: center;
    background-color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.series-info {
    padding: 10px;
    background: #181818;
}

.series-title {
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.series-meta-card {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Series Detail View */
.back-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    margin-bottom: 1rem;
    font-size: 1rem;
    display: flex;
    align-items: center;
}

.back-btn:hover {
    color: var(--text-color);
}

.series-hero {
    margin-bottom: 2rem;
}

.series-hero h1 {
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.series-meta {
    color: var(--success-color);
    font-weight: 600;
    font-size: 1.1rem;
}

.season-tabs {
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 5px;
    border-bottom: 1px solid #333;
}

.season-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    padding: 0.5rem 1rem;
    cursor: pointer;
    position: relative;
}

.season-tab.active {
    color: var(--text-color);
    font-weight: 700;
}

.season-tab.active::after {
    content: '';
    position: absolute;
    bottom: -6px;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--accent-color);
}

.episodes-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.episode-item {
    display: flex;
    align-items: center;
    padding: 1.5rem;
    background: #181818;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #222;
    position: relative;
    overflow: hidden;
}

.episode-item:hover {
    background: #222;
}

.episode-number {
    font-size: 1.5rem;
    color: var(--text-secondary);
    width: 50px;
    text-align: center;
    margin-right: 1.5rem;
}

.episode-details {
    flex: 1;
}

.episode-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.3rem;
}

.episode-duration {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.episode-progress-bg {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
}

.episode-progress-fill {
    height: 100%;
    background: var(--accent-color);
    width: 0%;
    /* Dynamic */
}

/* Player View */
#playerView {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    z-index: 1000;
    padding: 0;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

#playerView.minimized {
    top: auto;
    left: auto;
    bottom: 20px;
    right: 20px;
    width: 400px;
    height: 225px;
    /* 16:9 aspect ratio */
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#playerView.minimized .player-top-bar {
    padding: 5px 10px;
    background: rgba(0, 0, 0, 0.9);
}

#playerView.minimized #playingTitle {
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: none;
    /* Hide title in mini mode if too small, or keep it */
}

#playerView.minimized .nav-btn,
#playerView.minimized #turboProgressContainer {
    display: none;
    /* Hide Turbo button and progress in mini mode */
}

.player-top-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 1rem;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.9), transparent);
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 10;
    pointer-events: none;
}

.player-top-bar>* {
    pointer-events: auto;
}

.next-ep-overlay {
    position: absolute;
    top: 50%;
    left: 20px;
    transform: translateY(-50%);
    z-index: 20;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.player-bottom-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 1rem;
    padding-bottom: 3rem;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 10;
    pointer-events: none;
}

.player-bottom-bar.hidden {
    display: none;
}

.player-bottom-bar>* {
    pointer-events: auto;
}

#playerView.minimized .player-bottom-bar {
    display: none;
}

#playerView.minimized .next-ep-overlay {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
}

.icon-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.5rem;
    cursor: pointer;
}

.player-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #000;
    position: relative;
}

.player-header {
    width: 100%;
    /* Ensure full width */
    box-sizing: border-box;
    /* padding included */
}

video {
    max-width: 100%;
    max-height: 100vh;
    outline: none;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background: var(--modal-bg);
    width: 90%;
    max-width: 500px;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.8);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.close-btn {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 1.2rem;
}

.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

input,
textarea {
    width: 100%;
    padding: 10px;
    background: #333;
    border: none;
    border-radius: 4px;
    color: #fff;
    font-family: inherit;
}

textarea {
    resize: vertical;
}

.submit-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent-color);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
}

.submit-btn:hover {
    background: var(--accent-hover);
}

/* Utilities */
.hidden {
    display: none !important;
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    color: #000;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    z-index: 3000;
}

.toast.show {
    opacity: 1;
}

/* Turbo Progress */
.turbo-progress-container {
    background: rgba(0, 0, 0, 0.8);
    padding: 10px 20px;
    width: 100%;
}

.turbo-label {
    font-size: 0.8rem;
    color: var(--accent-color);
    margin-bottom: 5px;
    display: flex;
    justify-content: space-between;
}

.turbo-bar-bg {
    width: 100%;
    height: 4px;
    background: #333;
    border-radius: 2px;
    overflow: hidden;
}

.turbo-bar-fill {
    height: 100%;
    background: var(--accent-color);
    width: 0%;
    transition: width 0.2s;
}

/* Episode Selector Popup in Player */
.episode-selector {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(20, 20, 20, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    z-index: 50;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
}

.selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.selector-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.player-episodes-list {
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.player-episode-item {
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.player-episode-item:hover {
    background: rgba(255, 255, 255, 0.15);
}

.player-episode-item.active {
    background: rgba(229, 9, 20, 0.2);
    border-left: 3px solid var(--accent-color);
}

.player-episode-title {
    font-size: 1rem;
}

.player-episode-duration {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.nav-btn.danger {
    background: rgba(229, 9, 20, 0.15);
    color: #e50914;
    border: 1px solid rgba(229, 9, 20, 0.4);
}

.nav-btn.danger:hover {
    background: #e50914;
    color: #fff;
}