/* Smart Routing Rules - CSS Styles */

.smart-routing-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
}

.routing-header {
    background: white;
    border-bottom: 1px solid #dee2e6;
    padding: 1rem 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.header-left {
    display: flex;
    flex-direction: column;
}

.page-title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 600;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-subtitle {
    margin: 0.25rem 0 0 0;
    color: #6c757d;
    font-size: 0.95rem;
}

.header-actions {
    display: flex;
    gap: 0.5rem;
}

.routing-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    padding: 1rem 2rem;
}

.flow-toolbar {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.toolbar-section {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toolbar-label {
    font-weight: 500;
    color: #495057;
    margin: 0;
}

.toolbar-separator {
    height: 24px;
    width: 1px;
    background: #dee2e6;
    margin: 0 0.5rem;
}

.flow-canvas-container {
    flex: 1;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    min-height: 500px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.react-flow-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    background: 
        radial-gradient(circle, #e9ecef 1px, transparent 1px);
    background-size: 20px 20px;
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
    color: #6c757d;
}

.loading-content .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Node Configuration Panel Styles */
.node-config-form {
    padding: 1rem;
}

.node-config-form .alert {
    margin-bottom: 1rem;
}

.node-config-form .form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.node-config-form .form-control {
    margin-bottom: 1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .routing-header {
        padding: 1rem;
    }
    
    .header-content {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .header-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .routing-content {
        padding: 1rem;
    }
    
    .flow-toolbar {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .toolbar-section {
        width: 100%;
        justify-content: space-between;
    }
}

/* Animation for loading states */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.smart-routing-container {
    animation: fadeIn 0.3s ease-in;
}

/* Error states */
.error-message {
    color: #dc3545;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 0.75rem;
    margin: 1rem 0;
}

.success-message {
    color: #155724;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    padding: 0.75rem;
    margin: 1rem 0;
}

/* ===== CONEXIONES MEJORADAS ===== */
.connections-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.flow-connection-path {
    pointer-events: stroke;
    cursor: pointer;
    transition: all 0.3s ease;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.flow-connection-path:hover {
    stroke-width: 3.5 !important;
    opacity: 1 !important;
    filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.5));
    transform: translateZ(0); /* Forzar aceleración de hardware */
}

.connection-group {
    transition: all 0.3s ease;
}

.connection-group:hover .flow-connection-path {
    stroke-width: 3.5;
    opacity: 1;
}

.connection-group:hover .connection-label-group rect {
    opacity: 1;
    transform: scale(1.05);
    transform-origin: center;
}

.connection-label-group {
    pointer-events: none;
    transition: all 0.2s ease;
}

.connection-label-text {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 11px;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Animación para conexiones temporales */
.temp-connection {
    animation: dashFlow 2s linear infinite;
}

@keyframes dashFlow {
    0% {
        stroke-dashoffset: 0;
    }
    100% {
        stroke-dashoffset: 24;
    }
}

/* Efectos de glow para diferentes tipos de conexión */
.connection-success {
    filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.3));
}

.connection-error {
    filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.3));
}

.connection-retry {
    filter: drop-shadow(0 0 4px rgba(245, 158, 11, 0.3));
}

.connection-fallback {
    filter: drop-shadow(0 0 4px rgba(139, 92, 246, 0.3));
}

/* Mejoras para los puntos de conexión */
.connection-point {
    transition: all 0.2s ease;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.connection-point:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.connection-highlight {
    background-color: #10B981 !important;
    transform: scale(1.3);
    animation: pulse 1.5s ease-in-out infinite;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.3);
}

.connection-hover {
    background-color: #059669 !important;
    transform: scale(1.2);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.4);
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.3);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0.1);
    }
}

/* Mejoras responsivas para conexiones */
@media (max-width: 768px) {
    .flow-connection-path {
        stroke-width: 2;
    }
    
    .connection-label-text {
        font-size: 10px;
    }
    
    .connection-label-group rect {
        width: 40px;
        height: 14px;
    }
}

/* ===== CONDITION NODE STYLES (YES/NO PATHS) ===== */

/* Nodo Condition con dos salidas */
.flow-node.condition-node {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: 2px solid #5a67d8;
    min-width: 180px;
    position: relative;
}

.flow-node.condition-node::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
    opacity: 0.3;
    filter: blur(8px);
    z-index: -1;
}

.flow-node.condition-node .node-header {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.flow-node.condition-node .node-icon {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.flow-node.condition-node .node-title {
    color: white;
    font-weight: 600;
}

.flow-node.condition-node .node-type-badge {
    background: rgba(255, 255, 255, 0.25);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

/* Puntos de salida YES/NO */
.condition-outputs {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    background: rgba(255, 255, 255, 0.1);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    margin-top: 0.5rem;
}

.condition-output {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    position: relative;
}

.condition-output-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.15rem 0.5rem;
    border-radius: 10px;
    white-space: nowrap;
}

.condition-output.yes .condition-output-label {
    background: rgba(16, 185, 129, 0.9);
    color: white;
    box-shadow: 0 2px 4px rgba(16, 185, 129, 0.3);
}

.condition-output.no .condition-output-label {
    background: rgba(239, 68, 68, 0.9);
    color: white;
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.3);
}

.condition-output .connection-point {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid white;
    cursor: crosshair;
    transition: all 0.2s ease;
    position: relative;
}

.condition-output.yes .connection-point {
    background: #10B981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.condition-output.no .connection-point {
    background: #EF4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
}

.condition-output .connection-point:hover {
    transform: scale(1.3);
    box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.3);
}

.condition-output.yes .connection-point:hover {
    box-shadow: 0 0 0 5px rgba(16, 185, 129, 0.4);
}

.condition-output.no .connection-point:hover {
    box-shadow: 0 0 0 5px rgba(239, 68, 68, 0.4);
}

/* Indicador de condición configurada */
.condition-configured-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background: #10B981;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
    animation: pulse-indicator 2s ease-in-out infinite;
}

@keyframes pulse-indicator {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.3);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
    }
}

/* Estilos para las conexiones YES/NO */
.connection-yes {
    stroke: #10B981;
    stroke-width: 2.5;
    filter: drop-shadow(0 0 4px rgba(16, 185, 129, 0.4));
}

.connection-no {
    stroke: #EF4444;
    stroke-width: 2.5;
    filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.4));
}

.connection-default {
    stroke: #6B7280;
    stroke-width: 2;
    stroke-dasharray: 5, 5;
}

/* Labels para conexiones YES/NO */
.connection-label-yes {
    fill: white;
    stroke: #10B981;
    stroke-width: 1;
}

.connection-label-no {
    fill: white;
    stroke: #EF4444;
    stroke-width: 1;
}

.connection-label-text-yes {
    fill: #10B981;
    font-weight: 700;
}

.connection-label-text-no {
    fill: #EF4444;
    font-weight: 700;
}

/* Hover effects para conexiones condicionales */
.connection-yes:hover {
    stroke-width: 3.5;
    filter: drop-shadow(0 0 8px rgba(16, 185, 129, 0.6));
}

.connection-no:hover {
    stroke-width: 3.5;
    filter: drop-shadow(0 0 8px rgba(239, 68, 68, 0.6));
}

/* Animación para conexiones activas */
.connection-active {
    animation: connectionPulse 2s ease-in-out infinite;
}

@keyframes connectionPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* ===================================
   ESTILOS PARA NODOS CONDICIONALES
   =================================== */

/* Contenedor de outputs YES/NO */
.condition-outputs {
    display: flex;
    justify-content: space-around;
    align-items: center;
    width: 100%;
    margin-top: 8px;
    padding: 6px 0;
    gap: 20px;
}

/* Cada output individual (YES o NO) */
.condition-output {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    position: relative;
}

/* Labels YES y NO - Más pequeños */
.condition-output-label {
    font-size: 0.55rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    padding: 2px 6px;
    border-radius: 3px;
    text-transform: uppercase;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* Label YES - Verde */
.condition-output.yes .condition-output-label {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: white;
    border: 1px solid #059669;
}

/* Label NO - Rojo */
.condition-output.no .condition-output-label {
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
    color: white;
    border: 1px solid #DC2626;
}

/* Connection point dentro de YES */
.condition-output.yes .connection-point {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    border: 2px solid #059669;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.condition-output.yes .connection-point:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.5);
    transform: scale(1.2);
}

/* Connection point dentro de NO */
.condition-output.no .connection-point {
    background: linear-gradient(135deg, #EF4444 0%, #DC2626 100%);
    border: 2px solid #DC2626;
    box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.condition-output.no .connection-point:hover {
    background: linear-gradient(135deg, #DC2626 0%, #B91C1C 100%);
    box-shadow: 0 4px 12px rgba(239, 68, 68, 0.5);
    transform: scale(1.2);
}

/* Estado seleccionado */
.flow-node-condition .connection-point-selected {
    transform: scale(1.3);
    animation: pulseHandle 1s ease-in-out infinite;
}

@keyframes pulseHandle {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
    }
}

/* Estado activo durante creación de conexión */
.flow-node-condition .connection-point-active {
    border-width: 3px;
    animation: pulseActive 0.8s ease-in-out infinite;
}

@keyframes pulseActive {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
    }
}

/* ===================================
   BOTONES DE ACCIÓN EN NODOS
   =================================== */

/* Contenedor de acciones en el header */
.node-header-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    margin-left: auto;
}

/* Botón de configuración */
.btn-config-node {
    background: none;
    border: none;
    color: #6c757d;
    font-size: 0.85rem;
    cursor: pointer;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
    opacity: 0.7;
}

.btn-config-node:hover {
    background: rgba(108, 117, 125, 0.15);
    color: #495057;
    opacity: 1;
    transform: scale(1.1);
}

.btn-config-node:active {
    transform: scale(0.95);
}

/* Botón de cerrar */
.btn-close-node {
    background: none;
    border: none;
    color: #dc3545;
    font-size: 0.9rem;
    cursor: pointer;
    padding: 4px 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s;
    opacity: 0.7;
}

.btn-close-node:hover {
    background: rgba(220, 53, 69, 0.15);
    color: #c82333;
    opacity: 1;
    transform: scale(1.1);
}

.btn-close-node:active {
    transform: scale(0.95);
}

/* Asegurar que el header tenga flex para distribuir elementos */
.node-header {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.node-header .node-title {
    flex: 1;
}