/**
 * StarBr Play — Estilos Globais & Design System Futurista Cinematográfico (Clean Glass)
 * Inspirado nas melhores interfaces de Smart TV e IPTV (PlaySim, Blessed Player, TiviMate).
 * Arquitetura Ultra-Leve & Rápida para Smart TVs (LG webOS, Samsung Tizen, Android TV e Web).
 * Projetado para 1080p (Full HD) nativo, com responsividade total para 720p (HD 32"), 4K (UHD) e múltiplos aspect ratios.
 */

@font-face {
    font-family: 'AppFont';
    src: url('../assets/fonts/AppFont-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'AppFont';
    src: url('../assets/fonts/AppFont-Medium.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'AppFont';
    src: url('../assets/fonts/AppFont-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'AppFont';
    src: url('../assets/fonts/AppFont-Bold.ttf') format('truetype');
    font-weight: 900;
    font-style: normal;
    font-display: swap;
}

:root {
    /* =========================================================================
       1. PALETA CINEMATOGRÁFICA & FUTURISTA CLEAN (SEM CORES FORTES/BERRANTES)
       ========================================================================= */
    /* Fundo Preto Espacial Profundo (100% Paridade com ThemeData scaffoldBackgroundColor: Color(0xFF081120)) */
    --bg-dark: #081120;
    --bg-scaffold: #081120;
    --bg-amoled: #040810;
    --bg-surface: #0B1628;

    /* Superfícies Aero-Glass Translúcidas */
    --bg-card: rgba(19, 27, 38, 0.70);
    --bg-card-hover: rgba(255, 255, 255, 0.12);
    --bg-card-active: rgba(255, 255, 255, 0.18);
    --bg-glass-card: rgba(11, 22, 40, 0.88);
    --bg-glass-overlay: rgba(8, 17, 32, 0.92);
    --sidebar-bg: rgba(6, 12, 24, 0.96);

    /* Bordas Finas e Tecnológicas */
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-card: rgba(255, 255, 255, 0.12);
    --border-glass: rgba(255, 255, 255, 0.18);

    /* Acentos e Assinatura Flutter Nativo (primary: Color(0xFFFF1E1E), secondary: Color(0xFF00E676)) */
    --primary-red: #FF1E1E;
    --primary-red-hover: #FF4D4D;
    --primary-red-glow: rgba(255, 30, 30, 0.45);
    --secondary-green: #00E676;
    --accent-gold: #FFC107;
    --accent-cyan: #38BDF8;
    --accent-cyan-glow: rgba(56, 189, 248, 0.35);
    --accent-ice: #E0F2FE;
    --accent-green: #00E676;

    /* =========================================================================
       2. TIPOGRAFIA EM ALTO CONTRASTE (Legibilidade Perfeita em TVs 32" a 3m)
       Inspirado nos aplicativos oficiais Netflix e Globoplay.
       ========================================================================= */
    --text-white: #FFFFFF;
    --text-primary: #FFFFFF;
    --text-secondary: #F8FAFC;
    --text-muted: #E2E8F0;
    --text-subtle: #CBD5E1;

    /* Efeitos de Projeção de Fontes e Ícones (Sem desfoque - Nitidez Cristalina) */
    --tv-text-shadow: none;
    --tv-title-shadow: none;
    --tv-glow-shadow: none;
    --tv-icon-shadow: none;

    /* Sistema de Foco no Controle Remoto TV (Estilo Netflix / Globoplay: Borda Marcante) */
    --focus-border: var(--tv-primary-color, var(--primary-red, #FF1E1E));
    --focus-outline-width: 3.5px;
    --focus-glow: var(--tv-focus-glow, rgba(255, 30, 30, 0.70));
    --focus-shadow: 0 0 0 3.5px var(--focus-border, var(--primary-red, #FF1E1E)), 0 0 24px var(--focus-glow, rgba(255, 30, 30, 0.85)), 0 6px 28px rgba(0, 0, 0, 0.95);

    /* Raios de Borda Modernos */
    --radius-xs: 6px;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Safe Area TV Padding Proporcional */
    --tv-safe-padding-x: clamp(24px, 3.2vw, 48px);
    --tv-safe-padding-y: clamp(16px, 2.4vh, 28px);

    /* Tipografia Oficial Smart TV com Nitidez Cristalina (AppFont Prioritária) */
    --font-family: 'AppFont', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-title: 'AppFont', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-display: 'AppFont', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

    /* Escalas de Tamanho Base Proporcional via Viewport Width (vw) e rem */
    --base-font-size: clamp(16px, 1.15vw, 40px);
    --sidebar-width-collapsed: clamp(70px, 4.5vw, 88px);
    --sidebar-width-expanded: clamp(230px, 14vw, 280px);
    --poster-width: clamp(170px, 11vw, 215px);
    --poster-height: clamp(255px, 16.5vw, 322px);

    /* Variáveis Dinâmicas de Branding & Layout (Subdepartamento 2: TV Box, Smart TV & Desktop) */
    --tv-primary-color: #FF1E1E;
    --tv-secondary-color: #081120;
    --tv-accent-color: #00E676;
    --tv-text-color: #FFFFFF;
    --tv-focus-scale: 1.12;
    --tv-focus-border: var(--tv-primary-color, var(--primary-red, #FF1E1E));
    --tv-focus-glow: rgba(255, 30, 30, 0.70);
    --tv-hero-style: 'cinematic';
}

/* Base Root Responsivo: Todo o app escala dinamicamente com vw através de rem */
html,
body {
    font-size: clamp(16px, 1.15vw, 38px);
    font-family: var(--font-family) !important;
    text-shadow: none !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
    text-rendering: optimizeLegibility !important;
}

/* =========================================================================
   3. RESPONSIVIDADE ADAPTATIVA COMPLETA PARA SMART TVS E PROPORÇÕES DE TELA
   Suporte a: 720p (HD 32"), 1080p (Full HD), 4K UHD, 4:3 (Telas antigas),
   16:10, 16:9 padrão e 21:9 Ultrawide, com Overscan Safe-Area nativo.
   ========================================================================= */

/* Overscan TV Safe Area Universal (env.safe-area-inset para TVs modernas + clamp dinâmico) */
:root {
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
    --tv-safe-padding-x: clamp(1.2rem, calc(2.8vw + var(--safe-left)), 3.2rem);
    --tv-safe-padding-y: clamp(0.8rem, calc(2.2vh + var(--safe-top)), 2rem);
}

/* TV HD Pequena / 720p / 768p (TVs de 24" a 32", como a LG 32LB650B) - Escala Ampliada para Leitura Clara */
@media (max-width: 1366px) or (max-height: 768px) {
    :root {
        --base-font-size: clamp(16px, 1.35vw, 22px);
        --tv-safe-padding-x: clamp(1.1rem, 2.6vw, 2.2rem);
        --tv-safe-padding-y: clamp(0.7rem, 2.0vh, 1.5rem);
        --sidebar-width-collapsed: clamp(68px, 5.2vw, 82px);
        --sidebar-width-expanded: clamp(220px, 16vw, 260px);
        --poster-width: clamp(165px, 13vw, 205px);
        --poster-height: clamp(248px, 19.5vw, 308px);
    }

    html {
        font-size: clamp(16px, 1.35vw, 22px);
    }
}

/* TV Full HD 1080p (Padrão ouro de Smart TVs 40" a 55" — Proporções Globoplay) */
@media (min-width: 1367px) and (max-width: 1920px) and (min-height: 769px) {
    :root {
        --base-font-size: clamp(18px, 1.15vw, 24px);
        --tv-safe-padding-x: clamp(1.8rem, 2.2vw, 2.6rem);
        --tv-safe-padding-y: clamp(1.1rem, 1.6vh, 1.7rem);
        --sidebar-width-collapsed: 82px;
        --sidebar-width-expanded: 270px;
        --poster-width: 205px;
        --poster-height: 308px;
    }

    html {
        font-size: clamp(18px, 1.15vw, 24px);
    }
}

/* TV 4K UHD / 8K (3840x2160 e superiores em 55"+)
   Em WebViews Smart TV que operam com viewport nativo de 1080p ou escala por hardware (Tizen/webOS),
   mantemos os tamanhos consistentes para evitar fonte gigante e layout estourado. */
@media (min-width: 2400px) or (min-height: 1400px) {
    :root {
        --base-font-size: 16px;
        --tv-safe-padding-x: 48px;
        --tv-safe-padding-y: 32px;
        --sidebar-width-collapsed: 82px;
        --sidebar-width-expanded: 270px;
        --poster-width: 198px;
        --poster-height: 289px;
    }

    html {
        font-size: 16px;
    }
}

/* Proporção 4:3 ou Telas Quase Quadradas (TVs CRT antigas / Monitores legados) */
@media (max-aspect-ratio: 4/3) {
    :root {
        --tv-safe-padding-x: 16px;
        --tv-safe-padding-y: 12px;
        --sidebar-width-collapsed: 48px;
        --sidebar-width-expanded: 160px;
    }

    .login-center-wrapper {
        max-width: 94vw !important;
        padding: 8px 12px !important;
    }
}

/* Proporção 16:10 (Resoluções como 1280x800, 1440x900, 1680x1050, 1920x1200) */
@media (min-aspect-ratio: 16/10) and (max-aspect-ratio: 16/9) {
    :root {
        --tv-safe-padding-y: clamp(14px, 2.8vh, 26px);
    }
}

/* Telas Ultrawide 21:9 / 32:9 (Cinema e Monitores Ultrawide) */
@media (min-aspect-ratio: 21/10) {
    :root {
        --tv-safe-padding-x: clamp(60px, 8vw, 160px);
    }

    .home-main-area,
    .details-screen-container,
    .tv-live-channels-view {
        max-width: 2560px;
        margin: 0 auto;
    }
}

/* Telas de Celular/Tablet ou Proporção Vertical (Fallback Multiplataforma) */
@media (max-width: 768px) {
    :root {
        --base-font-size: clamp(14px, 1vw, 24px);
        --tv-safe-padding-x: 12px;
        --tv-safe-padding-y: 10px;
        --sidebar-width-collapsed: 0px;
        --sidebar-width-expanded: 100vw;
    }
}

/* Reset Global de Alta Performance */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    user-select: none;
    -webkit-user-select: none;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

input,
textarea {
    user-select: text !important;
    -webkit-user-select: text !important;
    cursor: text !important;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-dark);
    color: var(--text-white);
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 500;
    line-height: 1.4;
    letter-spacing: 0.01em;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* =========================================================================
   LAYOUT RESPONSIVO UNIVERSAL & CENTRALIZADO (SMART TVS & MONITORES)
   Compatível com 720p, 1080p, 1440p, 4K UHD, 8K e proporções 16:9, 16:10, 21:9, 4:3.
   Sem hacks de scale artificial, garantindo alinhamento nativo e coordenadas 1:1.
   ========================================================================= */
html,
body {
    width: 100%;
    height: 100%;
    min-width: 100%;
    min-height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
    display: block;
    position: relative;
    box-sizing: border-box;
}

.screen,
.modal-overlay,
.tv-modal-overlay,
#splash-screen,
#splash-offline-modal,
#login-screen,
#home-screen,
#profiles-screen,
#settings-screen,
#search-screen,
#content-loading-screen,
#details-modal,
.details-modal-fullscreen,
.details-screen-container,
#player-screen-container,
.details-skeleton-container,
.profile-edit-overlay-screen,
#exit-confirm-modal,
.exit-modal-fullscreen-card,
#mac-activation-modal,
#mac-expired-screen,
.cinematic-login-bg,
.live-video-player-container.is-fullscreen-live {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
}

/* Projeção de Títulos e Destaques — Nitidez 100% sem Desfoque */
h1,
h2,
h3,
h4,
h5,
h6,
.section-title,
.screen-title,
.hero-title,
.netflix-title {
    font-family: var(--font-title);
    font-weight: 800 !important;
    color: #FFFFFF !important;
    text-shadow: none !important;
    letter-spacing: -0.015em;
}

/* Ícones SVG com Contraste Otimizado para TV */
svg {
    shape-rendering: geometricPrecision;
}

/* Textos com Nitidez Cristalina (Fim do Efeito Desfoque) */
p,
span,
label,
div {
    text-shadow: none !important;
}

/* Remoção total de barras de rolagem nativas (Zero Distração) */
* {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
}

*::-webkit-scrollbar,
::-webkit-scrollbar {
    display: none !important;
    width: 0px !important;
    height: 0px !important;
    background: transparent !important;
}

.hidden {
    display: none !important;
}

/* Estrutura Base das Telas (Acelerada por GPU) */
.app-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-dark);
    display: flex;
    flex-direction: column;
    contain: strict;
    transform: translateZ(0);
}

/* Modais Universais em Aero-Glass Futurista Clean */
.modal-overlay,
.tv-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(4, 6, 12, 0.96);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    contain: layout style;
}

.modal-content {
    background: rgba(14, 18, 28, 0.94);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: clamp(20px, 2.5vw, 36px);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.9);
    max-width: 90%;
    max-height: 90%;
    overflow-y: auto;
    position: relative;
}

/* Botões Globais Clean & Futuristas */
.btn-primary {
    background: #FFFFFF;
    color: #06080F;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-sm);
    font-weight: 800;
    font-size: clamp(0.85rem, 1.1vw, 1.25rem);
    letter-spacing: 0.5px;
    padding: 10px 20px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform 0.15s ease, background-color 0.15s ease;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #FFFFFF;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: clamp(0.85rem, 1.1vw, 1.25rem);
    letter-spacing: 0.5px;
    padding: 10px 18px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

/* =========================================================================
   Otimizações de Fluidez para Smart TVs e Navegadores Antigos
   (Samsung Tizen 3/4/5, LG webOS 3/4/5, Android TV WebViews legadas)
   ========================================================================= */
* {
    -webkit-tap-highlight-color: transparent;
}

.horizontal-cards-scroller,
.vod-grid-col,
.vod-categories-scroll,
.home-main-area,
.home-subview,
.home-sidebar,
.details-content-column,
.details-screen-container {
    -webkit-overflow-scrolling: touch;
    transform: translate3d(0, 0, 0);
    -webkit-transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

body.live-fullscreen-active .home-main-area,
body.live-fullscreen-active #home-sidebar,
body.player-fullscreen-active .home-main-area,
body.player-fullscreen-active #home-sidebar {
    transform: none !important;
    -webkit-transform: none !important;
}

img {
    image-rendering: auto;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}

/* =========================================================================
   PERFORMANCE & INSTANT NAVIGATION OPTIMIZATION — webOS Chromium 53
   Transições instantâneas entre telas sem travamentos ou delay
   ========================================================================= */
.app-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    will-change: opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.app-screen.hidden {
    display: none !important;
    pointer-events: none !important;
}

.modal-overlay {
    will-change: opacity;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.modal-overlay.hidden {
    display: none !important;
    pointer-events: none !important;
}

/* Scroll e foco de alta performance e posicionamento relativo para offsetTop imediato */
.horizontal-cards-scroller,
.live-channel-list-container,
#live-channels-list,
#live-categories-list,
.vod-categories-scroll,
.vod-cats-wrapper,
#vod-posters-grid,
.vod-grid-col,
#live-epg-programs-list,
.sidebar-items-nav,
.home-subview {
    position: relative;
    scroll-behavior: auto !important;
    will-change: scroll-position;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.tv-focusable {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

body.live-fullscreen-active .home-main-area,
body.live-fullscreen-active #home-sidebar,
body.player-fullscreen-active .home-main-area,
body.player-fullscreen-active #home-sidebar {
    transform: none !important;
    -webkit-transform: none !important;
}

.tv-focusable:focus {
    outline: none;
}