:root {
    --bg-primary: #0C0C0E;
    --bg-surface: #17171B;
    --bg-surface-light: #1F1F24;
    --bg-header: #1C1013;
    --accent: #D62839;
    --accent-soft: rgba(214, 40, 57, 0.12);
    --accent-dark: #A81F2D;
    --text-primary: #F2F2F4;
    --text-secondary: #98989F;
    --divider: #26262B;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
}

a { color: inherit; }

/* ---- Tela de login ---- */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-box {
    width: 100%;
    max-width: 420px;
}

.login-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-content: center;
    margin-bottom: 28px;
}

.login-logo .logo-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, var(--accent), var(--accent-dark));
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 16px;
}

.login-logo h1 {
    font-size: 22px;
    font-weight: 700;
}

.login-intro {
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 24px;
}

.card-form {
    background: var(--bg-surface);
    border-radius: 16px;
    padding: 28px;
}

.form-row {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 140px;
}

.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    background: var(--bg-primary);
    border: 1px solid var(--divider);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 15px;
}

.form-group input:focus {
    border-color: var(--accent);
    outline: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    padding: 13px 28px;
    border: none;
    border-radius: 30px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:hover {
    background: var(--accent-dark);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: default;
}

.alerta {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    background: rgba(214, 40, 57, 0.12);
    color: #ff8890;
    border: 1px solid rgba(214, 40, 57, 0.3);
}

/* ======================================================================
   APP DO PLAYER (assistir)
   ====================================================================== */

.watch-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.watch-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: var(--bg-header);
    border-bottom: 1px solid var(--divider);
    flex-wrap: wrap;
}

.watch-tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.watch-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    padding: 8px 14px;
    border-radius: 18px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.watch-tab:hover {
    background: var(--bg-surface-light);
    color: var(--text-primary);
}

.watch-tab.active {
    background: var(--accent-soft);
    color: var(--accent);
}

.watch-topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.watch-search-input {
    background: var(--bg-primary);
    border: 1px solid var(--divider);
    border-radius: 16px;
    padding: 7px 14px;
    color: var(--text-primary);
    font-size: 13px;
    width: 180px;
}

.watch-logout-button {
    background: var(--bg-surface-light);
    border: none;
    color: var(--text-secondary);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 15px;
}

.watch-logout-button:hover {
    color: var(--accent);
}

.watch-body {
    display: flex;
    flex: 1;
    min-height: 0;
}

.watch-sidebar {
    width: 250px;
    flex-shrink: 0;
    overflow-y: auto;
    background: var(--bg-primary);
    border-right: 1px solid var(--divider);
    padding: 14px 10px;
}

.watch-sidebar-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: var(--text-secondary);
    padding: 0 10px 10px;
}

.watch-sidebar-item {
    display: block;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    border-left: 3px solid transparent;
    color: var(--text-secondary);
    padding: 10px 12px;
    border-radius: 0 8px 8px 0;
    font-size: 13px;
    line-height: 1.3;
    cursor: pointer;
    margin-bottom: 3px;
    transition: background 0.15s ease, color 0.15s ease;
}

.watch-sidebar-item:hover {
    background: var(--bg-surface-light);
    color: var(--text-primary);
}

.watch-sidebar-item:focus,
.watch-submenu-item:focus,
.watch-tab:focus {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    background: var(--bg-surface-light);
    color: var(--text-primary);
}

.watch-sidebar-item.active {
    background: var(--accent-soft);
    color: var(--accent);
    border-left-color: var(--accent);
    font-weight: 700;
}

.watch-submenu {
    margin: 4px 0 12px 14px;
    padding-left: 10px;
    border-left: 2px solid var(--divider);
}

.watch-submenu-title {
    padding: 6px 10px 6px;
    font-size: 10px;
}

.watch-submenu-item {
    font-size: 12.5px;
    padding: 8px 10px;
}

.watch-grid {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
    gap: 18px;
    align-content: start;
    background: var(--bg-primary);
}

.watch-empty-text {
    grid-column: 1 / -1;
    text-align: center;
    color: var(--text-secondary);
    padding: 60px 0;
}

.watch-load-more {
    grid-column: 1 / -1;
    justify-self: center;
    margin: 10px 0 20px;
    background: var(--bg-surface-light);
    border: 1px solid var(--divider);
    color: var(--text-primary);
    padding: 11px 28px;
    border-radius: 22px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.watch-load-more:hover {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}

.watch-pagination {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin: 10px 0 20px;
}

.watch-pagination .watch-load-more {
    margin: 0;
}

.watch-pagination-indicador {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    min-width: 50px;
    text-align: center;
}

.watch-card {
    background: var(--bg-surface);
    border: 1px solid var(--divider);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.watch-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 10px 24px rgba(0,0,0,0.35);
}

.watch-card:focus {
    outline: none;
    transform: translateY(-4px);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft), 0 10px 24px rgba(0,0,0,0.35);
}

.watch-card-poster {
    width: 100%;
    height: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    background: var(--bg-surface-light);
    display: block;
}

.watch-card-media {
    position: relative;
    aspect-ratio: 2 / 3;
    background: var(--bg-surface-light);
}

.watch-card-media .watch-card-poster {
    position: absolute;
    inset: 0;
}

/* Quando a imagem falha (ex: certificado SSL quebrado no provedor), mostra
   um ícone temático em vez de deixar o espaço vazio/quebrado — o nome do
   item continua sempre visível abaixo, então o card nunca fica "morto". */
.watch-card-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(160deg, var(--bg-surface-light), var(--bg-surface));
}

.watch-card-fallback-icon {
    font-size: 34px;
    opacity: 0.5;
}

/* Canais ao vivo: card com fundo próprio pra logo (evita "logo flutuando
   no preto") e o nome do canal em destaque abaixo, centralizado — como
   muitos logos de provedor são genéricos/parecidos entre si, o nome do
   canal (texto) é o principal jeito de diferenciar um canal do outro. */
.watch-card-live {
    background: linear-gradient(165deg, var(--bg-surface-light), var(--bg-surface));
    display: flex;
    flex-direction: column;
}

.watch-card-live .watch-card-media {
    aspect-ratio: 16 / 10;
    background: transparent;
}

.watch-card-live .watch-card-poster {
    object-fit: contain;
    background: transparent;
    padding: 16px 16px 4px;
}

.watch-card-live .watch-card-fallback-icon {
    font-size: 30px;
}

.watch-card-live .watch-card-name {
    text-align: center;
    font-weight: 700;
    padding: 2px 10px 12px;
    border-top: 1px solid var(--divider);
    margin-top: 4px;
    padding-top: 8px;
    white-space: normal;
    -webkit-line-clamp: 2;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.watch-card-name {
    padding: 9px 11px;
    font-size: 12.5px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.watch-card-fav {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.65);
    backdrop-filter: blur(2px);
    color: #fff;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.watch-card-fav:hover {
    background: var(--accent);
}

.watch-player-overlay {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 500;
    display: flex;
    flex-direction: column;
}

.watch-player-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: rgba(0,0,0,0.7);
    color: #fff;
}

.watch-player-back, .watch-player-favorite {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 15px;
    cursor: pointer;
}

.watch-player-title {
    font-weight: 600;
    font-size: 14px;
}

.watch-video {
    flex: 1;
    width: 100%;
    background: #000;
    display: block;
}

.watch-video-wrap {
    position: relative;
    flex: 1;
    display: flex;
    background: #000;
    overflow: hidden;
}

/* ---- Área que detecta clique/toque pra mostrar/esconder os controles ---- */
.watch-video-tap-catcher {
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* ---- Indicador de carregamento (buffering) ---- */
.watch-buffering {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    pointer-events: none;
}

.watch-spinner {
    width: 46px;
    height: 46px;
    border: 4px solid rgba(255,255,255,0.25);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: watch-spin 0.8s linear infinite;
}

@keyframes watch-spin {
    to { transform: rotate(360deg); }
}

/* ---- Sugestão de próximo episódio ---- */
.watch-next-episode {
    position: absolute;
    right: 24px;
    bottom: 110px;
    z-index: 3;
    background: var(--bg-surface);
    border: 1px solid var(--divider);
    border-radius: 12px;
    padding: 14px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 280px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.watch-next-episode span {
    font-size: 13px;
    color: var(--text-secondary);
}

.watch-next-episode button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 9px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.watch-next-episode button:hover {
    background: var(--accent-dark);
}

/* ---- Barra de controles customizada ---- */
.watch-controls {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    background: linear-gradient(to top, rgba(0,0,0,0.85), transparent);
    padding: 30px 20px 14px;
    transition: opacity 0.2s ease;
}

.watch-video-wrap.watch-controls-hidden .watch-controls {
    opacity: 0;
    pointer-events: none;
}

.watch-player-overlay.watch-controls-hidden .watch-player-header {
    opacity: 0;
    pointer-events: none;
}

.watch-player-header {
    transition: opacity 0.2s ease;
}

.watch-video-wrap.watch-controls-hidden {
    cursor: none;
}

.watch-progress-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.watch-time {
    color: #fff;
    font-size: 12px;
    font-family: monospace;
    min-width: 42px;
    text-align: center;
}

.watch-seek-bar {
    flex: 1;
    -webkit-appearance: none;
    height: 5px;
    border-radius: 3px;
    background: rgba(255,255,255,0.25);
    cursor: pointer;
    accent-color: var(--accent);
}

.watch-controls-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.watch-ctrl-btn {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    line-height: 1;
}

.watch-ctrl-btn:hover {
    background: rgba(255,255,255,0.12);
}

.watch-ctrl-btn-main {
    font-size: 24px;
}

.watch-volume-bar {
    width: 80px;
    -webkit-appearance: none;
    height: 4px;
    border-radius: 3px;
    background: rgba(255,255,255,0.25);
    cursor: pointer;
    accent-color: var(--accent);
}

.watch-controls-spacer {
    flex: 1;
}

.watch-speed-select {
    background: rgba(255,255,255,0.08);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    font-size: 12px;
    padding: 5px 6px;
    cursor: pointer;
}

.watch-epg-btn {
    background: #F59E0B;
    color: #1A1A1E;
    font-size: 11px;
    font-weight: 800;
    padding: 6px 12px;
    border-radius: 6px;
}

.watch-epg-btn:hover {
    background: #d98a06;
}

.watch-live-badge {
    background: #22c55e;
    color: #06280f;
    font-size: 11px;
    font-weight: 800;
    padding: 6px 12px;
    border-radius: 6px;
    border: none;
    letter-spacing: 0.3px;
    cursor: default;
    transition: background 0.2s ease;
}

/* Quando o player está atrasado em relação ao "agora" de verdade (pausou e
   retomou, ou teve uma travada) — vira um botão clicável pra voltar ao vivo. */
.watch-live-badge.watch-live-atrasado {
    background: var(--accent);
    color: #fff;
    cursor: pointer;
    animation: watch-live-pulse 1.4s ease-in-out infinite;
}

@keyframes watch-live-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.watch-pip-btn {
    font-size: 17px;
}

/* ---- Modal de EPG (grade de programação) ---- */
.watch-epg-modal {
    position: absolute;
    inset: 0;
    z-index: 10;
    background: rgba(0,0,0,0.75);
    display: flex;
    align-items: center;
    justify-content: center;
}

.watch-epg-modal-box {
    background: var(--bg-surface);
    border-radius: 14px;
    width: 90%;
    max-width: 480px;
    max-height: 70%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.watch-epg-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    border-bottom: 1px solid var(--divider);
}

.watch-epg-modal-header strong {
    font-size: 14px;
}

.watch-epg-modal-header button {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
}

.watch-epg-modal-list {
    overflow-y: auto;
    padding: 8px;
}

.watch-epg-item {
    display: flex;
    gap: 12px;
    padding: 10px 10px;
    border-radius: 8px;
}

.watch-epg-item.watch-epg-item-now {
    background: var(--accent-soft);
}

.watch-epg-item-time {
    color: var(--text-secondary);
    font-size: 12px;
    font-family: monospace;
    white-space: nowrap;
}

.watch-epg-item-title {
    font-size: 13px;
    color: var(--text-primary);
}

@media (max-width: 768px) {
    .watch-controls {
        padding: 20px 10px 10px;
    }
    .watch-volume-bar {
        width: 50px;
    }
    .watch-speed-select {
        display: none;
    }
    .watch-next-episode {
        right: 10px;
        left: 10px;
        max-width: none;
        bottom: 100px;
    }
}

@media (max-width: 768px) {
    .watch-sidebar {
        width: 130px;
    }
    .watch-search-input {
        width: 110px;
    }
    .watch-tabs {
        gap: 3px;
    }
    .watch-tab {
        padding: 6px 9px;
        font-size: 12px;
    }
}
