/* OSG Panel — tema oscuro refinado (15/08/2026).
 *
 * Sustituye al verde fosforito sobre negro. La idea: carbon en vez de negro
 * puro, tipografia de sistema en vez de monoespaciada en todo, un unico color
 * de acento (ambar) reservado para lo que de verdad importa, y separacion por
 * espacio antes que por lineas.
 *
 * Lo monoespaciado se queda SOLO donde aporta: logs, consola, rutas y cifras
 * que hay que comparar en vertical.
 *
 * Los nombres de clase que toca app.js (active, running, stopped, warn,
 * destacado, encima, box-label, player-row, descargas-*, subida, barra...) se
 * mantienen tal cual: esto es un cambio de piel, no de cableado.
 */

:root {
  --bg: #0b0d10;
  --surface: #14171c;
  --surface-2: #1a1e24;
  --surface-3: #22272f;
  --line: #262b33;
  --line-soft: #1d2128;

  --text: #e7e5e4;
  --text-2: #a1a1aa;
  --text-3: #71717a;

  --accent: #f59e0b;
  --accent-dim: rgba(245, 158, 11, 0.12);
  --accent-line: rgba(245, 158, 11, 0.35);

  --ok: #10b981;
  --bad: #ef4444;
  --bad-dim: rgba(239, 68, 68, 0.1);

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;

  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Consolas,
          "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text); text-decoration: none; }
a:hover { color: var(--accent); }

::selection { background: var(--accent-dim); }

/* --- Barra superior --------------------------------------------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(11, 13, 16, 0.82);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line-soft);
}

/* Misma caja que el contenido: sin esto la marca se pegaba al borde de la
   ventana mientras las tarjetas empezaban en el centro, y el ojo lo nota. */
.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 28px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  font-weight: 650;
  letter-spacing: 0.14em;
  font-size: 0.8rem;
  color: var(--text);
  white-space: nowrap;
}
.brand span { color: var(--accent); }

.tabs { display: flex; gap: 4px; }

/* Las pestañas de vista y los servidores comparten el estado .active porque
   app.js lo pone en los dos sitios. */
.tab {
  position: relative;
  padding: 6px 14px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.16s ease, background 0.16s ease;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab.active { color: var(--text); background: var(--surface-3); }

/* Subrayado que crece desde el centro: dice cual esta activa sin gritar. */
.tab::after {
  content: "";
  position: absolute;
  left: 50%;
  right: 50%;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  opacity: 0;
  transition: left 0.22s ease, right 0.22s ease, opacity 0.22s ease;
}
.tab.active::after { left: 14px; right: 14px; opacity: 1; }

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 20px;
}

/* Medidor de RAM del sistema, compacto y siempre visible. */
.ram-bar-container { display: flex; align-items: center; gap: 10px; }
.ram-bar-container .box-label { display: none; }

.ram-bar {
  width: 70px;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
}
.ram-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--text-2);
  border-radius: 999px;
  transition: width 0.4s ease, background 0.3s;
}
.ram-bar-fill.warn { background: var(--bad); }

#ram-text { font-size: 0.74rem; color: var(--text-3); white-space: nowrap; }

.sidebar-footer a {
  font-size: 0.8rem;
  color: var(--text-3);
}
.sidebar-footer a:hover { color: var(--accent); }

/* --- Estructura ------------------------------------------------------- */

.app { display: block; }

.main-panel {
  max-width: 1120px;
  margin: 0 auto;
  padding: 28px;
}

.panel-header {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin: 4px 0 22px;
}

.panel-header h1 {
  margin: 0;
  font-size: 1.55rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.status-text { color: var(--text-2); font-size: 0.84rem; }

/* Marcador mientras llega el dato: latido suave y puntos que avanzan, para
   que se distinga "esperando" de "vacio". */
.cargando { color: var(--text-3); animation: respirar 1.4s ease-in-out infinite; }
.cargando::after {
  content: "";
  animation: puntos 1.2s steps(4, end) infinite;
}

@keyframes respirar {
  0%, 100% { opacity: 0.45; }
  50%      { opacity: 0.9; }
}
@keyframes puntos {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
}

/* --- Selector de servidor --------------------------------------------- */

.server-list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

.server-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--text-2);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.16s ease, color 0.16s ease,
              background 0.16s ease, transform 0.16s ease;
}
.server-item:hover {
  border-color: var(--surface-3);
  color: var(--text);
  transform: translateY(-1px);
}
.server-item:active { transform: translateY(0); }

.server-item.active {
  border-color: var(--accent-line);
  background: var(--accent-dim);
  color: var(--text);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-3);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}
/* Late solo cuando esta vivo: el movimiento se reserva para lo que cambia. */
.status-dot.running {
  background: var(--ok);
  animation: latido 2.4s ease-in-out infinite;
}
.status-dot.stopped { background: var(--surface-3); animation: none; }

@keyframes latido {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45); }
  60%      { box-shadow: 0 0 0 5px rgba(16, 185, 129, 0); }
}

.nav-glyph { display: none; }
.nav-label { display: none; }

/* --- Tarjetas --------------------------------------------------------- */

.box, .card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.box-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 12px;
}

/* --- Cifras destacadas ------------------------------------------------ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  padding: 16px;
  text-align: center;
  transition: border-color 0.18s ease, transform 0.18s ease;
}
.stat:hover { border-color: var(--line); transform: translateY(-1px); }

.stat-label {
  font-size: 0.68rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
}
.stat-value {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
  transition: color 0.5s ease;
}
/* Destello corto cuando el numero cambia de verdad: el sondeo cada 3 s no
   debe parpadear si el valor es el mismo (lo decide app.js). */
.stat-value.cambiado { color: var(--accent); transition: color 0s; }

/* --- Botones ---------------------------------------------------------- */

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 24px;
}

button, .mock-button {
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 15px;
  cursor: pointer;
  display: inline-block;
  transition: background 0.14s ease, border-color 0.14s ease,
              color 0.14s ease, transform 0.1s ease;
}
button:hover, .mock-button:hover {
  background: var(--surface-3);
  border-color: var(--surface-3);
}
/* Hundir al pulsar: confirma el clic sin esperar a que responda el servidor. */
button:active, .mock-button:active { transform: translateY(1px); }

button:disabled { opacity: 0.4; cursor: default; }
button:disabled:hover { background: var(--surface-2); border-color: var(--line); }

/* El acento se reserva para la accion que de verdad quieres que se pulse. */
button.destacado, .mock-button.destacado, .descargas-boton.destacado {
  background: var(--accent);
  border-color: var(--accent);
  color: #1c1400;
  font-weight: 600;
}
button.destacado:hover, .mock-button.destacado:hover,
.descargas-boton.destacado:hover { background: #fbbf24; border-color: #fbbf24; }
button.destacado:disabled:hover { background: var(--accent); }

/* `input` a secas, no `input[type="text"]`: los campos de configuracion los
   crea app.js con createElement y sin atributo type, asi que el selector con
   atributo no los alcanzaba y salian blancos sobre el tema oscuro. */
input:not([type="file"]), select {
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.12s;
}
input:focus, select:focus { border-color: var(--accent-line); }
input::placeholder { color: var(--text-3); }

.quick-commands { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.quick-commands button {
  padding: 5px 11px;
  font-size: 0.78rem;
  font-family: var(--mono);
  color: var(--text-2);
}

.console input { margin-right: 8px; min-width: 240px; }

/* --- Texto tecnico ---------------------------------------------------- */

pre {
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.6;
  color: var(--text-2);
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--r);
  margin: 10px 0 0;
  padding: 12px 14px;
  height: 210px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

code { font-family: var(--mono); font-size: 0.78rem; }

/* La consola arranca vacia: sin esto era un agujero negro de 210 px que
   parecia un fallo de carga. Se encoge y dice para que sirve. */
#command-output { height: 130px; }
#command-output:empty::before,
#log-output:empty::before {
  content: attr(data-vacio);
  color: var(--text-3);
  font-style: italic;
}

/* --- Avisos ----------------------------------------------------------- */

.error-banner {
  color: #fca5a5;
  background: var(--bad-dim);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--r);
  padding: 11px 15px;
  margin: 0 0 18px;
  font-size: 0.85rem;
  animation: entrar-aviso 0.24s cubic-bezier(0.2, 0.8, 0.3, 1);
}

@keyframes entrar-aviso {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}

/* --- Movimiento ------------------------------------------------------- */

@keyframes aparecer {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* Al cambiar de pestaña la vista entra en vez de saltar de golpe. */
#view-servidores, #view-descargas { animation: aparecer 0.22s ease; }

/* Las tarjetas entran escalonadas: guia la mirada de arriba abajo en vez de
   soltar la pagina entera a la vez. Solo las primeras, para no alargarlo. */
.box { animation: aparecer 0.28s ease backwards; }
.box:nth-of-type(1) { animation-delay: 0.02s; }
.box:nth-of-type(2) { animation-delay: 0.05s; }
.box:nth-of-type(3) { animation-delay: 0.08s; }
.box:nth-of-type(4) { animation-delay: 0.11s; }
.stat { animation: aparecer 0.26s ease backwards; }
.stat:nth-child(2) { animation-delay: 0.04s; }
.stat:nth-child(3) { animation-delay: 0.08s; }
.stat:nth-child(4) { animation-delay: 0.12s; }

/* Nada de esto es informacion: si el sistema pide menos movimiento, fuera. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* --- Foco y barras de desplazamiento ---------------------------------- */

:focus-visible {
  outline: 2px solid var(--accent-line);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border: 3px solid var(--bg);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: #333a44; }

/* --- Login ------------------------------------------------------------ */

.login-box {
  max-width: 340px;
  margin: 16vh auto 0;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: 32px 28px;
  text-align: center;
}
.login-box h1 {
  margin: 0 0 4px;
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: 0.14em;
}
.login-box h1 span { color: var(--accent); }
.login-box .sub {
  color: var(--text-3);
  font-size: 0.8rem;
  margin: 0 0 22px;
}
.login-box form { display: flex; flex-direction: column; gap: 10px; }
.login-box button { background: var(--accent); border-color: var(--accent); color: #1c1400; font-weight: 600; padding: 9px; }
.login-box button:hover { background: #fbbf24; border-color: #fbbf24; }
.error { color: #fca5a5; font-size: 0.83rem; margin: 14px 0 0; }

/* --- Filas genericas -------------------------------------------------- */

.player-row, .schedule-row, .config-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 7px 0;
  border-top: 1px solid var(--line-soft);
  font-size: 0.85rem;
}
.player-row:first-of-type, .schedule-row:first-of-type,
.config-row:first-of-type { border-top: none; }

.player-row button, .schedule-row button, #backup-list button {
  font-size: 0.74rem;
  padding: 4px 10px;
}
.config-row label { min-width: 250px; font-size: 0.8rem; color: var(--text-2); }
.config-row input, .config-row select { width: 150px; }

#session-list, #metrics-summary {
  white-space: pre-line;
  font-size: 0.8rem;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
#drive-list div { font-size: 0.8rem; color: var(--text-2); }
#player-list, #backup-list, #whitelist-list, #schedule-list,
#action-history, #config-form { font-size: 0.85rem; }
/* Historial: columnas fijas para poder leerlo en vertical de un vistazo. */
.historial-fila {
  display: grid;
  grid-template-columns: 84px 78px 116px 1fr;
  gap: 10px;
  padding: 5px 0;
  border-top: 1px solid var(--line-soft);
  font-size: 0.76rem;
  align-items: baseline;
}
.historial-fila:first-child { border-top: none; }
.historial-fecha {
  font-family: var(--mono);
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}
.historial-servidor { color: var(--text-3); }
.historial-accion { color: var(--accent); font-weight: 500; }
.historial-detalle {
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 0.72rem;
  word-break: break-word;
}

@media (max-width: 720px) {
  .historial-fila { grid-template-columns: 1fr; gap: 1px; padding: 8px 0; }
}

/* --- Descargas -------------------------------------------------------- */

#descargas-url {
  display: block;
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--accent);
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  word-break: break-all;
}

.descargas-nota {
  font-size: 0.8rem;
  line-height: 1.6;
  color: var(--text-3);
  margin: 10px 0 0;
}
.descargas-nota strong { color: var(--text-2); font-weight: 600; }

.descargas-carpeta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 22px 0 2px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
}
.descargas-carpeta:first-child { margin-top: 0; }
.descargas-carpeta > span:first-child { flex: 1; min-width: 170px; }

.descargas-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 9px 10px;
  margin: 0 -10px;
  border-radius: var(--r-sm);
  border-bottom: 1px solid var(--line-soft);
  font-size: 0.85rem;
  transition: background 0.14s ease;
}
.descargas-row:last-child { border-bottom: none; }
/* Resaltar la fila bajo el cursor: con 10 archivos y 4 botones por linea,
   ayuda a no pulsar el boton de la fila de al lado. */
.descargas-row:hover { background: var(--surface-2); }

.descargas-nombre { flex: 1; min-width: 190px; word-break: break-all; }
.descargas-meta {
  white-space: nowrap;
  font-size: 0.78rem;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.descargas-boton {
  font-family: inherit;
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  padding: 4px 11px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.descargas-boton:hover {
  background: var(--surface-3);
  border-color: var(--surface-3);
  color: var(--text);
}

/* --- Subidas ---------------------------------------------------------- */

.subir-fila {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.subir-fila label {
  font-size: 0.7rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-3);
}

.zona-soltar {
  border: 1px dashed var(--line);
  border-radius: var(--r);
  padding: 26px 14px;
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-2);
  transition: border-color 0.14s, background 0.14s;
}
.zona-soltar .status-text {
  display: block;
  margin-top: 4px;
  font-size: 0.76rem;
  color: var(--text-3);
}
.zona-soltar.encima {
  border-color: var(--accent-line);
  border-style: solid;
  background: var(--accent-dim);
  transform: scale(1.008);
}
.zona-soltar:hover { border-color: var(--surface-3); }

.subida {
  margin-top: 14px;
  animation: aparecer 0.24s ease;
}
.subida-cabecera {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 0.84rem;
}
.subida-estado {
  white-space: nowrap;
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.barra {
  height: 3px;
  border-radius: 999px;
  background: var(--surface-3);
  overflow: hidden;
  margin-top: 7px;
}
.barra-relleno {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.25s linear;
}

/* Estado, no aviso pasajero: se queda hasta que se sincroniza. */
.sync-pendiente {
  margin: 0 0 12px;
  padding: 10px 14px;
  border: 1px solid var(--accent-line);
  border-radius: var(--r-sm);
  background: var(--accent-dim);
  color: #fcd34d;
  font-size: 0.83rem;
}

.sync-log { height: 120px; }

/* --- Pagina publica de descargas -------------------------------------- */

.publica {
  max-width: 820px;
  margin: 0 auto;
  padding: 44px 24px 60px;
}
.publica h1 {
  margin: 0 0 6px;
  font-size: 1.9rem;
  font-weight: 600;
  letter-spacing: -0.025em;
}
.publica .subtitulo {
  margin: 0 0 30px;
  color: var(--text-3);
  font-size: 0.9rem;
}

.aviso {
  border: 1px solid var(--line);
  border-left: 2px solid var(--accent);
  border-radius: var(--r);
  background: var(--surface);
  padding: 16px 18px;
  margin-bottom: 26px;
  font-size: 0.85rem;
  line-height: 1.65;
  color: var(--text-2);
}
.aviso strong { color: var(--text); font-weight: 600; }
.aviso p { margin: 0; }
.aviso p + p { margin-top: 10px; }

.carpeta-cabecera {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.carpeta-total {
  font-size: 0.76rem;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
}

.fila {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 11px 10px;
  margin: 0 -10px;
  border-radius: var(--r-sm);
  border-top: 1px solid var(--line-soft);
  font-size: 0.88rem;
  transition: background 0.14s ease;
}
.fila:first-of-type { border-top: none; }
.fila:hover { background: var(--surface-2); }
.fila-nombre { flex: 1; min-width: 200px; word-break: break-all; }
.fila-meta {
  font-size: 0.78rem;
  color: var(--text-3);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
a.descargar { text-decoration: none; }
a.descargar .mock-button { font-size: 0.78rem; padding: 5px 13px; }

.pie {
  margin-top: 38px;
  padding-top: 18px;
  border-top: 1px solid var(--line-soft);
  font-size: 0.76rem;
  color: var(--text-3);
}

/* --- Movil ------------------------------------------------------------ */

@media (max-width: 720px) {
  .topbar {
    height: auto;
    padding: 10px 16px;
    gap: 12px;
    flex-wrap: wrap;
  }
  .topbar-right { width: 100%; margin-left: 0; justify-content: space-between; }
  .main-panel { padding: 18px 16px 40px; }
  .panel-header h1 { font-size: 1.3rem; }
  .publica { padding: 28px 16px 48px; }
  .publica h1 { font-size: 1.5rem; }
  .config-row label { min-width: 0; }
  pre { height: 170px; }
}
