/* Bloco de identidade: define a aparência escura, televisiva e de alto contraste. */
:root {
    color-scheme: dark;
    --background: #07090d;
    --panel: #0f131a;
    --panel-soft: #171d26;
    --line: rgba(255, 255, 255, 0.1);
    --text: #f4f7fb;
    --muted: #9099a8;
    --accent: #6de3b5;
    --accent-dark: #123d31;
    --danger: #ff5c68;
    --sidebar-width: 350px;
}

/* Bloco de normalização: mantém tamanhos previsíveis em todos os elementos. */
* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-height: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--background);
}

body,
button,
input {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
a,
input {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Bloco estrutural: ocupa exatamente a janela e entrega o maior espaço possível ao vídeo. */
.app-shell {
    width: 100vw;
    height: 100dvh;
    display: grid;
    grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
    color: var(--text);
    background: var(--background);
    transition: grid-template-columns 220ms ease;
}

.app-shell.is-collapsed {
    grid-template-columns: 0 minmax(0, 1fr);
}

/* Bloco lateral: organiza marca, listas e resultados em uma coluna rolável. */
.sidebar {
    min-width: 0;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background:
        radial-gradient(circle at 20% 0%, rgba(109, 227, 181, 0.08), transparent 18rem),
        var(--panel);
    border-right: 1px solid var(--line);
    transition: opacity 150ms ease, transform 220ms ease;
    z-index: 5;
}

.is-collapsed .sidebar {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-100%);
}

.sidebar-header {
    min-height: 76px;
    padding: 15px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: var(--text);
    text-decoration: none;
}

.brand-mark {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    color: #07110e;
    background: var(--accent);
    border-radius: 12px;
    font-weight: 900;
}

.brand > span:last-child {
    display: flex;
    flex-direction: column;
}

.brand strong {
    font-size: 0.98rem;
}

.brand small {
    color: var(--muted);
    font-size: 0.68rem;
}

.icon-button {
    width: 39px;
    height: 39px;
    display: grid;
    place-items: center;
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--line);
    border-radius: 11px;
    cursor: pointer;
}

.mobile-only {
    display: none;
}

/* Bloco das listas: usa botões compactos para os cinco recortes principais. */
.playlist-tabs {
    padding: 14px 12px 8px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
}

.playlist-button {
    min-width: 0;
    padding: 9px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    text-align: left;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 11px;
    cursor: pointer;
}

.playlist-button:first-child {
    grid-column: 1 / -1;
}

.playlist-button:hover,
.playlist-button.is-active {
    color: var(--text);
    background: var(--panel-soft);
    border-color: rgba(109, 227, 181, 0.35);
}

.playlist-icon {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    color: var(--accent);
    background: var(--accent-dark);
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: 900;
}

.playlist-button strong,
.playlist-button small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.playlist-button strong {
    font-size: 0.75rem;
}

.playlist-button small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.58rem;
}

/* Bloco da pesquisa: cria uma entrada clara antes dos resultados. */
.search-area {
    padding: 9px 12px 10px;
}

.search-area label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 0.63rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.search-box {
    height: 42px;
    padding: 0 11px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #090c11;
    border: 1px solid var(--line);
    border-radius: 11px;
}

.search-box:focus-within {
    border-color: var(--accent);
}

.search-box span {
    color: var(--muted);
    font-size: 1.1rem;
}

.search-box input {
    width: 100%;
    min-width: 0;
    color: var(--text);
    background: transparent;
    border: 0;
    outline: 0;
}

.channel-count {
    margin: 7px 2px 0;
    color: var(--muted);
    font-size: 0.67rem;
}

/* Bloco dos canais: permite rolagem independente do restante do aplicativo. */
.channel-list {
    min-height: 0;
    padding: 0 9px 12px;
    flex: 1;
    overflow-y: auto;
    scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.channel-card {
    width: 100%;
    min-height: 62px;
    margin-bottom: 5px;
    padding: 7px 9px;
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    color: var(--text);
    text-align: left;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
}

.channel-card:hover,
.channel-card.is-active {
    background: var(--panel-soft);
    border-color: var(--line);
}

.channel-card.is-active {
    border-color: rgba(109, 227, 181, 0.38);
}

.channel-logo {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    object-fit: contain;
    color: var(--accent);
    background: #fff;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 900;
}

.channel-logo-fallback {
    color: var(--accent);
    background: var(--accent-dark);
}

.channel-copy {
    min-width: 0;
}

.channel-copy strong,
.channel-copy small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.channel-copy strong {
    font-size: 0.78rem;
}

.channel-copy small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 0.62rem;
}

.security-dot {
    width: 7px;
    height: 7px;
    background: var(--accent);
    border-radius: 50%;
}

.security-dot.is-insecure {
    background: #f2b95f;
}

.list-message {
    padding: 32px 16px;
    color: var(--muted);
    text-align: center;
    line-height: 1.55;
}

.load-more {
    margin: 0 12px 10px;
    padding: 10px;
    color: var(--accent);
    background: var(--accent-dark);
    border: 1px solid rgba(109, 227, 181, 0.28);
    border-radius: 10px;
    font-weight: 800;
    cursor: pointer;
}

.sidebar-footer {
    padding: 10px 14px 14px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    color: var(--muted);
    border-top: 1px solid var(--line);
    font-size: 0.62rem;
    line-height: 1.45;
}

.sidebar-footer a {
    color: var(--accent);
}

/* Bloco do reprodutor: mantém cabeçalho, vídeo e rodapé em toda a área central. */
.viewer {
    min-width: 0;
    height: 100dvh;
    display: grid;
    grid-template-rows: 68px minmax(0, 1fr) 36px;
    background: #030405;
}

.viewer-header {
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 13px;
    background: rgba(10, 13, 18, 0.94);
    border-bottom: 1px solid var(--line);
}

.now-playing {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.now-playing > div {
    min-width: 0;
}

.now-playing strong,
.now-playing small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.now-playing strong {
    font-size: 0.86rem;
}

.now-playing small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 0.66rem;
}

.live-indicator {
    padding: 5px 7px;
    color: #fff;
    background: #d83240;
    border-radius: 6px;
    font-size: 0.57rem;
    font-weight: 900;
    letter-spacing: 0.05em;
}

.copy-stream {
    margin-left: auto;
    padding: 8px 11px;
    color: var(--muted);
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 9px;
    font-weight: 750;
    cursor: pointer;
}

.copy-stream:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.video-stage {
    min-height: 0;
    position: relative;
    display: grid;
    place-items: center;
    overflow: hidden;
    background:
        radial-gradient(circle at center, rgba(37, 46, 58, 0.36), transparent 52%),
        #030405;
}

#video-player {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    background: #000;
}

.player-state {
    max-width: 720px;
    padding: 28px;
    position: absolute;
    text-align: center;
}

.player-state[hidden] {
    display: none;
}

.eyebrow {
    margin: 22px 0 10px;
    color: var(--accent);
    font-size: 0.72rem;
    font-weight: 900;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.player-state h1 {
    margin: 0 0 16px;
    font-size: clamp(2.1rem, 5.7vw, 5.5rem);
    line-height: 0.95;
    letter-spacing: -0.065em;
}

.player-state p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.signal-mark {
    height: 45px;
    display: inline-flex;
    align-items: flex-end;
    gap: 7px;
}

.signal-mark i {
    width: 8px;
    background: var(--accent);
    border-radius: 8px;
}

.signal-mark i:nth-child(1) {
    height: 18px;
}

.signal-mark i:nth-child(2) {
    height: 31px;
}

.signal-mark i:nth-child(3) {
    height: 44px;
}

.compact-state {
    padding: 22px 26px;
    display: flex;
    align-items: center;
    flex-direction: column;
    gap: 12px;
    background: rgba(8, 11, 15, 0.9);
    border: 1px solid var(--line);
    border-radius: 16px;
    backdrop-filter: blur(14px);
}

.loader {
    width: 28px;
    height: 28px;
    border: 3px solid rgba(255, 255, 255, 0.14);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 800ms linear infinite;
}

.error-state > span {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--danger);
    border-radius: 50%;
    font-weight: 900;
}

.error-state p {
    max-width: 430px;
    font-size: 0.8rem;
}

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

.viewer-footer {
    padding: 0 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    color: var(--muted);
    background: #090c10;
    border-top: 1px solid var(--line);
    font-size: 0.62rem;
}

/* Bloco do retorno: exibe confirmações sem interromper o vídeo. */
.toast {
    max-width: min(390px, calc(100vw - 28px));
    padding: 11px 14px;
    position: fixed;
    right: 16px;
    bottom: 50px;
    z-index: 20;
    color: var(--text);
    background: #17221e;
    border: 1px solid rgba(109, 227, 181, 0.35);
    border-radius: 11px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.4);
    font-size: 0.76rem;
}

.toast[hidden] {
    display: none;
}

.sidebar-backdrop {
    display: none;
}

/* Bloco responsivo: transforma a lateral em uma aba sobreposta e mantém o vídeo em 100%. */
@media (max-width: 760px) {
    .app-shell,
    .app-shell.is-collapsed {
        display: block;
    }

    .sidebar {
        width: min(88vw, 350px);
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        box-shadow: 18px 0 60px rgba(0, 0, 0, 0.55);
    }

    .app-shell.is-collapsed .sidebar {
        opacity: 1;
        pointer-events: auto;
        transform: translateX(-100%);
    }

    .app-shell:not(.is-collapsed) .sidebar {
        transform: translateX(0);
    }

    .mobile-only {
        display: grid;
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 4;
        background: rgba(0, 0, 0, 0.6);
        border: 0;
    }

    .sidebar-backdrop:not([hidden]) {
        display: block;
    }

    .viewer {
        width: 100%;
    }

    .viewer-header {
        padding: 0 10px;
    }

    .copy-stream {
        padding: 8px;
        font-size: 0.68rem;
    }

    .viewer-footer span:last-child {
        display: none;
    }

    .player-state {
        padding: 20px;
    }
}

/* Bloco de movimento reduzido: respeita a preferência de acessibilidade do sistema. */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
