/* Simusol Online — hoja de estilos común. Paleta solar cálida, light + dark automático. */

/* ---------- tokens ---------- */
:root {
  color-scheme: light dark;
  /* base */
  --bg:            #fffbf2;
  --surface:       #ffffff;
  --text:          #2d2418;
  --text-muted:    #6b5d4a;
  --border:        #e8dcc8;
  --border-strong: #9c8b70;
  /* acento solar */
  --accent:        #f59e0b;
  --accent-hover:  #d97706;
  --accent-ink:    #451a03;   /* texto sobre el acento */
  --link:          #b45309;
  --link-hover:    #92400e;
  --drop-over-bg:  #fef3c7;
  /* estados */
  --ok-bg:      #dcfce7;  --ok-text:      #14532d;
  --err-bg:     #fee2e2;  --err-text:     #991b1b;
  --warn-bg:    #ffedd5;  --warn-text:    #9a3412;
  --running-bg: #fef3c7;  --running-text: #78350f;
  /* log: oscuro en ambos temas */
  --log-bg: #171310;  --log-text: #d6d0c4;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #1c1917;
    --surface:       #292420;
    --text:          #f0e9df;
    --text-muted:    #b3a894;
    --border:        #44403a;
    --border-strong: #857a66;
    --accent:        #fbbf24;
    --accent-hover:  #f59e0b;
    --accent-ink:    #451a03;
    --link:          #fbbf24;
    --link-hover:    #fcd34d;
    --drop-over-bg:  #332810;
    --ok-bg:      #14331f;  --ok-text:      #86efac;
    --err-bg:     #3f1d1d;  --err-text:     #fca5a5;
    --warn-bg:    #3a2a10;  --warn-text:    #fcd34d;
    --running-bg: #332810;  --running-text: #fcd34d;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.55;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
.container { max-width: 1060px; margin: 0 auto; padding: 0 1.2rem; width: 100%; }
main.container { flex: 1; padding-top: 1.4rem; padding-bottom: 2rem; }
h1 { font-size: 1.45rem; margin: 0.2rem 0 0.8rem; }
h3 { margin: 1.2rem 0 0.5rem; }
a { color: var(--link); }
a:hover { color: var(--link-hover); }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.92em; }
.hint { color: var(--text-muted); font-size: 0.85rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- hero / descargas ---------- */
.hero { margin: 0.5rem 0; }
.hero h1 { font-size: 1.8rem; margin-bottom: 0.4rem; }
.hero p { margin: 0; max-width: 72ch; }
.two-col { margin-top: 1.5rem; display: grid; gap: 1.2rem; align-items: stretch; }
@media (min-width: 920px) { .two-col { grid-template-columns: 1fr 1fr; } }
.two-col .card { margin-top: 0; }
.dl-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 0.8rem; margin-top: 0.8rem;
}
a.dl {
  display: block; padding: 0.9rem 1rem; border: 1px solid var(--border-strong);
  border-radius: 10px; text-decoration: none; background: var(--bg); color: var(--text);
}
a.dl:hover { border-color: var(--accent); background: var(--drop-over-bg); color: var(--text); }
.dl-os { display: block; font-weight: 700; font-size: 1.05rem; }
.dl-sub { display: block; color: var(--text-muted); font-size: 0.8rem; margin-top: 0.15rem; }

/* ---------- header / footer ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.7rem 0;
}
.site-header .container { display: flex; align-items: baseline; gap: 0.8rem; }
.brand { text-decoration: none; color: var(--text); font-size: 1.15rem; white-space: nowrap; }
.brand:hover { color: var(--text); }
.brand b { font-weight: 700; }
.tagline { color: var(--text-muted); font-size: 0.85rem; }
@media (max-width: 560px) { .tagline { display: none; } }
.site-footer {
  margin-top: 2.5rem;
  border-top: 1px solid var(--border);
  padding: 0.9rem 0 1.4rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.site-footer p { margin: 0.25rem 0; }

/* ---------- botones y forms ---------- */
button.primary {
  margin-top: 1.2rem; padding: 0.6rem 1.4rem; font-size: 1rem; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); border: none;
  border-radius: 8px; font-weight: 600;
}
button.primary:hover { background: var(--accent-hover); }
button.primary:disabled { opacity: 0.55; cursor: not-allowed; }
a.btn {
  display: inline-block; margin-top: 1rem; padding: 0.5rem 1.1rem;
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
  text-decoration: none; border-radius: 8px;
}
a.btn:hover { background: var(--accent-hover); color: var(--accent-ink); }
button.linklike {
  background: none; border: none; color: var(--link); text-decoration: underline;
  cursor: pointer; font-size: inherit; padding: 0; font-family: inherit;
}
button.linklike:hover { color: var(--link-hover); }
label { display: block; margin: 0.8rem 0 0.3rem; font-weight: 600; }
select {
  width: 100%; padding: 0.45rem; border: 1px solid var(--border-strong);
  border-radius: 6px; background: var(--surface); color: var(--text); font: inherit;
}

/* ---------- cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 1rem 1.2rem; margin-top: 1.5rem;
}
.card h3 { margin-top: 0; }

/* ---------- dropzone compartida (index + Iterar) ---------- */
.drop {
  border: 2px dashed var(--border-strong); border-radius: 10px;
  padding: 1.4rem 1.2rem; text-align: center; color: var(--text-muted);
  margin: 0.6rem 0; cursor: pointer;
}
.drop.over { border-color: var(--accent); background: var(--drop-over-bg); color: var(--text); }
.file-list { list-style: none; margin: 0.6rem 0 0; padding: 0; }
.file-list li {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.25rem 0.2rem; border-bottom: 1px dotted var(--border);
  font-size: 0.92rem;
}
.file-list li:last-child { border-bottom: none; }
.file-list .fsize { color: var(--text-muted); font-size: 0.8rem; margin-left: auto; }
.file-list button {
  background: none; border: none; color: var(--err-text); cursor: pointer;
  font-size: 1rem; padding: 0 0.3rem; line-height: 1;
}

/* ---------- banners de estado ---------- */
#status { padding: 0.6rem 1rem; border-radius: 8px; font-weight: 600; }
.running { background: var(--running-bg); color: var(--running-text); }
.done { background: var(--ok-bg); color: var(--ok-text); }
.error, .timeout, .failed { background: var(--err-bg); color: var(--err-text); }
.banner-warn {
  background: var(--warn-bg); color: var(--warn-text);
  padding: 0.5rem 0.9rem; border-radius: 8px; font-size: 0.9rem; margin-top: 0.6rem;
}

/* ---------- log plegable ---------- */
.logbox { margin: 1rem 0; }
.logbox summary {
  cursor: pointer; font-weight: 600; padding: 0.35rem 0.2rem;
  color: var(--text); user-select: none;
}
pre#log {
  background: var(--log-bg); color: var(--log-text); padding: 1rem;
  border-radius: 8px; max-height: 320px; overflow: auto; font-size: 0.8rem;
  white-space: pre-wrap; margin: 0.3rem 0 0;
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
}

/* ---------- resultados / gráficos / lightbox ---------- */
.imgs { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0.8rem; }
.imgs .thumb {
  background: none; border: none; padding: 0; cursor: zoom-in; display: block;
}
.imgs img {
  display: block; width: 100%; background: #fff; padding: 0.5rem;
  border: 1px solid var(--border); border-radius: 8px;
}
.files { margin-top: 0.6rem; }
.files a { display: inline-block; margin-right: 1rem; }

/* --- gráficos interactivos (uPlot) --- */
.imgs .chartfig {
  grid-column: 1 / -1;   /* cada figura interactiva ocupa la fila completa */
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 0.6rem 0.8rem;
}
.chartbox { width: 100%; }
.chartbox + .chartbox { margin-top: 0.4rem; }
/* leyenda de uPlot: legible en claro y oscuro, series clickeables para togglear */
.u-legend { font: 0.8rem system-ui, sans-serif; color: var(--text); }
.u-legend .u-label { cursor: pointer; }
.u-legend th { font-weight: 600; }
.u-axis { color: var(--text-muted); }
.u-title { color: var(--text); }
dialog#lightbox {
  border: none; border-radius: 10px; padding: 1rem;
  max-width: 92vw; max-height: 92vh; background: #fff;
}
dialog#lightbox::backdrop { background: rgba(0, 0, 0, 0.72); }
#lightbox img { max-width: 100%; max-height: 82vh; display: block; }
#lightboxClose {
  position: absolute; top: 0.4rem; right: 0.5rem;
  background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #444;
}

/* ---------- iterar / modo vivo ---------- */
#liveRow { margin-top: 0.6rem; }
#liveRow button { padding: 0.4rem 0.9rem; cursor: pointer; background: var(--surface);
                  color: var(--text); border: 1px solid var(--border-strong);
                  border-radius: 8px; font: inherit; }
#liveRow button:hover { border-color: var(--accent); }
#liveStatus { font-weight: 600; color: var(--ok-text); margin-right: 0.6rem; }
#pendingNote { color: var(--warn-text); font-size: 0.85rem; margin-left: 0.4rem; }

/* ---------- galería de ejemplos ---------- */
.gallery {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.8rem; margin-top: 0.6rem;
}
.gallery form { margin: 0; }
.gallery button {
  width: 100%; height: 100%; text-align: left; padding: 0.7rem 0.9rem; cursor: pointer;
  border: 1px solid var(--border); border-radius: 10px; background: var(--bg);
  color: var(--text); font: inherit;
}
.gallery button:hover { border-color: var(--accent); background: var(--drop-over-bg); }
.gallery .ex-title { display: block; font-weight: 600; margin-bottom: 0.2rem; }
.gallery .ex-desc { display: block; color: var(--text-muted); font-size: 0.8rem; }

/* ---------- página de error ---------- */
.error-page { text-align: center; margin-top: 3rem; }
.error-page .code { font-size: 3rem; font-weight: 700; color: var(--err-text); }

/* ---------- feedback de envío ---------- */
.spinner {
  display: inline-block; width: 1em; height: 1em; vertical-align: -0.15em;
  border: 2px solid var(--border); border-top-color: var(--accent-ink);
  border-radius: 50%; animation: spin 0.8s linear infinite; margin-right: 0.4em;
}
@keyframes spin { to { transform: rotate(360deg); } }
