/* ---------- Historial: panel lateral, diálogo de versión, papelera y copias ---------- */

/* Los dos paneles laterales (Exportar e Historial) se excluyen, pero por si acaso cada uno tiene su columna. */
@media (min-width: 761px) {
  .layout { grid-template-columns: 350px 1fr auto auto; }
}

.histpanel {
  width: 360px; display: flex; flex-direction: column; min-height: 0;
  background: var(--panel); border-left: 1px solid var(--border);
}
.hist-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 12px 10px 16px; }
.hist-save {
  display: grid; gap: 6px; padding: 10px 12px 12px 16px;
  background: var(--panel-2); border-top: 1px solid var(--border);
}
.hist-save .in { height: 32px; }
.hist-save-actions { display: flex; justify-content: flex-end; gap: 6px; }
.hist-scroll { flex: 1; min-height: 0; overflow-y: auto; border-top: 1px solid var(--border); padding: 8px 8px 16px; }

/* Línea de tiempo: una línea vertical une las marcas de cada elemento. */
.hist-list { list-style: none; margin: 0; padding: 0; }
.hist-row { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; }
.hist-row::before {
  content: ""; position: absolute; left: 19px; top: 0; bottom: 0; width: 2px; background: var(--border);
}
.hist-row:first-child::before { top: 18px; }
.hist-row:last-child::before { bottom: auto; height: 18px; }
.hist-row:only-child::before { display: none; }
.hist-item {
  display: flex; align-items: flex-start; gap: 10px; width: 100%; min-width: 0;
  padding: 8px; border: 0; border-radius: 8px; background: transparent; color: inherit; text-align: left;
}
.hist-item:hover { background: var(--row-hover); }
.hist-mark {
  position: relative; z-index: 1; flex: none; display: grid; place-items: center;
  width: 24px; height: 24px; margin-top: -2px; border-radius: 50%; background: var(--panel);
}
.hist-item:hover .hist-mark { background: var(--row-hover); }
.hist-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--panel); border: 2px solid var(--border-strong); }
.group.current .hist-dot { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.mark .hist-mark svg { width: 15px; height: 15px; color: var(--accent); fill: var(--accent-soft); }
.mark:not(.manual) .hist-mark svg { color: var(--muted); fill: var(--panel-2); }
.start .hist-mark svg { width: 15px; height: 15px; color: var(--muted); }
.hist-body { flex: 1; min-width: 0; display: grid; gap: 3px; }
.hist-title { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-weight: 600; overflow-wrap: anywhere; }
.start .hist-title { color: var(--muted); }
.hist-meta { display: flex; align-items: center; gap: 6px; min-width: 0; color: var(--muted); font-size: 12px; }
.hist-meta-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-avs { display: flex; flex: none; padding-left: 4px; }
.hist-av { width: 18px; height: 18px; font-size: 8.5px; margin-left: -4px; box-shadow: 0 0 0 1.5px var(--panel); }
.hist-av.more { font-size: 8px; }
.hist-chip {
  font-size: 10.5px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap;
}
.hist-chip.auto { font-weight: 600; background: var(--panel-2); color: var(--muted); border: 1px solid var(--border); }
.hist-del { width: 28px; height: 28px; margin: 6px 2px 0 0; color: var(--faint); }
.hist-del:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }
.hist-del svg { width: 15px; height: 15px; }
.hist-note {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 4px 4px 8px; padding: 12px; border-radius: 8px; color: var(--muted);
}
.hist-note.warn { background: var(--warn-soft); color: var(--warn); }
.hist-note.error { background: var(--danger-soft); color: var(--danger); }
.hist-note .spinner { width: 16px; height: 16px; }
.hist-note + .hist-row::before { top: 18px; }
.hist-more { display: flex; justify-content: center; padding: 8px 0 0; }
.hist-more:has(> [hidden]) { display: none; }

/* ---------- Diálogo de una versión ---------- */
.version-box { gap: 12px; }
.version-head { display: grid; gap: 2px; min-width: 0; }
.version-head h2 { overflow-wrap: anywhere; }
.version-preview {
  height: min(48vh, 420px); overflow: auto;
  border: 1px solid var(--border); border-radius: 10px;
  background-color: var(--panel-2);
  background-image: radial-gradient(var(--grid) 1px, transparent 1px); background-size: 16px 16px;
}
.vp-msg {
  height: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 16px; color: var(--muted); text-align: center;
}
.vp-msg.error { color: var(--danger); }
.vp-msg .spinner { width: 18px; height: 18px; }
.vp-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 100%; padding: 12px; border: 0; background: transparent; cursor: zoom-in;
}
.vp-toggle img { display: block; max-width: 100%; max-height: 100%; border-radius: 6px; box-shadow: var(--shadow); background: #fff; }
.version-preview.actual .vp-toggle { width: max-content; height: max-content; min-width: 100%; min-height: 100%; cursor: zoom-out; }
.version-preview.actual .vp-toggle img { max-width: none; max-height: none; }
.version-changes { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.version-changes:not(:has(.vchg:not([hidden]))) { display: none; }
.vchg {
  display: grid; gap: 4px; align-content: start; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--panel-2);
}
.vchg .section-title { margin: 0; }
.vchg-list { margin: 0; padding-left: 18px; display: grid; gap: 2px; }
.version-foot { flex-wrap: wrap; align-items: center; }

/* ---------- Proyectos: copias .json y papelera ---------- */
.sample-row { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
.sample-sep { color: var(--faint); }
.trash { display: grid; gap: 8px; }
.proj.trashed { border-style: dashed; background: var(--panel-2); }

@media (max-width: 1100px) {
  .histpanel { width: 340px; }
}
@media (max-width: 760px) {
  .histpanel { position: fixed; inset: 0; width: auto; z-index: 20; }
  .version-preview { height: 40vh; }
}
@media (max-width: 520px) {
  .version-foot .btn { flex: 1 1 100%; justify-content: center; }
  .version-foot .spacer { display: none; }
  .modal-box.version-box { padding: 14px 14px 16px; }
}
