@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.2/css/all.min.css' );

:root {
    --bg-dark: #0f0f1a;
    --bg-panel: #1e1e2f;
    --bg-hover: #252538;
    --border-color: #2d2d44;
    --primary: #3498db;
    --text-main: #ffffff;
    --text-muted: #aaaaaa;
    --danger: #e74c3c;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* .screen mantido apenas para login.php */
.screen { display: none; height: 100vh; width: 100vw; }
.screen.active { display: flex; flex-direction: column; }

/* ── LOGIN SPLIT ───────────────────────────────────────────────────────────── */
#login-screen.active {
    flex-direction: row;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a2e 0%, #0f0f1a 100%);
}

/* Card pai: 40% largura, 70vh altura */
.login-card {
    width: 40%;
    height: 72vh;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 24px 64px rgba(0,0,0,0.6);
    border: 1px solid var(--border-color);
}

.login-split {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Lado esquerdo: formulário — 75% */
.login-form-side {
    width: 75%;
    flex: 0 0 75%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-panel);
    padding: 32px 28px;
    overflow-y: auto;
}

.login-inner {
    width: 100%;
    max-width: 360px;
    text-align: center;
}

.login-logo {
    font-size: 2.8rem;
    color: var(--primary);
    margin-bottom: 12px;
}

.login-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 6px;
}

.login-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-bottom: 24px;
}

/* Lado direito: imagem — 25% */
.login-image-side {
    width: 25%;
    flex: 0 0 25%;
    position: relative;
    overflow: hidden;
    background-image: url('https://picsum.photos/seed/iptv/900/1080');
    background-size: cover;
    background-position: center;
}

.login-image-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(15,15,26,0.55) 0%, rgba(52,152,219,0.18) 100%);
    display: flex;
    align-items: flex-end;
    padding: 28px;
}

.login-image-overlay span {
    color: rgba(255,255,255,0.85);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    display: flex;
    align-items: center;
    gap: 8px;
    text-shadow: 0 2px 8px rgba(0,0,0,0.6);
}

/* Inputs */
.input-group { position: relative; margin-bottom: 12px; }
.input-group input {
    width: 100%;
    padding: 11px 40px 11px 36px;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 8px;
    outline: none;
    font-size: 0.9rem;
    transition: border-color 0.2s;
}
.input-group input:focus { border-color: var(--primary); }
.input-group .icon-input {
    position: absolute; left: 12px; top: 50%;
    transform: translateY(-50%); color: var(--text-muted); font-size: 0.9rem;
    pointer-events: none;
}

/* Botão ver senha */
.btn-toggle-pass {
    position: absolute; right: 10px; top: 50%;
    transform: translateY(-50%);
    background: none; border: none;
    color: var(--text-muted); font-size: 0.9rem;
    cursor: pointer; padding: 4px;
    transition: color 0.2s;
}
.btn-toggle-pass:hover { color: var(--primary); }

/* Lembrar-me */
.login-options {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 16px;
}

.remember-label {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
    font-size: 0.83rem;
    color: var(--text-muted);
    user-select: none;
}

.remember-label input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: var(--primary);
    cursor: pointer;
}

.remember-label:hover { color: var(--text-main); }

/* Botão entrar */
.btn { width: 100%; padding: 11px; border: none; border-radius: 8px; font-weight: bold; cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 0.9rem; }
.btn-primary { background: linear-gradient(135deg, var(--primary), #2980b9); color: #fff; }
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(52,152,219,0.35); }

.alert { padding: 9px 12px; border-radius: 8px; margin-bottom: 14px; font-size: 0.85rem; display: flex; align-items: center; gap: 8px; }
.alert.error { background: rgba(231,76,60,0.12); color: var(--danger); border: 1px solid rgba(231,76,60,0.3); }

/* Responsivo: empilha em telas pequenas */
@media (max-width: 900px) {
    .login-card { width: 90%; height: auto; min-height: 70vh; }
}
@media (max-width: 700px) {
    .login-card { width: 96%; border-radius: 10px; }
    .login-split { flex-direction: column; }
    .login-form-side { width: 100%; flex: none; }
    .login-image-side { display: none; }
}

.player-header { height: 50px; background: var(--bg-panel); border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; padding: 0 15px; }
.player-header .brand { font-size: 1.1rem; font-weight: bold; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.player-header .user-info { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; }

/* Nav entre páginas */
.header-nav { display: flex; gap: 4px; }
.header-nav a { color: var(--text-muted); text-decoration: none; font-size: 0.82rem; padding: 5px 12px; border-radius: 6px; display: flex; align-items: center; gap: 6px; transition: background 0.2s, color 0.2s; }
.header-nav a:hover { background: var(--bg-hover); color: var(--text-main); }
.header-nav a.active { background: var(--primary); color: #fff; }
.btn-icon { background: none; border: none; color: var(--text-muted); font-size: 1.1rem; cursor: pointer; transition: 0.2s; }
.btn-icon:hover { color: var(--danger); }
.player-footer { height: 30px; background: var(--bg-panel); border-top: 1px solid var(--border-color); display: flex; align-items: center; justify-content: center; color: var(--text-muted); font-size: 0.75rem; }

/* ── Player fullscreen toggle ─────────────────────────────────────────────── */
body.player-active .player-header,
body.player-active .player-footer {
    display: none !important;
}
body.player-active .media-main {
    height: 100vh;
}

.player-main { display: grid; grid-template-columns: 24fr 24fr 50fr; gap: 15px; padding: 15px; flex: 1; min-height: 0; background: var(--bg-dark); }

.panel { background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: 10px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 5px 15px rgba(0,0,0,0.2); }
.panel-header { padding: 10px 15px; font-weight: bold; font-size: 0.9rem; background: rgba(0,0,0,0.2); border-bottom: 1px solid var(--border-color); display: flex; align-items: center; gap: 8px; }

.search-box { padding: 8px; border-bottom: 1px solid var(--border-color); position: relative; }
.search-box input { width: 100%; padding: 6px 10px 6px 28px; background: var(--bg-dark); border: 1px solid var(--border-color); color: #fff; border-radius: 4px; outline: none; font-size: 0.85rem; }
.search-box > i { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 0.75rem; pointer-events: none; }

.list-group { flex: 1; overflow-y: auto; list-style: none; }
.list-group::-webkit-scrollbar { width: 4px; }
.list-group::-webkit-scrollbar-track { background: transparent; }
.list-group::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 10px; }
.list-group::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

.list-item { padding: 8px 12px; border-bottom: 1px solid rgba(255,255,255,0.02); cursor: pointer; transition: 0.2s; display: flex; align-items: center; gap: 8px; font-size: 0.85rem; }
.list-item:hover { background: var(--bg-hover); }
.list-item.active { background: var(--primary); color: #fff; border-left: 3px solid #fff; }
.list-item img { width: 30px; height: 30px; object-fit: contain; border-radius: 4px; background: rgba(0,0,0,0.2); }

.video-panel { background: var(--bg-panel); display: flex; flex-direction: column; }

.channel-info { padding: 10px 15px; background: rgba(0,0,0,0.2); border-bottom: 1px solid var(--border-color); }
.channel-info h2 { font-size: 1.1rem; margin: 0; color: var(--primary); }

.video-container { flex: 1; display: flex; align-items: center; justify-content: center; background: #000; min-height: 0; position: relative; overflow: hidden; }
.video-container video { width: 100%; height: 100%; outline: none; }

/* Plyr: forçar ocupar toda a área do container */
.video-container .plyr {
    width: 100%;
    height: 100%;
    position: absolute;
    inset: 0;
}
.video-container .plyr video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ── PRELOADER ─────────────────────────────────────────────────────────────── */
.video-preloader {
    position: absolute;
    inset: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}
.video-preloader.active {
    opacity: 1;
    pointer-events: all;
}
.video-preloader.hiding {
    opacity: 0;
}

/* Fundo desfocado com a imagem do canal */
.preloader-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    filter: blur(22px) brightness(0.35) saturate(1.4);
    transform: scale(1.08);
    transition: background-image 0.3s ease;
}

/* Conteúdo central */
.preloader-content {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
    padding: 20px;
}

/* Logo do canal */
.preloader-logo {
    width: 90px;
    height: 90px;
    object-fit: contain;
    border-radius: 16px;
    background: rgba(255,255,255,0.06);
    padding: 10px;
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

/* Nome do canal */
.preloader-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
    max-width: 260px;
    line-height: 1.3;
}

.preloader-hint {
    font-size: 0.78rem;
    color: rgba(255,255,255,0.5);
    letter-spacing: 0.04em;
}

/* Spinner de 3 bolinhas pulsantes */
.preloader-spinner {
    display: flex;
    gap: 8px;
    align-items: center;
}
.preloader-spinner span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--primary);
    animation: preloader-bounce 1.2s ease-in-out infinite;
}
.preloader-spinner span:nth-child(1) { animation-delay: 0s; }
.preloader-spinner span:nth-child(2) { animation-delay: 0.2s; }
.preloader-spinner span:nth-child(3) { animation-delay: 0.4s; }

@keyframes preloader-bounce {
    0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
    40%            { transform: scale(1.2); opacity: 1; }
}

/* EPG Overlay (Por cima do player) */
.epg-container { 
    position: absolute; 
    bottom: 0; 
    left: 0; 
    width: 100%; 
    height: 0; 
    display: flex; 
    flex-direction: column; 
    background: rgba(0, 0, 0, 0.9); /* 10% de transparência */
    backdrop-filter: blur(3px);
    transition: height 0.3s ease; 
    z-index: 10;
    overflow: hidden;
}
.epg-container.active { height: 50%; }

.epg-header { padding: 8px 15px; font-weight: bold; font-size: 0.85rem; border-bottom: 1px solid rgba(255,255,255,0.1); color: #fff; display: flex; justify-content: space-between; align-items: center; }
.epg-header .btn-icon { color: #fff; }
.epg-content { padding: 10px 15px; overflow-y: auto; font-size: 0.85rem; color: var(--text-main); flex: 1; }
.epg-item { margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px dashed rgba(255,255,255,0.1); }
.epg-item:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.epg-time { color: var(--primary); font-weight: bold; margin-right: 8px; }

/* Wrapper do botão Toggle na parte inferior */
.epg-toggle-wrapper { padding: 10px; background: rgba(0,0,0,0.2); border-top: 1px solid var(--border-color); text-align: center; }
.btn-icon-epg { font-size: 0.85rem; background: var(--primary); color: #fff; padding: 6px 15px; border-radius: 4px; border: none; cursor: pointer; transition: 0.2s; display: inline-flex; align-items: center; gap: 5px; }
.btn-icon-epg:hover { background: #2980b9; }

/* ── Filtros (gênero/ano) ─────────────────────────────────────────────────── */
.filter-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-select {
    padding: 6px 10px; background: var(--bg-panel); border: 1px solid var(--border-color);
    color: var(--text-main); border-radius: 6px; font-size: 0.8rem; outline: none; cursor: pointer;
    max-width: 140px;
}
.filter-select:focus { border-color: var(--primary); }
.search-tabs .btn-filter {
    padding: 5px 14px; border-radius: 20px; border: 1px solid var(--border-color);
    background: transparent; color: var(--text-muted); cursor: pointer; font-size: 0.8rem; transition: 0.2s;
}
.search-tabs .btn-filter.active, .search-tabs .btn-filter:hover {
    background: var(--primary); color: #fff; border-color: var(--primary);
}

@media (max-width: 1000px) {
    .player-main { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; overflow-y: auto; height: auto; min-height: calc(100vh - 80px); }
    .panel { height: 250px; }
    .video-panel { height: 500px; }
}
