/* ============================================================
 * Eligentia · treeview.css
 *
 * Estilos compartidos del componente TreeView (treeview.js).
 * Usado por proyectos.html (mode='proyecto') y plantillas.html
 * (mode='plantilla'). El CSS está duplicado inline en proyectos.html
 * por compatibilidad legacy; este archivo es la fuente única para
 * cualquier página nueva que monte el TreeView.
 *
 * Convenciones:
 *   .treeview-root      → wrapper donde se monta el componente
 *   .tv-header          → barra superior con picker + botones
 *   .tv-container       → contenedor de la lista de nodos
 *   .tv-node            → un nodo (li)
 *   .tv-row             → fila visible del nodo (grid)
 *   .tv-act             → botón de acción de la toolbar
 *   .tv-modal*          → modal del nodo (#31)
 *   .tv-badge*          → indicadores 📅 📝 (#31)
 * ============================================================ */

.treeview-root { padding: 18px 24px 40px; }

.tv-header {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 14px; margin-bottom: 14px;
  background: #fff; border: 1px solid #e6e3da; border-radius: 8px;
}
.tv-picker-label { font-weight: 600; color: #555; font-size: 13px; }
.tv-picker {
  flex: 1 1 320px; min-width: 240px;
  padding: 7px 10px; border: 1px solid #ccc; border-radius: 6px;
  font-size: 14px; background: #fff;
}
.tv-btn {
  padding: 7px 14px; border: 1px solid #d0cabe; background: #fafaf6;
  border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer;
  color: #2c2c2a;
}
.tv-btn:hover:not(:disabled) { background: #f0ede2; }
.tv-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.tv-btn--primary {
  background: #534AB7; color: #fff; border-color: #534AB7;
}
.tv-btn--primary:hover:not(:disabled) { background: #4338a0; }
.tv-btn--danger {
  background: #fff5f5; color: #b02a37; border-color: #f5c2c2;
}
.tv-btn--danger:hover:not(:disabled) { background: #fde8e8; }
.tv-spacer { flex: 1; }

.tv-msg {
  padding: 8px 12px; margin-bottom: 10px; border-radius: 6px;
  font-size: 13px;
}
.tv-msg.is-ok { background: #e6f4ee; color: #1c6b4d; border: 1px solid #b3dfca; }
.tv-msg.is-error { background: #fde8e8; color: #8a1f1f; border: 1px solid #f5c2c2; }

.tv-empty {
  padding: 60px 32px; text-align: center; color: #888;
  background: #fff; border: 1px dashed #d0cabe; border-radius: 8px;
  font-size: 14px;
}
.tv-container { background: #fff; border: 1px solid #e6e3da; border-radius: 8px; padding: 6px 0; }
.tv-list { list-style: none; padding: 0; margin: 0; }
.tv-list--children {
  background: rgba(83, 74, 183, 0.03);
  border-left: 2px solid rgba(83, 74, 183, 0.18);
  margin-left: 28px;
}
.tv-node { border-bottom: 1px solid #f0eee6; }
.tv-node:last-child { border-bottom: 0; }

.tv-row {
  display: grid;
  grid-template-columns: 50px 24px 36px 56px 1fr auto auto;
  align-items: center; gap: 10px;
  padding: 8px 14px; font-size: 13.5px;
  transition: background 0.1s;
  cursor: pointer;
}
.tv-row:hover { background: rgba(83, 74, 183, 0.05); }

.tv-node--plt > .tv-row {
  background: rgba(29, 158, 117, 0.04);
  grid-template-columns: 50px 24px 28px 1fr auto auto auto;
  font-weight: 600;
}
.tv-node--title > .tv-row, .tv-node--subtitle > .tv-row {
  grid-template-columns: 50px 24px 24px 1fr auto auto;
}

.tv-num {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11.5px; font-weight: 700; color: #888;
  text-align: right; padding-right: 4px;
}
.tv-toggle {
  width: 22px; height: 22px; border: 0; background: transparent;
  cursor: pointer; color: #534AB7; font-size: 13px;
  border-radius: 4px;
}
.tv-toggle:hover { background: rgba(83, 74, 183, 0.12); }
.tv-toggle-spacer { display: inline-block; width: 22px; }
.tv-icon { font-size: 18px; }
.tv-block-tag {
  display: inline-block; padding: 2px 6px; border-radius: 4px;
  color: #fff; font-size: 10px; font-weight: 800; text-align: center;
  letter-spacing: 0.04em;
}
.tv-clave {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11.5px; font-weight: 700; color: #4c3fa3;
}
.tv-titulo { color: #1a1a1a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-meta { color: #888; font-size: 11.5px; font-weight: 500; }
.tv-desc { color: #777; font-size: 11.5px; max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-node--plt.is-collapsed > .tv-row .tv-toggle { color: #888; }

/* Toolbar por nodo (#30) — siempre visible, hover boost (#51) */
.tv-actions {
  display: inline-flex;
  gap: 2px;
  opacity: 0.55;
  transition: opacity 0.15s;
}
.tv-row:hover .tv-actions { opacity: 1; }
@media (hover: none) { .tv-actions { opacity: 1; } }

.tv-act {
  border: 1px solid transparent;
  background: transparent;
  width: 24px; height: 24px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  color: #555;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0;
}
.tv-act:hover {
  background: rgba(83, 74, 183, 0.10);
  border-color: rgba(83, 74, 183, 0.30);
  color: #534AB7;
}
.tv-act--danger:hover {
  background: rgba(220, 53, 69, 0.12);
  border-color: rgba(220, 53, 69, 0.35);
  color: #b02a37;
}

/* Títulos y subtítulos del árbol */
.tv-node--title > .tv-row {
  background: #f5f1ff;
  border-left: 3px solid #534AB7;
}
.tv-node--title .tv-titulo--label {
  font-weight: 700;
  font-size: 14px;
  color: #2c2456;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.tv-node--subtitle > .tv-row {
  background: rgba(83, 74, 183, 0.04);
  border-left: 3px solid #8b80d8;
}
.tv-node--subtitle .tv-titulo--label {
  font-weight: 600;
  font-size: 13px;
  color: #4c3fa3;
}
.tv-title-icon {
  color: #534AB7;
  font-size: 14px;
}
.tv-node--subtitle .tv-title-icon { color: #8b80d8; font-size: 12px; }

/* Modal por nodo (#31) */
.tv-modal {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}
.tv-modal[hidden] { display: none !important; }
.tv-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(20, 18, 40, 0.55);
  backdrop-filter: blur(2px);
}
.tv-modal-box {
  position: relative;
  width: min(680px, calc(100vw - 32px));
  max-height: calc(100vh - 64px);
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.tv-modal-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #534AB7 0%, #4338a0 100%);
  color: #fff;
}
.tv-modal-icon { font-size: 20px; flex: 0 0 24px; }
.tv-modal-num {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px; font-weight: 700; opacity: 0.85;
}
.tv-modal-title {
  flex: 1; font-weight: 600; font-size: 15px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tv-modal-x {
  background: rgba(255,255,255,0.15);
  color: #fff; border: 0;
  width: 28px; height: 28px;
  border-radius: 6px; cursor: pointer;
  font-size: 14px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.tv-modal-x:hover { background: rgba(255,255,255,0.28); }
.tv-modal-body {
  padding: 18px 22px;
  overflow-y: auto;
  flex: 1;
}
.tv-modal-row { margin-bottom: 16px; }
.tv-modal-row label {
  display: block;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #555;
  margin-bottom: 6px;
}
.tv-modal-row input[type="text"],
.tv-modal-row input[type="date"],
.tv-modal-row textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
  box-sizing: border-box;
}
.tv-modal-row input:focus,
.tv-modal-row textarea:focus {
  outline: 2px solid #534AB7;
  outline-offset: -1px;
  border-color: #534AB7;
}
.tv-modal-row textarea {
  min-height: 180px;
  max-height: 50vh;
  resize: both;
  overflow: auto;
  white-space: pre;
  line-height: 1.5;
}
.tv-modal-row--fechas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.tv-modal-fld label { margin-bottom: 4px; }
.tv-modal-err {
  padding: 8px 12px;
  background: #fde8e8;
  color: #8a1f1f;
  border: 1px solid #f5c2c2;
  border-radius: 6px;
  font-size: 13px;
  margin-top: 4px;
}
.tv-modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 22px;
  border-top: 1px solid #eee;
  background: #fafaf6;
}

/* Badges 📅 📝 🎯 en cada fila */
.tv-meta-badges {
  display: inline-flex; gap: 4px;
  align-items: center;
}
.tv-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  font-size: 12px;
  background: rgba(83, 74, 183, 0.10);
  cursor: help;
}
.tv-badge--fechas  { background: rgba(14, 124, 201, 0.14); }
.tv-badge--nota    { background: rgba(29, 158, 117, 0.14); }
.tv-badge--pruebas { background: rgba(186, 117, 23, 0.14); width: auto; min-width: 22px; padding: 0 6px; font-weight: 700; }
.tv-badge--pruebas sub { font-size: 9px; margin-left: -2px; }

/* Selector de pruebas en modal (#49) */
.tv-pruebas-loading,
.tv-pruebas-none,
.tv-pruebas-err {
  padding: 12px 14px;
  background: #f7f5ef;
  border: 1px dashed #d0cabe;
  border-radius: 6px;
  font-size: 13px;
  color: #777;
  line-height: 1.5;
}
.tv-pruebas-err {
  background: #fde8e8; color: #8a1f1f; border-color: #f5c2c2; border-style: solid;
}
.tv-pruebas-locked {
  padding: 14px 16px;
  background: linear-gradient(135deg, #ede9ff 0%, #fff4cf 100%);
  border: 1px solid #c9c0ee;
  border-radius: 8px;
  font-size: 13.5px;
  color: #2c2456;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.tv-pruebas-link {
  color: #534AB7; font-weight: 700; text-decoration: none;
  padding: 4px 10px; border: 1px solid #534AB7; border-radius: 6px;
}
.tv-pruebas-link:hover { background: rgba(83, 74, 183, 0.08); }
.tv-pruebas-hint {
  margin: 0 0 8px;
  font-size: 12.5px;
  color: #666;
  font-weight: 500;
}
.tv-pruebas-list {
  list-style: none; padding: 0; margin: 0 0 12px;
  max-height: 200px; overflow-y: auto;
  border: 1px solid #e5e2da; border-radius: 6px;
  background: #fafaf6;
}
.tv-pruebas-list li {
  border-bottom: 1px solid #efece4;
}
.tv-pruebas-list li:last-child { border-bottom: 0; }
.tv-pruebas-item {
  display: grid;
  grid-template-columns: 18px 1fr;
  align-items: start; gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.1s;
}
.tv-pruebas-item:hover { background: #f3efe5; }
.tv-pruebas-checkbox { margin: 4px 0; }
.tv-pruebas-name {
  font-weight: 600; color: #2c2c2a;
  display: block; font-size: 13px;
  line-height: 1.3;
}
.tv-pruebas-meta {
  display: block;
  font-size: 11px; color: #888;
  margin-top: 2px;
}
.tv-pruebas-select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-family: inherit; font-size: 14px;
  background: #fff;
}
.tv-pruebas-select:focus { outline: 2px solid #534AB7; border-color: #534AB7; }
/* #60: Bloque "¿qué incluir en el reporte?" — checkboxes gráfico/datos + radio formato */
.tv-pruebas-incluir {
  margin-top: 12px;
  padding: 12px 14px;
  background: rgba(83, 74, 183, 0.05);
  border: 1px solid rgba(83, 74, 183, 0.20);
  border-radius: 6px;
}
.tv-pruebas-incluir-header {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #4c3fa3;
  margin-bottom: 8px;
}
.tv-pruebas-tabs {
  display: flex; gap: 18px; flex-wrap: wrap;
  margin-bottom: 4px;
}
.tv-pruebas-tab {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: #2c2456;
  cursor: pointer;
  font-weight: 500;
}
.tv-pruebas-tab input { margin: 0; }

.tv-pruebas-formato {
  margin-top: 10px;
  padding: 8px 10px 6px;
  background: rgba(255,255,255,0.6);
  border-radius: 4px;
}
.tv-pruebas-formato[hidden] { display: none; }
.tv-pruebas-formato-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #666;
  margin-bottom: 6px;
}
.tv-pruebas-radio {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 4px 0;
  font-size: 12.5px;
  color: #333;
  cursor: pointer;
}
.tv-pruebas-radio input {
  margin: 3px 0 0;
  flex: 0 0 14px;
}
.tv-pruebas-radio span { line-height: 1.4; }
.tv-pruebas-formato-hint {
  margin: 6px 0 0;
  font-size: 11px;
  color: #888;
  font-style: italic;
  line-height: 1.4;
}
