/* Panel web de programación. Mismos valores que el panel del playout (theme.css). */
:root {
  --bg: #0e1015; --panel: #161920; --panel2: #1d2129; --panel3: #252a34;
  --border: #2b313c; --border-strong: #3a4250;
  --fg: #e8eaef; --dim: #8f98a8; --faint: #5d6574;
  --onair: #e5484d; --cued: #f5a524; --ok: #30a46c; --accent: #4c8dff; --accent-strong: #2f6fe0; --sel: #1d3358;
  --nav-w: 216px; --top-h: 52px; --radius: 8px; --radius-sm: 6px;
  --mono: "Cascadia Mono", "Cascadia Code", Consolas, monospace;
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { font: 14px/1.4 var(--sans); background: var(--bg); color: var(--fg); margin: 0; }
[hidden] { display: none !important; }
h1 { font-size: 20px; font-weight: 600; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 10px; }
p { margin: 0 0 10px; }
a { color: var(--accent); }
.dim { color: var(--dim); }
.mono { font-family: var(--mono); font-size: 12.5px; }

/* --- estructura --- */
#app { display: flex; min-height: 100%; }
#sidenav {
  position: fixed; inset: 0 auto 0 0; width: var(--nav-w); background: #0b0d11; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 14px 10px; overflow-y: auto;
}
#sidenav .marca { font-weight: 700; letter-spacing: 0.02em; padding: 4px 10px 14px; }
#sidenav .marca small { display: block; color: var(--dim); font-weight: 400; }
#sidenav a.item {
  display: block; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--fg); text-decoration: none;
  transition: background-color 120ms;
}
#sidenav a.item:hover { background: var(--panel2); }
#sidenav a.item[aria-current="page"] { background: var(--sel); font-weight: 600; }
#sidenav .pie { margin-top: auto; padding: 12px 10px 4px; border-top: 1px solid var(--border); }
#sidenav .pie .nombre { font-weight: 600; overflow-wrap: anywhere; }
#sidenav .pie .rol { color: var(--dim); font-size: 12px; margin-bottom: 10px; }
#sidenav .pie button { width: 100%; margin-top: 6px; }
#main { flex: 1; min-width: 0; padding: 22px 26px 60px; outline: none; }
#app.con-nav #main { margin-left: var(--nav-w); }
.cabecera { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.cabecera .espacio { flex: 1; }
.tarjeta { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.fila { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* --- botones y campos --- */
button {
  font: inherit; color: var(--fg); background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 14px; cursor: pointer; transition: background-color 120ms, border-color 120ms;
}
button:hover { background: var(--panel3); border-color: var(--border-strong); }
button.primary { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; font-weight: 600; }
button.primary:hover { background: #2a63c8; border-color: #2a63c8; }
button.danger { color: #ff8a8e; }
button.enlace { background: none; border: none; padding: 2px 4px; color: var(--accent); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
input, select, textarea {
  font: inherit; color: var(--fg); background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 6px 9px; width: 100%;
}
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--accent); }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px #4c8dff22; outline: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: block; color: var(--dim); font-size: 12.5px; margin-bottom: 4px; }
label.casilla { display: flex; align-items: center; gap: 8px; color: var(--fg); font-size: 14px; margin: 0; }
.campo { margin-bottom: 12px; }
.campo .ayuda { color: var(--faint); font-size: 12px; margin-top: 4px; }
.campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 14px; }
.error-campo { color: #ff8a8e; font-size: 12.5px; margin: 0 0 10px; }

/* --- tablas --- */
.tabla-caja { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--dim);
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
td { padding: 8px 10px; border-bottom: 1px solid #1f232b; vertical-align: middle; }
tr:last-child td { border-bottom: none; }
td.acciones { text-align: right; white-space: nowrap; }
td.acciones button { margin-left: 6px; }

/* --- etiquetas de estado --- */
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px; border: 1px solid var(--border-strong); color: var(--dim); }
.chip.ok { color: #6fd7a0; border-color: #1f6b47; }
.chip.aviso { color: var(--cued); border-color: #7a5512; }
.chip.mal { color: #ff8a8e; border-color: #7d2b2e; }

/* --- estados de una lista --- */
.estado { padding: 26px 10px; text-align: center; color: var(--dim); }
.estado.error { color: #ff8a8e; }
.estado button { margin-top: 10px; }

/* --- inicio de sesión --- */
.entrada { max-width: 360px; margin: 9vh auto 0; }
.entrada h1 { margin-bottom: 4px; }
.entrada .tarjeta { margin-top: 18px; }
.entrada button.primary { width: 100%; margin-top: 4px; }

/* --- avisos --- */
#avisos { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 20; max-width: min(420px, 90vw); }
.aviso {
  background: var(--panel3); border: 1px solid var(--border-strong); border-left: 3px solid var(--accent); border-radius: var(--radius-sm);
  padding: 10px 14px; box-shadow: 0 6px 20px #0008;
}
.aviso.ok { border-left-color: var(--ok); }
.aviso.error { border-left-color: var(--onair); }

/* --- diálogo --- */
dialog {
  background: var(--panel); color: var(--fg); border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 20px; width: min(520px, 92vw); max-height: 90vh; overflow-y: auto;
}
dialog::backdrop { background: #000a; }
dialog h2 { font-size: 16px; margin-bottom: 14px; }
dialog .botones { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

@media (max-width: 760px) {
  #sidenav { position: static; width: auto; border-right: none; border-bottom: 1px solid var(--border); }
  #app { flex-direction: column; }
  #app.con-nav #main { margin-left: 0; }
  #main { padding: 16px 14px 60px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* --- ficha de programa: pestañas y filas editables --- */
.pestanas { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: -4px 0 16px; flex-wrap: wrap; }
.pestanas [role="tab"] {
  background: none; border: none; border-bottom: 2px solid transparent; border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  padding: 8px 14px; color: var(--dim);
}
.pestanas [role="tab"]:hover { color: var(--fg); background: var(--panel2); }
.pestanas [role="tab"][aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); font-weight: 600; }
.panel-pestana { outline-offset: 4px; }
.fila-editable {
  display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; padding: 12px; margin-bottom: 10px;
  background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.fila-editable > button { margin-bottom: 12px; }
.fila-editable input, .fila-editable select { background: var(--panel); }
.fila-campos { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; flex: 1; min-width: 0; }
.fila-campos .campo { min-width: 150px; }
fieldset.dias { border: none; padding: 0; margin: 0 0 12px; display: flex; gap: 6px; flex-wrap: wrap; }
fieldset.dias legend { color: var(--dim); font-size: 12.5px; padding: 0; margin-bottom: 4px; }
label.casilla.dia {
  gap: 5px; padding: 5px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--panel);
  font-family: var(--mono); cursor: pointer;
}
label.casilla.dia:has(input:checked) { border-color: var(--accent); background: var(--sel); }
label.casilla.dia:has(input:disabled) { cursor: default; opacity: 0.7; }
.solo-lector { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.pie-ficha { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
.pie-ficha .espacio { flex: 1; }
.nota { margin-top: 16px; padding: 10px 12px; border-left: 3px solid var(--cued); background: var(--panel2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--dim); }
h2.con-margen { margin-top: 18px; }
input[role="switch"] { width: 34px; height: 18px; }

/* --- semana y estado del playout --- */
.semana { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; align-items: start; }
.semana .dia { margin-bottom: 0; }
.semana .dia h2 { text-transform: capitalize; display: flex; gap: 8px; align-items: center; }
.semana .dia h3 { font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--dim); margin: 12px 0 6px; }
.dia-lista { list-style: none; margin: 0 0 10px; padding: 0; }
.dia-lista li { padding: 5px 0; border-bottom: 1px solid #1f232b; }
.dia-lista li:last-child { border-bottom: none; }
.dia-lista li .chip { margin-left: 6px; }
.dia-lista li.es-rep { color: var(--dim); }
.dia-lista .detalle { font-size: 12px; }
.dia-lista.propuestas li { border-bottom-style: dashed; }
table.datos th { text-transform: none; letter-spacing: 0; font-size: 13px; width: 220px; border-bottom: 1px solid #1f232b; }

/* --- capítulos: filas de bloque y progreso de subida --- */
.capitulo h2 { margin: 0; }
.capitulo .fila { margin-bottom: 8px; }
.capitulo .fila .espacio, .fila .espacio { flex: 1; }
.fila-bloque {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 8px 10px; margin-top: 6px;
  background: var(--panel2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.fila-bloque strong { min-width: 74px; }
.fila-bloque input[type="file"] { width: auto; max-width: 260px; background: var(--panel); }
.fila-bloque progress { width: 160px; height: 10px; accent-color: var(--accent); }
.fila-bloque .progreso-texto { font-family: var(--mono); font-size: 12.5px; min-width: 44px; }

/* --- acabado general --- */
* { scrollbar-width: thin; scrollbar-color: #3a4250 transparent; }
body { background: radial-gradient(1200px 500px at 70% -10%, #17202f 0%, var(--bg) 60%) fixed; }
.tarjeta { box-shadow: 0 1px 0 #ffffff08 inset, 0 8px 24px #0003; }
tbody tr { transition: background-color 120ms; }
tbody tr:hover { background: #ffffff06; }
td a { font-weight: 600; text-decoration: none; }
td a:hover { text-decoration: underline; }
.cabecera h1 { font-size: 22px; letter-spacing: -0.01em; }
button.primary { box-shadow: 0 1px 0 #ffffff26 inset, 0 2px 8px #2f6fe055; }
button.danger:hover { border-color: #7d2b2e; background: #2a1719; }
#sidenav .marca { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
#sidenav .marca small { margin-top: 1px; font-size: 12px; }
.logo {
  flex: none; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; color: #fff; font-weight: 800;
  font-size: 10px; letter-spacing: 0.04em; background: linear-gradient(135deg, #4c8dff, #2f6fe0 55%, #7a5cff); box-shadow: 0 4px 14px #2f6fe066;
}
#sidenav a.item { display: flex; align-items: center; gap: 10px; position: relative; color: #c9cfda; margin-bottom: 2px; }
#sidenav a.item svg { flex: none; width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; opacity: 0.85; }
#sidenav a.item[aria-current="page"] { color: #fff; }
#sidenav a.item[aria-current="page"]::before { content: ""; position: absolute; left: -10px; top: 7px; bottom: 7px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
#sidenav .pie .avatar {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--panel3); border: 1px solid var(--border-strong);
  font-weight: 700; font-size: 12px; flex: none;
}
#sidenav .pie .quien { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; min-width: 0; }
#sidenav .pie .rol { margin-bottom: 0; }
.entrada { text-align: center; }
.entrada .logo { width: 52px; height: 52px; font-size: 14px; border-radius: 14px; margin: 0 auto 14px; }
.entrada .tarjeta { text-align: left; padding: 22px; }

/* --- parrilla semanal --- */
.pg-barra { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.pg-barra .espacio { flex: 1; }
.pg-control { display: flex; align-items: center; gap: 8px; margin: 0; white-space: nowrap; }
.pg-control select { width: auto; }
.pg-ayuda { font-size: 12.5px; margin-bottom: 12px; }
.pg-cuerpo { display: flex; gap: 14px; align-items: stretch; height: calc(100vh - 212px); min-height: 420px; }
.pg-lista {
  flex: none; width: 236px; display: flex; flex-direction: column; gap: 8px; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; min-height: 0;
}
.pg-lista-items { overflow-y: auto; min-height: 0; flex: 1; margin: 0 -4px; padding: 0 4px; }
.pg-vacio { padding: 12px 4px; }
.pg-item {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left; padding: 7px 8px; margin-bottom: 2px; background: none;
  border-color: transparent; cursor: grab; touch-action: none;
}
.pg-item:hover { background: var(--panel2); border-color: var(--border); }
.pg-item.inactivo .pg-item-nombre { color: var(--dim); }
.pg-item-texto { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.pg-item-nombre { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-item-sub { color: var(--dim); font-size: 12px; }
.pg-punto { flex: none; width: 10px; height: 10px; border-radius: 3px; background: hsl(var(--pg-h) 70% 60%); }
.pg-marca { color: var(--cued); font-size: 10px; }
.pg-caja {
  flex: 1; min-width: 0; overflow: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  position: relative; overscroll-behavior: contain;
}
.pg-rejilla { display: grid; grid-template-columns: 58px minmax(770px, 1fr); }
.pg-cabeza {
  display: grid; grid-template-columns: 58px repeat(7, minmax(110px, 1fr)); position: sticky; top: 0; z-index: 6; background: #12151b;
  border-bottom: 1px solid var(--border-strong);
}
.pg-dia { padding: 8px 10px; border-left: 1px solid var(--border); display: flex; flex-direction: column; gap: 2px; min-width: 0; align-items: flex-start; }
.pg-dia-nombre { font-weight: 600; }
.pg-dia-nombre .corto { display: none; }
.pg-dia-total { color: var(--dim); font-size: 12px; font-family: var(--mono); }
.pg-dia.hoy .pg-dia-nombre { color: var(--accent); }
.pg-horas { position: relative; }
.pg-hora { position: absolute; right: 8px; transform: translateY(-50%); font-family: var(--mono); font-size: 11px; color: var(--faint); }
.pg-hora:first-child { transform: translateY(2px); }
.pg-columnas { display: grid; grid-template-columns: repeat(7, minmax(110px, 1fr)); }
.pg-col {
  position: relative; border-left: 1px solid var(--border);
  background-image: linear-gradient(to bottom, #2b313c 1px, transparent 1px), linear-gradient(to bottom, #1c2028 1px, transparent 1px);
  background-size: 100% var(--pg-hora), 100% calc(var(--pg-hora) / 2);
}
.pg-col.hoy { background-color: #4c8dff0a; }
.pg-bloque, .pg-previa {
  position: absolute; z-index: 2; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; overflow: hidden;
  padding: 3px 6px 3px 8px; font-size: 12.5px; line-height: 1.25; color: #f2f4f8; border-radius: 6px;
  border: 1px solid hsl(var(--pg-h) 38% 36%); border-left: 3px solid hsl(var(--pg-h) 75% 62%); background: hsl(var(--pg-h) 40% 21%);
}
.pg-bloque { cursor: grab; touch-action: none; transition: background-color 120ms, box-shadow 120ms; }
.pg-bloque:hover { background: hsl(var(--pg-h) 42% 26%); border-color: hsl(var(--pg-h) 45% 46%); border-left-color: hsl(var(--pg-h) 80% 68%); z-index: 3; }
.pg-bloque:focus-visible { z-index: 4; outline: 2px solid #fff; outline-offset: 1px; }
.pg-nombre { font-weight: 600; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-horario { font-family: var(--mono); font-size: 11px; color: #ffffffb0; white-space: nowrap; }
.pg-bloque.chico { flex-direction: row; align-items: center; gap: 6px; padding-top: 0; padding-bottom: 0; font-size: 11.5px; }
.pg-bloque.chico .pg-horario { display: none; }
.pg-bloque.choque { border-color: var(--onair); border-left-color: var(--onair); box-shadow: 0 0 0 1px var(--onair) inset; }
.pg-bloque.inactivo { opacity: 0.55; }
.pg-bloque.cola { cursor: pointer; opacity: 0.7; border-top-style: dashed; border-radius: 0 0 6px 6px; }
.pg-bloque.arrastrando { z-index: 10; cursor: grabbing; opacity: 0.92; box-shadow: 0 10px 28px #000a; transition: none; }
.pg-vivo { position: absolute; top: 3px; right: 6px; font-size: 9.5px; font-weight: 800; letter-spacing: 0.06em; color: #fff; background: var(--onair); border-radius: 3px; padding: 0 4px; }
.pg-bloque.chico .pg-vivo { position: static; }
.pg-bloque.corto { border-bottom: 2px dashed var(--warn, #d9a441); }
.pg-corto { position: absolute; bottom: 3px; right: 6px; font-size: 9.5px; font-weight: 700; letter-spacing: 0.04em; color: #1b1b1b; background: var(--warn, #d9a441); border-radius: 3px; padding: 0 4px; }
.pg-bloque.chico .pg-corto { display: none; }
.pg-asa { position: absolute; left: 0; right: 0; bottom: 0; height: 7px; cursor: ns-resize; }
.pg-asa::after { content: ""; position: absolute; left: 50%; bottom: 2px; width: 22px; height: 2px; margin-left: -11px; border-radius: 2px; background: #fff6; opacity: 0; transition: opacity 120ms; }
.pg-bloque:hover .pg-asa::after, .pg-bloque.arrastrando .pg-asa::after { opacity: 1; }
.pg-previa { left: 0; width: calc(100% - 6px); z-index: 9; pointer-events: none; opacity: 0.85; border-style: dashed; border-left-style: solid; }
.pg-fantasma {
  position: absolute; left: 0; right: 0; z-index: 1; pointer-events: none; overflow: hidden; padding: 2px 6px; font-size: 11px; color: var(--dim);
  border: 1px dashed var(--border-strong); border-radius: 6px;
  background: repeating-linear-gradient(135deg, #ffffff07 0 6px, transparent 6px 12px);
}
.pg-fantasma span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-fantasma.propuesta { border-color: #7a5512; color: var(--cued); }
.pg-ahora { position: absolute; left: 0; right: 0; height: 2px; background: var(--onair); z-index: 5; pointer-events: none; }
.pg-ahora::before { content: ""; position: absolute; left: -4px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--onair); }
.pg-volando {
  position: fixed; z-index: 50; pointer-events: none; padding: 5px 10px; border-radius: 6px; font-weight: 600; font-size: 12.5px; color: #fff;
  background: hsl(var(--pg-h) 45% 28%); border: 1px solid hsl(var(--pg-h) 60% 55%); box-shadow: 0 10px 28px #000a; max-width: 240px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
body.pg-arrastrando { user-select: none; cursor: grabbing; }
body.pg-arrastrando .pg-bloque, body.pg-arrastrando .pg-item { cursor: grabbing; }

@media (max-width: 1100px) {
  .pg-dia-nombre .largo { display: none; }
  .pg-dia-nombre .corto { display: inline; }
}
@media (max-width: 760px) {
  .pg-cuerpo { flex-direction: column; height: auto; }
  .pg-lista { width: auto; max-height: 220px; }
  .pg-caja { height: 70vh; }
}

/* --- parrilla: repeticiones previstas y armado automático --- */
.pg-fantasma.estimada {
  color: hsl(var(--pg-h) 75% 80%); border-color: hsl(var(--pg-h) 55% 50%);
  background: repeating-linear-gradient(135deg, hsl(var(--pg-h) 45% 30% / 0.42) 0 6px, hsl(var(--pg-h) 45% 22% / 0.22) 6px 12px);
}
.pg-col.editable { cursor: cell; }
.pg-elegir { max-height: 230px; overflow-y: auto; margin: 10px 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); }
.pg-elegir-fila { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.pg-elegir-fila .casilla { flex: 1; min-width: 0; margin: 0; }
.pg-elegir-fila input.pg-min { width: 76px; flex: none; }

/* --- biblioteca --- */
.bib-barra { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.bib-barra input[type="search"] { flex: 1; min-width: 240px; max-width: 520px; }
.bib-barra select { width: auto; }
.bib-titulo { font-weight: 600; }
.bib-archivo { font-size: 12px; font-family: var(--mono); word-break: break-all; }
td.num { font-family: var(--mono); text-align: right; white-space: nowrap; }
.bib-mas { margin-top: 12px; }
