@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;700;800&family=IBM+Plex+Mono:wght@400;600&display=swap');

:root {
    --bg-main: #0e1114;
    --bg-soft: #171b20;
    --bg-panel: #1c2128;
    --line: #2c333d;
    --text-main: #eef3f8;
    --text-soft: #aeb8c3;
    --danger: #d82b3f;
    --danger-strong: #b51f32;
}

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

body {
    font-family: 'Manrope', 'Segoe UI', sans-serif;
    background:
        radial-gradient(1000px 450px at 85% -10%, rgba(216, 43, 63, 0.2), transparent 60%),
        radial-gradient(700px 300px at -10% 10%, rgba(63, 147, 216, 0.12), transparent 55%),
        var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* Layout */
.layout { display: flex; height: 100vh; overflow: hidden; }

.sidebar {
    width: 240px;
    min-width: 240px;
    background: color-mix(in srgb, var(--bg-soft) 92%, black 8%);
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 12px;
    overflow-y: auto;
}

.sidebar h2 { font-size: 1.2rem; padding-bottom: 8px; border-bottom: 1px solid #2a2a2a; }

.btn-import {
    display: block;
    background: #e50914;
    color: #fff;
    text-align: center;
    padding: 8px;
    border-radius: 6px;
    font-weight: 600;
    font-size: .9rem;
}
.btn-import:hover { background: #c0070f; }

.search-form input {
    width: 100%;
    padding: 7px 10px;
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: .9rem;
}

.search-form {
    display: flex;
    gap: 6px;
}

.search-btn {
    border: 1px solid var(--line);
    background: #252b33;
    color: var(--text-main);
    border-radius: 6px;
    padding: 7px 10px;
    font-size: .8rem;
    cursor: pointer;
}

.search-btn:hover { background: #2f3741; }

nav { display: flex; flex-direction: column; gap: 2px; }

.group-link {
    padding: 6px 10px;
    border-radius: 5px;
    font-size: .85rem;
    color: #aaa;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.group-link:hover { background: #2a2a2a; color: #fff; }
.group-link.active { background: #e50914; color: #fff; }

/* Content */
.content { flex: 1; overflow-y: auto; padding: 20px; }

.result-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    color: var(--text-soft);
    font-size: .85rem;
}

.channel-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 12px;
}

.channel-card {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: border-color .2s, transform .1s;
    text-align: center;
}
.channel-card:hover { border-color: #e50914; transform: scale(1.03); }

.channel-card img { width: 60px; height: 40px; object-fit: contain; }
.channel-card .no-logo { font-size: 2rem; }
.channel-card span { font-size: .78rem; color: #ccc; line-height: 1.3; }

.empty { text-align: center; padding: 60px; color: #666; }
.empty a { color: #e50914; }

/* Player */
.player-page { background: #000; }

.player-wrap {
    max-width: 960px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.player-header {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.player-header h1 { font-size: 1.2rem; flex: 1; }
.player-logo { height: 36px; object-fit: contain; }
.back { color: #e50914; font-size: .9rem; }
.group-badge {
    background: #2a2a2a;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: .75rem;
    color: #aaa;
}

#video { width: 100%; border-radius: 8px; background: #111; max-height: 70vh; }

.player-url { color: #444; font-size: .7rem; word-break: break-all; }

/* Import page */
.container {
    max-width: 520px;
    margin: 60px auto;
    padding: 0 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.container h1 { font-size: 1.4rem; }

.alert {
    padding: 10px 14px;
    border-radius: 6px;
    font-size: .9rem;
}
.alert.success { background: #1a3a1a; border: 1px solid #2d6a2d; color: #7ec87e; }
.alert.error { background: #3a1a1a; border: 1px solid #6a2d2d; color: #c87e7e; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: .85rem; color: #aaa; }
.form-group input {
    padding: 9px 12px;
    background: #1a1a1a;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: .95rem;
}

.divider { text-align: center; color: #555; font-size: .85rem; }

button[type=submit] {
    padding: 10px;
    background: #e50914;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}
button[type=submit]:hover { background: #c0070f; }

.btn-danger {
    padding: 8px;
    background: #2a2a2a;
    color: #c87e7e;
    border: 1px solid #6a2d2d;
    border-radius: 6px;
    font-size: .85rem;
    cursor: pointer;
}

.btn-link { color: #e50914; font-size: .9rem; }
.stats { font-size: .85rem; color: #666; }

/* ===== Auth / Sidebar user ===== */
.sidebar-top { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; border-bottom: 1px solid #2a2a2a; }
.sidebar-user { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: .8rem; color: #aaa; }
.badge-admin  { background: #e50914; color: #fff; padding: 2px 7px; border-radius: 4px; font-size: .75rem; }
.badge-logout { color: #888; text-decoration: underline; font-size: .75rem; }
.badge-logout:hover { color: #fff; }

/* ===== Admin layout ===== */
.admin-wrap { max-width: 860px; margin: 0 auto; padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.admin-header { display: flex; align-items: center; justify-content: space-between; padding-bottom: 12px; border-bottom: 1px solid #2a2a2a; }
.admin-header h1 { font-size: 1.3rem; }
.admin-header-right { display: flex; gap: 14px; font-size: .85rem; color: #aaa; }
.admin-header-right a { color: #e50914; }

.admin-tabs { display: flex; gap: 4px; }
.admin-tabs a { padding: 8px 16px; border-radius: 6px 6px 0 0; background: #1a1a1a; color: #aaa; font-size: .9rem; border: 1px solid #2a2a2a; border-bottom: none; }
.admin-tabs a.active { background: #2a2a2a; color: #fff; }

.admin-section { background: #1a1a1a; border: 1px solid #2a2a2a; border-radius: 0 8px 8px 8px; padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.admin-section h2 { font-size: 1rem; color: #ccc; }
.admin-section hr { border: none; border-top: 1px solid #2a2a2a; }
.admin-help { color: var(--text-soft); font-size: .9rem; margin-top: -8px; }

.stats-bar { display: flex; gap: 20px; font-size: .9rem; color: #aaa; }

/* Formulário inline (adicionar usuário) */
.form-inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form-inline input, .form-inline select {
    padding: 7px 10px;
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    color: #e0e0e0;
    font-size: .9rem;
}

/* Tabela de usuários */
.admin-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.admin-table th, .admin-table td { padding: 8px 10px; border-bottom: 1px solid #2a2a2a; text-align: left; }
.admin-table th { color: #888; font-weight: 600; }

.role-badge { padding: 2px 8px; border-radius: 4px; font-size: .75rem; font-weight: 600; }
.role-badge.admin { background: #e50914; color: #fff; }
.role-badge.user  { background: #2a2a2a; color: #aaa; border: 1px solid #3a3a3a; }

.actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.form-inline-sm { display: flex; gap: 4px; align-items: center; }
.form-inline-sm input { padding: 4px 8px; font-size: .8rem; background: #2a2a2a; border: 1px solid #3a3a3a; border-radius: 5px; color: #e0e0e0; width: 110px; }

.btn-sm { padding: 4px 8px; background: #2a2a2a; border: 1px solid #3a3a3a; border-radius: 5px; color: #ccc; cursor: pointer; font-size: .8rem; }
.btn-sm:hover { background: #3a3a3a; }
.btn-sm.btn-danger { border-color: #6a2d2d; color: #c87e7e; }

/* ===== Visitante / locked ===== */
.channel-card.locked { opacity: .6; }
.channel-card.locked::after {
    content: '🔒';
    position: absolute;
    top: 6px; right: 6px;
    font-size: .75rem;
}
.channel-card { position: relative; }

.locked-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 60px 20px;
    text-align: center;
    background: #111;
    border-radius: 8px;
    min-height: 300px;
}
.locked-icon { font-size: 3rem; }
.locked-screen h2 { font-size: 1.2rem; color: #fff; }
.locked-screen p  { color: #888; font-size: .95rem; max-width: 340px; }
.locked-actions { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

.btn-primary {
    padding: 10px 24px;
    background: #e50914;
    color: #fff;
    border-radius: 6px;
    font-weight: 600;
    font-size: .95rem;
}
.btn-primary:hover { background: #c0070f; }

.setup-card {
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px;
}

.setup-card h2 {
    font-size: 1rem;
    margin-bottom: 4px;
}

.setup-card p {
    color: var(--text-soft);
    margin-bottom: 12px;
    font-size: .9rem;
}

.pagination {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    justify-content: center;
}

.page-btn {
    border: 1px solid var(--line);
    background: var(--bg-soft);
    color: var(--text-main);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: .85rem;
}

.page-btn:hover {
    border-color: var(--danger);
    color: #fff;
}

/* ===== Series tree ===== */
.series-block, .season-block {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
}

.series-title, .season-title {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
.series-title::-webkit-details-marker,
.season-title::-webkit-details-marker { display: none; }

.series-title { font-size: .95rem; font-weight: 600; }
.series-title img { width: 48px; height: 32px; object-fit: contain; border-radius: 3px; }
.series-title .no-logo-sm { font-size: 1.4rem; }
.series-title span { flex: 1; }
.series-title small, .season-title small { color: #666; font-size: .75rem; font-weight: 400; }

.series-block:hover > .series-title,
.series-block[open] > .series-title { background: #222; }

.season-block { margin: 0 12px 8px; border-radius: 6px; }
.season-title { font-size: .85rem; color: #aaa; padding: 8px 12px; }
.season-block[open] > .season-title { color: #fff; }

.episode-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px 12px;
}

.episode-item {
    padding: 5px 10px;
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 5px;
    font-size: .8rem;
    color: #ccc;
    transition: background .15s, border-color .15s;
}
.episode-item:hover { background: #e50914; border-color: #e50914; color: #fff; }
.episode-item.locked { opacity: .55; }

/* ===== Serie card & detail ===== */
.series-card { justify-content: flex-start; }
.series-meta { font-size: .72rem; color: #666; margin-top: -4px; }

.serie-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    margin-bottom: 16px;
}
.serie-header img { width: 80px; height: 54px; object-fit: contain; border-radius: 4px; }
.serie-header h1 { font-size: 1.2rem; margin-bottom: 4px; }
.serie-header p  { font-size: .85rem; color: #888; }

.serie-hero {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(28, 33, 40, 0.96), rgba(15, 20, 26, 0.94));
    border: 1px solid #2a2f38;
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
}

.serie-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: var(--hero-bg, none);
    background-size: cover;
    background-position: center;
    opacity: .18;
    pointer-events: none;
}

.serie-hero > * {
    position: relative;
    z-index: 1;
}

.serie-poster {
    width: 120px;
    min-width: 120px;
    height: 180px;
    border-radius: 10px;
    object-fit: cover;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

.genre-list {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
}

.genre-pill {
    font-size: .72rem;
    color: #d9e4f0;
    background: rgba(41, 50, 62, .84);
    border: 1px solid #3a4655;
    border-radius: 999px;
    padding: 3px 9px;
}

.serie-synopsis {
    margin-top: 10px;
    color: #d3dde7;
    font-size: .88rem;
    line-height: 1.45;
    max-width: 760px;
}

.season-block {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
}
.season-title {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    cursor: pointer;
    list-style: none;
    font-size: .9rem;
    color: #ccc;
    user-select: none;
}
.season-title::-webkit-details-marker { display: none; }
.season-block[open] > .season-title { color: #fff; background: #222; }
.season-title small { color: #555; font-size: .75rem; }

@media (max-width: 980px) {
    .layout {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        width: 100%;
        min-width: 100%;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        max-height: none;
    }

    nav {
        flex-direction: row;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    .group-link {
        white-space: nowrap;
        flex: 0 0 auto;
    }

    .content {
        padding: 14px;
    }

    .channel-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 10px;
    }

    .admin-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .admin-header-right {
        flex-wrap: wrap;
        gap: 8px;
    }

    .admin-section {
        padding: 14px;
    }

    .admin-table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .result-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .serie-hero {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .serie-poster {
        width: 130px;
        height: 195px;
    }

    .genre-list {
        justify-content: center;
    }
}
