/*
GENERAR v5 — hoja de estilos base.
Reutiliza el sistema visual validado en el mockup unificado del Sprint 0
(01_documentacion/mockups_unificado.html), para mantener consistencia entre
la maqueta aprobada por el equipo y la plataforma real.
*/
:root {
  --navbar-bg: #121A1F;
  --brand-blue: #4dabf7;
  --green: #2b8a3e;
  --green-light: #d3f9d8;
  --green-medium: #69db7c;
  --orange: #e8590c;
  --orange-light: #fff4e6;
  --purple: #7048e8;
  --purple-light: #f3f0ff;
  --red: #e03131;
  --red-light: #ffe3e3;
  --danger: #e03131;
  --danger-light: #ffe3e3;
  --grey-100: #f1f3f5;
  --grey-200: #dee2e6;
  --grey-300: #ced4da;
  --grey-400: #adb5bd;
  --grey-500: #6c757d;
  --grey-600: #495057;
  --grey-800: #343a40;
  --white: #ffffff;
  --font: -apple-system, 'Segoe UI', system-ui, sans-serif;
  --radius: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 2px 8px rgba(0,0,0,0.10);
  --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: var(--font);
  background: #e9ecef;
  color: #212529;
  line-height: 1.45;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  background: var(--white);
  min-height: 100vh;
  box-shadow: var(--shadow-lg);
}

/* ================== TOP-LEVEL NAVBAR ================== */
.top-navbar {
  background: var(--navbar-bg);
  color: var(--white);
  padding: 0 18px;
  height: 42px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 11px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.top-navbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 12px;
  color: var(--white);
  white-space: nowrap;
  letter-spacing: -0.3px;
  text-decoration: none;
}
.top-navbar .nav-items {
  display: flex;
  gap: 2px;
  list-style: none;
  flex: 1;
}
.top-navbar .nav-items li a {
  display: block;
  padding: 5px 12px;
  border-radius: 5px;
  cursor: pointer;
  color: #adb5bd;
  transition: all 0.15s;
  white-space: nowrap;
  font-size: 11px;
  text-decoration: none;
}
.top-navbar .nav-items li a:hover { color: var(--white); background: rgba(255,255,255,0.06); }
.top-navbar .nav-items li a.active { color: var(--brand-blue); }
.top-navbar .badge-v5 {
  background: var(--brand-blue);
  color: var(--white);
  padding: 1px 7px;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 600;
  white-space: nowrap;
}
.top-navbar .help-icon {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--grey-800);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

/* ================== SCREENS ================== */
.screen {
  background: #e9ecef;
  padding: 20px 18px 30px 18px;
}

/* ================== PAGE HEADER ================== */
.page-header { margin-bottom: 16px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 12px; }
.page-header h1, .page-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: #212529;
  margin-bottom: 1px;
}
.page-header .subtitle {
  font-size: 10px;
  color: var(--grey-500);
}

/* ================== STAT ROW ================== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.stat-card .stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--grey-500);
  margin-bottom: 4px;
}
.stat-card .stat-value {
  font-size: 24px;
  font-weight: 700;
  color: #212529;
}

/* ================== BADGES / TAGS ================== */
.badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 8px;
  font-weight: 600;
  text-transform: uppercase;
  vertical-align: middle;
  margin-left: 6px;
}
.badge-blue   { background: #e7f5ff; color: #1971c2; }
.badge-green  { background: var(--green-light); color: var(--green); }
.badge-orange { background: var(--orange-light); color: var(--orange); }
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-red    { background: var(--red-light); color: var(--red); }
.badge-grey   { background: var(--grey-100); color: #868e96; }

.tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 8px;
  font-weight: 600;
}
.tag-blue   { background: #e7f5ff; color: #1971c2; }
.tag-green  { background: #d3f9d8; color: #2b8a3e; }
.tag-orange { background: #fff4e6; color: #e8590c; }
.tag-purple { background: #f3f0ff; color: #7048e8; }
.tag-red    { background: #ffe3e3; color: #e03131; }
.tag-grey   { background: #f1f3f5; color: #868e96; }

.tag-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 14px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--grey-100);
  color: var(--grey-600);
  margin: 2px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.tag-pill:hover { background: var(--grey-200); }
.tag-pill.active { background: var(--brand-blue); color: var(--white); }
.tag-pill.active:hover { background: #379fda; }

/* ================== CARDS ================== */
.card {
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
}
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-weight: 600;
  font-size: 12px;
  color: var(--grey-600);
}
.card.no-pad { padding: 0; overflow: hidden; }
.card-body { padding: 16px; }

/* ================== TABLES ================== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 10px;
}
table th {
  text-align: left;
  padding: 7px 8px;
  border-bottom: 2px solid var(--grey-200);
  color: var(--grey-500);
  font-weight: 600;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
table td {
  padding: 6px 8px;
  border-bottom: 1px solid #f1f3f5;
}
table tr:hover td { background: #f8f9fa; }

/* ================== BUTTONS ================== */
.btn {
  padding: 6px 13px;
  border-radius: 6px;
  border: 1px solid var(--grey-200);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  background: var(--white);
  color: var(--grey-600);
  font-family: var(--font);
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { background: var(--grey-100); }
.btn-primary {
  background: var(--brand-blue);
  color: var(--white);
  border-color: var(--brand-blue);
}
.btn-primary:hover { background: #379fda; border-color: #379fda; }
.btn-success {
  background: var(--green);
  color: var(--white);
  border-color: var(--green);
}
.btn-danger {
  background: var(--white);
  color: var(--red);
  border-color: var(--red);
}
.btn-sm { padding: 4px 9px; font-size: 9px; }

/* ================== NAV FOLDERS (carpetas del dashboard) ================== */
.nav-folder { position: relative; }

.nav-folder-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  border: 1px solid var(--grey-200);
  background: var(--white);
  color: var(--grey-600);
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.nav-folder-btn:hover { background: var(--grey-100); border-color: var(--grey-300); color: var(--grey-800); }
.nav-folder-btn:focus-visible { outline: 2px solid var(--brand-blue); outline-offset: 2px; }
.nav-folder-btn .chev { color: var(--grey-400); transition: transform 0.18s ease; }
.nav-folder[open] .nav-folder-btn { background: var(--grey-100); border-color: var(--brand-blue); color: var(--grey-800); }
.nav-folder[open] .nav-folder-btn .chev { transform: rotate(180deg); }

.nav-folder-menu {
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  min-width: 195px;
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(18, 26, 31, 0.12);
  padding: 5px;
  z-index: 40;
  opacity: 0;
  transform: translateY(-5px);
  pointer-events: none;
  transition: opacity 0.14s ease, transform 0.14s ease;
}
.nav-folder[open] .nav-folder-menu { opacity: 1; transform: translateY(0); pointer-events: auto; }

.nav-folder-item {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 5px;
  font-size: 10px;
  color: var(--grey-600);
  text-decoration: none;
  border-left: 2px solid transparent;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.nav-folder-item:hover { background: var(--grey-100); color: var(--grey-800); border-left-color: var(--brand-blue); }

@media (prefers-reduced-motion: reduce) {
  .nav-folder-menu, .nav-folder-btn .chev { transition: none; }
}

/* ================== GRAPH ================== */
.graph-placeholder {
  background: #f8f9fa;
  border: 2px dashed var(--grey-200);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--grey-400);
  font-size: 12px;
  text-align: center;
  min-height: 180px;
}
#grafo-canvas { width: 100%; min-height: 420px; background: #fafbfc; border-radius: var(--radius); }
#grafo-canvas svg { width: 100%; height: 420px; }
#timeline-canvas { width: 100%; min-height: 120px; background: #fafbfc; border-radius: var(--radius); }
#timeline-canvas svg { width: 100%; height: 120px; }
#bandas-canvas { width: 100%; min-height: 450px; background: #fafbfc; border-radius: var(--radius); }
#bandas-canvas svg { width: 100%; height: 450px; }

/* ================== DELTA VALUES ================== */
.delta-value {
  font-weight: 700;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 10px;
}
.delta-positive { color: var(--green); }
.delta-negative { color: var(--red); }
.delta-zero { color: #868e96; }

/* ================== FORM ELEMENTS ================== */
select {
  padding: 5px 10px;
  border: 1px solid var(--grey-200);
  border-radius: 6px;
  font-size: 10px;
  font-family: var(--font);
  background: var(--white);
}
.form-group { margin-bottom: 10px; }
.form-group label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  color: var(--grey-600);
  margin-bottom: 3px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--grey-200);
  border-radius: 6px;
  font-size: 13px;
  font-family: var(--font);
}
.form-group textarea { min-height: 70px; resize: vertical; }
.form-errors { color: var(--red); font-size: 11px; margin-top: 3px; }

/* ================== LAYOUT ================== */
.two-col-layout { display: grid; grid-template-columns: 1fr 300px; gap: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.grid-4 { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 12px; }

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 12px 16px;
  background: #fafbfc;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  margin-top: 12px;
  align-items: center;
}
.filter-bar .filter-label { font-size: 11px; font-weight: 600; text-transform: uppercase; color: var(--grey-500); margin-right: 8px; letter-spacing: 0.5px; }

.messages { margin-bottom: 14px; }
.messages li { list-style: none; padding: 10px 14px; border-radius: 6px; margin-bottom: 6px; font-size: 12px; }
.messages .success { background: var(--green-light); color: var(--green); }
.messages .error { background: var(--red-light); color: var(--red); }
.messages .info { background: #e7f5ff; color: #1971c2; }

/* ================== UTILITY ================== */
.text-mono { font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; font-size: 10px; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-grey { color: var(--grey-500); }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8  { margin-bottom: 8px; }
.mb-14 { margin-bottom: 14px; }
.mb-16 { margin-bottom: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.gap-8  { gap: 8px; }
.gap-10 { gap: 10px; }
hr { border: none; border-top: 1px solid var(--grey-200); margin: 20px 0; }

@media (max-width: 900px) {
  .two-col-layout { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

/* ================== TRIPLE COL / CADENA DE INTERFACES ==================
   Usadas por cadena_temporal.html y proceso_morfogenetico.html. Valores
   tomados de 01_documentacion/mockups_unificado.html para mantener la
   maqueta y la app en el mismo sistema visual. */
.triple-col { display: grid; grid-template-columns: 1fr 1.2fr 1fr; gap: 16px; margin-bottom: 20px; }
@media (max-width: 900px) {
  .triple-col { grid-template-columns: 1fr; }
}

.interface-chain { display: flex; flex-direction: column; gap: 8px; }
.interface-card {
  background: var(--white);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
  position: relative;
}
.interface-card::after {
  content: '\2193';
  position: absolute;
  bottom: -16px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--grey-400);
  font-size: 16px;
  z-index: 1;
}
.interface-card:last-child::after { display: none; }
.interface-card .iface-name { font-weight: 600; font-size: 13px; }
.interface-card .iface-meta { font-size: 11px; color: var(--grey-500); margin-top: 2px; }

/* ================== OVERLAYS (panel de activación) ================== */
.overlay-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  margin-bottom: 10px;
  background: var(--white);
  box-shadow: var(--shadow-sm);
}
.overlay-card .overlay-info { flex: 1; margin-right: 16px; }
.overlay-card .overlay-name { font-weight: 600; font-size: 14px; }
.overlay-card .overlay-desc { font-size: 12px; color: var(--grey-500); margin-top: 2px; }

/* ================== MODO FOTOGRAFÍAS / PROCESO (toggle) ================== */
.mode-toggle {
  display: flex;
  gap: 0;
  border: 1px solid var(--grey-200);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 16px;
  width: fit-content;
}
.mode-btn {
  padding: 6px 16px;
  font-size: 12px;
  cursor: pointer;
  background: var(--white);
  color: var(--grey-500);
  border: none;
  border-right: 1px solid var(--grey-200);
  transition: all 0.15s;
  font-family: var(--font);
}
.mode-btn:last-child { border-right: none; }
.mode-btn.active { background: var(--brand-blue); color: var(--white); }
.mode-btn:hover:not(.active) { background: var(--grey-100); }

/* ================== MATRIZ DE PERFORMATIVIDAD (ficha de Dispositivo) ==================
   Escala de 7 grados (C38+C39); mismos colores que performatividad_color()
   en arm/templatetags/arm_tags.py — mantener sincronizados. */
.perfo-grid {
  display: grid;
  grid-template-columns: 1.3fr repeat(7, 1fr);
  gap: 1px;
  background: var(--grey-200);
  border: 1px solid var(--grey-200);
  border-radius: var(--radius);
  overflow: hidden;
  font-size: 11.5px;
}
.perfo-cell {
  background: var(--white);
  padding: 8px 6px;
  text-align: center;
  font-weight: 500;
}
.perfo-cell.header { background: #f8f9fa; font-weight: 600; font-size: 10.5px; color: var(--grey-500); }
.perfo-cell.row-label { text-align: left; font-weight: 600; background: #fafbfc; }
.perfo-grade-ppp { background: #2b8a3e; color: white; }
.perfo-grade-pp  { background: #69db7c; color: #1a5c28; }
.perfo-grade-p   { background: #b2f2bb; color: #1a5c28; }
.perfo-grade-0   { background: #f8f9fa; color: var(--grey-500); }
.perfo-grade-m   { background: #ffc9c9; color: #862e2e; }
.perfo-grade-mm  { background: #ff8787; color: white; }
.perfo-grade-mmm { background: #c92a2a; color: white; }

/* ================== AYUDA CONTEXTUAL (C12) ================== */
.help-icon-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--grey-400);
  color: var(--white);
  font-size: 8px;
  font-weight: 700;
  margin-left: 5px;
  cursor: help;
  vertical-align: middle;
}
.help-search { width: 100%; padding: 10px 14px; border: 1px solid var(--grey-200); border-radius: 6px; font-size: 13px; margin-bottom: 16px; font-family: var(--font); }
.help-inline-entries { overflow-y: auto; }
.help-entry { padding: 12px 0; border-bottom: 1px solid var(--grey-100); }
.help-entry .term { font-weight: 700; font-size: 14px; color: #212529; }
.help-entry .def { font-size: 12.5px; color: var(--grey-600); margin-top: 4px; line-height: 1.6; }

.ayuda-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 200;
}
.ayuda-overlay[hidden] { display: none; }
.ayuda-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 380px;
  max-width: 90vw;
  height: 100vh;
  background: var(--white);
  box-shadow: var(--shadow-lg);
  z-index: 201;
  display: flex;
  flex-direction: column;
}
.ayuda-panel[hidden] { display: none; }
.ayuda-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--grey-200);
  font-size: 13px;
  flex-shrink: 0;
}
.ayuda-panel-body { padding: 16px; overflow-y: auto; flex: 1; }

/* ================== FICHA INLINE DEL GRAFO (UX ENTRAMADO) ==================
   Panel lateral que se abre al hacer clic en un nodo del grafo del dashboard.
   Reutiliza el patrón de .ayuda-panel (overlay + drawer derecho). */
.ficha-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 460px;
  max-width: 92vw;
  height: 100vh;
  background: var(--white);
  box-shadow: var(--shadow-lg);
  z-index: 201;
  display: flex;
  flex-direction: column;
}
.ficha-panel[hidden] { display: none; }
.ficha-head { border-bottom: 1px solid var(--grey-200); padding-bottom: 12px; margin-bottom: 4px; }
.ficha-titulo { font-size: 18px; font-weight: 700; margin: 0 0 6px 0; line-height: 1.25; color: #212529; }
.ficha-badges { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 10px; }
.ficha-badges .tag { font-size: 11px; padding: 3px 8px; }
.ficha-datos-clave {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 6px;
}
.ficha-dato { background: var(--grey-100); border-radius: 6px; padding: 6px 10px; }
.ficha-dato .k { display: block; font-size: 9px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--grey-500); }
.ficha-dato .v { display: block; font-size: 12.5px; font-weight: 600; color: #212529; margin-top: 1px; word-break: break-word; }

.ficha-bloque { margin: 14px 0; }
.ficha-bloque-titulo {
  display: flex; align-items: center; gap: 7px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--grey-600); margin-bottom: 6px;
}
.ficha-bloque-titulo .dot { width: 8px; height: 8px; border-radius: 2px; flex-shrink: 0; }

.ficha-fineza { background: #fff9db; border-left: 3px solid #e8a94d; border-radius: 4px; padding: 10px 12px; font-size: 12px; line-height: 1.5; }
.ficha-fineza .nivel { font-weight: 700; color: #d4950b; }
.ficha-fineza .nota { color: var(--grey-500); font-size: 11px; }

.ficha-atributos-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.ficha-atributo .k { display: block; font-size: 9px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--grey-500); }
.ficha-atributo .v { font-size: 12px; color: #212529; word-break: break-word; }
.ficha-atributo .v .tag { margin: 1px 4px 1px 0; }

.ficha-conexiones { font-size: 12px; }
.ficha-conexion { display: flex; gap: 8px; align-items: baseline; padding: 4px 0; border-bottom: 1px solid var(--grey-100); }
.ficha-conexion:last-child { border-bottom: none; }
.ficha-conexion .dir { color: var(--grey-500); font-size: 10.5px; width: 56px; flex-shrink: 0; }
.ficha-conexion a { color: var(--brand-blue); text-decoration: none; }
.ficha-conexion a:hover { text-decoration: underline; }
.ficha-conexion .peso { margin-left: auto; color: var(--grey-500); font-family: 'SF Mono','Fira Code','Consolas',monospace; font-size: 11px; }

/* Lista clave-valor (legacy, usada por otras fichas) */
.detail-list { margin: 0; }
.detail-list dt {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--grey-500);
  margin-top: 8px;
}
.detail-list dd { margin: 2px 0 0 0; font-size: 12px; }

/* ================== NOTA DE ADVERTENCIA (C14, etc.) ==================
   Usada por dispositivo_list.html; faltaba en base.css (misma regresión
   que .interface-chain/.overlay-card/.mode-toggle — clase referenciada por
   una plantilla sin su definición correspondiente). */
.repo-note { background: #fef9e7; border: 1px solid #f0e0a0; border-radius: var(--radius); padding: 12px 16px; font-size: 12.5px; color: #7d6608; }
