/* MiplayTV — Panel de administración. Tema OSCURO (sin modo claro). */

:root {
	--bg: #0b1120;
	--surface: #131c2f;
	--surface-2: #1b2537;
	--surface-3: #232f47;
	--sidebar: #0a0f1c;
	--sidebar-2: #1b2537;
	--text: #e6eaf2;
	--muted: #94a3b8;
	--border: #26324a;
	--primary: #3b82f6;
	--primary-d: #2563eb;
	--danger: #ef4444;
	--ok: #22c55e;
	--warn: #f59e0b;
	--radius: 12px;
	--shadow: 0 1px 3px rgba(0,0,0,.5), 0 1px 2px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }

body.tvp-admin {
	margin: 0;
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	background: var(--bg);
	color: var(--text);
	font-size: 14px;
	line-height: 1.5;
}

/* ---------------- Layout ---------------- */
.tvp-shell { display: flex; min-height: 100vh; }

.tvp-sidebar {
	width: 240px;
	background: var(--sidebar);
	color: #cbd5e1;
	display: flex;
	flex-direction: column;
	position: fixed;
	inset: 0 auto 0 0;
	z-index: 50;
	border-right: 1px solid var(--border);
	transition: transform .2s ease;
}

.tvp-brand {
	display: flex; align-items: center; gap: .6rem;
	padding: 1.25rem 1.25rem;
	font-size: 1.25rem; font-weight: 700; color: #fff;
	border-bottom: 1px solid rgba(255,255,255,.06);
}
.tvp-brand-mark { color: var(--primary); }

.tvp-nav { padding: .75rem; display: flex; flex-direction: column; gap: .15rem; flex: 1; }
.tvp-nav-link {
	display: flex; align-items: center; gap: .75rem;
	padding: .65rem .75rem; border-radius: 8px;
	color: #cbd5e1; text-decoration: none; font-weight: 500;
	transition: background .15s, color .15s;
}
.tvp-nav-link:hover { background: var(--sidebar-2); color: #fff; }
.tvp-nav-link.is-active { background: var(--primary); color: #fff; }
.tvp-nav-ico { width: 20px; text-align: center; opacity: .9; }

.tvp-sidebar-foot { padding: 1rem; border-top: 1px solid rgba(255,255,255,.06); font-size: .85rem; }
.tvp-player-link { display: block; color: #93c5fd; text-decoration: none; margin-bottom: .75rem; }
.tvp-user { display: flex; justify-content: space-between; color: #94a3b8; }
.tvp-user a { color: #f87171; text-decoration: none; }

.tvp-main { flex: 1; margin-left: 240px; min-width: 0; }

.tvp-topbar {
	display: none;
	align-items: center; gap: 1rem;
	padding: .75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
	position: sticky; top: 0; z-index: 40;
}
.tvp-burger { background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--text); }

.tvp-content { padding: 1.75rem clamp(1rem, 3vw, 2.25rem); max-width: 1200px; }

/* ---------------- Tipografía ---------------- */
.tvp-h1 { font-size: 1.6rem; margin: 0 0 1.25rem; font-weight: 700; }
.tvp-h2 { font-size: 1.15rem; margin: 1.75rem 0 .9rem; font-weight: 650; }
.tvp-muted { color: var(--muted); font-size: .85rem; }
.tvp-right { text-align: right; }
.tvp-hint { color: var(--muted); font-size: .82rem; margin: .6rem 0 0; }

/* ---------------- Stats ---------------- */
.tvp-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 1rem; }
.tvp-stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.tvp-stat-num { font-size: 2rem; font-weight: 750; line-height: 1; }
.tvp-stat-num span { font-size: 1rem; color: var(--muted); font-weight: 500; }
.tvp-stat-label { color: var(--muted); margin-top: .4rem; }

/* ---------------- Cards de pantallas ---------------- */
.tvp-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px,1fr)); gap: 1rem; }
.tvp-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem; box-shadow: var(--shadow); }
.tvp-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .5rem; }
.tvp-card-code { color: var(--muted); font-size: .8rem; }
.tvp-card-title { font-weight: 650; font-size: 1.05rem; }
.tvp-card-sub { color: var(--muted); margin-bottom: .75rem; }
.tvp-card-meta { display: grid; gap: .35rem; margin: 0; }
.tvp-card-meta div { display: flex; justify-content: space-between; font-size: .85rem; }
.tvp-card-meta dt { color: var(--muted); margin: 0; }
.tvp-card-meta dd { margin: 0; font-weight: 550; }

/* ---------------- Estados ---------------- */
.tvp-status { display: inline-flex; align-items: center; gap: .4rem; font-size: .75rem; font-weight: 700; padding: .25rem .6rem; border-radius: 999px; text-transform: uppercase; letter-spacing: .03em; }
.tvp-status::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.tvp-status-online { background: rgba(34,197,94,.16); color: #4ade80; }
.tvp-status-offline { background: rgba(148,163,184,.16); color: #cbd5e1; }
.tvp-status-actualizando { background: rgba(245,158,11,.16); color: #fbbf24; }
.tvp-status-error { background: rgba(239,68,68,.16); color: #f87171; }

/* ---------------- Paneles ---------------- */
.tvp-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.tvp-panel-title { font-size: 1rem; font-weight: 650; margin: 0 0 1rem; }
.tvp-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.tvp-panel-head .tvp-panel-title { margin: 0; }
.tvp-panel-actions { display: flex; align-items: center; gap: .5rem; }
.tvp-panel-actions form { display: inline; }

/* ---------------- Formularios ---------------- */
.tvp-field { display: flex; flex-direction: column; gap: .3rem; }
.tvp-field > span { font-size: .8rem; color: var(--muted); font-weight: 550; }
.tvp-field input, .tvp-field select, .tvp-input, .tvp-url-input {
	padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px; font-size: .9rem; background: var(--surface-2); color: var(--text); width: 100%;
}
.tvp-field input::placeholder, .tvp-input::placeholder { color: #5b6b86; }
.tvp-field input:focus, .tvp-field select:focus, .tvp-input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.tvp-field select option { background: var(--surface-2); color: var(--text); }
.tvp-grow { flex: 1; min-width: 180px; }
.tvp-check { display: inline-flex; align-items: center; gap: .5rem; font-size: .9rem; }
.tvp-check input, .tvp-login-remember input { accent-color: var(--primary); }

.tvp-upload-row, .tvp-form-row, .tvp-inline-form { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.tvp-inline-form { align-items: center; }
.tvp-settings-form { display: grid; gap: .9rem; }

/* ---------------- Botones ---------------- */
.tvp-btn {
	display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
	padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--border);
	background: var(--surface-2); color: var(--text); font-weight: 600; font-size: .88rem; cursor: pointer; text-decoration: none;
	transition: background .15s, border-color .15s, opacity .15s;
}
.tvp-btn:hover { background: var(--surface-3); }
.tvp-btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.tvp-btn-primary:hover { background: var(--primary-d); }
.tvp-btn-danger { color: #f87171; border-color: rgba(239,68,68,.35); background: rgba(239,68,68,.12); }
.tvp-btn-danger:hover { background: rgba(239,68,68,.2); }
.tvp-btn-sm { padding: .35rem .7rem; font-size: .8rem; }
.tvp-btn-block { width: 100%; }
.tvp-btn:disabled { opacity: .5; cursor: not-allowed; }
.tvp-icon-btn { background: none; border: none; cursor: pointer; font-size: 1rem; color: var(--muted); padding: .25rem; border-radius: 6px; }
.tvp-icon-btn:hover { background: var(--surface-2); color: #f87171; }

.tvp-chip { border: none; border-radius: 999px; padding: .3rem .7rem; font-size: .78rem; font-weight: 650; cursor: pointer; }
.tvp-chip-on { background: rgba(34,197,94,.16); color: #4ade80; }
.tvp-chip-off { background: rgba(148,163,184,.16); color: #94a3b8; }

.tvp-badge { display: inline-block; background: rgba(59,130,246,.18); color: #93c5fd; border-radius: 6px; padding: .2rem .5rem; font-size: .78rem; font-weight: 700; }

/* ---------------- Tablas ---------------- */
.tvp-table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.tvp-table th, .tvp-table td { text-align: left; padding: .8rem 1rem; border-bottom: 1px solid var(--border); }
.tvp-table th { background: var(--surface-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tvp-table tr:last-child td { border-bottom: none; }
.tvp-link-strong { font-weight: 650; color: #93c5fd; text-decoration: none; }
.tvp-link-strong:hover { text-decoration: underline; }

/* ---------------- Biblioteca de videos ---------------- */
.tvp-video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 1.1rem; }
.tvp-video-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.tvp-video-card.is-inactive { opacity: .5; }
.tvp-video-thumb { position: relative; aspect-ratio: 16/9; background: #000; }
.tvp-video-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.tvp-video-dur { position: absolute; right: .5rem; bottom: .5rem; background: rgba(0,0,0,.75); color: #fff; font-size: .72rem; padding: .1rem .4rem; border-radius: 4px; }
.tvp-video-body { padding: .8rem; }
.tvp-video-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tvp-video-meta { color: var(--muted); font-size: .8rem; margin: .25rem 0 .6rem; }
.tvp-warn { background: rgba(245,158,11,.14); color: #fbbf24; border-radius: 6px; padding: .3rem .5rem; font-size: .72rem; font-weight: 600; margin-bottom: .6rem; line-height: 1.3; }
.tvp-video-actions { display: flex; justify-content: space-between; align-items: center; }
.tvp-video-actions form { display: inline; }

/* ---------------- Editor de playlist ---------------- */
.tvp-edit-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 1.25rem; flex-wrap: wrap; gap: 1rem; }
.tvp-back { color: var(--muted); text-decoration: none; font-size: .85rem; }
.tvp-back:hover { color: var(--text); }
.tvp-edit-head .tvp-h1 { margin: .25rem 0 0; }
.tvp-edit-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1.25rem; align-items: start; }

.tvp-sortable { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; }
.tvp-sort-item {
	display: flex; align-items: center; gap: .75rem;
	background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: .7rem .8rem; cursor: grab;
}
.tvp-sort-item.dragging { opacity: .4; }
.tvp-sort-item.drag-over { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(59,130,246,.35); }
.tvp-drag-handle { color: #64748b; cursor: grab; }
.tvp-sort-num { width: 22px; height: 22px; background: var(--primary); color: #fff; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .75rem; font-weight: 700; }
.tvp-sort-title { flex: 1; font-weight: 550; }
.tvp-sort-dur { color: var(--muted); font-size: .82rem; }
.tvp-sort-remove { display: inline; }

.tvp-add-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .5rem; max-height: 420px; overflow-y: auto; }
.tvp-add-list li { display: flex; align-items: center; gap: .6rem; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 8px; }
.tvp-add-title { flex: 1; font-weight: 550; }
.tvp-add-dur { color: var(--muted); font-size: .8rem; }

/* ---------------- Pantallas (filas) ---------------- */
.tvp-screen-row { }
.tvp-screen-status { display: flex; align-items: flex-end; }
.tvp-screen-extra { margin-top: 1rem; padding-top: 1rem; border-top: 1px dashed var(--border); display: grid; gap: .75rem; }
.tvp-url-box { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.tvp-url-label { font-size: .8rem; color: var(--muted); }
.tvp-url-input { max-width: 480px; font-family: ui-monospace, monospace; font-size: .8rem; }
.tvp-screen-meta { display: flex; gap: 1.25rem; flex-wrap: wrap; font-size: .82rem; color: var(--muted); }
.tvp-screen-tools { display: flex; gap: .5rem; }
.tvp-screen-tools form { display: inline; }

/* ---------------- Alertas / vacíos ---------------- */
.tvp-alert { padding: .8rem 1rem; border-radius: 8px; margin-bottom: 1.25rem; font-weight: 550; }
.tvp-alert-ok { background: rgba(34,197,94,.14); color: #4ade80; }
.tvp-alert-error { background: rgba(239,68,68,.14); color: #f87171; }
.tvp-empty { background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); padding: 2rem; text-align: center; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 1rem; }
.tvp-empty-sm { padding: 1.25rem; }

/* ---------------- Login (oscuro) ---------------- */
.tvp-login-body {
	margin: 0; min-height: 100vh; display: flex; align-items: center; justify-content: center;
	background: radial-gradient(1200px 600px at 50% -10%, #16223c 0%, #0b1120 55%);
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); padding: 1rem;
}
.tvp-login-card {
	background: var(--surface); border: 1px solid var(--border); border-radius: 18px;
	padding: 2.5rem 2.25rem; width: 100%; max-width: 380px;
	box-shadow: 0 24px 60px rgba(0,0,0,.55);
}
.tvp-login-logo {
	width: 64px; height: 64px; margin: 0 auto .9rem; border-radius: 16px;
	display: flex; align-items: center; justify-content: center;
	background: rgba(59,130,246,.14); color: var(--primary); font-size: 1.9rem;
	border: 1px solid rgba(59,130,246,.3);
}
.tvp-login-brand { font-size: 1.7rem; font-weight: 750; text-align: center; letter-spacing: -.01em; }
.tvp-login-sub { text-align: center; color: var(--muted); margin: .25rem 0 1.6rem; font-size: .9rem; }

.tvp-login-error {
	background: rgba(239,68,68,.14); color: #f87171; border: 1px solid rgba(239,68,68,.3);
	border-radius: 10px; padding: .7rem .9rem; font-size: .85rem; margin-bottom: 1rem; text-align: center;
}

.tvp-login-form { display: flex; flex-direction: column; gap: .9rem; }
.tvp-login-field { position: relative; }
.tvp-login-input {
	width: 100%; padding: .8rem .95rem; font-size: .95rem;
	background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; color: var(--text);
}
.tvp-login-input::placeholder { color: #5b6b86; }
.tvp-login-input:focus { outline: 2px solid var(--primary); outline-offset: -1px; border-color: var(--primary); }
.tvp-login-password .tvp-login-input { padding-right: 3rem; }

.tvp-login-eye {
	position: absolute; right: .5rem; top: 50%; transform: translateY(-50%);
	background: none; border: none; cursor: pointer; padding: .4rem; border-radius: 8px;
	display: flex; align-items: center; justify-content: center;
}
.tvp-login-eye:hover { background: var(--surface-3); }
.tvp-eye { width: 22px; height: 22px; display: block; background-repeat: no-repeat; background-position: center; background-size: 22px 22px; }
.tvp-eye-closed { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24'/%3E%3Cline x1='1' y1='1' x2='23' y2='23'/%3E%3C/svg%3E"); }
.tvp-eye-open { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z'/%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3C/svg%3E"); }

.tvp-login-remember { display: inline-flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .88rem; cursor: pointer; }
.tvp-login-btn {
	margin-top: .3rem; padding: .85rem 1rem; border: none; border-radius: 10px;
	background: var(--primary); color: #fff; font-weight: 700; font-size: .95rem; cursor: pointer;
	transition: background .15s;
}
.tvp-login-btn:hover { background: var(--primary-d); }
.tvp-login-forgot { text-align: center; color: var(--muted); font-size: .85rem; text-decoration: none; margin-top: .3rem; }
.tvp-login-forgot:hover { color: #93c5fd; }

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
	.tvp-edit-grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
	.tvp-sidebar { transform: translateX(-100%); }
	.tvp-sidebar.is-open { transform: translateX(0); }
	.tvp-main { margin-left: 0; }
	.tvp-topbar { display: flex; }
}

/* Orientación, grupos y destinos (1.7). */
.tvp-orient { display: inline-block; border-radius: 6px; padding: .12rem .45rem; font-size: .72rem; font-weight: 700; white-space: nowrap; }
.tvp-orient-horizontal { background: rgba(59,130,246,.16); color: #93c5fd; }
.tvp-orient-vertical { background: rgba(168,85,247,.18); color: #d8b4fe; }
.tvp-orient-form { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; margin: .5rem 0; }
.tvp-tag { display: inline-block; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: .2rem .6rem; font-size: .8rem; }
.tvp-group-screens { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; margin-top: 1rem; }
.tvp-push-right { margin-left: auto; }
.tvp-targets { position: relative; font-size: .8rem; }
.tvp-targets summary { cursor: pointer; color: var(--muted); list-style: none; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: .15rem .45rem; border: 1px dashed var(--border); border-radius: 6px; }
.tvp-targets summary::-webkit-details-marker { display: none; }
.tvp-targets[open] summary { color: var(--text); border-style: solid; }
.tvp-targets-form { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; width: 280px; max-height: 360px; overflow: auto; display: grid; gap: .4rem; padding: .9rem; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.tvp-targets-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin-top: .4rem; }
.tvp-using-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.tvp-using-list li { display: flex; align-items: center; gap: .6rem; justify-content: space-between; font-size: .9rem; }

/* Imágenes en la biblioteca (1.8). */
.tvp-video-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
