/* Reset and base styles - Updated for Vercel deployment */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    min-height: 100vh;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    position: relative;
}

.header h1 {
    color: #4a5568;
    margin-bottom: 10px;
    font-size: 2.5rem;
    font-weight: 700;
}

.header p {
    color: #718096;
    font-size: 1.1rem;
    margin-bottom: 20px;
}

.header-actions {
    display: flex;
    gap: 10px;
    position: absolute;
    top: 16px;
    right: 16px;
}

.upload-area {
    border: 3px dashed #cbd5e0;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    background: #f7fafc;
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-area:hover {
    border-color: #667eea;
    background: #edf2f7;
}

.upload-area.dragover {
    border-color: #667eea;
    background: #e6fffa;
}

.file-input {
    display: none;
}

.upload-text {
    color: #4a5568;
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.upload-subtext {
    color: #718096;
    font-size: 0.9rem;
}

.controls {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 14px 16px;
    margin-bottom: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    display: none;
}

.controls.visible {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.control-group {
    margin-bottom: 8px;
}

.control-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #4a5568;
}

.control-group select, .control-group input {
    width: 100%;
    padding: 10px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.3s ease;
}

.control-group select:focus, .control-group input:focus {
    outline: none;
    border-color: #667eea;
}

.btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 18px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: transform 0.2s ease;
    margin-right: 8px;
    margin-bottom: 8px;
}

/* Toggle buttons for visualization types */
.viz-button-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.btn-toggle {
    background: linear-gradient(135deg, #94a3b8 0%, #64748b 100%);
}

.btn-toggle-active {
    outline: 2px solid #22c55e;
    box-shadow: 0 0 0 3px rgba(34,197,94,0.25);
}

.btn:hover {
    transform: translateY(-2px);
}

.btn:active {
    transform: translateY(0);
}

/* Edit mode specific buttons */
.btn-edit {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.3);
}

.btn-edit:hover {
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

.btn-edit.edit-active {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.3);
}

.btn-secondary {
    background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
    box-shadow: 0 4px 15px rgba(107, 114, 128, 0.3);
    font-size: 12px;
    padding: 8px 16px;
}

.btn-secondary:hover {
    box-shadow: 0 6px 20px rgba(107, 114, 128, 0.4);
}

/* Help button variant for better visibility */
.btn-help {
    background: linear-gradient(135deg, #facc15 0%, #eab308 100%);
    color: #1f2937;
    box-shadow: 0 4px 15px rgba(250, 204, 21, 0.35);
}

.btn-help:hover {
    box-shadow: 0 6px 22px rgba(250, 204, 21, 0.45);
}

/* Edit controls layout */
.edit-controls {
    display: flex;
    flex-direction: row;
    gap: 10px;
    align-items: flex-end;
}

.edit-toolbar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

/* Edit mode visual indicators */
.edit-mode .node-summary {
    cursor: pointer;
    transition: all 0.2s ease;
}

.edit-mode .node-summary:hover {
    background: rgba(16, 185, 129, 0.1);
    border-color: #10b981;
}

.edit-mode .node-content {
    border-left: 3px solid #10b981;
}

/* Draggable indicators */
.node-draggable {
    cursor: grab;
}

.node-draggable:active {
    cursor: grabbing;
}

.node-drag-handle {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    cursor: grab;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.edit-mode .node-drag-handle {
    opacity: 1;
}

.node-drag-handle:hover {
    background: rgba(255, 255, 255, 0.3);
}

.visualizations {
    display: grid;
    gap: 20px;
    margin-top: 20px;
}

.viz-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    padding: 25px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

.viz-card h3 {
    color: #4a5568;
    margin-bottom: 15px;
    font-size: 1.3rem;
    font-weight: 600;
}

.pathway {
    background: #f7fafc;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    border-left: 4px solid #667eea;
}

.pathway h4 {
    color: #2d3748;
    margin-bottom: 15px;
    font-size: 1.1rem;
    padding-bottom: 10px;
    border-bottom: 1px solid #e2e8f0;
}

.pathway-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.step-container {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.step-container:hover {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
}

.step {
    background: white;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    font-size: 0.9rem;
    color: #4a5568;
}

.step.start { background: #c6f6d5; border-color: #68d391; }
.step.conversation { background: #f0f8ff; border-color: #87ceeb; }
.step.function { background: #fed7d7; border-color: #fc8181; }
.step.extract_dynamic_variables { background: #fff2e6; border-color: #ff9900; }
.step.end { background: #e9d8fd; border-color: #b794f6; }
.step.global { box-shadow: 0 0 0 2px #ffd700; }
.step.tool { background: #ffe6cc; border-color: #ff9900; }

.arrow {
    color: #718096;
    font-weight: bold;
}

.condition {
    background: #fff5b4;
    border: 1px solid #f6e05e;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #744210;
    font-style: italic;
}

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9rem;
    opacity: 0.9;
}



.node-details {
    background: #f7fafc;
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
    border-left: 4px solid #667eea;
}

.node-details-alphabetical {
    margin-bottom: 25px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Alphabetical Node List Styles */
.alphabetical-section {
    margin-bottom: 30px;
}

.alphabetical-header {
    font-size: 24px;
    color: #4a5568;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
    margin-bottom: 20px;
}

.node-summary {
    cursor: pointer;
    padding: 10px 14px;
    background: linear-gradient(135deg, #d1e7ff 0%, #e1f0ff 100%);
    border: none;
    border-radius: 12px 12px 0 0;
    font-weight: 600;
    color: white;
    font-size: 15px;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.node-summary:hover {
    background-color: #edf2f7;
    border-color: #cbd5e0;
}

.node-summary:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.node-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 0 0 300px;
}

.node-info.inline {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    flex: unset;
}

/* Ensure badges align perfectly in single-line header */
.node-info.inline .node-type {
    margin: 0 !important; /* override global margin-bottom */
}

.node-info.inline .node-type,
.node-info.inline .node-type-indicator,
.node-info.inline .node-name {
    align-self: center !important;
}

.node-name {
    font-weight: 700;
    color: #2d3748;
    line-height: 1;
    display: inline-flex;
    align-items: center;
}

.node-type {
    font-size: 12px;
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 4px;
    border-radius: 4px;
    display: inline-block;
    border: 1px solid rgba(255, 255, 255, 0.3);
    white-space: nowrap;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
    line-height: 1;
    text-align: center;
    margin: 0;
    flex: 0 0 auto;
    width: fit-content;
    align-self: center;
    vertical-align: middle;
}

/* Color coding for different node types */
.node-type.conversation {
    background-color: #3b82f6;
}

.node-type.function {
    background-color: #ef4444;
}

.node-type.extract_dynamic_variables {
    background-color: #f59e0b;
}

.node-type.end {
    background-color: #8b5cf6;
}

.node-type.start {
    background-color: #10b981;
}

.node-type.global {
    background-color: #fbbf24;
}

.node-type.branch {
    background-color: #22c55e;
}

.node-type.transfer_call {
    background-color: #0ea5e9;
}

.node-type.unknown {
    background-color: #6b7280;
}

.node-indicators {
    display: flex;
    gap: 8px;
    align-items: center;
    flex: 0 0 auto;
    justify-content: flex-end;
}

.node-badge {
    font-size: 11px;
    padding: 3px 6px;
    border-radius: 3px;
    font-weight: 600;
}

.node-badge.start {
    background-color: #c6f6d5;
    color: #22543d;
}

.node-badge.global {
    background-color: #ffd700;
    color: #744210;
}

.node-badge.tool {
    background-color: #ffe6cc;
    color: #744210;
}

.node-content {
    margin-top: 0;
    padding: 16px 20px;
    background-color: #f8fafc;
    border: 2px solid #e2e8f0;
    border-top: none;
    border-radius: 0 0 12px 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.node-properties {
    display: grid;
    gap: 20px;
}

.node-property {
    margin-bottom: 8px;
}

.node-property strong {
    color: #2d3748;
    font-weight: 700;
    font-size: 15px;
    display: block;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 2px solid #e2e8f0;
}

.node-property-content {
    margin-top: 8px;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #d1d5db;
    font-size: 14px;
    line-height: 1.5;
    background-color: white;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.node-property-content.prompt {
    background-color: #f7fafc;
    color: #4a5568;
    white-space: pre-wrap;
    border-left: 4px solid #667eea;
}

.node-property-content.tool {
    background-color: #fff5f5;
    border-color: #fed7d7;
    border-left: 4px solid #fc8181;
}

.node-property-content.variables {
    background-color: #fffbf5;
    border-color: #fbb6ce;
    border-left: 4px solid #f687b3;
}

.node-property-content.connections {
    background-color: #f0fff4;
    border-color: #9ae6b4;
    border-left: 4px solid #68d391;
}

.node-property-content.skip {
    background-color: #fff5f5;
    border-color: #fed7d7;
    border-left: 4px solid #fc8181;
}

.node-property-content.global {
    background-color: #fffbf5;
    border-color: #fbb6ce;
    border-left: 4px solid #fbb6ce;
}

.node-property-content.other {
    background-color: #f7fafc;
    border-color: #e2e8f0;
    border-left: 4px solid #a0aec0;
}

.variable-tag {
    background: #fed7d7;
    padding: 4px 8px;
    border-radius: 4px;
    margin: 2px;
    display: inline-block;
    font-size: 12px;
    color: #c53030;
}

.connection-item {
    margin: 4px 0;
    padding: 4px 8px;
    background: white;
    border-radius: 3px;
    font-size: 13px;
}

.clickable-node {
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
}

.clickable-node:hover {
    background-color: #e3f2fd !important;
    border-color: #2196f3;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(33, 150, 243, 0.2);
}

.clickable-node:active {
    transform: translateY(0);
}

/* Responsive adjustments for alphabetical view */
@media (max-width: 768px) {
    .node-summary {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .node-indicators {
        align-self: flex-end;
    }
    
    .node-properties {
        grid-template-columns: 1fr;
    }
}

.node-type {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.error {
    background: #fed7d7;
    border: 1px solid #fc8181;
    color: #c53030;
    padding: 15px;
    border-radius: 8px;
    margin: 10px 0;
}

.success {
    background: #c6f6d5;
    border: 1px solid #68d391;
    color: #22543d;
    padding: 15px;
    border-radius: 8px;
    margin: 10px 0;
}

/* Tooltip styles for Conversation Pathways visualization */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.4;
    max-width: 400px;
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
}

.tooltip.show {
    opacity: 1;
}

.tooltip-header {
    font-weight: 600;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.tooltip-type {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.tooltip-type.prompt {
    background: #3182ce;
    color: white;
}

.tooltip-type.static {
    background: #38a169;
    color: white;
}

/* Hide transient UI during export */
body.exporting .tooltip { display: none !important; }
body.exporting .node-drag-handle { display: none !important; }
body.exporting .success { display: none !important; }

.tooltip-content {
    word-wrap: break-word;
    white-space: pre-wrap;
}

.tooltip-content .variable {
    background: #fed7d7;
    color: #c53030;
    padding: 1px 3px;
    border-radius: 2px;
    font-weight: 600;
}

.tooltip-content .important {
    color: #f6ad55;
    font-weight: 600;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .pathway-steps {
        flex-direction: column;
        align-items: stretch;
    }
    
    .arrow {
        transform: rotate(90deg);
        align-self: center;
    }
    
    .tooltip {
        max-width: 300px;
        font-size: 12px;
        padding: 10px 14px;
    }
}

/* Footer styles */
.footer {
    text-align: center;
    padding: 20px 0;
    margin-top: 40px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
}

.footer p {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    margin: 0;
    font-weight: 400;
}

.footer p:hover {
    color: rgba(255, 255, 255, 0.9);
    transition: color 0.2s ease;
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.show { display: flex; }

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: #ffffff;
    border-radius: 14px;
    padding: 24px;
    max-width: 800px;
    width: calc(100% - 40px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    z-index: 1001;
}

.modal-content h2 {
    margin-bottom: 12px;
    color: #4a5568;
}

.modal-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: transparent;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: #718096;
}

.modal-body {
    color: #2d3748;
}

.help-steps {
    padding-left: 20px;
    margin-bottom: 16px;
}

.help-steps li { margin: 8px 0; }

.help-steps ul {
    padding-left: 28px;
    margin-top: 6px;
}

.help-tips ul { padding-left: 20px; }

/* Node type indicator styles for alphabetical view */
.node-type-indicator {
    font-size: 0.8rem !important;
    color: white !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    padding: 4px 8px !important;
    border-radius: 4px !important;
    margin-left: 8px !important;
    display: inline-block !important;
    border: 1px solid rgba(255, 255, 255, 0.3) !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
    font-family: Arial, sans-serif !important;
    line-height: 1 !important;
    text-align: center !important;
    width: fit-content !important;
    flex: 0 0 auto !important;
    align-self: center !important;
    vertical-align: middle !important;
}

.node-type-indicator.prompt {
    color: white !important;
    background-color: #3182ce !important;
    border: none !important;
}

.node-type-indicator.static {
    color: white !important;
    background-color: #38a169 !important;
    border: none !important;
}