/* Flow Designer & Canvas Specific Styles */

/* Layout & Sidebar Navigation */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar-nav {
  width: 260px;
  background: var(--bg-glass-heavy);
  border-right: 1px solid var(--border-subtle);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-shrink: 0;
  backdrop-filter: blur(20px);
  transition: width var(--transition-normal), padding var(--transition-normal), opacity var(--transition-fast);
  position: relative;
  z-index: 100;
}

.app-layout.sidebar-collapsed .sidebar-nav {
  width: 0;
  min-width: 0;
  padding: 0;
  margin: 0;
  overflow: hidden;
  border-right: none;
  opacity: 0;
  pointer-events: none;
}

.btn-sidebar-toggle-hamburger {
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.btn-sidebar-toggle-hamburger:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-orange);
  color: var(--accent-orange);
}

.btn-open-sidebar-floating {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 99;
  background: var(--bg-glass-heavy);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  width: 38px;
  height: 38px;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.25rem;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(15px);
  transition: all var(--transition-fast);
}

.app-layout.sidebar-collapsed .btn-open-sidebar-floating {
  display: flex;
}

.btn-open-sidebar-floating:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-orange);
  color: var(--accent-orange);
  transform: scale(1.05);
}

/* Espacio reservado para las 3 rayitas cuando el menú está oculto (evita solapamientos) */
.app-layout.sidebar-collapsed .flow-toolbar {
  padding-left: 4.75rem;
}

.app-layout.sidebar-collapsed .app-header {
  padding-left: 2.75rem;
}

.app-layout.sidebar-collapsed #view-home > div:first-child,
.app-layout.sidebar-collapsed #view-architecture > div:first-child,
.app-layout.sidebar-collapsed #view-processes > div:first-child,
.app-layout.sidebar-collapsed #view-artifacts > div:first-child,
.app-layout.sidebar-collapsed #view-lineage > div:first-child,
.app-layout.sidebar-collapsed #view-security > div:first-child,
.app-layout.sidebar-collapsed #view-governance > div:first-child,
.app-layout.sidebar-collapsed #view-observability > div:first-child,
.app-layout.sidebar-collapsed #view-documentation > div:first-child,
.app-layout.sidebar-collapsed #view-exports > div:first-child,
.app-layout.sidebar-collapsed #view-settings > div:first-child {
  padding-left: 3.5rem;
}

/* Espacio reservado para el widget superior derecho de usuario logueado en todas las vistas */
#view-architecture > div:first-child > div:first-child,
#view-documentation > div:first-child > div:first-child {
  padding-right: 240px;
}

.nav-brand-group {
  padding: 0 0.25rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
}

.nav-menu-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  overflow-y: auto;
  flex: 1;
}

/* Submenú de Gobernanza */
.nav-item-group {
  display: flex;
  flex-direction: column;
}

.nav-submenu-list {
  list-style: none;
  padding-left: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.25rem;
  margin-bottom: 0.35rem;
  border-left: 2px solid var(--border-subtle);
  margin-left: 1.25rem;
  transition: all var(--transition-fast);
}

.nav-submenu-list.is-collapsed {
  display: none;
}

.nav-subitem-btn {
  padding: 0.45rem 0.65rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.nav-subitem-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.nav-subitem-btn.active {
  color: var(--accent-cyan);
  font-weight: 700;
  border-color: var(--border-highlight);
}

.nav-item-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.85rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: all var(--transition-fast);
}

.nav-item-btn:hover {
  background: var(--bg-card);
  color: var(--text-primary);
  border-color: var(--border-subtle);
}

.nav-item-btn.active {
  background: hsla(174, 90%, 45%, 0.12);
  color: var(--accent-cyan);
  border-color: var(--border-highlight);
  box-shadow: 0 2px 10px var(--accent-cyan-glow);
}

.nav-icon {
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
}

/* Main Content Area */
.main-view-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  height: 100vh;
}

.app-view {
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
}

#view-flow {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Flow Designer Top Toolbar */
.flow-toolbar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.9rem 230px 0.9rem 1.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  transition: padding-left var(--transition-fast);
}

.flow-title-group {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.flow-title {
  font-size: 1.25rem;
  font-weight: 800;
}

.flow-actions-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

/* View Perspective Switcher */
.perspective-selector {
  display: flex;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.2rem;
  gap: 0.2rem;
}

.perspective-btn {
  background: transparent;
  border: none;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.perspective-btn:hover {
  color: var(--text-primary);
}

.perspective-btn.active {
  background: var(--bg-card-hover);
  color: var(--accent-cyan);
  box-shadow: var(--shadow-sm);
}

/* Flow Score Pill */
.flow-score-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.95rem;
  border-radius: var(--radius-full);
  background: hsla(142, 71%, 45%, 0.12);
  border: 1px solid var(--success-border);
  color: var(--success);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

/* Flow Canvas Area */
.flow-canvas-wrapper {
  flex: 1;
  position: relative;
  background: radial-gradient(circle, hsla(217, 33%, 20%, 0.35) 1px, transparent 1px);
  background-size: 24px 24px;
  background-color: var(--bg-primary);
  overflow: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Transversal Layers Bars (Top and Bottom of Canvas) */
.transversal-banner {
  background: var(--bg-glass-heavy);
  border: 1px solid var(--border-subtle);
  padding: 0.65rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  backdrop-filter: blur(16px);
  z-index: 10;
  font-size: 0.8rem;
}

.transversal-banner.security-bar {
  border-top: none;
  border-bottom: 1px solid hsla(212, 100%, 55%, 0.3);
  background: linear-gradient(90deg, hsla(212, 100%, 55%, 0.08) 0%, hsla(222, 45%, 9%, 0.92) 100%);
}

.transversal-banner.governance-bar {
  border-top: 1px solid hsla(174, 90%, 45%, 0.3);
  border-bottom: none;
  background: linear-gradient(90deg, hsla(174, 90%, 45%, 0.08) 0%, hsla(222, 45%, 9%, 0.92) 100%);
}

.transversal-chips {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  flex-wrap: wrap;
}

.transversal-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
  color: var(--text-secondary);
}

/* Flow Workspace: Left Toolbox + Central Canvas + Floating Controls */
.flow-workspace {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

/* Left Toolbox Panel: 8 Architectural Stages */
.flow-toolbox-panel {
  width: 280px;
  background: var(--bg-glass-heavy);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 25;
  transition: transform var(--transition-normal), width var(--transition-normal);
  backdrop-filter: blur(20px);
  flex-shrink: 0;
  box-shadow: 4px 0 20px rgba(0, 0, 0, 0.25);
}

.flow-toolbox-panel.collapsed {
  width: 0;
  overflow: hidden;
  border-right: none;
  pointer-events: none;
}

.toolbox-header {
  padding: 0.85rem 1.1rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-secondary);
}

.toolbox-header-title {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.toolbox-search-box {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
}

.toolbox-scroll-list {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.toolbox-scroll-list::-webkit-scrollbar {
  width: 6px;
}

.toolbox-scroll-list::-webkit-scrollbar-track {
  background: transparent;
}

.toolbox-scroll-list::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 4px;
}

.toolbox-scroll-list::-webkit-scrollbar-thumb:hover {
  background: var(--accent-orange);
}

/* Paleta de Componentes: Acordeón por Tipología */
.toolbox-accordion-group {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  overflow: hidden;
  margin-bottom: 0.5rem;
  transition: border-color var(--transition-fast);
  flex-shrink: 0;
  width: 100%;
}

.toolbox-accordion-group:hover {
  border-color: var(--border-highlight);
}

.toolbox-accordion-header {
  width: 100%;
  background: var(--bg-secondary);
  border: none;
  padding: 0.55rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  color: var(--text-primary);
  font-family: inherit;
  user-select: none;
  transition: background var(--transition-fast);
  text-align: left;
}

.toolbox-accordion-header:hover {
  background: var(--bg-card-hover);
}

.toolbox-accordion-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.toolbox-accordion-icon {
  font-size: 0.85rem;
  line-height: 1;
}

.toolbox-accordion-meta {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.toolbox-accordion-count {
  font-size: 0.65rem;
  padding: 0.1rem 0.4rem;
  border-radius: var(--radius-full);
  background: hsla(24, 95%, 53%, 0.15);
  color: var(--accent-orange);
  font-weight: 800;
}

.toolbox-accordion-arrow {
  font-size: 0.7rem;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
  display: inline-block;
}

.toolbox-accordion-group.is-collapsed .toolbox-accordion-arrow {
  transform: rotate(-90deg);
}

.toolbox-accordion-content {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.5rem;
  background: var(--bg-primary);
  border-top: 1px solid var(--border-subtle);
  height: auto;
  overflow: visible;
  flex-shrink: 0;
}

.toolbox-accordion-group.is-collapsed .toolbox-accordion-content {
  display: none;
}

.toolbox-item-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  cursor: grab;
  transition: all var(--transition-fast);
  user-select: none;
  flex-shrink: 0;
}

.toolbox-item-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent-cyan);
  transform: translateX(3px);
  box-shadow: var(--shadow-sm);
}

.toolbox-item-card:active {
  cursor: grabbing;
}

.toolbox-item-logo {
  width: 24px;
  height: 24px;
  background: var(--bg-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  flex-shrink: 0;
}

.toolbox-item-logo svg {
  width: 100%;
  height: 100%;
}

.toolbox-item-info {
  flex: 1;
  min-width: 0;
}

.toolbox-item-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toolbox-item-desc {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Central Canvas Viewport */
.flow-canvas-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle, var(--canvas-grid-dot) 1.5px, transparent 1.5px);
  background-size: 24px 24px;
  background-color: var(--canvas-bg);
  cursor: grab;
  min-width: 0;
}

.flow-canvas-viewport.panning {
  cursor: grabbing;
}

/* Floating Canvas Controls Bar */
.flow-canvas-controls {
  position: absolute;
  top: 1rem;
  right: 1.25rem;
  background: var(--bg-glass-heavy);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.35rem 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  z-index: 30;
  backdrop-filter: blur(16px);
  box-shadow: var(--shadow-md);
}

.canvas-control-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.canvas-control-btn:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-subtle);
  color: var(--accent-cyan);
}

.canvas-zoom-label {
  font-size: 0.72rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  padding: 0 0.3rem;
  min-width: 44px;
  text-align: center;
}

/* Popover de Validación Arquitectónica */
.flow-validation-popover {
  position: absolute;
  top: 3.5rem;
  right: 1.25rem;
  width: 380px;
  max-width: 90vw;
  background: var(--bg-glass-heavy);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.2rem;
  z-index: 40;
  backdrop-filter: blur(24px);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  gap: 0.85rem;
}

.flow-validation-popover.open {
  display: flex;
}

.validation-issue-card {
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  font-size: 0.75rem;
  border-left: 3px solid var(--warning);
}

.validation-issue-card.error {
  border-left-color: var(--danger);
}

.validation-issue-card.info {
  border-left-color: var(--info);
}

/* Canvas World Container (Pan & Zoom Transformer) */
.flow-canvas-world {
  position: absolute;
  top: 0;
  left: 0;
  width: 5000px;
  height: 4000px;
  transform-origin: 0 0;
  will-change: transform;
}

/* SVG Connection Layer */
.canvas-connections-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.conn-path {
  fill: none;
  stroke: var(--accent-cyan);
  stroke-width: 2.5;
  pointer-events: stroke;
  cursor: pointer;
  transition: stroke var(--transition-fast), stroke-width var(--transition-fast);
}

.conn-path:hover {
  stroke: var(--danger);
  stroke-width: 4.5;
}

.conn-arrow {
  fill: var(--accent-cyan);
}

/* HTML Nodes Container */
.canvas-nodes-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: auto;
}

/* Estado Vacío del Canvas (Armado Inicial de Flujo) */
.canvas-empty-state {
  position: absolute;
  top: 120px;
  left: 180px;
  max-width: 560px;
  background: var(--bg-card);
  border: 2px dashed var(--accent-cyan);
  border-radius: var(--radius-xl);
  padding: 2.2rem 2rem;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(16px);
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* 2D Interactive Flow Node Card */
.flow-node-card {
  position: absolute;
  width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  cursor: grab;
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
  box-shadow: var(--shadow-md);
  user-select: none;
  z-index: 10;
}

.flow-node-card.dragging {
  cursor: grabbing;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  opacity: 0.95;
}

.flow-node-card:hover {
  border-color: var(--accent-cyan);
  box-shadow: 0 8px 24px var(--accent-cyan-glow);
}

.flow-node-card.selected,
.flow-node-card.is-selected {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px var(--accent-cyan), 0 0 25px var(--accent-cyan-glow);
  z-index: 25;
}

.flow-node-card.selected::before,
.flow-node-card.is-selected::before {
  content: '✓ SELECCIONADO (Supr para borrar)';
  position: absolute;
  top: -10px;
  left: 12px;
  background: var(--accent-cyan);
  color: #04131d;
  font-size: 0.62rem;
  font-weight: 800;
  padding: 0.12rem 0.5rem;
  border-radius: var(--radius-full);
  z-index: 26;
  letter-spacing: 0.03em;
}

.flow-node-card.failed {
  border-color: var(--danger);
  box-shadow: 0 0 25px var(--danger-bg);
  background: hsla(0, 84%, 60%, 0.08);
}

.flow-node-card.failed::after {
  content: '⚠ FALLA CONFIGURADA';
  position: absolute;
  top: -10px;
  right: 12px;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-full);
  z-index: 22;
}

/* Estado de Error Activo Durante Simulación */
.flow-node-card.simulation-error-node {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 3px var(--danger), 0 0 35px rgba(239, 68, 68, 0.7) !important;
  background: hsla(0, 84%, 60%, 0.15) !important;
  animation: pulse-sim-error 0.8s infinite alternate;
  z-index: 30;
}

.flow-node-card.simulation-error-node::after {
  content: '💥 FALLA CRÍTICA EN SIMULACIÓN';
  position: absolute;
  top: -12px;
  right: 12px;
  background: var(--danger);
  color: white;
  font-size: 0.65rem;
  font-weight: 900;
  padding: 0.15rem 0.55rem;
  border-radius: var(--radius-full);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
  z-index: 32;
}

@keyframes pulse-sim-error {
  from { transform: scale(1); }
  to { transform: scale(1.03); }
}

/* Estado de Nodos Downstream Bloqueados Durante Simulación */
.flow-node-card.simulation-blocked-node {
  opacity: 0.45;
  filter: grayscale(0.85);
  border-style: dashed !important;
  border-color: var(--border-subtle) !important;
  pointer-events: none;
}

.flow-node-card.simulation-blocked-node::after {
  content: '⛔ BLOQUEADO POR ERROR UPSTREAM';
  position: absolute;
  top: -10px;
  right: 12px;
  background: #475569;
  color: #cbd5e1;
  font-size: 0.60rem;
  font-weight: 800;
  padding: 0.12rem 0.45rem;
  border-radius: var(--radius-full);
  z-index: 22;
}

/* Node Connection Ports (Interactive Linking) */
.node-port {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-cyan);
  border: 2px solid var(--bg-card);
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  cursor: crosshair;
  z-index: 22;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background var(--transition-fast);
}

.node-port:hover {
  transform: translateY(-50%) scale(1.35);
  box-shadow: 0 0 12px var(--accent-cyan);
}

.node-port.input-port {
  left: -7px;
  background: var(--accent-blue);
}

.node-port.output-port {
  right: -7px;
  background: var(--accent-cyan);
}

.node-port.active-source {
  background: var(--warning);
  box-shadow: 0 0 15px var(--warning);
  animation: pulse-port 1s infinite alternate;
}

@keyframes pulse-port {
  from { transform: translateY(-50%) scale(1.1); }
  to { transform: translateY(-50%) scale(1.45); }
}

/* Botón de Eliminación de Nodo */
.node-delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: var(--danger);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.55;
  transition: all var(--transition-fast);
  z-index: 23;
}

.flow-node-card:hover .node-delete-btn,
.flow-node-card.selected .node-delete-btn,
.flow-node-card.is-selected .node-delete-btn {
  opacity: 1;
  background: rgba(239, 68, 68, 0.22);
  border-color: var(--danger);
  transform: scale(1.08);
}

.node-delete-btn:hover {
  background: var(--danger) !important;
  color: #ffffff !important;
  transform: scale(1.18);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.5);
}

/* Modo Operador: Solo ejecución, sin edición de nodos ni paleta */
body.role-operator .node-delete-btn,
body.role-operator .node-port {
  display: none !important;
}

body.role-operator .flow-toolbox-panel {
  display: none !important;
}

/* Node Stage Badge */
.node-stage-badge {
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--bg-primary);
  color: var(--accent-cyan);
  border: 1px solid var(--border-subtle);
  display: inline-block;
}

.flow-node-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.flow-node-identity {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.flow-node-logo {
  width: 32px;
  height: 32px;
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
}

.flow-node-logo svg {
  width: 100%;
  height: 100%;
}

.flow-node-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.flow-node-subtitle {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Node Perspective Body */
.node-perspective-body {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.node-perspective-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-cyan);
  font-weight: 800;
}

.node-perspective-val {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
}

.node-perspective-meta {
  font-size: 0.68rem;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
}

/* Connector Pipe between Nodes */
.flow-connector {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  position: relative;
  min-width: 90px;
}

.flow-connector-line {
  height: 3px;
  width: 100%;
  background: linear-gradient(90deg, var(--accent-blue), var(--accent-cyan));
  position: relative;
}

.flow-connector-line::after {
  content: '';
  position: absolute;
  right: -2px;
  top: -4px;
  border: solid transparent;
  border-width: 5px 0 5px 8px;
  border-left-color: var(--accent-cyan);
}

.flow-connector-badge {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  padding: 0.2rem 0.55rem;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent-cyan);
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

/* Right Inspector Drawer (Section 47) */
.flow-inspector-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 440px;
  background: var(--bg-glass-heavy);
  backdrop-filter: blur(24px);
  border-left: 1px solid var(--border-subtle);
  box-shadow: -10px 0 35px rgba(0, 0, 0, 0.6);
  z-index: 1050;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-normal);
}

.flow-inspector-drawer.open {
  transform: translateX(0);
}

.inspector-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
}

.inspector-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.inspector-section {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.inspector-section-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-cyan);
  font-weight: 800;
}

.inspector-data-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.45;
}

/* Simulation Console Overlay */
.simulation-console-drawer {
  position: fixed;
  bottom: 0;
  left: 260px;
  right: 0;
  height: 280px;
  background: hsla(222, 47%, 5%, 0.96);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  z-index: 95;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform var(--transition-normal);
  box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.7);
}

.simulation-console-drawer.open {
  transform: translateY(0);
}

.console-header {
  padding: 0.65rem 1.25rem;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.console-logs-content {
  flex: 1;
  padding: 1rem 1.25rem;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: hsl(142, 71%, 65%);
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

/* Data Lineage Graph View */
.lineage-container {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.lineage-tree-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.lineage-step-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.85rem 1.25rem;
}

.lineage-arrow-down {
  display: flex;
  justify-content: center;
  color: var(--accent-cyan);
  font-size: 1.2rem;
}

/* ============================================================ */
/* AUTHENTICATION & RBAC STYLES (ADMINISTRADOR vs OPERADOR)      */
/* ============================================================ */

/* Widget Superior Derecho: Avatar y Dropdown de Sesión (Fijo y No Responsive) */
.top-user-profile-widget {
  position: fixed;
  top: 10px;
  right: 18px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

#btn-close-inspector {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

#btn-close-inspector:hover {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.5);
  transform: rotate(90deg);
}

.top-user-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  padding: 0.28rem 0.85rem 0.28rem 0.35rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(16px);
  transition: all var(--transition-fast);
  color: var(--text-primary);
  font-family: var(--font-body);
}

.top-user-btn:hover {
  border-color: var(--border-highlight);
  background: var(--bg-surface);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.top-user-avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  color: #000;
  font-weight: 800;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

.top-user-avatar-circle.operator {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

.top-user-avatar-circle::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 8px;
  height: 8px;
  background: #10b981;
  border-radius: 50%;
  border: 1.5px solid var(--bg-card);
}

.top-user-info-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  line-height: 1.15;
}

.top-user-name {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-primary);
  max-width: 130px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-user-dropdown-caret {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-left: 0.15rem;
  transition: transform 0.2s;
}

.top-user-profile-widget.is-open .top-user-dropdown-caret {
  transform: rotate(180deg);
}

/* Menú Desplegable Superior Derecho (Dropdown) */
.top-user-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 290px;
  background: var(--bg-surface);
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-lg);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.45);
  padding: 1.1rem;
  backdrop-filter: blur(24px);
  z-index: 1060;
  animation: userDropdownAnim 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes userDropdownAnim {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.user-dropdown-meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  background: var(--bg-primary);
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.user-sso-badge {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-weight: 600;
}

.user-dropdown-divider {
  border-top: 1px solid var(--border-subtle);
  margin: 0.75rem 0;
}

.btn-session-action.logout {
  border-color: rgba(239, 68, 68, 0.4);
  color: #f87171;
}

.btn-session-action.logout:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  color: #ffffff;
}

.user-session-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  margin-bottom: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.user-session-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.user-avatar-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-blue));
  color: #000;
  font-weight: 800;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

.user-avatar-circle.operator {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #fff;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.3);
}

.user-meta-info {
  flex: 1;
  min-width: 0;
}

.user-display-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-corporate-email {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.62rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  width: fit-content;
}

.user-role-badge.admin {
  background: rgba(0, 240, 255, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 240, 255, 0.35);
}

.user-role-badge.operator {
  background: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.35);
}

.user-session-actions {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.2rem;
}

.btn-session-action {
  flex: 1;
  padding: 0.28rem 0.45rem;
  font-size: 0.68rem;
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
}

.btn-session-action:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--accent-cyan);
}

/* Bloqueo visual de items de navegación para rol restringido */
.nav-item-btn.is-locked {
  opacity: 0.38;
  cursor: not-allowed;
  position: relative;
}

.nav-item-btn.is-locked:hover {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.nav-item-btn .lock-indicator {
  margin-left: auto;
  font-size: 0.65rem;
  color: #f59e0b;
  background: rgba(245, 158, 11, 0.15);
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  display: none;
}

.nav-item-btn.is-locked .lock-indicator {
  display: inline-block;
}

/* Pantalla de Acceso No Autorizado */
.unauthorized-card {
  max-width: 680px;
  margin: 4rem auto;
  background: var(--bg-card);
  border: 1px solid rgba(255, 51, 102, 0.4);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), 0 0 20px rgba(255, 51, 102, 0.1);
  text-align: center;
}

.unauthorized-icon {
  font-size: 3.5rem;
  margin-bottom: 1rem;
}

.unauthorized-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--danger);
  margin-bottom: 0.5rem;
}

.unauthorized-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

.allowed-views-box {
  background: var(--bg-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 1.5rem;
  text-align: left;
}

