/* ============================================
   STREAMSERIES — CSS Completo
   Tema: Dark Netflix/Prime inspired
   ============================================ */

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a2e;
    --bg-card: #16162a;
    --bg-hover: #222240;
    --accent: #e50914;
    --accent-hover: #ff1a25;
    --accent-glow: rgba(229, 9, 20, 0.4);
    --text-primary: #f5f5f5;
    --text-secondary: #a0a0b0;
    --text-muted: #6a6a7a;
    --border: #2a2a3e;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
    --shadow-hover: 0 16px 48px rgba(0, 0, 0, 0.8);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --navbar-h: 64px;
}

*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
    text-decoration: none;
}

img {
    max-width: 100%;
    display: block;
}

/* ============================================
   NAVBAR
   ============================================ */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-h);
    z-index: 1000;
    background: linear-gradient(180deg, rgba(10,10,15,0.95) 0%, rgba(10,10,15,0.8) 70%, transparent 100%);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: var(--transition);
}

.navbar.scrolled {
    background: rgba(10, 10, 15, 0.98);
    border-bottom: 1px solid var(--border);
}

.nav-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 800;
    font-size: 1.3rem;
    letter-spacing: -0.5px;
}

.logo-icon {
    background: var(--accent);
    color: white;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    font-size: 0.8rem;
}

.logo-text {
    background: linear-gradient(135deg, var(--accent), #ff6b6b);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-links {
    display: flex;
    gap: 1.5rem;
}

.nav-link {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
    position: relative;
}

.nav-link:hover,
.nav-link.active {
    color: var(--text-primary);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--accent);
    border-radius: 1px;
}

/* ============================================
   HERO (HOME)
   ============================================ */
.hero {
    position: relative;
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: linear-gradient(135deg, #0a0a1a 0%, #1a0a0a 50%, #0a0a1a 100%);
}

.hero-overlay {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(229,9,20,0.08) 0%, transparent 70%);
}

.hero-content {
    position: relative;
    text-align: center;
    padding: 2rem;
    z-index: 1;
}

.hero-title {
    font-size: clamp(2.5rem, 6vw, 4.5rem);
    font-weight: 900;
    letter-spacing: -2px;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, #fff 0%, #a0a0b0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.hero-subtitle {
    font-size: clamp(1rem, 2vw, 1.3rem);
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

.hero-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 2.5rem;
    background: var(--accent);
    color: white;
    border-radius: 50px;
    font-weight: 600;
    font-size: 1rem;
    transition: var(--transition);
}

.hero-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px var(--accent-glow);
}

/* ============================================
   CATÁLOGO
   ============================================ */
.catalog {
    max-width: 1400px;
    margin: 0 auto;
    padding: 3rem 2rem 4rem;
}

.section-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.section-line {
    width: 4px;
    height: 28px;
    background: var(--accent);
    border-radius: 2px;
}

.series-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.serie-card {
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition);
    position: relative;
    background: var(--bg-card);
}

.serie-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-hover);
}

.serie-card-cover {
    position: relative;
    aspect-ratio: 2/3;
    overflow: hidden;
}

.serie-card-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.serie-card:hover .serie-card-cover img {
    transform: scale(1.08);
}

.serie-card-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-tertiary), var(--bg-card));
    gap: 0.5rem;
}

.placeholder-icon {
    font-size: 2.5rem;
}

.placeholder-name {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding: 0 0.5rem;
    text-align: center;
}

.serie-card-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: var(--transition);
}

.serie-card:hover .serie-card-overlay {
    opacity: 1;
}

.play-badge {
    padding: 0.6rem 1.5rem;
    background: var(--accent);
    color: white;
    border-radius: 50px;
    font-weight: 600;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

.serie-card-info {
    padding: 0.8rem;
}

.serie-card-name {
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.3rem;
}

.serie-card-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-muted);
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.empty-state code {
    background: var(--bg-tertiary);
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.85rem;
}

/* ============================================
   SÉRIE PAGE — HERO
   ============================================ */
.serie-hero {
    position: relative;
    min-height: 60vh;
    display: flex;
    align-items: flex-end;
    padding: 0 2rem 3rem;
    background-size: cover;
    background-position: center top;
    background-repeat: no-repeat;
}

.serie-hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(0deg, var(--bg-primary) 0%, rgba(10,10,15,0.7) 50%, rgba(10,10,15,0.4) 100%);
}

.serie-hero-content {
    position: relative;
    z-index: 1;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    align-items: flex-end;
    gap: 2.5rem;
}

.serie-hero-poster {
    width: 220px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    flex-shrink: 0;
}

.serie-hero-info {
    flex: 1;
    padding-bottom: 1rem;
}

.serie-title {
    font-size: clamp(2rem, 4vw, 3.5rem);
    font-weight: 900;
    letter-spacing: -1px;
    margin-bottom: 0.5rem;
}

.serie-meta {
    color: var(--text-secondary);
    font-size: 1rem;
    margin-bottom: 1.5rem;
}

.btn-play-hero {
    display: inline-flex;
    align-items: center;
    gap: 0.7rem;
    padding: 1rem 2.5rem;
    background: var(--accent);
    color: white;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1.1rem;
    transition: var(--transition);
}

.btn-play-hero:hover {
    background: var(--accent-hover);
    transform: scale(1.05);
    box-shadow: 0 8px 30px var(--accent-glow);
}

.btn-play-icon {
    font-size: 1.2rem;
}

/* ============================================
   EPISÓDIOS
   ============================================ */
.episodes-section {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.season-block {
    margin-bottom: 3rem;
}

.season-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.episode-count {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 400;
}

.episodes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.episode-card {
    display: flex;
    gap: 1rem;
    padding: 0.8rem;
    background: var(--bg-card);
    border-radius: var(--radius);
    transition: var(--transition);
    border: 1px solid transparent;
}

.episode-card:hover {
    background: var(--bg-hover);
    border-color: var(--border);
    transform: translateY(-2px);
}

.episode-thumb {
    position: relative;
    width: 160px;
    min-width: 160px;
    aspect-ratio: 16/9;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-tertiary);
}

.episode-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.episode-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-tertiary), #1e1e3a);
}

.ep-number {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-muted);
    opacity: 0.4;
}

.episode-thumb-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.4);
    opacity: 0;
    transition: var(--transition);
}

.episode-card:hover .episode-thumb-overlay {
    opacity: 1;
}

.thumb-play {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.2);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.progress-bar-container {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: rgba(255,255,255,0.1);
}

.progress-bar {
    height: 100%;
    background: var(--accent);
    border-radius: 0 2px 2px 0;
    transition: width 0.3s;
}

.episode-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

.episode-name {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.episode-duration {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================
   PLAYER PAGE
   ============================================ */
.page-player {
    background: var(--bg-primary);
}

.navbar-player {
    background: rgba(10, 10, 15, 0.98);
    border-bottom: 1px solid var(--border);
}

.nav-back {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    transition: var(--transition);
}

.nav-back:hover {
    color: var(--accent);
}

.back-arrow {
    font-size: 1.2rem;
}

.player-view-modes {
    display: flex;
    gap: 0.5rem;
}

.view-mode-btn {
    padding: 0.4rem 0.8rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font);
}

.view-mode-btn:hover,
.view-mode-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Player Layout */
.player-layout {
    padding-top: var(--navbar-h);
    display: flex;
    min-height: calc(100vh - var(--navbar-h));
    transition: var(--transition);
}

/* Video Area */
.player-area {
    flex: 1;
    min-width: 0;
}

.video-wrapper {
    position: relative;
    width: 100%;
    background: #000;
    aspect-ratio: 16/9;
    overflow: hidden;
}

.video-wrapper video {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

/* Custom Controls */
.custom-controls {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(0deg, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.6) 60%, transparent 100%);
    padding: 0.5rem 1rem 0.8rem;
    opacity: 0;
    transition: opacity 0.3s;
}

.video-wrapper:hover .custom-controls,
.video-wrapper.paused .custom-controls {
    opacity: 1;
}

.controls-progress {
    position: relative;
    height: 5px;
    background: rgba(255,255,255,0.15);
    border-radius: 3px;
    margin-bottom: 0.8rem;
    cursor: pointer;
    transition: height 0.15s;
}

.controls-progress:hover {
    height: 8px;
}

.progress-buffered {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

.progress-played {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
}

.progress-handle {
    position: absolute;
    top: 50%;
    width: 14px;
    height: 14px;
    background: var(--accent);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    opacity: 0;
    transition: opacity 0.15s;
    box-shadow: 0 0 10px var(--accent-glow);
}

.controls-progress:hover .progress-handle {
    opacity: 1;
}

.controls-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.controls-left,
.controls-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ctrl-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 4px;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.ctrl-btn:hover {
    background: rgba(255,255,255,0.1);
}

.volume-area {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.volume-slider {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
    outline: none;
    cursor: pointer;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    background: white;
    border-radius: 50%;
    cursor: pointer;
}

.time-display {
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 500;
    margin-left: 0.5rem;
    font-variant-numeric: tabular-nums;
}

.speed-label {
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 700;
}

/* Episode Detail */
.episode-detail {
    padding: 1.5rem 2rem;
    max-width: 1200px;
}

.detail-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 0.3rem;
}

.detail-season {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.detail-nav {
    display: flex;
    gap: 1rem;
}

.detail-nav-btn {
    padding: 0.6rem 1.5rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: var(--transition);
}

.detail-nav-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent);
}

.detail-nav-btn.next {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.detail-nav-btn.next:hover {
    background: var(--accent-hover);
}

/* Episodes Sidebar */
.episodes-sidebar {
    width: 380px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--transition);
}

.sidebar-header {
    padding: 1.2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: 1.1rem;
    font-weight: 700;
}

.season-select {
    padding: 0.4rem 0.8rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: 6px;
    font-size: 0.85rem;
    font-family: var(--font);
    cursor: pointer;
    outline: none;
}

.sidebar-episodes {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.sidebar-episodes::-webkit-scrollbar {
    width: 4px;
}

.sidebar-episodes::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-episodes::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 2px;
}

.sidebar-ep-item {
    display: flex;
    gap: 0.8rem;
    padding: 0.6rem;
    border-radius: 6px;
    transition: var(--transition);
    margin-bottom: 0.3rem;
}

.sidebar-ep-item:hover {
    background: var(--bg-hover);
}

.sidebar-ep-item.active {
    background: var(--bg-hover);
    border-left: 3px solid var(--accent);
}

.sidebar-ep-thumb {
    position: relative;
    width: 120px;
    min-width: 120px;
    aspect-ratio: 16/9;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--bg-tertiary);
}

.sidebar-ep-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-ep-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-tertiary), #1e1e3a);
}

.sidebar-ep-placeholder span {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-muted);
    opacity: 0.3;
}

.sidebar-ep-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: rgba(255,255,255,0.1);
}

.sidebar-ep-progress-bar {
    height: 100%;
    background: var(--accent);
}

.sidebar-ep-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.sidebar-ep-title {
    font-size: 0.85rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.2rem;
}

.sidebar-ep-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* ============================================
   VIEW MODES
   ============================================ */

/* Flat Mode — sidebar embaixo do player */
.player-layout.flat-mode {
    flex-direction: column;
}

.player-layout.flat-mode .episodes-sidebar {
    width: 100%;
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 400px;
}

.player-layout.flat-mode .sidebar-episodes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.8rem;
}

.player-layout.flat-mode .sidebar-ep-item {
    width: 200px;
    flex-direction: column;
}

.player-layout.flat-mode .sidebar-ep-thumb {
    width: 100%;
}

.player-layout.flat-mode .sidebar-header {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
}

/* Fullscreen Mode — esconde sidebar */
.player-layout.fullscreen-mode .episodes-sidebar {
    width: 0;
    overflow: hidden;
    border: none;
    padding: 0;
}

.player-layout.fullscreen-mode .episode-detail {
    max-width: 1200px;
    margin: 0 auto;
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border);
    margin-top: 2rem;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .player-layout {
        flex-direction: column;
    }
    .episodes-sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
        max-height: 500px;
    }
}

@media (max-width: 768px) {
    .nav-content {
        padding: 0 1rem;
    }

    .hero {
        min-height: 50vh;
    }

    .series-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 1rem;
    }

    .serie-hero-content {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .serie-hero-poster {
        width: 160px;
    }

    .episodes-grid {
        grid-template-columns: 1fr;
    }

    .episode-thumb {
        width: 120px;
        min-width: 120px;
    }

    .player-view-modes {
        display: none;
    }

    .volume-slider {
        width: 50px;
    }

    .episode-detail {
        padding: 1rem;
    }

    .detail-nav {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .series-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.8rem;
    }

    .serie-card-info {
        padding: 0.5rem;
    }

    .serie-card-name {
        font-size: 0.8rem;
    }

    .controls-bar {
        flex-wrap: wrap;
        gap: 0.3rem;
    }

    .time-display {
        font-size: 0.7rem;
    }

    .episodes-sidebar {
        max-height: 300px;
    }
}

/* ============================================
   ANIMAÇÕES
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.serie-card {
    animation: fadeIn 0.5s ease backwards;
}

.serie-card:nth-child(1) { animation-delay: 0.05s; }
.serie-card:nth-child(2) { animation-delay: 0.1s; }
.serie-card:nth-child(3) { animation-delay: 0.15s; }
.serie-card:nth-child(4) { animation-delay: 0.2s; }
.serie-card:nth-child(5) { animation-delay: 0.25s; }
.serie-card:nth-child(6) { animation-delay: 0.3s; }
.serie-card:nth-child(7) { animation-delay: 0.35s; }
.serie-card:nth-child(8) { animation-delay: 0.4s; }

/* Scrollbar global */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================
   PLAYER PROGRESS BAR & CONTROLS UPGRADE
   ============================================ */

.video-wrapper {
    touch-action: pan-x; /* Permite scroll horizontal, bloqueia vertical para swipe */
    -webkit-tap-highlight-color: transparent;
}

.controls-progress {
    position: relative;
    height: 6px;
    padding: 14px 0; /* Área de toque ampliada */
    background: rgba(255,255,255,0.15);
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 0.6rem;
    transition: height 0.2s, background 0.2s;
}

.controls-progress:hover,
.controls-progress.dragging {
    height: 8px;
    padding: 12px 0;
    background: rgba(255,255,255,0.25);
}

.progress-buffered,
.progress-played {
    position: absolute;
    top: 0;
    height: 100%;
    border-radius: 4px;
    pointer-events: none;
}

.progress-buffered { background: rgba(255,255,255,0.2); }
.progress-played { background: var(--accent); }

.progress-handle {
    position: absolute;
    top: 50%;
    width: 18px;
    height: 18px;
    background: #fff;
    border: 2px solid var(--accent);
    border-radius: 50%;
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.15s;
    box-shadow: 0 0 0 transparent;
    pointer-events: none;
    z-index: 5;
}

.controls-progress:hover .progress-handle,
.controls-progress.dragging .progress-handle {
    transform: translate(-50%, -50%) scale(1);
    box-shadow: 0 0 12px var(--accent-glow);
}

/* Controles fade out */
.video-wrapper.controls-hidden .custom-controls {
    opacity: 0 !important;
    pointer-events: none;
    transform: translateY(10px);
}

.custom-controls {
    transition: opacity 0.3s, transform 0.3s;
}

/* Ajuste mobile para controles */
@media (max-width: 768px) {
    .controls-progress { padding: 10px 0; }
    .progress-handle { width: 20px; height: 20px; }
    .volume-area { display: none; } /* Oculta slider no mobile, mantém botão */
}

/* ============================================
   THUMBS GERADAS DINAMICAMENTE (Serie + Player)
   ============================================ */

.episode-thumb img,
.sidebar-ep-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

/* Quando a thumb é gerada via JS, ela replace o placeholder suavemente */
.sidebar-ep-thumb img[src^="data:"] {
    animation: thumbFadeIn 0.4s ease;
}

.episode-thumb img[src^="data:"] {
    animation: thumbFadeIn 0.4s ease;
}

@keyframes thumbFadeIn {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

/* Fallback: mantém ícone centralizado se não houver imagem */
.sidebar-ep-placeholder,
.episode-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-tertiary), #1e1e3a);
    position: absolute;
    top: 0;
    left: 0;
}

/* Animação de pulse para feedback visual */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}
.ctrl-btn {
    transition: transform 0.15s ease;
}

/* ============================================
   MOBILE + TEXT WRAP FIX (serie.php)
   ============================================ */

/* Card de episódio: texto quebra linha corretamente */
.episode-name {
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: normal;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Máx 2 linhas no desktop */
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Mobile: permite mais linhas e ajusta layout */
@media (max-width: 768px) {
    .episode-card {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .episode-thumb {
        width: 100%;
        min-width: 100%;
        aspect-ratio: 16/9;
    }
    
    .episode-info {
        width: 100%;
        padding-top: 0.5rem;
    }
    
    .episode-name {
        -webkit-line-clamp: 3; /* Até 3 linhas no mobile */
        font-size: 0.9rem;
    }
    
    /* Remove meta info no mobile se houver */
    .episode-duration {
        display: none;
    }
}

/* Small mobile: ajusta grid para 1 coluna */
@media (max-width: 480px) {
    .episodes-grid {
        grid-template-columns: 1fr !important;
    }
    
    .episode-name {
        -webkit-line-clamp: 4;
        font-size: 0.95rem;
    }
}

/* FORÇA INTERAÇÃO NO PLAYER */
.video-wrapper {
    cursor: pointer !important;
    -webkit-tap-highlight-color: transparent !important;
    touch-action: manipulation !important; /* Otimizado para toque */
}
.video-wrapper video {
    pointer-events: auto !important;
}
.custom-controls {
    pointer-events: auto !important;
}
.custom-controls .controls-bar,
.custom-controls .controls-progress {
    pointer-events: auto !important;
}

/* 🔍 ESTILOS DO FILTRO DE BUSCA */
.search-container, .sidebar-search {
    position: relative;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.6rem 1rem;
    transition: var(--transition);
}
.search-container:focus-within, .sidebar-search:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.search-icon { font-size: 1rem; margin-right: 0.6rem; opacity: 0.5; pointer-events: none; }
.search-container input, .sidebar-search input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-family: var(--font);
    font-size: 0.9rem;
}
.search-container input::placeholder, .sidebar-search input::placeholder {
    color: var(--text-muted);
}
.sidebar-search {
    margin: 0.5rem 0.8rem 1rem;
    width: calc(100% - 1.6rem);
}

/* Oculta itens filtrados */
.episode-card.hidden, .sidebar-ep-item.hidden {
    display: none !important;
}

/* Garante que a marca d'água do placeholder seja Prieme Plus */
/* (Controlado via thumb.php, mas mantido aqui por consistência) */

/* ============================================
   TV MODE — Android TV / Fire Stick / WebOS / Tizen
   ============================================ */

html, body {
    width: 100%;
    min-height: 100%;
}
html.tv-mode, html.tv-mode body {
    width: 100vw;
    min-height: 100vh;
    overflow-x: hidden;
}

html.tv-mode {
    font-size: 18px;             /* base maior p/ leitura à distância */
    -webkit-text-size-adjust: 100%;
}
html.tv-mode body {
    overflow-x: hidden;
}

/* Safe area p/ overscan típico de TV (~3-5%) */
html.tv-mode .nav-content,
html.tv-mode .catalog,
html.tv-mode .episodes-section,
html.tv-mode .serie-hero,
html.tv-mode .episode-detail {
    padding-left: max(3vw, 32px);
    padding-right: max(3vw, 32px);
}
html.tv-mode .navbar { height: 80px; }
html.tv-mode { --navbar-h: 80px; }

/* Grids maiores e mais espaçados */
html.tv-mode .series-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 2rem;
}
html.tv-mode .episodes-grid {
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 1.3rem;
}
html.tv-mode .episode-thumb { width: 200px; min-width: 200px; }
html.tv-mode .episodes-sidebar { width: 420px; }
html.tv-mode .sidebar-ep-thumb { width: 140px; min-width: 140px; }

/* Texto maior */
html.tv-mode .serie-card-name { font-size: 1rem; }
html.tv-mode .episode-name { font-size: 1rem; -webkit-line-clamp: 2; }
html.tv-mode .sidebar-ep-title { font-size: 0.95rem; }
html.tv-mode .section-title { font-size: 1.8rem; }
html.tv-mode .nav-link { font-size: 1rem; }

/* ===== FOCO VISÍVEL (D-pad) ===== */
html.tv-mode *:focus { outline: none; }

html.tv-mode .serie-card:focus,
html.tv-mode .episode-card:focus,
html.tv-mode .sidebar-ep-item:focus {
    outline: 4px solid var(--accent);
    outline-offset: 4px;
    transform: translateY(-6px) scale(1.04);
    box-shadow: 0 12px 40px var(--accent-glow), 0 0 0 8px rgba(229,9,20,.18);
    z-index: 5;
    position: relative;
    transition: transform .15s ease, box-shadow .15s ease;
}

html.tv-mode .nav-link:focus,
html.tv-mode .nav-back:focus,
html.tv-mode .btn-play-hero:focus,
html.tv-mode .hero-btn:focus,
html.tv-mode .view-mode-btn:focus,
html.tv-mode .detail-nav-btn:focus,
html.tv-mode .ctrl-btn:focus,
html.tv-mode .season-select:focus,
html.tv-mode button:focus,
html.tv-mode a:focus {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
    box-shadow: 0 0 0 6px rgba(229,9,20,.25);
    color: #fff;
    transition: outline .12s, box-shadow .12s;
}

html.tv-mode .btn-play-hero:focus,
html.tv-mode .hero-btn:focus {
    transform: scale(1.06);
    background: var(--accent-hover);
}

/* Garante que itens em foco sejam visíveis ao rolar */
html.tv-mode .serie-card,
html.tv-mode .episode-card,
html.tv-mode .sidebar-ep-item { scroll-margin: 120px; }

/* Esconde scrollbars na TV (mouse não existe) */
html.tv-mode ::-webkit-scrollbar { width: 0; height: 0; }

/* Remove hover/animações pesadas que confundem com foco */
html.tv-mode .serie-card:hover { transform: none; box-shadow: var(--shadow); }
html.tv-mode .episode-card:hover { transform: none; }

/* Player em TV: oculta sidebar pequena, dá ao vídeo o protagonismo */
html.tv-mode .player-view-modes { display: none; }
html.tv-mode .controls-progress { height: 8px; padding: 18px 0; }
html.tv-mode .progress-handle { width: 22px; height: 22px; }
html.tv-mode .ctrl-btn { font-size: 1.6rem; padding: 0.6rem; }
html.tv-mode .time-display { font-size: 1rem; }

/* Resolução baixa (720p stick): reduz um pouco */
@media (max-width: 1366px) {
    html.tv-mode { font-size: 16px; }
    html.tv-mode .series-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

/* 4K: ampliar */
@media (min-width: 2560px) {
    html.tv-mode { font-size: 22px; }
}