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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    overflow: hidden;
}

.screen { display: none; }
.screen.active { display: block; }

/* ====== LOGIN ====== */
#login-screen, #register-screen {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
#login-screen.active, #register-screen.active { display: flex; }

.login-container {
    background: white;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 400px;
    max-width: 90%;
}
.login-container h1 { text-align: center; margin-bottom: 8px; color: #333; }
.login-container .subtitle { text-align: center; color: #666; margin-bottom: 30px; }
.login-container input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}
.login-container input:focus { outline: none; border-color: #667eea; }
.login-link { text-align: center; margin-top: 20px; color: #666; }
.login-link a { color: #667eea; text-decoration: none; font-weight: 600; }

/* ====== BOTONES ====== */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}
.btn-block { width: 100%; padding: 12px; }
.btn-primary { background: #667eea; color: white; }
.btn-primary:hover { background: #5568d3; }
.btn-success { background: #10b981; color: white; }
.btn-success:hover { background: #059669; }
.btn-warning { background: #f59e0b; color: white; }
.btn-warning:hover { background: #d97706; }
.btn-secondary { background: #6b7280; color: white; }
.btn-secondary:hover { background: #4b5563; }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }

/* ====== APP ====== */
.container { display: flex; flex-direction: column; height: 100vh; }

header {
    background: white;
    padding: 12px 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 100;
    flex-wrap: wrap;
    gap: 10px;
}
.header-left { display: flex; align-items: center; gap: 15px; }
header h1 { font-size: 18px; color: #333; }
.cliente-info { color: #666; font-size: 13px; }
.header-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.select-flujos {
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    min-width: 180px;
}

.main-content { display: flex; flex: 1; overflow: hidden; }

/* ====== SIDEBAR ====== */
.sidebar {
    width: 200px;
    background: white;
    border-right: 1px solid #ddd;
    padding: 15px;
    overflow-y: auto;
}
.sidebar h3 { margin-bottom: 15px; color: #333; font-size: 15px; }

.nodo-item {
    background: #f9f9f9;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 10px;
    margin-bottom: 8px;
    cursor: move;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    font-size: 13px;
}
.nodo-item:hover { background: white; border-color: #667eea; transform: translateX(2px); }
.nodo-icon { font-size: 18px; }

/* ====== CANVAS ====== */
.canvas-container { flex: 1; position: relative; overflow: auto; background: #fafafa; }
.canvas {
    position: relative;
    width: 4000px;
    height: 3000px;
    background-image: 
        linear-gradient(rgba(0,0,0,0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,0,0,0.05) 1px, transparent 1px);
    background-size: 20px 20px;
}
.svg-connections {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* ====== NODOS ====== */
.nodo {
    position: absolute;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    padding: 12px;
    min-width: 160px;
    cursor: move;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 10;
    transition: box-shadow 0.2s;
}
.nodo:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.nodo.selected { border-color: #667eea; box-shadow: 0 4px 12px rgba(102,126,234,0.3); }
.nodo-header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-weight: 600; font-size: 13px; }
.nodo-body { font-size: 11px; color: #666; }

.nodo-port {
    width: 14px; height: 14px;
    background: #667eea;
    border: 2px solid white;
    border-radius: 50%;
    position: absolute;
    cursor: pointer;
    z-index: 20;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.nodo-port.input { left: -7px; top: 50%; transform: translateY(-50%); }
.nodo-port.output { right: -7px; top: 50%; transform: translateY(-50%); }
.nodo-port:hover { background: #5568d3; transform: translateY(-50%) scale(1.3); }

.connection-line { stroke: #667eea; stroke-width: 2; fill: none; pointer-events: stroke; cursor: pointer; }
.connection-line:hover { stroke-width: 4; stroke: #5568d3; }

/* ====== PROPIEDADES ====== */
.properties-panel {
    width: 300px;
    background: white;
    border-left: 1px solid #ddd;
    padding: 15px;
    overflow-y: auto;
}
.properties-panel h3 { margin-bottom: 15px; color: #333; font-size: 15px; }
.no-selection { color: #999; font-style: italic; text-align: center; margin-top: 40px; }

.property-group { margin-bottom: 15px; }
.property-group label { display: block; margin-bottom: 5px; color: #555; font-size: 12px; font-weight: 500; }
.property-group input, .property-group textarea, .property-group select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 13px;
}
.property-group textarea { min-height: 80px; resize: vertical; font-family: 'Courier New', monospace; }
.property-group small { color: #888; font-size: 11px; margin-top: 4px; display: block; }

.btn-delete-nodo {
    background: #ef4444; color: white;
    padding: 8px; border: none; border-radius: 6px;
    cursor: pointer; margin-top: 10px; width: 100%;
}

/* ====== MODALES ====== */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal.active { display: flex; }
.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
}
.modal-content.large { max-width: 1000px; }
.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #ddd;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.modal-header h2 { font-size: 18px; color: #333; }
.modal-close { background: none; border: none; font-size: 28px; cursor: pointer; color: #999; }
.modal-body { padding: 20px; }
.modal-footer { padding: 15px 20px; border-top: 1px solid #ddd; display: flex; justify-content: flex-end; gap: 10px; }

.alert-info {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 6px;
    padding: 12px;
    margin-top: 15px;
    font-size: 13px;
    color: #1e40af;
}
.alert-info ol { margin-left: 20px; margin-top: 8px; }

/* ====== MENSAJES ====== */
.mensajes-layout { display: flex; height: 500px; gap: 15px; padding: 0 !important; }
.contactos-list {
    width: 280px;
    border-right: 1px solid #ddd;
    overflow-y: auto;
    padding: 10px;
}
.contacto-item {
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background 0.2s;
}
.contacto-item:hover { background: #f5f5f5; }
.contacto-item.active { background: #eff6ff; }
.contacto-item .nombre { font-weight: 600; font-size: 14px; }
.contacto-item .telefono { font-size: 12px; color: #666; }
.contacto-item .ultimo { font-size: 12px; color: #888; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-area { flex: 1; overflow-y: auto; padding: 15px; background: #f9f9f9; }
.mensaje-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 12px;
    margin-bottom: 10px;
    font-size: 14px;
    word-wrap: break-word;
}
.mensaje-bubble.entrante { background: white; margin-right: auto; border-bottom-left-radius: 4px; }
.mensaje-bubble.saliente { background: #dcf8c6; margin-left: auto; border-bottom-right-radius: 4px; }
.mensaje-bubble .hora { font-size: 10px; color: #888; margin-top: 4px; text-align: right; }

/* ====== EJECUCIONES ====== */
.ejecucion-item {
    padding: 12px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ejecucion-item .estado { padding: 4px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.estado-completado { background: #d1fae5; color: #065f46; }
.estado-error { background: #fee2e2; color: #991b1b; }
.estado-ejecutando { background: #fef3c7; color: #92400e; }

.log-item {
    padding: 10px;
    margin-bottom: 8px;
    border-radius: 6px;
    background: #f9f9f9;
    border-left: 3px solid #667eea;
}
.log-item.error { border-left-color: #ef4444; }
.log-item pre {
    background: #1f2937;
    color: #10b981;
    padding: 8px;
    border-radius: 4px;
    margin-top: 6px;
    font-size: 11px;
    overflow-x: auto;
}

/* ====== RESPONSIVE ====== */
@media (max-width: 768px) {
    .sidebar { width: 150px; }
    .properties-panel { width: 250px; }
    header h1 { font-size: 16px; }
}
