/* ========================================================================
   AGENTOS VISUAL FLOW EDITOR
   Node-based automation builder with macOS Tahoe glassmorphic design
   ======================================================================== */

/* Canvas Container */
#agentos-canvas {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1a1a1a;
    overflow: hidden;
}

/* Drawflow Canvas Background - Black with white dots */
#agentos-canvas .drawflow,
.drawflow {
    width: 100%;
    height: 100%;
    position: relative;
    background-color: #1a1a1a;
    background-image: radial-gradient(circle, rgba(255,255,255,0.15) 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: 0 0;
}

/* Override any Drawflow defaults */
.drawflow .parent-drawflow {
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: none;
}

/* Node Wrapper */
.drawflow .drawflow-node {
    background: rgba(26, 26, 26, 0.95);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.4),
        inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    color: rgba(255, 255, 255, 0.9);
    padding: 0;
    min-width: 200px;
    transition: all 0.2s ease;
}

.drawflow .drawflow-node:hover {
    border-color: rgba(102, 126, 234, 0.4);
    box-shadow:
        0 12px 48px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(102, 126, 234, 0.3),
        inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.drawflow .drawflow-node.selected {
    border-color: rgba(102, 126, 234, 0.6);
    box-shadow:
        0 16px 64px rgba(0, 0, 0, 0.6),
        0 0 0 2px rgba(102, 126, 234, 0.5),
        inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* Node Header */
.node-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px 12px 0 0;
}

.node-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: rgba(102, 126, 234, 0.9);
}

.node-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.node-title {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    letter-spacing: -0.2px;
}

.node-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
}

/* Node Body */
.node-body {
    padding: 12px 16px;
}

.node-description {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    line-height: 1.4;
    margin-bottom: 8px;
}

.node-params {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.node-param {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 11px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 6px;
}

.node-param-label {
    color: rgba(255, 255, 255, 0.5);
    font-weight: 500;
}

.node-param-value {
    color: rgba(255, 255, 255, 0.8);
    font-weight: 400;
}

/* Node Execution States */
.drawflow-node.executing {
    border-color: #3b82f6;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.5);
    animation: pulseBlue 1.5s ease-in-out infinite;
}

.drawflow-node.success {
    border-color: #10b981;
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.4);
}

.drawflow-node.error {
    border-color: #ef4444;
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.4);
}

@keyframes pulseBlue {
    0%, 100% { box-shadow: 0 0 20px rgba(59, 130, 246, 0.5); }
    50% { box-shadow: 0 0 30px rgba(59, 130, 246, 0.8); }
}

/* Connection Lines */
.drawflow .connection .main-path {
    stroke: rgba(102, 126, 234, 0.6);
    stroke-width: 2px;
    fill: none;
}

.drawflow .connection .main-path:hover {
    stroke: rgba(102, 126, 234, 0.9);
    stroke-width: 3px;
}

.drawflow .connection.selected .main-path {
    stroke: rgba(102, 126, 234, 1);
    stroke-width: 3px;
}

/* Connection Points */
.drawflow .drawflow-node .input,
.drawflow .drawflow-node .output {
    width: 12px;
    height: 12px;
    background: rgba(102, 126, 234, 0.8);
    border: 2px solid rgba(26, 26, 26, 0.9);
    border-radius: 50%;
}

.drawflow .drawflow-node .input:hover,
.drawflow .drawflow-node .output:hover {
    background: rgba(102, 126, 234, 1);
    width: 14px;
    height: 14px;
}

/* Icon Toolbar */
.agentos-toolbar {
    position: absolute;
    top: 20px;
    left: 20px;
    display: flex;
    gap: 16px;
    z-index: 100;
}

.panel-icon-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: move;
    transition: all 0.2s ease;
    padding: 8px;
    user-select: none;
}

.panel-icon-btn:hover {
    color: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
}

.panel-icon-btn.active {
    color: #667eea;
}

.panel-icon-btn.floating {
    position: absolute;
}

.panel-icon-btn.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.panel-icon-btn i {
    font-size: 24px;
}

.panel-icon-btn span {
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* Library Panels - Crystal Clear Tahoe Glass */
.agentos-library-panel {
    position: fixed;
    left: 0;
    top: 0;
    width: 340px;
    height: 100vh;
    background: rgba(18, 18, 18, 0.75);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border-right: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow:
        inset -1px 0 0 0 rgba(255, 255, 255, 0.1),
        4px 0 32px rgba(0, 0, 0, 0.5),
        inset 0 0 100px rgba(255, 255, 255, 0.02);
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000;
    overflow-y: auto;
}

.agentos-library-panel.open {
    transform: translateX(0);
}

.library-panel-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.library-panel-title {
    font-size: 18px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    letter-spacing: -0.3px;
}

.library-panel-close {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.library-panel-close:hover {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 1);
}

.library-panel-search {
    padding: 12px 16px;
    margin: 16px 20px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    color: rgba(255, 255, 255, 0.9);
    box-shadow:
        inset 0 1px 2px rgba(0, 0, 0, 0.3),
        0 1px 0 rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
    width: calc(100% - 40px);
}

.library-panel-search:focus {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(102, 126, 234, 0.5);
    outline: none;
    box-shadow:
        inset 0 1px 2px rgba(0, 0, 0, 0.3),
        0 0 0 3px rgba(102, 126, 234, 0.15);
}

.library-category-header {
    padding: 12px 20px;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    margin-top: 8px;
}

.library-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    cursor: grab;
    transition: all 0.2s ease;
    position: relative;
}

.library-item::before {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0);
    border-radius: 8px;
    transition: background 0.2s ease;
}

.library-item:hover::before {
    background: rgba(102, 126, 234, 0.12);
}

.library-item:active {
    cursor: grabbing;
}

.library-item:active::before {
    background: rgba(102, 126, 234, 0.18);
}

.library-item-icon {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.library-item-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.library-item-icon i {
    font-size: 20px;
    color: rgba(255, 255, 255, 0.7);
}

.library-item-content {
    flex: 1;
    min-width: 0;
}

.library-item-name {
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 2px;
}

.library-item-description {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.library-item-status {
    flex-shrink: 0;
    font-size: 11px;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    font-weight: 500;
}

.library-item-status.not-connected {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.5);
}

/* Execution Panel - Right Sidebar */
.execution-panel {
    position: fixed;
    right: 0;
    top: 0;
    width: 360px;
    height: 100vh;
    background: rgba(18, 18, 18, 0.75);
    backdrop-filter: blur(40px) saturate(180%);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    border-left: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow:
        inset 1px 0 0 0 rgba(255, 255, 255, 0.1),
        -4px 0 32px rgba(0, 0, 0, 0.5),
        inset 0 0 100px rgba(255, 255, 255, 0.02);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 2000;
    display: flex;
    flex-direction: column;
}

.execution-panel.open {
    transform: translateX(0);
}

.execution-panel-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.execution-panel-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    display: flex;
    align-items: center;
    gap: 8px;
}

.execution-panel-toggle {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.06);
    border: none;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.execution-panel-toggle:hover {
    background: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 1);
}

.execution-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.execution-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 10px;
    margin-bottom: 16px;
}

.execution-status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px currentColor;
}

.execution-status-indicator.running {
    background: #3b82f6;
    animation: pulseBlue 1.5s ease-in-out infinite;
}

.execution-status-indicator.error {
    background: #ef4444;
}

.execution-status-text {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
}

.execution-progress {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 8px;
}

.execution-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.execution-progress-text {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 20px;
}

.execution-logs-container {
    margin-top: 16px;
}

.execution-logs-container h4 {
    font-size: 13px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.execution-logs {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 12px;
    max-height: 300px;
    overflow-y: auto;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 11px;
}

.execution-log-entry {
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.execution-log-entry:last-child {
    border-bottom: none;
}

.log-entry-time {
    color: rgba(255, 255, 255, 0.4);
    margin-right: 8px;
}

.log-entry-message {
    color: rgba(255, 255, 255, 0.8);
}

.log-entry-message.info {
    color: #3b82f6;
}

.log-entry-message.success {
    color: #10b981;
}

.log-entry-message.error {
    color: #ef4444;
}

/* Scrollbar Styling */
.agentos-library-panel::-webkit-scrollbar,
.execution-panel-body::-webkit-scrollbar,
.execution-logs::-webkit-scrollbar {
    width: 8px;
}

.agentos-library-panel::-webkit-scrollbar-track,
.execution-panel-body::-webkit-scrollbar-track,
.execution-logs::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
}

.agentos-library-panel::-webkit-scrollbar-thumb,
.execution-panel-body::-webkit-scrollbar-thumb,
.execution-logs::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.agentos-library-panel::-webkit-scrollbar-thumb:hover,
.execution-panel-body::-webkit-scrollbar-thumb:hover,
.execution-logs::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}
