/* Interfaz web de Generación Scop. Misma paleta "Petróleo" que tema.py del escritorio, con
   modo claro y oscuro (sigue al sistema salvo que se elija uno con el interruptor). */

:root {
  --fondo: #F4F6F8;
  --superficie: #FFFFFF;
  --superficie-2: #EDF1F4;
  --superficie-3: #E3E9EE;
  --borde: #DDE3E8;
  --texto: #1B2430;
  --texto-tenue: #6B7A8C;
  --texto-sobre-acento: #FFFFFF;
  --acento: #00707F;
  --acento-hover: #005C69;
  --acento-suave: #DDEFF1;
  --exito: #1F9D6B;
  --aviso: #C77A0A;
  --error: #C0392B;
  --fila-procesando: #CFE2FF;
  --fila-ok: #D1E7DD;
  --fila-obs: #FFF3CD;
  --fila-error: #F8D7DA;
  --fila-gris: #E2E3E5;
  --radio: 10px;
  --radio-sm: 6px;
  --sombra: 0 1px 2px rgb(16 24 40 / 6%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fondo: #12171D;
    --superficie: #1A2027;
    --superficie-2: #222A33;
    --superficie-3: #2A333D;
    --borde: #2C3540;
    --texto: #E6EDF3;
    --texto-tenue: #8B99A8;
    --texto-sobre-acento: #0B1116;
    --acento: #2AA5B3;
    --acento-hover: #3FBCC9;
    --acento-suave: #173840;
    --exito: #35C08A;
    --aviso: #E0A030;
    --error: #E4635A;
    --fila-procesando: #1E3A56;
    --fila-ok: #1B4536;
    --fila-obs: #4A3B12;
    --fila-error: #4D2225;
    --fila-gris: #2A313A;
    --sombra: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --fondo: #12171D;
  --superficie: #1A2027;
  --superficie-2: #222A33;
  --superficie-3: #2A333D;
  --borde: #2C3540;
  --texto: #E6EDF3;
  --texto-tenue: #8B99A8;
  --texto-sobre-acento: #0B1116;
  --acento: #2AA5B3;
  --acento-hover: #3FBCC9;
  --acento-suave: #173840;
  --exito: #35C08A;
  --aviso: #E0A030;
  --error: #E4635A;
  --fila-procesando: #1E3A56;
  --fila-ok: #1B4536;
  --fila-obs: #4A3B12;
  --fila-error: #4D2225;
  --fila-gris: #2A313A;
  --sombra: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font: 14px/1.45 "Segoe UI", system-ui, -apple-system, sans-serif;
}

[hidden] { display: none !important; }
.tenue { color: var(--texto-tenue); }

/* --------------------------------------------------------------------- Estructura */

.app { display: flex; min-height: 100vh; }

.lateral {
  width: 215px;
  flex-shrink: 0;
  background: var(--superficie);
  border-right: 1px solid var(--borde);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.marca { padding: 20px 16px 16px; border-bottom: 1px solid var(--borde); }
.marca strong { display: block; font-size: 16px; }
.marca span { font-size: 12px; }

#secciones { padding: 12px 8px; display: flex; flex-direction: column; gap: 2px; }

.seccion {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-left: 3px solid transparent;
  border-radius: var(--radio-sm);
  background: transparent;
  color: var(--texto-tenue);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.seccion:hover { background: var(--superficie-2); }
.seccion.activa {
  background: var(--acento-suave);
  border-left-color: var(--acento);
  color: var(--acento);
  font-weight: 600;
}
.seccion .nombre { flex: 1; }

.insignia {
  font-size: 11px;
  font-weight: 600;
  padding: 0 7px;
  border-radius: 999px;
  line-height: 18px;
}
.insignia-ejecutando { color: var(--exito); animation: latido 1.4s ease-in-out infinite; }
.insignia-espera { background: var(--superficie-3); color: var(--aviso); }
.seccion-admin { margin-top: 12px; position: relative; }
.seccion-admin::before {
  content: ""; position: absolute; left: 8px; right: 8px; top: -7px;
  border-top: 1px solid var(--borde);
}

.cola-general {
  margin: 0 12px 12px; padding: 10px 12px; font-size: 12px;
  background: var(--superficie-2); border-radius: var(--radio-sm);
  display: flex; flex-direction: column; gap: 3px;
}
.contenido-cola { display: flex; flex-direction: column; gap: 3px; }
.titulo-cola { font-size: 10px; font-weight: 600; letter-spacing: .06em; color: var(--texto-tenue); }
.barra-cola { height: 6px; background: var(--superficie-3); border-radius: 999px; overflow: hidden; margin: 3px 0; }
.relleno-cola { height: 100%; background: var(--acento); border-radius: 999px; transition: width .3s; }
.relleno-cola.lleno { background: var(--aviso); }
.texto-espera { color: var(--aviso); font-weight: 600; }

.pie-lateral { margin-top: auto; padding: 16px; border-top: 1px solid var(--borde); }
.nota-pie { font-size: 11px; margin: 10px 0 0; }

.usuario-sesion {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--borde);
}
.datos-usuario { min-width: 0; }
.datos-usuario strong, .datos-usuario span {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.datos-usuario span { font-size: 12px; }

/* --------------------------------------------------------------------- Inicio de sesión */

.vista-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.login { width: min(380px, 100%); padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login h1 { margin: 4px 0 0; font-size: 20px; }
.marca-login { display: flex; align-items: center; gap: 12px; }
.marca-login strong { display: block; font-size: 16px; }
.marca-login span { font-size: 12px; }
.login .campo input { height: 38px; }
.ancho-completo { width: 100%; justify-content: center; height: 40px; }
.nota-login { margin: 0; font-size: 12px; text-align: center; }

.interruptor { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13px; }
.interruptor input { position: absolute; opacity: 0; pointer-events: none; }
.interruptor .pista {
  width: 32px; height: 18px; border-radius: 999px; background: var(--superficie-3);
  position: relative; transition: background .15s;
}
.interruptor .pista::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px;
  border-radius: 50%; background: var(--superficie); box-shadow: var(--sombra); transition: transform .15s;
}
.interruptor input:checked + .pista { background: var(--acento); }
.interruptor input:checked + .pista::after { transform: translateX(14px); }
.interruptor input:focus-visible + .pista { outline: 2px solid var(--acento); outline-offset: 2px; }

#contenido { flex: 1; min-width: 0; padding: 20px 24px 32px; }

.panel { display: flex; flex-direction: column; gap: 12px; max-width: 1500px; }

.cabecera h1 { margin: 0; font-size: 22px; display: flex; align-items: center; gap: 10px; }
.cabecera p { margin: 2px 0 0; }

.chip {
  font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px;
  background: var(--superficie-3); color: var(--texto-tenue);
}
.chip-ejecutando { background: var(--acento-suave); color: var(--acento); }
.chip-espera { background: var(--fila-obs); color: var(--aviso); }
.chip-completada { background: var(--fila-ok); color: var(--exito); }
.chip-error { background: var(--fila-error); color: var(--error); }

/* --------------------------------------------------------------------- Tarjetas y controles */

.tarjeta {
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
  padding: 12px 14px;
}

.titulo-tarjeta {
  margin: 0 0 10px;
  font-size: 11px;
  letter-spacing: .06em;
  color: var(--texto-tenue);
  font-weight: 600;
}
.titulo-con-accion { display: flex; justify-content: space-between; align-items: center; }
.titulo-con-accion .titulo-tarjeta { margin: 0; }

.boton {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: var(--radio-sm);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.boton:disabled { opacity: .5; cursor: not-allowed; }
.boton.principal { background: var(--acento); color: var(--texto-sobre-acento); }
.boton.principal:not(:disabled):hover { background: var(--acento-hover); }
.boton.secundario { background: var(--superficie-2); color: var(--texto); border-color: var(--borde); }
.boton.secundario:not(:disabled):hover { background: var(--superficie-3); }
.boton.peligro { background: var(--error); color: #fff; }
.boton.fantasma { background: transparent; color: var(--texto-tenue); }
.boton.fantasma:not(:disabled):hover { background: var(--superficie-2); color: var(--texto); }
.boton.pequeno { height: 26px; padding: 0 10px; font-size: 12px; }

input[type="text"], input[type="number"], input[type="password"], select {
  height: 32px;
  padding: 0 9px;
  border: 1px solid var(--borde);
  border-radius: var(--radio-sm);
  background: var(--superficie-2);
  color: var(--texto);
  font: inherit;
}
input:focus-visible, select:focus-visible, .boton:focus-visible, .seccion:focus-visible, .icono:focus-visible {
  outline: 2px solid var(--acento);
  outline-offset: 1px;
}
input.solo-lectura { color: var(--texto-tenue); background: var(--superficie); }
input[type="checkbox"] { accent-color: var(--acento); width: 16px; height: 16px; margin: 0; }

.fila-botones { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.archivo { font-size: 12px; overflow-wrap: anywhere; }

.opciones {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 22px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--borde);
}
.opcion { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.contador { width: 70px; }

/* --------------------------------------------------------------------- Panel manual */

.manual.editando { border-color: var(--acento); }
.manual.editando .titulo-tarjeta { color: var(--acento); }

.campos { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.campo { display: flex; flex-direction: column; gap: 3px; }
.campo span { font-size: 11px; color: var(--texto-tenue); }
.campo input, .campo select { width: 100%; }
.ancho-largo { width: 300px; }
.ancho-normal { width: 205px; }
.ancho-corto { width: 130px; }
.ancho-cantidad { width: 110px; }
.acciones-campos { margin-left: auto; display: flex; gap: 8px; }
.ayuda-campos, .nota { margin: 8px 0 0; font-size: 12px; color: var(--texto-tenue); }
.nota:empty { display: none; }
.nota-ok { color: var(--exito); }
.nota-error { color: var(--error); }

/* Campo con lista de sugerencias (combobox.js). La lista cuelga de <body> con posición fija
   para que ninguna tarjeta la recorte, y se ensancha hasta que cada opción se lee entera. */
.combo { position: relative; }
.combo input { width: 100%; padding-right: 26px; }
.combo-flecha {
  position: absolute; right: 1px; top: 1px; bottom: 1px; width: 24px;
  border: 0; border-radius: 0 var(--radio-sm) var(--radio-sm) 0;
  background: transparent; color: var(--texto-tenue); cursor: pointer; font-size: 13px;
}
.combo-flecha:hover { color: var(--texto); }
.combo input[readonly] + .combo-flecha { display: none; }
.combo-lista {
  position: fixed; z-index: 1000; margin: 0; padding: 4px 0; list-style: none;
  width: max-content; overflow: auto;
  background: var(--superficie); color: var(--texto);
  border: 1px solid var(--borde); border-radius: var(--radio-sm);
  box-shadow: 0 8px 24px rgb(16 24 40 / 18%);
  font-size: 13px;
}
.combo-lista li { padding: 6px 12px; cursor: pointer; white-space: normal; overflow-wrap: anywhere; }
.combo-lista li:hover, .combo-lista li.activa { background: var(--acento-suave); color: var(--acento); }
.combo-lista li.elegida { font-weight: 600; }
.combo-lista li.combo-mas { cursor: default; color: var(--texto-tenue); font-style: italic; }
.combo-lista li.combo-mas:hover { background: transparent; }
.error-texto { color: var(--error); margin: 0 12px 0 0; }

/* --------------------------------------------------------------------- Administración */

.pestanas { display: flex; gap: 4px; border-bottom: 1px solid var(--borde); }
.pestana {
  padding: 8px 16px; border: 0; border-bottom: 2px solid transparent; margin-bottom: -1px;
  background: transparent; color: var(--texto-tenue); font: inherit; font-weight: 600; cursor: pointer;
}
.pestana:hover { color: var(--texto); }
.pestana.activa { color: var(--acento); border-bottom-color: var(--acento); }
.pestana:focus-visible { outline: 2px solid var(--acento); outline-offset: -2px; }

.bloques { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
.separado { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--borde); }
.titulo-tabla { padding: 12px 14px 0; }
.sin-margen { margin-top: 0; }
.acciones-izquierda { margin-left: 0; }

.tabla-usuarios td { vertical-align: middle; }
.tabla-usuarios select { height: 28px; }
.acciones-usuario { text-align: right; display: flex; gap: 6px; justify-content: flex-end; align-items: center; }
.clave-en-linea { height: 26px !important; width: 180px; }
.usuario-inactivo td:first-child { color: var(--texto-tenue); }
.boton.peligro-texto { color: var(--error); }
.boton.peligro-texto:not(:disabled):hover { background: var(--fila-error); color: var(--error); }
.interruptor:has(input:disabled) { opacity: .5; cursor: not-allowed; }

.lista-correos { display: flex; flex-direction: column; gap: 8px; }
.lista-correos input { width: 280px; }
.etiquetas-correo { display: flex; flex-wrap: wrap; gap: 6px; }
.etiqueta-correo {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 4px 2px 10px;
  border-radius: 999px; background: var(--acento-suave); color: var(--texto); font-size: 13px;
}
.etiqueta-correo .quitar {
  border: 0; background: transparent; color: var(--texto-tenue); cursor: pointer;
  width: 20px; height: 20px; border-radius: 50%; font-size: 11px;
}
.etiqueta-correo .quitar:hover { background: var(--superficie-3); color: var(--error); }
.tipos-correo { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 12px; margin-top: 10px; }
.tipo-correo { padding: 10px 12px; border: 1px solid var(--borde); border-radius: var(--radio-sm); }
.tipo-correo h3 { margin: 0 0 8px; font-size: 13px; }

/* --------------------------------------------------------------------- Avisos */

.aviso {
  padding: 10px 14px;
  border-radius: var(--radio-sm);
  border: 1px solid var(--borde);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.aviso.espera { background: var(--fila-obs); border-color: transparent; }
.aviso.error { background: var(--fila-error); border-color: transparent; }
#aviso-global { margin-bottom: 16px; }

/* --------------------------------------------------------------------- Tabla */

.tabla-contenedor { padding: 0; overflow: hidden; }
.desplazable { overflow: auto; max-height: 46vh; }

table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 6px 10px; text-align: left; border-bottom: 1px solid var(--borde); white-space: nowrap; }
td { max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
th {
  position: sticky; top: 0; z-index: 1;
  background: var(--superficie-2);
  font-size: 12px; font-weight: 600; color: var(--texto-tenue);
}
tbody tr:hover { background: var(--superficie-2); }
tbody tr { cursor: default; }

.col-estado { width: 34px; text-align: center; font-weight: 700; }
.col-acciones { width: 72px; text-align: right; }

tr.estado-procesando { background: var(--fila-procesando); }
tr.estado-procesando .col-estado { animation: latido 1.4s ease-in-out infinite; }
tr.estado-ok { background: var(--fila-ok); }
tr.estado-ok .col-estado { color: var(--exito); }
tr.estado-obs { background: var(--fila-obs); }
tr.estado-obs .col-estado { color: var(--aviso); }
tr.estado-error { background: var(--fila-error); }
tr.estado-error .col-estado { color: var(--error); }
tr.estado-omitida, tr.estado-cancelada { background: var(--fila-gris); color: var(--texto-tenue); }
tbody tr[class^="estado-"]:hover { filter: brightness(.97); }

.icono {
  border: 0; background: transparent; color: var(--texto-tenue);
  width: 26px; height: 26px; border-radius: var(--radio-sm); cursor: pointer; font-size: 14px;
}
.icono:not(:disabled):hover { background: var(--superficie-3); color: var(--texto); }
.icono:disabled { opacity: .35; cursor: not-allowed; }

.tabla-vacia { padding: 24px; text-align: center; margin: 0; }
.ayuda { margin: -4px 0 0; font-size: 12px; }

/* --------------------------------------------------------------------- Progreso y log */

.progreso { display: flex; align-items: center; gap: 12px; }
.barra { flex: 1; height: 10px; background: var(--superficie-3); border-radius: 999px; overflow: hidden; }
.relleno { height: 100%; width: 0; background: var(--acento); border-radius: 999px; transition: width .3s; }
.relleno.activa {
  background-image: linear-gradient(90deg, transparent 0 40%, rgb(255 255 255 / 25%) 50%, transparent 60% 100%);
  background-size: 200% 100%;
  animation: brillo 1.6s linear infinite;
}
.texto-progreso { min-width: 130px; text-align: right; font-variant-numeric: tabular-nums; }
.tiempo { min-width: 200px; text-align: right; font-variant-numeric: tabular-nums; }

.log {
  margin: 10px 0 0;
  height: 220px;
  overflow: auto;
  padding: 8px 10px;
  background: var(--superficie-2);
  border-radius: var(--radio-sm);
  font: 12px/1.5 Consolas, "Cascadia Mono", monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.linea { display: flex; gap: 10px; }
.linea .hora { color: var(--texto-tenue); flex-shrink: 0; }
.nivel-ok { color: var(--exito); }
.nivel-warn { color: var(--aviso); }
.nivel-error { color: var(--error); }

@keyframes latido { 50% { opacity: .35; } }
@keyframes brillo { from { background-position: 100% 0; } to { background-position: -100% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* --------------------------------------------------------------------- Pantallas estrechas */

@media (max-width: 800px) {
  .app { flex-direction: column; }
  .lateral { width: auto; height: auto; position: static; border-right: 0; border-bottom: 1px solid var(--borde); }
  #secciones { flex-direction: row; overflow-x: auto; }
  .seccion { width: auto; border-left: 0; border-bottom: 3px solid transparent; }
  .seccion.activa { border-bottom-color: var(--acento); }
  .cola-general { display: none; }
  .pie-lateral { padding: 8px 16px; }
  .usuario-sesion { padding-bottom: 0; margin-bottom: 0; border-bottom: 0; }
  .pie-lateral .interruptor, .nota-pie { display: none; }
  #contenido { padding: 16px; }
  .ancho-largo, .ancho-normal, .ancho-corto, .ancho-cantidad { width: 100%; }
  .acciones-campos { margin-left: 0; }
  .tiempo { display: none; }
  .tipos-correo { grid-template-columns: 1fr; }
  .lista-correos input { width: 100%; }
  .acciones-usuario { flex-wrap: wrap; }
}
