/* ============================================================
   PainelTV - Estilos do painel administrativo
   ============================================================ */
:root {
    --azul: #2563eb;
    --azul-dark: #1d4ed8;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --texto: #0f172a;
    --muted: #64748b;
    --borda: #e2e8f0;
    --verde: #16a34a;
    --vermelho: #dc2626;
    --amarelo: #d97706;
    --radius: 12px;
    --sombra: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: var(--bg);
    color: var(--texto);
    font-size: 15px;
    line-height: 1.5;
}
a { color: var(--azul); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #eef2ff; padding: 2px 6px; border-radius: 6px; font-size: .9em; }
h1 { font-size: 24px; margin: 0; }
h2 { font-size: 19px; margin: 0; }

/* ===== Topbar ===== */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    background: var(--surface); border-bottom: 1px solid var(--borda);
    padding: 0 20px; height: 60px; position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; font-size: 18px; color: var(--texto); display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand-logo { font-size: 22px; }
.topbar-user { display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 14px; }

/* ===== Layout ===== */
.layout { display: flex; min-height: calc(100vh - 60px); }
.sidebar {
    width: 220px; background: var(--surface); border-right: 1px solid var(--borda);
    padding: 16px 12px; flex-shrink: 0;
}
.menu-item {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 14px; border-radius: 10px; color: var(--texto);
    font-weight: 500; margin-bottom: 4px;
}
.menu-item:hover { background: var(--bg); text-decoration: none; }
.menu-item.active { background: var(--azul); color: #fff; }
.menu-icon { font-size: 18px; }
.content { flex: 1; padding: 28px; max-width: 1100px; }

/* ===== Cabecalho de pagina ===== */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 16px; }
.page-header .muted { margin: 4px 0 0; }

/* ===== Cards / estatisticas ===== */
.card { background: var(--surface); border: 1px solid var(--borda); border-radius: var(--radius); padding: 20px; box-shadow: var(--sombra); margin-bottom: 16px; }
.card.empty { color: var(--muted); text-align: center; padding: 40px 20px; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.stat-card { background: var(--surface); border: 1px solid var(--borda); border-radius: var(--radius); padding: 22px; box-shadow: var(--sombra); }
.stat-num { font-size: 34px; font-weight: 700; color: var(--azul); }
.stat-label { color: var(--muted); font-size: 14px; margin-top: 4px; }

/* ===== Grid de telas ===== */
.tela-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.tela-card { background: var(--surface); border: 1px solid var(--borda); border-radius: var(--radius); padding: 18px; box-shadow: var(--sombra); }
.tela-card-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.tela-code { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.tela-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== Tabela ===== */
table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--borda); border-radius: var(--radius); overflow: hidden; box-shadow: var(--sombra); }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--borda); }
th { background: #f8fafc; font-size: 13px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
tr:last-child td { border-bottom: none; }
td.actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ===== Badges ===== */
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-secondary { background: #e2e8f0; color: #475569; }

/* ===== Botoes ===== */
.btn-primary, .btn-secondary, .btn-danger {
    display: inline-block; border: none; border-radius: 9px; padding: 10px 16px;
    font-size: 14px; font-weight: 600; cursor: pointer; text-align: center;
}
.btn-primary { background: var(--azul); color: #fff; }
.btn-primary:hover { background: var(--azul-dark); text-decoration: none; }
.btn-secondary { background: #fff; color: var(--texto); border: 1px solid var(--borda); }
.btn-secondary:hover { background: var(--bg); text-decoration: none; }
.btn-danger { background: var(--vermelho); color: #fff; }
.btn-danger:hover { background: #b91c1c; text-decoration: none; }
.btn-link { color: var(--muted); font-size: 14px; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 10px; font-size: 13px; }
button[disabled] { opacity: .4; cursor: not-allowed; }

/* ===== Formularios ===== */
.form .field, .field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field > span { font-weight: 600; font-size: 14px; }
.field input, .field select, input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="time"], select {
    padding: 10px 12px; border: 1px solid var(--borda); border-radius: 9px; font-size: 15px; font-family: inherit; background: #fff;
}
.field input:focus, .field select:focus { outline: 2px solid #bfdbfe; border-color: var(--azul); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field-actions { display: flex; align-items: flex-end; padding-bottom: 16px; }
.field-check { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; font-weight: 500; }
.field-check input { width: 18px; height: 18px; }
.form-actions { display: flex; gap: 10px; align-items: center; margin-top: 8px; }
.info-box { background: #eff6ff; border: 1px solid #bfdbfe; border-radius: var(--radius); padding: 16px; margin-bottom: 20px; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.info-box code { background: #dbeafe; }
.info-box .muted { width: 100%; margin: 6px 0 0; }
.muted { color: var(--muted); font-size: 13px; }
small.muted { font-size: 12px; }

/* ===== Alertas / flash ===== */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 18px; font-weight: 500; }
.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error   { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ===== Biblioteca de midias ===== */
.upload-form { padding: 20px; }
.midia-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.midia-card { background: var(--surface); border: 1px solid var(--borda); border-radius: var(--radius); overflow: hidden; box-shadow: var(--sombra); display: flex; flex-direction: column; }
.midia-thumb { position: relative; aspect-ratio: 16/9; background: #0f172a; display: flex; align-items: center; justify-content: center; }
.midia-thumb img, .midia-thumb video { width: 100%; height: 100%; object-fit: cover; }
.midia-badge { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,.7); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 6px; }
.midia-info { padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.midia-info strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.midia-card form { padding: 0 12px 12px; }

/* ===== Editor de playlist ===== */
.add-form { padding: 18px; }
.playlist-item { display: flex; gap: 16px; align-items: flex-start; }
.playlist-item.is-inactive { opacity: .6; }
.pi-thumb { width: 130px; aspect-ratio: 16/9; flex-shrink: 0; background: #0f172a; border-radius: 8px; overflow: hidden; position: relative; display: flex; align-items: center; justify-content: center; }
.pi-thumb img, .pi-thumb video { width: 100%; height: 100%; object-fit: cover; }
.pi-body { flex: 1; min-width: 0; }
.pi-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.pi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.pi-grid .field { margin-bottom: 8px; }
.pi-dias { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 6px 0 12px; }
.dia-check { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.pi-actions { display: flex; align-items: center; gap: 16px; }
.pi-order { display: flex; flex-direction: column; gap: 6px; flex-shrink: 0; }
.pi-order form { margin: 0; }

/* ===== Login ===== */
.auth-body { background: linear-gradient(135deg, #1e3a8a, #2563eb); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { background: #fff; border-radius: 16px; padding: 36px; width: 100%; max-width: 400px; box-shadow: 0 20px 50px rgba(0,0,0,.2); }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-logo { font-size: 48px; }
.auth-brand h1 { margin: 8px 0 4px; }
.auth-brand p { color: var(--muted); margin: 0; font-size: 14px; }

/* ===== Responsivo ===== */
@media (max-width: 760px) {
    .layout { flex-direction: column; }
    .sidebar { width: 100%; display: flex; gap: 6px; overflow-x: auto; padding: 10px; }
    .menu-item { margin-bottom: 0; white-space: nowrap; }
    .content { padding: 18px; }
    .field-row { grid-template-columns: 1fr; }
    .playlist-item { flex-direction: column; }
    .pi-thumb { width: 100%; }
    .pi-order { flex-direction: row; }
}
