/* ===========================================================
   flujo.css — Flujo operativo de Claudia (#/flujo)
   Diagrama del proceso real + panel de Variables de operación.
   Estilo Altto (navy/azure), sin emoji; tokens de main.css →
   se adapta solo a claro/oscuro.
   =========================================================== */

/* Tokens de semáforo — también los consume visitas.css (no mover). */
:root {
  --sem-verde: #10b981;
  --sem-amber: #c98a16;
  --sem-red:   #b42318;
}
:root[data-theme="dark"], .theme-dark {
  --sem-verde: #34d399;
  --sem-amber: #e0a53a;
  --sem-red:   #f87171;
}

#view-flujo .view-body { padding: 18px 20px 48px; overflow-y: auto; }
.fl-loading, .fl-empty { color: var(--fg-muted); padding: 28px; text-align: center; }

/* ---- layout: diagrama + panel lateral ---- */
.fj-layout {
  display: grid; grid-template-columns: minmax(0, 1fr) 340px;
  gap: 22px; max-width: 1240px; margin: 0 auto; align-items: start;
}
.fj-main { min-width: 0; }
.fj-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 8px; }
.fj-side-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; color: var(--fg-subtle); padding: 2px 2px 0;
}

/* ---- cabecera del diagrama (KPIs compactos) ---- */
.fd-head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin-bottom: 14px; font-size: 13px; color: var(--fg-muted);
}
.fd-head-kpi b { font-size: 16px; color: var(--fg); font-weight: 750; }
.fd-head-kpi.is-red b { color: var(--sem-red); }
.fd-head-kpi.is-amber b { color: var(--sem-amber); }
.fd-head-hint { margin-left: auto; font-size: 12px; color: var(--fg-subtle); }

/* ---- flujo vertical ---- */
.fd-flow { display: flex; flex-direction: column; align-items: stretch; }

.fd-node {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-elev); padding: 12px 16px; box-shadow: var(--shadow-sm);
}
.fd-node-title { font-size: 13.5px; font-weight: 700; color: var(--fg); }
.fd-node-sub { font-size: 12px; color: var(--fg-muted); line-height: 1.45; margin-top: 3px; }
.fd-node-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.fd-start {
  border-radius: 999px; text-align: center;
  border-color: var(--accent); background: var(--accent-soft);
}
.fd-start .fd-node-title { color: var(--accent); }

/* Decisiones: glifo de rombo + ramas internas etiquetadas */
.fd-diamond {
  width: 10px; height: 10px; background: var(--accent);
  transform: rotate(45deg); border-radius: 2px; flex: none;
}
.fd-decision { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.fd-branch {
  display: flex; align-items: flex-start; gap: 10px; margin-top: 10px;
  padding: 9px 12px; border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm); background: var(--bg-alt);
}
.fd-branch-tag {
  flex: none; font-size: 11px; font-weight: 750; text-transform: uppercase;
  letter-spacing: .05em; color: var(--accent); background: var(--accent-soft);
  border-radius: 999px; padding: 2px 9px; margin-top: 1px;
}
.fd-branch-body { font-size: 12px; color: var(--fg-muted); line-height: 1.5; }
.fd-branch-body b { color: var(--fg); }

/* Gates (reglas duras que cortan el flujo) */
.fd-gate { border-left: 3px solid var(--warn); }
.fd-gate-tag {
  flex: none; font-size: 10.5px; font-weight: 800; letter-spacing: .08em;
  color: var(--warn-fg); background: var(--warn-soft);
  border-radius: 4px; padding: 2px 7px;
}
.fd-gate-badge {
  font-size: 11px; font-weight: 700; color: var(--warn-fg);
  background: var(--warn-soft); border: 1px solid var(--warn);
  border-radius: 999px; padding: 1px 8px;
}

/* Perfilado VEN/COM */
.fd-perfil { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 9px; }
.fd-perfil-col {
  font-size: 12px; color: var(--fg-muted); line-height: 1.5;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-alt);
}
.fd-tipo-chip {
  display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: .05em;
  border-radius: 4px; padding: 1px 6px; margin-right: 6px; color: #fff;
}
.fd-tipo-ven { background: #2ba396; }
.fd-tipo-com { background: #8b78d0; }

/* Conector vertical con flecha (y etiqueta opcional) */
.fd-link {
  position: relative; height: 26px; margin: 0 auto; width: 2px;
  background: var(--line-strong);
  display: flex; align-items: center;
}
.fd-link::after {
  content: ""; position: absolute; left: 50%; bottom: -1px;
  transform: translateX(-50%);
  border-top: 6px solid var(--line-strong);
  border-left: 5px solid transparent; border-right: 5px solid transparent;
}
.fd-link-lbl {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--fg-subtle); white-space: nowrap;
  background: transparent;
}

/* Bandas de etapas */
.fd-band {
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--bg-elev) 55%, var(--bg-alt));
  padding: 12px 14px 14px; display: flex; flex-direction: column;
}
.fd-band-title {
  font-size: 11px; font-weight: 750; text-transform: uppercase;
  letter-spacing: .08em; color: var(--fg-subtle); margin-bottom: 10px;
}
.fd-band .fd-link { height: 16px; }
.fd-band-humana { border-style: dashed; }
.fd-band-final { gap: 10px; }

/* Nodo de etapa (clickable → drill-down) */
.fd-stage {
  display: grid; grid-template-columns: 12px auto auto auto 1fr; gap: 10px;
  align-items: center; text-align: left; width: 100%;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-elev); cursor: pointer;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.fd-stage:hover { border-color: var(--stage-color, var(--line-strong)); box-shadow: var(--shadow-sm); }
.fd-stage.is-active {
  border-color: var(--stage-color, var(--accent));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--stage-color, var(--accent)) 24%, transparent);
}
.fd-stage-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--stage-color, var(--accent)); flex: none;
}
.fd-stage-name { font-size: 13px; font-weight: 700; color: var(--fg); white-space: nowrap; }
.fd-stage-count {
  font-size: 13px; font-weight: 750; color: var(--fg);
  background: var(--bg-alt); border-radius: 999px; padding: 1px 9px;
  font-variant-numeric: tabular-nums;
}
.fd-stage-alert {
  font-size: 11px; font-weight: 750; color: #fff; background: var(--sem-red);
  border-radius: 999px; padding: 1px 7px;
}
.fd-stage-note {
  font-size: 11.5px; color: var(--fg-muted); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; justify-self: end; text-align: right;
}

/* Loop de fechas (anidado en Pre-Visita) */
.fd-loop {
  margin: 8px 0 0 22px; padding: 10px 12px;
  border: 1px dashed color-mix(in srgb, var(--accent) 45%, var(--line-strong));
  border-radius: var(--radius); background: var(--bg-elev);
}
.fd-loop-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 700; color: var(--fg);
}
.fd-loop-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.fd-loop-row {
  font-size: 12px; color: var(--fg-muted); line-height: 1.45;
  padding: 6px 9px; border-radius: var(--radius-sm); border: 1px solid transparent;
}
.fd-loop-row.is-now {
  border-color: var(--accent); background: var(--accent-soft); color: var(--fg);
}
.fd-loop-tag {
  display: inline-block; font-size: 10.5px; font-weight: 750; text-transform: uppercase;
  letter-spacing: .05em; color: var(--accent); margin-right: 6px;
}
.fd-loop-live { margin-top: 8px; font-size: 11.5px; color: var(--fg-subtle); }
.fd-loop-live b { color: var(--accent); }

/* Resumen del operador (3 salidas) */
.fd-resumen { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 9px; }
.fd-res {
  font-size: 11.5px; font-weight: 650; border-radius: 999px; padding: 4px 11px;
  border: 1px solid var(--line-strong); color: var(--fg-muted); background: var(--bg-alt);
}
.fd-res-ok { border-color: color-mix(in srgb, var(--sem-verde) 50%, var(--line)); color: var(--sem-verde); }
.fd-res-no { border-color: color-mix(in srgb, var(--sem-red) 45%, var(--line)); color: var(--sem-red); }
.fd-res-re { border-color: color-mix(in srgb, var(--sem-amber) 55%, var(--line)); color: var(--sem-amber); }

/* Retorno (reactivación desde Base de Datos) */
.fd-return {
  font-size: 12px; color: var(--fg-muted); padding: 8px 12px;
  border: 1px dashed var(--line-strong); border-radius: var(--radius-sm);
  background: var(--bg-alt); margin-left: 22px;
}
.fd-return b { color: var(--accent); }

/* ---- drill-down de leads por etapa ---- */
.fd-drill { margin-top: 18px; }
.fd-drill-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.fd-drill-head h3 { font-size: 15px; font-weight: 700; color: var(--fg); display: flex; gap: 8px; align-items: center; }
.fd-drill-count {
  font-size: 12px; font-weight: 700; color: var(--accent-fg);
  background: var(--accent); padding: 1px 8px; border-radius: 999px;
}
.fd-drill-close {
  margin-left: auto; font-size: 12px; color: var(--fg-muted); background: none;
  border: 1px solid var(--line-strong); border-radius: 999px; padding: 5px 12px; cursor: pointer;
}
.fd-drill-close:hover { border-color: var(--accent); color: var(--accent); }
.fd-drill-list { display: flex; flex-direction: column; gap: 4px; }
.fd-lead {
  display: grid; grid-template-columns: 14px 64px minmax(120px, 1.2fr) 78px 1fr auto;
  align-items: center; gap: 10px; width: 100%;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--bg-elev); cursor: pointer; text-align: left; font-size: 13px;
  transition: border-color .12s var(--ease), background .12s var(--ease);
}
.fd-lead:hover { border-color: var(--line-strong); background: var(--hover); }
.fd-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.fd-dot-verde { background: var(--sem-verde); }
.fd-dot-sin_fecha, .fd-dot-sin_plan { background: var(--sem-amber); }
.fd-dot-vencido { background: var(--sem-red); }
.fd-lead-id { font-family: var(--font-mono); font-size: 12px; color: var(--fg-muted); }
.fd-lead-name { font-weight: 600; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fd-lead-tipo { font-size: 11.5px; color: var(--fg-muted); }
.fd-lead-paso { font-size: 12px; color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fd-lead-last { font-size: 12px; color: var(--fg-subtle); white-space: nowrap; }
.fd-empty { color: var(--fg-muted); padding: 16px; font-size: 13px; }

/* ---- panel: Variables de operación ---- */
.fj-card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-elev); padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.fj-card-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; color: var(--fg); margin-bottom: 6px;
}
.fj-chip-edit, .fj-chip-ro {
  font-size: 10px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em;
  border-radius: 999px; padding: 2px 8px; margin-left: auto;
}
.fj-chip-edit { color: var(--accent); background: var(--accent-soft); }
.fj-chip-ro { color: var(--fg-subtle); background: var(--bg-alt); }
.fj-card-desc { font-size: 12px; color: var(--fg-muted); line-height: 1.5; margin-bottom: 10px; }
/* .btn-sm no existe en main.css (clase marcadora): el tamaño compacto de los
   botones del panel se define aquí, scoped a las tarjetas de esta vista. */
.fj-card .btn { padding: 6px 14px; font-size: 12.5px; border-radius: 8px; }
.fj-note { font-size: 11.5px; color: var(--fg-subtle); margin-top: 8px; }
.fj-empty { font-size: 12.5px; color: var(--fg-subtle); padding: 6px 0; }

/* Modo de Claudia */
.fj-modo-val { font-size: 22px; font-weight: 750; letter-spacing: -.01em; color: var(--fg); }
.fj-modo-val.is-auto { color: var(--warn-fg); }
.fj-modo-sub { font-size: 12px; color: var(--fg-muted); margin-top: 2px; }
.fj-modo-form { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.fj-modo-form label { font-size: 11.5px; color: var(--fg-muted); }
.fj-modo-form input[type="datetime-local"] {
  padding: 7px 10px; font-size: 13px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: var(--bg); color: var(--fg);
}
.fj-modo-form-btns { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* Pausas por chat */
.fj-pausa {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-top: 1px solid var(--line);
}
.fj-pausa-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.fj-pausa-lead { font-family: var(--font-mono); font-size: 11.5px; color: var(--fg-muted); }
.fj-pausa-name { font-size: 13px; font-weight: 650; color: var(--fg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fj-pausa-until { font-size: 11.5px; color: var(--warn-fg); }
.fj-pausa .btn { margin-left: auto; flex: none; }

/* Colonias prioritarias */
.fj-colonias { display: flex; flex-wrap: wrap; gap: 6px; }
.fj-colonia {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12px; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); border-radius: 999px; padding: 4px 10px;
}
.fj-colonia-x {
  border: 0; background: none; color: var(--accent); font-size: 14px;
  line-height: 1; cursor: pointer; padding: 0 2px; border-radius: 50%;
}
.fj-colonia-x:hover { color: var(--danger); }
.fj-colonia-add { display: flex; gap: 8px; margin-top: 10px; }
.fj-colonia-add .input { flex: 1; min-width: 0; }

/* Reglas fijas (solo lectura) */
.fj-card-ro { background: color-mix(in srgb, var(--bg-elev) 60%, var(--bg-alt)); }
.fj-reglas { display: grid; gap: 2px 0; margin: 0; }
.fj-reglas dt {
  font-size: 11px; font-weight: 750; text-transform: uppercase;
  letter-spacing: .06em; color: var(--fg-subtle); margin-top: 9px;
}
.fj-reglas dd { font-size: 12.5px; color: var(--fg-muted); line-height: 1.5; margin: 1px 0 0; }

/* ---- responsive ---- */
@media (max-width: 1100px) {
  .fj-layout { grid-template-columns: 1fr; }
  .fj-side { position: static; }
}
@media (max-width: 700px) {
  #view-flujo .view-body { padding: 12px 12px 40px; }
  .fd-stage { grid-template-columns: 12px auto auto auto; }
  .fd-stage-note { display: none; }
  .fd-perfil { grid-template-columns: 1fr; }
  .fd-lead { grid-template-columns: 14px 58px 1fr auto; }
  .fd-lead-tipo, .fd-lead-paso { display: none; }
  .fd-loop, .fd-return { margin-left: 8px; }
}
