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

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

.container {
   max-width: 100%;
   margin: 0 auto;
   padding: 20px;
   min-height: 100vh;
}

.header {
   text-align: center;
   margin-bottom: 30px;
   color: white;
}

.header h1 {
   font-size: 2.5rem;
   margin-bottom: 10px;
   text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.mode-selector {
   display: flex;
   gap: 10px;
   margin-bottom: 20px;
   max-width: 400px;
   margin-left: auto;
   margin-right: auto;
}

.mode-btn {
   flex: 1;
   padding: 15px;
   border: none;
   border-radius: 12px;
   font-size: 1.1rem;
   font-weight: 600;
   cursor: pointer;
   transition: all 0.3s ease;
   background: rgba(255,255,255,0.9);
   color: #333;
}

.mode-btn.active {
   background: #4CAF50;
   color: white;
   transform: translateY(-2px);
   box-shadow: 0 4px 12px rgba(76,175,80,0.3);
}

.mode-btn:hover {
   transform: translateY(-1px);
   box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

/* Main Layout for Create Mode */
.main-layout {
   display: flex;
   gap: 20px;
   height: calc(100vh - 200px);
   min-height: 600px;
}

/* Left Sidebar */
.sidebar {
   width: 25%;
   min-width: 300px;
   max-width: 400px;
   position: sticky;
   top: 20px;
   height: fit-content;
   max-height: calc(100vh - 220px);
   overflow-y: auto;
}

/* Main Content Area */
.main-content {
   flex: 1;
   display: flex;
   flex-direction: column;
   min-width: 0;
}

/* Enhanced Flowchart Canvas Styles with Zoom Support */
#flowchart-canvas {
   flex: 1;
   min-height: 0;
   height: 100%;
   background: #fafafa;
   border-radius: 12px;
   padding: 20px;
   overflow: auto;
   position: relative;
   border: 2px dashed #e0e0e0;
   transition: border-color 0.3s ease;
   /* Prevent default browser zoom behaviors */
   touch-action: pan-x pan-y;
}

#flowchart-canvas:hover {
   border-color: #667eea;
}

#flowchart-content {
   position: relative;
   min-width: 100%;
   min-height: 100%;
   /* Ensure content can expand beyond initial container */
   width: max-content;
   height: max-content;
   /* Transform origin for zooming */
   transform-origin: 0 0;
   /* Smooth zoom transitions */
   transition: transform 0.3s ease;
}

/* Zoom controls positioned in top-right of canvas */
.canvas-zoom-controls {
   position: absolute;
   top: 15px;
   right: 15px;
   z-index: 1001;
   display: flex;
   flex-direction: column;
   gap: 8px;
   background: rgba(255, 255, 255, 0.95);
   padding: 8px;
   border-radius: 8px;
   box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
   backdrop-filter: blur(5px);
}

.zoom-btn {
   width: 36px;
   height: 36px;
   border: none;
   border-radius: 6px;
   background: #667eea;
   color: white;
   font-size: 1.2rem;
   font-weight: bold;
   cursor: pointer;
   transition: all 0.3s ease;
   display: flex;
   align-items: center;
   justify-content: center;
   margin: 0;
   padding: 0;
}

.zoom-btn:hover {
   background: #5a6fd8;
   transform: scale(1.1);
}

.zoom-btn:active {
   transform: scale(0.95);
}

.zoom-btn:disabled {
   background: #bdc3c7;
   cursor: not-allowed;
   transform: none;
}

.zoom-level-display {
   font-size: 0.7rem;
   color: #666;
   text-align: center;
   font-weight: 600;
   margin: 4px 0;
   user-select: none;
}

/* Hide zoom controls in navigate mode */
#navigate-mode .canvas-zoom-controls {
    display: none !important;
}

/* Only show zoom controls in create mode */
#create-mode .canvas-zoom-controls {
    display: flex !important;
}
/* Enhanced canvas controls with better positioning */
.canvas-controls {
   position: absolute;
   top: 15px;
   left: 15px;
   z-index: 1000;
   display: flex;
   gap: 8px;
   background: rgba(255, 255, 255, 0.95);
   padding: 8px;
   border-radius: 8px;
   box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
   backdrop-filter: blur(5px);
}

.canvas-controls .btn {
   padding: 8px 12px;
   font-size: 0.8rem;
   margin: 0;
   white-space: nowrap;
}

/* Ensure flowchart nodes maintain their dimensions during zoom */
.flowchart-node {
   position: absolute;
   background: white;
   border: 2px solid #667eea;
   border-radius: 12px;
   padding: 12px;
   box-shadow: 0 4px 12px rgba(0,0,0,0.15);
   cursor: move;
   user-select: none;
   font-size: 0.85rem;
   word-wrap: break-word;
   overflow-wrap: break-word;
   /* Prevent node from shrinking */
   flex-shrink: 0;
   /* Ensure minimum dimensions */
   min-width: 160px;
   min-height: 120px;
   /* Default width for consistent sizing */
   width: fit-content;
   max-width: 350px;
   /* Prevent text overflow issues */
   overflow: visible;
   /* Ensure proper box model */
   box-sizing: border-box;
}

/* Prevent canvas from constraining nodes */
#flowchart-canvas {
   /* Allow horizontal and vertical scrolling */
   overflow-x: auto;
   overflow-y: auto;
   /* Ensure smooth scrolling */
   scroll-behavior: smooth;
}

/* Mini-map styles (optional enhancement) */
.canvas-minimap {
   position: absolute;
   bottom: 15px;
   right: 15px;
   width: 200px;
   height: 150px;
   background: rgba(255, 255, 255, 0.9);
   border: 2px solid #e0e0e0;
   border-radius: 8px;
   z-index: 999;
   display: none; /* Hidden by default, can be toggled */
   overflow: hidden;
}

.minimap-content {
   width: 100%;
   height: 100%;
   transform-origin: 0 0;
   position: relative;
}

.minimap-viewport {
   position: absolute;
   border: 2px solid #667eea;
   background: rgba(102, 126, 234, 0.1);
   cursor: move;
}

.minimap-toggle {
   position: absolute;
   bottom: 15px;
   left: 15px;
   z-index: 1000;
   background: rgba(255, 255, 255, 0.95);
   border: none;
   border-radius: 6px;
   padding: 8px 12px;
   font-size: 0.8rem;
   cursor: pointer;
   color: #667eea;
   font-weight: 600;
   box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
   transition: all 0.3s ease;
}

.minimap-toggle:hover {
   background: #667eea;
   color: white;
   transform: translateY(-1px);
}

/* Responsive adjustments for zoom controls */
@media (max-width: 768px) {
   .canvas-zoom-controls {
       top: 10px;
       right: 10px;
       padding: 6px;
   }
   
   .zoom-btn {
       width: 32px;
       height: 32px;
       font-size: 1rem;
   }
   
   .canvas-controls {
       top: 10px;
       left: 10px;
       padding: 6px;
       gap: 6px;
   }
   
   .canvas-controls .btn {
       padding: 6px 10px;
       font-size: 0.75rem;
   }
}

.panel {
   background: rgba(255,255,255,0.95);
   border-radius: 20px;
   padding: 25px;
   margin-bottom: 20px;
   box-shadow: 0 8px 32px rgba(0,0,0,0.1);
   backdrop-filter: blur(10px);
}

.form-panel {
   margin-bottom: 0;
}

.flowchart-panel {
   height: 100%;
   display: flex;
   flex-direction: column;
   margin-bottom: 0;
}

.form-group {
   margin-bottom: 20px;
}

label {
   display: block;
   margin-bottom: 8px;
   font-weight: 600;
   color: #555;
}

input, textarea, select {
   width: 100%;
   padding: 12px;
   border: 2px solid #e0e0e0;
   border-radius: 8px;
   font-size: 0.9rem;
   transition: border-color 0.3s ease;
}

input:focus, textarea:focus, select:focus {
   outline: none;
   border-color: #667eea;
   box-shadow: 0 0 0 3px rgba(102,126,234,0.1);
}

textarea {
   resize: vertical;
   min-height: 60px;
}

.options-container {
   border: 2px dashed #ddd;
   border-radius: 8px;
   padding: 15px;
   margin-top: 10px;
}

.option-item {
   display: flex;
   gap: 8px;
   margin-bottom: 10px;
   align-items: center;
}

.option-item input {
   flex: 1;
}

.remove-option {
   background: #ff4757;
   color: white;
   border: none;
   width: 30px;
   height: 30px;
   border-radius: 50%;
   cursor: pointer;
   font-size: 1rem;
   transition: all 0.3s ease;
   flex-shrink: 0;
}

.remove-option:hover {
   background: #ff3742;
   transform: scale(1.1);
}

.btn {
   padding: 12px 20px;
   border: none;
   border-radius: 8px;
   font-size: 0.9rem;
   font-weight: 600;
   cursor: pointer;
   transition: all 0.3s ease;
   margin: 5px;
}

.btn-primary {
   background: #667eea;
   color: white;
}

.btn-secondary {
   background: #95a5a6;
   color: white;
}

.btn-success {
   background: #27ae60;
   color: white;
}

.btn-danger {
   background: #e74c3c;
   color: white;
}

.btn-example {
   background: #f39c12;
   color: white;
}

.btn:hover {
   transform: translateY(-2px);
   box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

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

.btn:disabled {
   opacity: 0.6;
   cursor: not-allowed;
   transform: none;
}

.btn-large {
   width: 100%;
   padding: 15px;
   margin: 8px 0;
   font-size: 1rem;
}

.navigation-buttons {
   display: flex;
   gap: 10px;
   margin-top: 20px;
}

.navigation-buttons .btn {
   flex: 1;
}

#navigation-content {
   transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Navigate Mode Styles */
#navigate-mode .panel {
   max-width: 800px;
   margin: 0 auto;
}

.current-node {
   text-align: center;
   margin-bottom: 30px;
   padding: 25px;
   background: #f8f9fa;
   border-radius: 15px;
   border-left: 4px solid #667eea;
}

.node-id {
   font-size: 0.85rem;
   color: #666;
   margin-bottom: 8px;
   font-weight: 500;
}

.node-instruction {
   font-size: 1.2rem;
   font-weight: 600;
   color: #333;
   line-height: 1.4;
   margin-bottom: 15px;
   white-space: pre-wrap;
   word-wrap: break-word;
}

.node-instruction a {
   color: #667eea;
   text-decoration: underline;
   transition: color 0.3s ease;
}

.node-instruction a:hover {
   color: #5a6fd8;
   text-decoration: underline;
}

.navigate-options {
   display: grid;
   gap: 12px;
   margin-bottom: 25px;
}

.navigate-options .btn-large {
   padding: 16px 20px;
   font-size: 1rem;
   min-height: auto;
   border-radius: 10px;
}

.navigation-buttons {
   display: flex;
   gap: 12px;
   margin-top: 20px;
   max-width: 400px;
   margin-left: auto;
   margin-right: auto;
}

.navigation-buttons .btn {
   flex: 1;
   padding: 12px 20px;
   font-size: 0.95rem;
   margin: 0;
}

.node-image {
   margin-top: 15px;
   text-align: center;
}

.node-image img {
   max-width: 100%;
   max-height: 250px;
   border-radius: 12px;
   box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.file-input-wrapper {
   position: relative;
   overflow: hidden;
   display: inline-block;
   width: 100%;
}

.file-input-wrapper input[type=file] {
   position: absolute;
   left: -9999px;
}

.file-input-label {
   display: block;
   padding: 12px;
   background: #3498db;
   color: white;
   text-align: center;
   border-radius: 8px;
   cursor: pointer;
   transition: all 0.3s ease;
   font-size: 0.9rem;
}

.file-input-label:hover {
   background: #2980b9;
   transform: translateY(-2px);
}

/* Enhanced Flowchart Display */
.flowchart-header {
   display: flex;
   justify-content: space-between;
   align-items: center;
   margin-bottom: 20px;
   padding-bottom: 15px;
   border-bottom: 2px solid #e0e0e0;
}

.flowchart-title {
   font-size: 1.3rem;
   font-weight: 700;
   color: #333;
}

.flowchart-stats {
   font-size: 0.85rem;
   color: #666;
   background: #f8f9fa;
   padding: 6px 12px;
   border-radius: 15px;
}

.flowchart-sections {
   display: flex;
   flex-direction: column;
   gap: 20px;
}

.flowchart-section {
   background: #f8f9fa;
   border-radius: 12px;
   padding: 15px;
   border-left: 4px solid #667eea;
}

.flowchart-section.collapsed .nodes-grid {
   max-height: 350px;
   overflow: hidden;
   position: relative;
}

.flowchart-section.collapsed .nodes-grid::after {
   content: '';
   position: absolute;
   bottom: 0;
   left: 0;
   right: 0;
   height: 50px;
   background: linear-gradient(transparent, #f8f9fa);
   pointer-events: none;
}

.show-more-btn {
   width: 100%;
   margin-top: 12px;
   padding: 10px;
   background: #667eea;
   color: white;
   border: none;
   border-radius: 6px;
   font-size: 0.85rem;
   font-weight: 600;
   cursor: pointer;
   transition: all 0.3s ease;
}

.show-more-btn:hover {
   background: #5a6fd8;
   transform: translateY(-1px);
}

.show-more-btn.show-less {
   background: #95a5a6;
}

.show-more-btn.show-less:hover {
   background: #839496;
}

.section-header {
   display: flex;
   justify-content: space-between;
   align-items: center;
   margin-bottom: 12px;
}

.section-title {
   font-size: 1.1rem;
   font-weight: 600;
   color: #333;
   display: flex;
   align-items: center;
   gap: 6px;
}

.section-count {
   background: #667eea;
   color: white;
   padding: 3px 10px;
   border-radius: 12px;
   font-size: 0.75rem;
   font-weight: 600;
}

.nodes-grid {
   display: grid;
   gap: 12px;
}

.node-card {
   background: white;
   border-radius: 10px;
   padding: 15px;
   box-shadow: 0 2px 6px rgba(0,0,0,0.1);
   transition: all 0.3s ease;
   border: 2px solid transparent;
}

.node-card:hover {
   transform: translateY(-2px);
   box-shadow: 0 4px 12px rgba(0,0,0,0.15);
   border-color: #667eea;
}

.node-card.start-node {
   border-left: 4px solid #27ae60;
}

.node-card.end-node {
   border-left: 4px solid #e74c3c;
}

.node-header {
   display: flex;
   justify-content: space-between;
   align-items: flex-start;
   margin-bottom: 10px;
}

.node-id-badge {
   font-size: 1rem;
   font-weight: 700;
   color: #333;
   font-family: 'Monaco', 'Consolas', monospace;
   text-decoration: underline;
}

.node-indicators {
   display: flex;
   gap: 4px;
}

.node-indicator {
   width: 18px;
   height: 18px;
   border-radius: 50%;
   display: flex;
   align-items: center;
   justify-content: center;
   font-size: 0.65rem;
}

.has-image {
   background: #3498db;
   color: white;
}

.node-instruction-text {
   color: #333;
   line-height: 1.4;
   margin-bottom: 12px;
   font-size: 0.9rem;
   white-space: pre-wrap;
   word-wrap: break-word;
}

.node-instruction-text a {
   color: #667eea;
   text-decoration: underline;
   transition: color 0.3s ease;
}

.node-instruction-text a:hover {
   color: #5a6fd8;
   text-decoration: underline;
}

.node-options {
   display: flex;
   flex-direction: column;
   gap: 6px;
}

.option-flow {
   display: flex;
   align-items: center;
   padding: 6px 10px;
   background: #f8f9fa;
   border-radius: 6px;
   font-size: 0.8rem;
   border-left: 3px solid #667eea;
}

.option-label {
   font-weight: 600;
   color: #333;
   margin-right: 6px;
}

.option-arrow {
   color: #666;
   margin: 0 6px;
}

.option-target {
   color: #667eea;
   font-family: 'Monaco', 'Consolas', monospace;
   font-size: 0.75rem;
}

.node-actions {
   display: flex;
   gap: 6px;
   margin-top: 12px;
   padding-top: 12px;
   border-top: 1px solid #e0e0e0;
}

.node-actions .btn {
   padding: 6px 12px;
   font-size: 0.8rem;
   margin: 0;
}

/* Improved flowchart actions - better sizing without unnecessary stacking */
.flowchart-actions {
   display: flex;
   gap: 12px;
   margin-top: 20px;
   flex-wrap: wrap;
   justify-content: center;
   align-items: center;
}

.flowchart-actions .btn {
   flex: 0 0 auto; /* Don't grow or shrink, use content size */
   min-width: 140px;
   max-width: 180px;
   padding: 10px 16px;
   font-size: 0.85rem;
   white-space: nowrap;
}

.flowchart-actions .file-input-wrapper {
   flex: 0 0 auto; /* Don't grow or shrink, use content size */
   min-width: 140px;
   max-width: 180px;
}

.flowchart-actions .file-input-label {
   padding: 10px 16px;
   font-size: 0.85rem;
   white-space: nowrap;
   display: block;
   width: 100%;
   box-sizing: border-box;
}

.example-dropdown {
   position: relative;
   display: inline-block;
   flex: 0 0 auto; /* Don't grow or shrink, use content size */
   min-width: 140px;
   max-width: 180px;
}

.example-dropdown-btn {
   width: 100%;
   padding: 10px 16px;
   font-size: 0.85rem;
   background: #f39c12;
   color: white;
   border: none;
   border-radius: 8px;
   cursor: pointer;
   transition: all 0.3s ease;
   display: flex;
   align-items: center;
   justify-content: center;
   gap: 6px;
   white-space: nowrap;
   box-sizing: border-box;
}

.example-dropdown-btn:hover {
   background: #e67e22;
   transform: translateY(-2px);
}

/* Only stack on mobile screens */
@media (max-width: 600px) {
   .flowchart-actions {
       flex-direction: column;
       align-items: stretch;
       gap: 8px;
   }
   
   .flowchart-actions .btn,
   .flowchart-actions .file-input-wrapper,
   .example-dropdown {
       flex: none;
       max-width: none;
       min-width: auto;
       width: 100%;
   }
}

/* Search functionality styles */
.search-container {
   margin-bottom: 20px;
   background: #f8f9fa;
   border-radius: 8px;
   padding: 8px 15px;
   border-left: 4px solid #3498db;
}

.search-input-wrapper {
   position: relative;
   margin-bottom: 0;
   max-width: 400px;
   margin-left: auto;
   margin-right: auto;
}

.search-input-wrapper input {
   width: 100%;
   padding: 10px 40px 10px 16px;
   border: 2px solid #e0e0e0;
   border-radius: 6px;
   font-size: 0.9rem;
   transition: border-color 0.3s ease;
}

.search-input-wrapper input:focus {
   outline: none;
   border-color: #3498db;
   box-shadow: 0 0 0 3px rgba(52,152,219,0.1);
}

.search-clear-btn {
   position: absolute;
   right: 12px;
   top: 50%;
   transform: translateY(-50%);
   background: #95a5a6;
   color: white;
   border: none;
   width: 24px;
   height: 24px;
   border-radius: 50%;
   cursor: pointer;
   font-size: 1rem;
   transition: all 0.3s ease;
   display: none;
}

.search-clear-btn:hover {
   background: #7f8c8d;
   transform: translateY(-50%) scale(1.1);
}

.search-clear-btn.show {
   display: block;
}

.search-results {
   display: none;
}

.search-results.show {
   display: block;
}

.search-result-item {
   background: white;
   border-radius: 8px;
   padding: 12px;
   margin-bottom: 8px;
   box-shadow: 0 2px 6px rgba(0,0,0,0.1);
   transition: all 0.3s ease;
   cursor: pointer;
   border: 2px solid transparent;
}

.search-result-item:hover {
   transform: translateY(-1px);
   box-shadow: 0 4px 12px rgba(0,0,0,0.15);
   border-color: #3498db;
}

.search-result-header {
   display: flex;
   justify-content: space-between;
   align-items: center;
   margin-bottom: 6px;
}

.search-result-id {
   font-size: 0.9rem;
   font-weight: 700;
   color: #3498db;
   font-family: 'Monaco', 'Consolas', monospace;
}

.search-result-actions {
   display: flex;
   gap: 4px;
}

.search-result-actions .btn {
   padding: 4px 8px;
   font-size: 0.75rem;
   margin: 0;
}

.search-result-instruction {
   color: #333;
   line-height: 1.4;
   margin-bottom: 8px;
   font-size: 0.85rem;
   white-space: pre-wrap;
   word-wrap: break-word;
}

.search-result-instruction a {
   color: #667eea;
   text-decoration: underline;
   transition: color 0.3s ease;
}

.search-result-instruction a:hover {
   color: #5a6fd8;
   text-decoration: underline;
}

.search-result-options {
   display: flex;
   flex-wrap: wrap;
   gap: 4px;
}

.search-result-option {
   background: #ecf0f1;
   padding: 3px 6px;
   border-radius: 4px;
   font-size: 0.7rem;
   color: #555;
}

.search-highlight {
   background: #fff3cd;
   padding: 1px 3px;
   border-radius: 2px;
   font-weight: 600;
}

.no-results {
   text-align: center;
   color: #666;
   font-style: italic;
   padding: 15px;
}

.example-dropdown {
   position: relative;
   display: inline-block;
   flex: 1;
   min-width: 100px;
}

.example-dropdown-btn {
   width: 100%;
   padding: 10px 12px;
   font-size: 0.85rem;
   background: #f39c12;
   color: white;
   border: none;
   border-radius: 8px;
   cursor: pointer;
   transition: all 0.3s ease;
   display: flex;
   align-items: center;
   justify-content: center;
   gap: 6px;
}

.example-dropdown-btn:hover {
   background: #e67e22;
   transform: translateY(-2px);
}

.example-dropdown-content {
   display: none;
   position: absolute;
   background-color: white;
   min-width: 180px;
   box-shadow: 0 6px 12px rgba(0,0,0,0.2);
   border-radius: 8px;
   z-index: 1000;
   bottom: 100%;
   left: 0;
   margin-bottom: 4px;
   overflow: hidden;
}

.example-dropdown-content.show {
   display: block;
}

.example-option {
   color: #333;
   padding: 10px 12px;
   text-decoration: none;
   display: block;
   cursor: pointer;
   transition: background-color 0.3s ease;
   border-bottom: 1px solid #f0f0f0;
   font-size: 0.85rem;
}

.example-option:last-child {
   border-bottom: none;
}

.example-option:hover {
   background-color: #f8f9fa;
}

.hidden {
   display: none;
}

.image-preview {
   margin-top: 12px;
   text-align: center;
}

.image-preview img {
   max-width: 100%;
   max-height: 150px;
   border-radius: 6px;
   box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}

/* Empty state */
.empty-state {
   text-align: center;
   padding: 40px 20px;
   color: #666;
}

.empty-state-icon {
   font-size: 3rem;
   margin-bottom: 15px;
   opacity: 0.5;
}

.empty-state-text {
   font-size: 1rem;
   margin-bottom: 8px;
}

.empty-state-subtext {
   font-size: 0.85rem;
   opacity: 0.7;
}

/* Responsive Design */
@media (max-width: 1200px) {
   .main-layout {
       gap: 15px;
   }
   
   .sidebar {
       width: 30%;
       min-width: 280px;
   }
}

@media (max-width: 960px) {
   .main-layout {
       flex-direction: column;
       height: auto;
       min-height: calc(100vh - 200px);
   }
   
   .sidebar {
       width: 100%;
       max-width: none;
       position: static;
       max-height: none;
       margin-bottom: 20px;
   }
   
   .main-content {
       flex: 1;
       min-height: 500px;
   }
   
   #flowchart-canvas {
       min-height: 400px;
   }
}

@media (max-width: 768px) {
   .container {
       padding: 15px;
   }
   
   .header h1 {
       font-size: 2rem;
   }
   
   .panel {
       padding: 20px;
   }

   .flowchart-actions {
       flex-direction: column;
   }

   .flowchart-actions .btn, .example-dropdown {
       flex: none;
   }
   
   .mode-selector {
       flex-direction: column;
       gap: 8px;
   }
   
   .option-item {
       flex-direction: column;
       gap: 8px;
   }
   
   .option-item input {
       width: 100%;
   }
}

@media (max-width: 480px) {
   .container {
       padding: 10px;
   }
   
   .panel {
       padding: 15px;
   }
   
   input, textarea {
       padding: 10px;
       font-size: 0.85rem;
   }
   
   .btn {
       padding: 10px 15px;
       font-size: 0.85rem;
   }
}
/* Enhanced Flowchart Canvas Styles */
#flowchart-canvas {
   flex: 1;
   min-height: 0;
   height: 100%;
   background: #fafafa;
   border-radius: 12px;
   padding: 20px;
   overflow: auto;
   position: relative;
   border: 2px dashed #e0e0e0;
   transition: border-color 0.3s ease;
}

#flowchart-canvas:hover {
   border-color: #667eea;
}

#flowchart-content {
   position: relative;
   min-width: 100%;
   min-height: 100%;
   /* Ensure content can expand beyond initial container */
   width: max-content;
   height: max-content;
}

/* Ensure flowchart nodes maintain their dimensions */
.flowchart-node {
   position: absolute;
   background: white;
   border: 2px solid #667eea;
   border-radius: 12px;
   padding: 12px;
   box-shadow: 0 4px 12px rgba(0,0,0,0.15);
   cursor: move;
   user-select: none;
   font-size: 0.85rem;
   word-wrap: break-word;
   overflow-wrap: break-word;
   /* Prevent node from shrinking */
   flex-shrink: 0;
   /* Ensure minimum dimensions */
   min-width: 160px;
   min-height: 120px;
   /* Default width for consistent sizing */
   width: fit-content;
   max-width: 350px;
   /* Prevent text overflow issues */
   overflow: visible;
   /* Ensure proper box model */
   box-sizing: border-box;
}

/* Prevent canvas from constraining nodes */
#flowchart-canvas {
   /* Allow horizontal and vertical scrolling */
   overflow-x: auto;
   overflow-y: auto;
   /* Ensure smooth scrolling */
   scroll-behavior: smooth;
}
/* New sidebar header styles with navigate button */
.sidebar-header {
    text-align: center;
    margin-bottom: 20px;
    padding: 20px;
    background: rgba(255,255,255,0.95);
    border-radius: 15px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    color: #333;
}

.sidebar-header h1 {
    font-size: 1.8rem;
    margin-bottom: 8px;
    text-shadow: none;
}

.sidebar-header p {
    font-size: 0.9rem;
    color: #666;
    margin: 0 0 20px 0;
}

/* Navigate button styling under logo */
.navigate-from-create {
    background: #27ae60 !important;
    color: white;
    font-size: 1rem;
    padding: 16px 24px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3);
    margin-top: 15px;
    width: 100%;
    font-weight: 600;
}

.navigate-from-create:hover {
    background: #229954 !important;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(39, 174, 96, 0.4);
}

.navigate-from-create:active {
    transform: translateY(0);
}

/* Create button styling in navigate mode */
.create-from-navigate {
    background: #667eea !important;
    color: white;
    font-size: 0.95rem;
    padding: 12px 20px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
    font-weight: 600;
}

.create-from-navigate:hover {
    background: #5a6fd8 !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.create-from-navigate:active {
    transform: translateY(0);
}

/* Hide old mode tabs */
.mode-tabs {
    display: none;
}

/* Remove old header and mode selector styles */
.header {
    display: none;
}

.mode-selector {
    display: none;
}

/* Update flowchart header to use flexbox properly */
.flowchart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e0e0e0;
    flex-wrap: wrap;
    gap: 15px;
}

.flowchart-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #333;
}

.flowchart-stats {
    font-size: 0.85rem;
    color: #666;
    background: #f8f9fa;
    padding: 6px 12px;
    border-radius: 15px;
}

/* Remove old header and mode selector styles */
.header {
    display: none;
}

.mode-selector {
    display: none;
}
/* Make flowchart panel full height */
.flowchart-panel {
    height: calc(100vh - 40px); /* Full viewport height minus container padding */
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
}

#flowchart-canvas {
    flex: 1;
    min-height: 0;
    height: 100%;
    background: #fafafa;
    border-radius: 12px;
    padding: 20px;
    overflow: auto;
    position: relative;
    border: 2px dashed #e0e0e0;
    transition: border-color 0.3s ease;
}
@media (max-width: 768px) {
    
    #flowchart-canvas {
        height: calc(100% - 140px);
        padding: 10px;

    }
}
/* Ensure the main layout uses full height */
.main-layout {
    display: flex;
    gap: 20px;
    height: calc(100vh - 40px);
    min-height: 600px;
}

/* Make sure the main content takes full height */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: 100%;
}

/* Adjust container padding */
.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    height: 100vh;
    overflow: hidden;
}
/* =================================
   MOBILE UI IMPROVEMENTS
   Add this entire section to the END of your style.css file
   ================================= */

/* Mobile Navigation Bar */
.mobile-nav {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: rgba(102, 126, 234, 0.95);
    backdrop-filter: blur(10px);
    z-index: 2000;
    padding: 0 20px;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.mobile-nav-title {
    color: white;
    font-size: 1.2rem;
    font-weight: 600;
}

.mobile-menu-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.mobile-menu-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* REPLACE THE MOBILE SIDE MENU CSS (around line 1200 in style.css) WITH THIS: */

/* Mobile Side Menu - Opens from RIGHT side */
.mobile-side-menu {
    position: fixed;
    top: 0;
    right: -100%;  /* Start hidden on the right */
    width: 90%;
    max-width: 400px;
    height: 100vh;
    background: white;
    z-index: 3000;
    transition: right 0.3s ease;  /* Animate right property */
    overflow-y: auto;
    box-shadow: -2px 0 20px rgba(0,0,0,0.3);  /* Shadow on left side */
}

.mobile-side-menu.open {
    right: 0;  /* Slide in from right */
}

/* Update the mobile menu button to indicate left-side menu */
.mobile-menu-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.mobile-menu-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* Mobile FAB positioning - move to left since menu is on right */
.mobile-fab {
    position: fixed;
    bottom: 20px;
    left: 20px;  /* Move to left since menu is on right */
    width: 60px;
    height: 60px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(39, 174, 96, 0.4);
    z-index: 1500;
    transition: all 0.3s ease;
    display: none;
    /* Fix for bottom cutoff */
    margin-bottom: env(safe-area-inset-bottom, 0px);
}
.mobile-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(39, 174, 96, 0.5);
}

.mobile-fab:active {
    transform: scale(0.95);
}

/* Mobile node toolbar - position away from right menu and fix bottom cutoff */
.mobile-node-toolbar {
    position: fixed;
    bottom: 90px;  /* More space from bottom */
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    z-index: 1600;
    display: none;
    gap: 8px;
    /* Fix for bottom cutoff */
    margin-bottom: env(safe-area-inset-bottom, 0px);
    max-width: 90vw;  /* Prevent overflow on small screens */
    flex-wrap: wrap;  /* Allow buttons to wrap if needed */
}

.mobile-node-toolbar.show {
    display: flex;
}

.mobile-node-toolbar .btn {
    padding: 8px 12px;
    font-size: 0.8rem;
    margin: 0;
    min-width: auto;
    flex: 0 0 auto;  /* Prevent button shrinking */
}
.mobile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2500;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.mobile-overlay.show {
    opacity: 1;
    visibility: visible;
}

.mobile-menu-header {
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mobile-menu-close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
}

/* Enhanced mobile menu content with better spacing */
.mobile-menu-content {
    padding: 20px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));  /* Add safe area padding */
    min-height: calc(100vh - 120px);  /* Ensure content doesn't overflow */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Mobile Floating Action Button */
.mobile-fab {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background: #27ae60;
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(39, 174, 96, 0.4);
    z-index: 1500;
    transition: all 0.3s ease;
    display: none;
}

.mobile-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(39, 174, 96, 0.5);
}

.mobile-fab:active {
    transform: scale(0.95);
}

/* Mobile Node Selection */
.flowchart-node.mobile-selected {
    border-color: #3498db !important;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3), 0 4px 12px rgba(0,0,0,0.15) !important;
    transform: scale(1.02);
}

.mobile-node-toolbar {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    z-index: 1600;
    display: none;
    gap: 8px;
}

.mobile-node-toolbar.show {
    display: flex;
}

.mobile-node-toolbar .btn {
    padding: 8px 12px;
    font-size: 0.8rem;
    margin: 0;
    min-width: auto;
}

/* Mobile Scroll Hints */
.scroll-hint {
    position: absolute;
    background: rgba(102, 126, 234, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    z-index: 1100;
    pointer-events: none;
    animation: pulse 2s infinite;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.scroll-hint-horizontal {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.scroll-hint-vertical {
    right: 20px;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
}

@keyframes pulse {
    0%, 100% { opacity: 0.7; transform: translateX(-50%) scale(1); }
    50% { opacity: 1; transform: translateX(-50%) scale(1.05); }
}

/* Mobile Layout Adjustments */
@media (max-width: 768px) {
    /* Show mobile elements */
    .mobile-nav {
        display: flex;
    }
    
    .mobile-fab {
        display: block;
    }
    
    /* Hide desktop sidebar */
    .sidebar {
        display: none;
    }
    
    /* Adjust container for mobile nav */
    .container {
        padding: 70px 10px 20px 10px;
        height: 100vh;
        overflow: hidden;
    }
    
    /* Full width main content */
    .main-layout {
        flex-direction: column;
        height: calc(100vh - 90px);
        gap: 0;
    }
    
    .main-content {
        flex: 1;
        height: 100%;
        min-height: 0;
    }
    
    /* Adjust flowchart panel */
    .flowchart-panel {
        height: 100%;
        margin-bottom: 0;
        padding: 15px;
    }
    
    /* ENHANCED MOBILE CANVAS WITH IMPROVED SCROLLING */
    #flowchart-canvas {
        height: calc(100% - 140px);
        padding: 10px;
        border-radius: 8px;
        /* Critical scrolling improvements */
        overflow: auto;
        overflow-x: auto;
        overflow-y: auto;
        /* Enable momentum scrolling on iOS */
        -webkit-overflow-scrolling: touch;
        /* Smooth scrolling */
        scroll-behavior: smooth;
        /* Allow touch panning in all directions */
        touch-action: pan-x pan-y;
        /* Ensure scrollbars are visible */
        scrollbar-width: auto;
        /* Add scroll padding for better UX */
        scroll-padding: 20px;
        /* Prevent content from being cut off */
        box-sizing: border-box;
        /* Better scroll snapping */
        scroll-snap-type: none;
        /* Optimize for touch scrolling */
        overscroll-behavior: contain;
        /* Prevent rubber band effect */
        overscroll-behavior-x: none;
        overscroll-behavior-y: none;
    }
    
    /* Enhanced scrollbar styling for mobile */
    #flowchart-canvas::-webkit-scrollbar {
        width: 10px;
        height: 10px;
        background: rgba(0,0,0,0.05);
        border-radius: 5px;
    }
    
    #flowchart-canvas::-webkit-scrollbar-track {
        background: rgba(0,0,0,0.05);
        border-radius: 5px;
        margin: 5px;
    }
    
    #flowchart-canvas::-webkit-scrollbar-thumb {
        background: rgba(102, 126, 234, 0.7);
        border-radius: 5px;
        border: 1px solid rgba(255,255,255,0.2);
    }
    
    #flowchart-canvas::-webkit-scrollbar-thumb:hover {
        background: rgba(102, 126, 234, 0.9);
    }
    
    #flowchart-canvas::-webkit-scrollbar-corner {
        background: rgba(0,0,0,0.05);
    }
    
    /* Enhanced flowchart content for better scrolling */
    #flowchart-content {
        position: relative;
        /* Ensure minimum scrollable area */
        min-width: 100vw;
        min-height: 100vh;
        /* Allow content to expand as needed */
        width: max-content;
        height: max-content;
        /* Add padding for better scroll experience */
        padding: 20px;
        /* Ensure proper box model */
        box-sizing: border-box;
        /* Ensure proper touch handling */
        touch-action: pan-x pan-y;
        /* Better rendering */
        will-change: transform;
        /* Optimize for scrolling */
        contain: layout style paint;
    }
    
    /* Performance optimizations during scroll */
    #flowchart-content.scrolling {
        transform: translateZ(0);
        will-change: scroll-position;
    }
    
    #flowchart-content.scrolling .flowchart-node:not(.mobile-selected) {
        transition: none !important;
        transform: translateZ(0);
    }
    
    /* Mobile flowchart header */
    .flowchart-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
        margin-bottom: 15px;
        padding-bottom: 10px;
    }
    
    .flowchart-title {
        font-size: 1.1rem;
        text-align: center;
    }
    
    .flowchart-stats {
        text-align: center;
        align-self: center;
    }
    
    /* Mobile flowchart actions */
    .flowchart-actions {
        flex-direction: row;
        gap: 8px;
        margin-top: 15px;
        justify-content: center;
        flex-wrap: wrap;
    }
    
    .flowchart-actions .btn,
    .flowchart-actions .file-input-wrapper,
    .example-dropdown {
        flex: 0 0 auto;
        min-width: 100px;
        max-width: 150px;
    }
    
    .flowchart-actions .btn {
        padding: 8px 12px;
        font-size: 0.75rem;
    }
    
    .flowchart-actions .file-input-label {
        padding: 8px 12px;
        font-size: 0.75rem;
    }
    
    /* Mobile node styling with enhanced touch support */
    .flowchart-node {
        min-width: 140px;
        max-width: 280px;
        font-size: 0.8rem;
        padding: 10px;
        /* Enable touch interactions */
        touch-action: manipulation;
        /* Prevent text selection on touch */
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        /* Enhanced visual feedback for touch */
        transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
        /* Optimize rendering during scroll */
        will-change: transform;
        /* Better compositing */
        transform: translateZ(0);
        /* Reduce repaints */
        contain: layout style paint;
        /* Ensure proper stacking */
        z-index: 10;
    }
    
    /* Touch feedback for nodes */
    .flowchart-node:active {
        transform: scale(0.98);
    }
    
    /* Enhanced dragging state */
    .flowchart-node.dragging {
        z-index: 1000;
        transform: translateZ(10px) scale(1.05);
        opacity: 0.9;
        box-shadow: 0 8px 32px rgba(0,0,0,0.3) !important;
        transition: none;
        will-change: transform, left, top;
    }
    
    /* Performance optimizations for non-interacting nodes */
    .flowchart-node:not(.mobile-selected):not(.dragging) {
        transition: none;
    }
    
    /* Mobile search container */
    .search-container {
        padding: 8px 12px;
        margin-bottom: 15px;
    }
    
    .search-input-wrapper {
        max-width: 100%;
    }
    
    .search-input-wrapper input {
        padding: 8px 35px 8px 12px;
        font-size: 0.85rem;
    }
    
    /* Mobile navigate mode adjustments */
    #navigate-mode .panel {
        padding: 15px;
        margin: 0;
        height: calc(100vh - 90px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .current-node {
        padding: 20px;
        margin-bottom: 20px;
    }
    
    .node-instruction {
        font-size: 1.1rem;
        line-height: 1.5;
    }
    
    .navigate-options {
        gap: 10px;
        margin-bottom: 20px;
    }
    
    .navigate-options .btn-large {
        padding: 14px 18px;
        font-size: 0.95rem;
        border-radius: 8px;
    }
    
    .navigation-buttons {
        flex-direction: column;
        gap: 10px;
        max-width: 100%;
    }
    
    .navigation-buttons .btn {
        padding: 12px 18px;
        font-size: 0.9rem;
    }
    
    /* Mobile zoom controls */
    .canvas-zoom-controls {
        top: 10px;
        right: 10px;
        padding: 6px;
        gap: 6px;
    }
    
    .zoom-btn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }
    
    .zoom-level-display {
        font-size: 0.65rem;
    }
    
    /* Empty state adjustments for mobile */
    .empty-state {
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%, -50%);
        width: 80%;
        max-width: 300px;
        text-align: center;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    .container {
        padding: 65px 5px 15px 5px;
    }
    
    .flowchart-panel {
        padding: 10px;
    }
    
    #flowchart-canvas {
        padding: 8px;
        height: calc(100% - 120px);
    }
    
    #flowchart-content {
        min-width: 120vw;
        min-height: 100vh;
        padding: 15px;
    }
    
    .flowchart-actions {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    
    .flowchart-actions .btn,
    .flowchart-actions .file-input-wrapper,
    .example-dropdown {
        max-width: 100%;
        min-width: auto;
        width: 100%;
    }
    
    .mobile-side-menu {
        width: 95%;
    }
    
    .mobile-menu-content {
        padding: 15px;
    }
    
    .flowchart-node {
        min-width: 120px;
        max-width: 240px;
        padding: 8px;
        font-size: 0.75rem;
    }
    
    .mobile-fab {
        width: 50px;
        height: 50px;
        font-size: 1.3rem;
        bottom: 15px;
        right: 15px;
    }
    
    .scroll-hint {
        font-size: 0.65rem;
        padding: 6px 10px;
    }
    
    #flowchart-canvas::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }
}

/* Landscape mobile adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .container {
        padding: 65px 10px 15px 10px;
    }
    
    #flowchart-canvas {
        height: calc(100% - 100px);
        overflow-x: scroll;
        overflow-y: auto;
    }
    
    #flowchart-content {
        min-width: 150vw;
        min-height: 80vh;
    }
    
    .current-node {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .navigate-options .btn-large {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
    
    .scroll-hint-horizontal {
        animation: pulseHorizontal 2s infinite;
    }
    
    @keyframes pulseHorizontal {
        0%, 100% { opacity: 0.8; transform: translateX(-50%) scale(1); }
        50% { opacity: 1; transform: translateX(-50%) scale(1.1); }
    }
}

/* High DPI screen optimizations */
@media (max-width: 768px) and (-webkit-min-device-pixel-ratio: 2) {
    #flowchart-canvas::-webkit-scrollbar {
        width: 8px;
        height: 8px;
    }
    
    .flowchart-node {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
}

/* iPhone specific optimizations */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 768px) {
        #flowchart-canvas {
            -webkit-overflow-scrolling: touch;
            touch-action: pan-x pan-y;
        }
        
        #flowchart-content * {
            -webkit-touch-callout: none;
            -webkit-user-select: none;
            -khtml-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
        }
        
        input, textarea {
            -webkit-user-select: text !important;
            -moz-user-select: text !important;
            -ms-user-select: text !important;
            user-select: text !important;
        }
    }
}

/* Prevent zoom on form inputs on iOS */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    textarea,
    select {
        font-size: 16px !important;
    }
}
/* Fix mobile FAB + icon size and appearance */
.mobile-fab {
    display: flex !important;
    align-items: center;
    justify-content: center;
    font-size: 32px !important;
    font-weight: 200 !important;
    line-height: 1 !important;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif !important;
}

.mobile-fab::before {
    content: '+';
    font-size: 36px;
    font-weight: 100;
    line-height: 0.8;
    transform: translateY(-2px);
}
/* Enhanced mobile scrolling improvements */
@media (max-width: 768px) {
    #flowchart-canvas {
        /* Critical: Enable smooth native scrolling */
        overflow: auto !important;
        -webkit-overflow-scrolling: touch !important;
        /* Allow all touch gestures by default */
        touch-action: auto !important;
        /* Smooth momentum scrolling */
        scroll-behavior: smooth;
        /* Prevent overscroll effects that interfere with scrolling */
        overscroll-behavior: contain;
        /* Better scroll performance */
        will-change: scroll-position;
    }
    
    #flowchart-content {
        /* Ensure content is large enough to scroll */
        min-width: 150vw !important;
        min-height: 150vh !important;
        /* Better touch handling */
        touch-action: auto;
        /* Performance optimization */
        contain: layout style paint;
    }
    
    /* Enhanced scrollbars for mobile */
    #flowchart-canvas::-webkit-scrollbar {
        width: 8px;
        height: 8px;
        background: rgba(0,0,0,0.1);
    }
    
    #flowchart-canvas::-webkit-scrollbar-thumb {
        background: rgba(102, 126, 234, 0.6);
        border-radius: 4px;
    }
    
    #flowchart-canvas::-webkit-scrollbar-thumb:active {
        background: rgba(102, 126, 234, 0.8);
    }
    
    /* Optimize node touch handling */
    .flowchart-node {
        /* Only manipulate touch for nodes when selected */
        touch-action: manipulation;
        /* Better touch feedback */
        transition: transform 0.1s ease;
    }
    
    .flowchart-node.mobile-selected {
        /* Allow node dragging when selected */
        touch-action: none;
    }
    
    .flowchart-node.dragging {
        /* Optimize during drag */
        touch-action: none;
        pointer-events: none;
        z-index: 1000;
    }
}
/* Enhanced mobile node dragging */
@media (max-width: 768px) {
    .flowchart-node {
        /* Better touch target */
        min-height: 100px;
        min-width: 120px;
        /* Ensure touch events work */
        touch-action: manipulation;
        /* Better visual feedback */
        transition: transform 0.1s ease, box-shadow 0.1s ease;
    }
    
    .flowchart-node.mobile-selected {
        /* Clear visual selection */
        border-color: #3498db !important;
        box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3) !important;
        /* Allow dragging when selected */
        touch-action: none;
    }
    
    .flowchart-node.dragging {
        /* Enhanced dragging state */
        z-index: 1000 !important;
        opacity: 0.9 !important;
        transform: scale(1.05) !important;
        box-shadow: 0 8px 32px rgba(0,0,0,0.3) !important;
        /* Disable transitions during drag for better performance */
        transition: none !important;
        /* Prevent touch conflicts */
        touch-action: none;
        pointer-events: auto;
    }
    
    /* Ensure canvas allows node interactions */
    #flowchart-canvas {
        /* Allow scrolling AND node interactions */
        touch-action: auto;
    }
    
    #flowchart-content {
        /* Allow both scrolling and node manipulation */
        touch-action: auto;
    }
}
/* Fixed position zoom controls */
.canvas-zoom-controls {
    position: fixed !important;
    top: 50% !important;
    right: 20px !important;
    transform: translateY(-50%) !important;
    z-index: 1001 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    background: rgba(255, 255, 255, 0.95) !important;
    padding: 8px !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    backdrop-filter: blur(5px) !important;
    transition: opacity 0.3s ease !important;
}

/* Hide zoom controls when not in create mode */
#navigate-mode .canvas-zoom-controls {
    display: none !important;
}

/* Mobile adjustments for zoom controls */
@media (max-width: 768px) {
    .canvas-zoom-controls {
        right: 15px !important;
        padding: 6px !important;
        gap: 6px !important;
    }
    
    .zoom-btn {
        width: 32px !important;
        height: 32px !important;
        font-size: 1rem !important;
    }
    
    .zoom-level-display {
        font-size: 0.65rem !important;
    }
}
/* ADD THIS CSS RULE TO YOUR style.css FILE: */

/* Hide desktop node action buttons on mobile */
@media (max-width: 768px) {
    .flowchart-node .btn {
        display: none !important;
    }
    
    /* Specifically hide the actions container on mobile */
    .flowchart-node > div:last-child {
        display: none !important;
    }
}

/* Ensure buttons are visible on desktop */
@media (min-width: 769px) {
    .flowchart-node .btn {
        display: inline-block;
    }
}
/* ADD/UPDATE this CSS in your style.css - Mobile Node Options Styling */

/* =================================
   MOBILE NODE OPTIONS - KEEP VISIBLE
   ================================= */

@media (max-width: 768px) {
    
    /* Hide ONLY the edit/delete action buttons on mobile */
    .desktop-node-actions {
        display: none !important;
    }
    
    /* Hide any standalone edit/delete buttons */
    .flowchart-node .btn:not(.mobile-node-toolbar .btn) {
        display: none !important;
    }
    
    /* KEEP options visible and well-styled on mobile */
    .flowchart-node {
        /* Better touch targets */
        min-height: 100px !important;
        min-width: 140px !important;
        max-width: 280px !important;
        padding: 12px !important;
        
        /* Enhanced touch feedback */
        transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease !important;
        
        /* Clean appearance */
        border: 2px solid #667eea !important;
        border-radius: 12px !important;
        background: white !important;
    }
    
    /* Enhanced mobile option styling */
    .flowchart-node > div:not(.desktop-node-actions) {
        /* Ensure all content except desktop actions is visible */
        display: block !important;
    }
    
    /* Better option readability on mobile */
    .flowchart-node > div > div {
        /* Options container styling */
        margin-bottom: 8px;
    }
    
    .flowchart-node > div > div > div {
        /* Individual option styling */
        display: flex !important;
        align-items: center !important;
        padding: 6px 8px !important;
        background: #f8f9fa !important;
        border-radius: 5px !important;
        margin-bottom: 3px !important;
        font-size: 0.7rem !important;
        border-left: 3px solid #667eea !important;
    }
    
    /* Better mobile option text */
    .flowchart-node span {
        font-size: 0.65rem !important;
        line-height: 1.2 !important;
    }
    
    /* Mobile node header */
    .flowchart-node > div:first-child {
        margin-bottom: 8px !important;
        font-size: 0.7rem !important;
        font-weight: bold !important;
    }
    
    /* Mobile instruction text */
    .flowchart-node > div:nth-child(2) {
        margin-bottom: 8px !important;
        font-size: 0.75rem !important;
        line-height: 1.3 !important;
    }
    
    /* Mobile selection state */
    .flowchart-node.mobile-selected {
        border-color: #3498db !important;
        box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3), 0 4px 12px rgba(0,0,0,0.15) !important;
        transform: scale(1.02) !important;
    }
    
    /* Mobile touch feedback */
    .flowchart-node:active {
        transform: scale(0.98) !important;
    }
    
    /* Enhanced mobile toolbar - keep existing functionality */
    .mobile-node-toolbar {
        position: fixed;
        bottom: 90px;
        left: 50%;
        transform: translateX(-50%);
        background: white;
        border-radius: 12px;
        padding: 12px;
        box-shadow: 0 8px 32px rgba(0,0,0,0.2);
        z-index: 1600;
        display: none;
        gap: 10px;
        max-width: 90vw;
        flex-wrap: wrap;
        margin-bottom: env(safe-area-inset-bottom, 0px);
    }
    
    .mobile-node-toolbar.show {
        display: flex;
    }
    
    .mobile-node-toolbar .btn {
        padding: 10px 16px !important;
        font-size: 0.85rem !important;
        margin: 0 !important;
        min-width: 80px;
        flex: 0 0 auto;
        border-radius: 8px;
        font-weight: 600;
        transition: all 0.3s ease;
        display: inline-block !important; /* Override the hide rule for toolbar buttons */
    }
    
    /* Broken link warning styling on mobile */
    .flowchart-node span[style*="color: #e74c3c"] {
        color: #e74c3c !important;
        font-weight: 600;
    }
    
    /* Valid link styling on mobile */
    .flowchart-node span[style*="color: #667eea"] {
        color: #667eea !important;
        font-weight: 500;
    }
}

/* =================================
   DESKTOP STYLING - UNCHANGED
   ================================= */

@media (min-width: 769px) {
    
    /* Desktop nodes with action buttons */
    .desktop-node-actions {
        display: flex !important;
        gap: 6px;
        padding-top: 10px;
        border-top: 1px solid #e0e0e0;
        margin-top: 8px;
    }
    
    .desktop-node-actions .btn {
        padding: 6px 12px !important;
        font-size: 0.75rem !important;
        margin: 0 !important;
        min-width: auto !important;
        flex: 1;
        border-radius: 6px;
        font-weight: 600;
        transition: all 0.3s ease;
    }
    
    .desktop-node-actions .btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    }
    
    /* Enhanced desktop node hover effects */
    .flowchart-node:hover {
        transform: translateY(-2px);
        box-shadow: 0 6px 20px rgba(0,0,0,0.15);
        border-color: #5a6fd8;
    }
    
    /* Desktop node styling */
    .flowchart-node {
        cursor: move;
        transition: all 0.3s ease;
    }
}

/* =================================
   OPTION STYLING FOR BOTH PLATFORMS
   ================================= */

/* Consistent option styling across desktop and mobile */
.flowchart-node div[style*="border-left: 3px solid"] {
    font-size: 0.7rem;
    padding: 4px 6px;
    margin-bottom: 2px;
    border-radius: 4px;
    display: flex;
    align-items: center;
}

/* Mobile-specific option adjustments */
@media (max-width: 768px) {
    .flowchart-node div[style*="border-left: 3px solid"] {
        font-size: 0.65rem !important;
        padding: 5px 7px !important;
        margin-bottom: 3px !important;
    }
}
/* ADD/UPDATE this CSS in your style.css - Mobile Node Colors Fix */

/* =================================
   MOBILE NODE TYPE COLORS - FIXED
   ================================= */

@media (max-width: 768px) {
    
    /* Base mobile node styling */
    .flowchart-node {
        min-height: 100px !important;
        min-width: 140px !important;
        max-width: 280px !important;
        padding: 12px !important;
        transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease !important;
        border-radius: 12px !important;
        background: white !important;
        /* Default border - will be overridden by node type */
        border: 2px solid #667eea !important;
    }
    
    /* START NODE - Green border (mobile) */
    .flowchart-node[style*="border-color: #27ae60"],
    .flowchart-node[style*="border-left-width: 6px"][style*="border-color: #27ae60"] {
        border-color: #27ae60 !important;
        border-left-width: 6px !important;
        border-left-color: #27ae60 !important;
    }
    
    /* END NODE - Red border (mobile) */
    .flowchart-node[style*="border-color: #e74c3c"],
    .flowchart-node[style*="border-left-width: 6px"][style*="border-color: #e74c3c"] {
        border-color: #e74c3c !important;
        border-left-width: 6px !important;
        border-left-color: #e74c3c !important;
    }
    
    /* REGULAR NODE - Blue border (mobile) */
    .flowchart-node:not([style*="border-color: #27ae60"]):not([style*="border-color: #e74c3c"]) {
        border-color: #667eea !important;
        border-left-width: 2px !important;
    }
    
    /* Mobile selection state - preserve node type colors */
    .flowchart-node.mobile-selected[style*="border-color: #27ae60"] {
        border-color: #27ae60 !important;
        border-left-width: 6px !important;
        box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.3), 0 4px 12px rgba(0,0,0,0.15) !important;
        transform: scale(1.02) !important;
    }
    
    .flowchart-node.mobile-selected[style*="border-color: #e74c3c"] {
        border-color: #e74c3c !important;
        border-left-width: 6px !important;
        box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.3), 0 4px 12px rgba(0,0,0,0.15) !important;
        transform: scale(1.02) !important;
    }
    
    .flowchart-node.mobile-selected:not([style*="border-color: #27ae60"]):not([style*="border-color: #e74c3c"]) {
        border-color: #3498db !important;
        box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3), 0 4px 12px rgba(0,0,0,0.15) !important;
        transform: scale(1.02) !important;
    }
    
    /* Mobile touch feedback - maintain colors */
    .flowchart-node:active {
        transform: scale(0.98) !important;
    }
    
    /* Enhanced visual indicators for mobile */
    .flowchart-node[style*="border-color: #27ae60"]::before {
        content: "🚀";
        position: absolute;
        top: -5px;
        left: -5px;
        font-size: 0.8rem;
        background: #27ae60;
        color: white;
        width: 20px;
        height: 20px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.6rem;
        z-index: 10;
    }
    
    .flowchart-node[style*="border-color: #e74c3c"]::before {
        content: "🏁";
        position: absolute;
        top: -5px;
        left: -5px;
        font-size: 0.8rem;
        background: #e74c3c;
        color: white;
        width: 20px;
        height: 20px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.6rem;
        z-index: 10;
    }
}

/* =================================
   ENSURE DESKTOP COLORS STILL WORK
   ================================= */

@media (min-width: 769px) {
    
    /* Desktop start nodes */
    .flowchart-node[style*="border-color: #27ae60"] {
        border-color: #27ae60 !important;
        border-left-width: 6px !important;
    }
    
    /* Desktop end nodes */
    .flowchart-node[style*="border-color: #e74c3c"] {
        border-color: #e74c3c !important;
        border-left-width: 6px !important;
    }
    
    /* Desktop regular nodes */
    .flowchart-node:not([style*="border-color: #27ae60"]):not([style*="border-color: #e74c3c"]) {
        border-color: #667eea !important;
    }
    
    /* Desktop hover states maintain colors */
    .flowchart-node[style*="border-color: #27ae60"]:hover {
        border-color: #229954 !important;
        box-shadow: 0 6px 20px rgba(39, 174, 96, 0.25);
    }
    
    .flowchart-node[style*="border-color: #e74c3c"]:hover {
        border-color: #c0392b !important;
        box-shadow: 0 6px 20px rgba(231, 76, 60, 0.25);
    }
    
    .flowchart-node:not([style*="border-color: #27ae60"]):not([style*="border-color: #e74c3c"]):hover {
        border-color: #5a6fd8 !important;
        box-shadow: 0 6px 20px rgba(102, 126, 234, 0.25);
    }
}

/* =================================
   ALTERNATIVE APPROACH - CLASS-BASED
   ================================= */

/* If the inline style approach doesn't work, use these classes */
.flowchart-node.start-node {
    border-color: #27ae60 !important;
    border-left-width: 6px !important;
}

.flowchart-node.end-node {
    border-color: #e74c3c !important;
    border-left-width: 6px !important;
}

.flowchart-node.regular-node {
    border-color: #667eea !important;
    border-left-width: 2px !important;
}

/* Mobile-specific class styling */
@media (max-width: 768px) {
    .flowchart-node.start-node {
        border-color: #27ae60 !important;
        border-left-width: 6px !important;
        border-left-color: #27ae60 !important;
    }
    
    .flowchart-node.end-node {
        border-color: #e74c3c !important;
        border-left-width: 6px !important;
        border-left-color: #e74c3c !important;
    }
    
    .flowchart-node.start-node.mobile-selected {
        box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.3), 0 4px 12px rgba(0,0,0,0.15) !important;
    }
    
    .flowchart-node.end-node.mobile-selected {
        box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.3), 0 4px 12px rgba(0,0,0,0.15) !important;
    }
}
@media (max-width: 768px) {
    /* ... existing mobile styles ... */
    
    /* MOBILE ONLY - TALLER CANVAS */
    #flowchart-canvas {
        height: calc(100% - 80px) !important; /* Taller - was 140px, now 80px */
        padding: 10px;
        border-radius: 8px;
        /* Keep all existing mobile scrolling properties */
        overflow: auto !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: auto !important;
        scroll-behavior: smooth;
        overscroll-behavior: contain;
        will-change: scroll-position;
    }
    
    /* MOBILE ONLY - EXPANDED CONTENT AREA */
    #flowchart-content {
        min-width: 150vw !important;
        min-height: 180vh !important; /* Increased from 150vh for more scroll space */
        touch-action: auto;
        contain: layout style paint;
        padding: 25px !important; /* More padding for better scroll experience */
    }
    
    /* MOBILE ONLY - PUSH BUTTONS LOWER */
    .flowchart-actions {
        margin-top: 30px !important; /* Increased spacing */
        margin-bottom: 25px !important; /* More bottom space */
        padding-top: 20px !important; /* Additional top padding */
        border-top: 2px solid #f0f0f0 !important; /* Visual separator */
    }
    
    /* MOBILE ONLY - MORE COMPACT HEADER */
    .flowchart-header {
        margin-bottom: 8px !important; /* Reduced from default */
        padding-bottom: 6px !important; /* Less padding */
    }
    
    .flowchart-title {
        font-size: 1rem !important; /* Slightly smaller */
    }
    
    .flowchart-stats {
        font-size: 0.8rem !important; /* Smaller stats */
        padding: 4px 10px !important;
    }
}

/* MOBILE NAVIGATE BUTTON - MOBILE ONLY */
.mobile-navigate-button {
    display: none; /* Hidden by default (desktop) */
}

@media (max-width: 768px) {
    /* MOBILE ONLY - Show navigate button above search */
    .mobile-navigate-button {
        display: block !important;
        text-align: center;
        padding: 8px 0;
        margin-bottom: 12px !important;
        border-bottom: 1px solid rgba(102, 126, 234, 0.2);
    }
    
    .navigate-from-create-mobile {
        background: #27ae60 !important;
        color: white !important;
        font-size: 0.95rem !important;
        padding: 12px 20px !important;
        border-radius: 8px !important;
        border: none !important;
        cursor: pointer !important;
        transition: all 0.3s ease !important;
        box-shadow: 0 3px 10px rgba(39, 174, 96, 0.3) !important;
        width: 100% !important;
        max-width: 280px !important;
        font-weight: 600 !important;
    }
    
    .navigate-from-create-mobile:hover {
        background: #229954 !important;
        transform: translateY(-2px) !important;
        box-shadow: 0 5px 14px rgba(39, 174, 96, 0.4) !important;
    }
    
    /* MOBILE ONLY - Hide desktop navigate button */
    .sidebar .navigate-from-create {
        display: none !important;
    }
}

/* DESKTOP ONLY - Ensure desktop button stays visible */
@media (min-width: 769px) {
    .mobile-navigate-button {
        display: none !important;
    }
    
    .sidebar .navigate-from-create {
        display: block !important;
    }
    
    /* Ensure desktop canvas is unchanged */
    #flowchart-canvas {
        /* Desktop styles remain exactly as they were */
        height: 100%; 
        /* All other desktop properties unchanged */
    }
}
/* =================================
   MOBILE FULL-HEIGHT CANVAS FIX
   Replace the existing mobile section in style.css with this
   ================================= */

/* =================================
   MOBILE LAYOUT - FIXED ORDER AND HEIGHT
   ================================= */

/* Mobile Layout Adjustments */
@media (max-width: 768px) {
    /* Show mobile elements */
    .mobile-nav {
        display: flex;
    }
    
    .mobile-fab {
        display: block;
    }
    
    /* Hide desktop sidebar */
    .sidebar {
        display: none;
    }
    
    /* Container adjustments */
    .container {
        padding: 70px 10px 20px 10px;
        min-height: 100vh;
        height: auto;
        overflow: visible;
    }
    
    /* Main layout */
    .main-layout {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 90px);
        gap: 0;
    }
    
    .main-content {
        flex: 1;
        height: auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    
    /* CRITICAL: Fixed order for mobile elements */
    .flowchart-panel {
        height: auto;
        margin-bottom: 0;
        padding: 15px;
        display: flex;
        flex-direction: column;
        order: 1;
    }
    
    /* 1. Mobile navigate button - FIRST */
    .mobile-navigate-button {
        order: 1;
        display: block !important;
        text-align: center;
        padding: 12px 15px;
        margin-bottom: 15px;
        background: rgba(255,255,255,0.95);
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    .navigate-from-create-mobile {
        background: #27ae60 !important;
        color: white !important;
        font-size: 0.95rem !important;
        padding: 14px 20px !important;
        border-radius: 10px !important;
        border: none !important;
        cursor: pointer !important;
        transition: all 0.3s ease !important;
        box-shadow: 0 3px 10px rgba(39, 174, 96, 0.3) !important;
        width: 100% !important;
        font-weight: 600 !important;
    }
    
    .navigate-from-create-mobile:hover {
        background: #229954 !important;
        transform: translateY(-2px) !important;
        box-shadow: 0 5px 14px rgba(39, 174, 96, 0.4) !important;
    }
    
    /* 2. Flowchart header - SECOND */
    .flowchart-header {
        order: 2;
        margin-bottom: 15px;
        padding: 12px 15px;
        background: rgba(255,255,255,0.95);
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }
    
    .flowchart-title {
        font-size: 1.1rem;
        text-align: center;
        margin-bottom: 5px;
    }
    
    .flowchart-stats {
        text-align: center;
        align-self: center;
        margin-bottom: 0;
        font-size: 0.8rem;
        padding: 4px 10px;
    }
    
    /* 3. Search container - THIRD */
    .search-container {
        order: 3;
        margin-bottom: 15px;
        padding: 10px 15px;
        background: rgba(255,255,255,0.95);
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }
    
    /* 4. CANVAS - FOURTH - MAXIMUM AVAILABLE HEIGHT */
    #flowchart-canvas {
        order: 4;
        /* Calculate height: viewport - nav bar - all other elements */
        height: calc(100vh - 70px - 60px - 80px - 60px - 40px) !important;
        min-height: 400px !important; /* Minimum fallback */
        max-height: calc(100vh - 310px) !important;
        
        padding: 10px;
        border-radius: 8px;
        margin-bottom: 15px;
        
        /* Enhanced scrolling */
        overflow: auto !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: auto !important;
        scroll-behavior: smooth;
        overscroll-behavior: contain;
        will-change: scroll-position;
        
        flex: none;
    }
    #flowchart-canvas {
    height: calc(100vh - 450px) !important;
    min-height: 250px !important;
    max-height: calc(100vh - 400px) !important;
    padding: 8px;
}
    #flowchart-canvas {
    height: calc(100vh - 65px - 55px - 75px - 55px - 35px) !important;
    min-height: 350px !important;
    max-height: calc(100vh - 285px) !important;
    
    /* 5. Actions - LAST */
    .flowchart-actions {
        order: 5;
        flex-direction: column;
        gap: 10px;
        margin: 0;
        padding: 15px;
        background: rgba(255,255,255,0.95);
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        align-items: stretch;
    }
    
    .flowchart-actions .btn,
    .flowchart-actions .file-input-wrapper,
    .example-dropdown {
        flex: none;
        max-width: none;
        min-width: auto;
        width: 100%;
        margin: 0;
    }
    
    .flowchart-actions .btn {
        padding: 12px 18px !important;
        font-size: 0.85rem !important;
        font-weight: 600;
        border-radius: 8px;
    }
    
    .flowchart-actions .file-input-label {
        padding: 12px 18px !important;
        font-size: 0.85rem !important;
        font-weight: 600;
        border-radius: 8px;
    }
    
    .example-dropdown-btn {
        padding: 12px 18px !important;
        font-size: 0.85rem !important;
        font-weight: 600;
        border-radius: 8px;
    }
    
    /* Enhanced flowchart content */
    #flowchart-content {
        min-width: 150vw !important;
        min-height: 150vh !important;
        touch-action: auto;
        contain: layout style paint;
        padding: 20px !important;
    }
    
    /* Better scrollbars */
    #flowchart-canvas::-webkit-scrollbar {
        width: 8px;
        height: 8px;
        background: rgba(0,0,0,0.05);
    }
    
    #flowchart-canvas::-webkit-scrollbar-thumb {
        background: rgba(102, 126, 234, 0.7);
        border-radius: 4px;
    }
    
    #flowchart-canvas::-webkit-scrollbar-thumb:active {
        background: rgba(102, 126, 234, 0.9);
    }
    
    /* Hide desktop navigate button on mobile */
    .sidebar .navigate-from-create {
        display: none !important;
    }
}

/* Extra small mobile devices */
@media (max-width: 480px) {
    .container {
        padding: 65px 5px 15px 5px;
    }
    
    #flowchart-canvas {
        height: calc(100vh - 65px - 55px - 75px - 55px - 35px) !important;
        min-height: 350px !important;
        max-height: calc(100vh - 285px) !important;
        padding: 8px;
    }
    
    .flowchart-actions .btn,
    .flowchart-actions .file-input-label,
    .example-dropdown-btn {
        padding: 10px 15px !important;
        font-size: 0.8rem !important;
    }
}
/* Extra small mobile devices - maintain full height */
@media (max-width: 480px) {
    .container {
        padding: 65px 5px 15px 5px;
        height: auto !important;
        overflow: visible !important;
    }
    
    #flowchart-canvas {
        /* Still full height on small devices */
        height: calc(100vh - 85px) !important;
        min-height: calc(100vh - 85px) !important;
        max-height: calc(100vh - 85px) !important;
        padding: 8px;
    }
    
    #flowchart-content {
        min-width: 140vw !important;
        min-height: 180vh !important;
        padding: 15px !important;
    }
    
    .flowchart-actions {
        padding: 15px;
        margin: 15px 0;
    }
    
    .flowchart-actions .btn,
    .flowchart-actions .file-input-label,
    .example-dropdown-btn {
        padding: 12px 18px !important;
        font-size: 0.85rem !important;
    }
}

/* Landscape mobile - still maintain full height */
@media (max-width: 768px) and (orientation: landscape) {
    .container {
        padding: 65px 10px 15px 10px;
        height: auto !important;
        overflow: visible !important;
    }
    
    #flowchart-canvas {
        height: calc(100vh - 85px) !important;
        min-height: calc(100vh - 85px) !important;
        max-height: calc(100vh - 85px) !important;
        padding: 8px;
    }
    
    #flowchart-content {
        min-width: 200vw !important; /* More horizontal space in landscape */
        min-height: 150vh !important;
        padding: 15px !important;
    }
}

/* Desktop - ensure no changes */
@media (min-width: 769px) {
    .mobile-navigate-button {
        display: none !important;
    }
    
    .sidebar .navigate-from-create {
        display: block !important;
    }
    
    /* Desktop canvas remains unchanged */
    #flowchart-canvas {
        height: 100%;
        flex: 1;
        min-height: 0;
    }
    
    .container {
        height: 100vh;
        overflow: hidden;
    }
    
    .main-layout {
        height: calc(100vh - 40px);
    }
}

}
/* Force hide zoom controls in navigate mode */
#navigate-mode .canvas-zoom-controls,
.canvas-zoom-controls[style*="display: none"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Ensure they only show in create mode on desktop */
#create-mode .canvas-zoom-controls {
    display: flex !important;
}


/* =================================
   MOBILE ACTIONS CLEANUP - MOVE TO MENU
   Add this CSS to style.css
   ================================= */

@media (max-width: 768px) {
    /* HIDE flowchart actions on mobile completely */
    .flowchart-actions {
        display: none !important;
    }
    
    /* MAXIMIZE canvas height by removing actions space */
    #flowchart-canvas {
        /* Remove the space previously used by actions */
        height: calc(100vh - 65px - 55px - 75px - 25px) !important;
        min-height: calc(100vh - 220px) !important;
        max-height: calc(100vh - 220px) !important;
        padding: 10px;
        margin-bottom: 20px; /* Bottom spacing */
    }
    
    /* Add actions to mobile menu - styling for new section */
    .mobile-menu-actions {
        margin-top: 25px;
        padding-top: 20px;
        border-top: 2px solid #e0e0e0;
    }
    
    .mobile-menu-actions h3 {
        margin: 0 0 15px 0;
        font-size: 1.1rem;
        color: #333;
        font-weight: 600;
    }
    
    .mobile-menu-actions .btn,
    .mobile-menu-actions .file-input-wrapper,
    .mobile-menu-actions .example-dropdown {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .mobile-menu-actions .btn {
        padding: 12px 16px;
        font-size: 0.9rem;
        font-weight: 600;
        border-radius: 8px;
        display: block;
        text-align: center;
    }
    
    .mobile-menu-actions .file-input-label {
        padding: 12px 16px;
        font-size: 0.9rem;
        font-weight: 600;
        border-radius: 8px;
        display: block;
        text-align: center;
    }
    
    .mobile-menu-actions .example-dropdown-btn {
        padding: 12px 16px;
        font-size: 0.9rem;
        font-weight: 600;
        border-radius: 8px;
        width: 100%;
        padding: 12px 16px !important;
    }
    
}


/* Extra small devices get even more canvas space */
@media (max-width: 480px) {
    #flowchart-canvas {
        height: calc(100vh - 200px) !important;
        min-height: calc(100vh - 200px) !important;
        max-height: calc(100vh - 200px) !important;
    }
}

/* =================================
   FIX CANVAS OVERFLOW ISSUES
   Replace the mobile canvas section in your style.css
   ================================= */

@media (max-width: 768px) {
    /* MOBILE LAYOUT - PREVENT CANVAS CUTOFF */
    
    /* Container adjustments - better space management */
    .container {
        padding: 70px 10px 10px 10px !important; /* Reduced bottom padding */
        min-height: 100vh;
        height: 100vh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }
    
    /* Main layout - use remaining space */
    .main-layout {
        flex-direction: column;
        height: auto;
        flex: 1;
        min-height: 0;
        gap: 0;
        display: flex;
    }
    
    .main-content {
        flex: 1;
        height: auto;
        min-height: 0;
        display: flex;
        flex-direction: column;
    }
    
    /* Flowchart panel - use all available space */
    .flowchart-panel {
        height: auto;
        flex: 1;
        margin-bottom: 0;
        padding: 10px !important; /* Reduced padding */
        display: flex;
        flex-direction: column;
        min-height: 0;
    }
    
    /* FIXED ORDER AND SIZING */
    
    /* 1. Mobile navigate button - COMPACT */
    .mobile-navigate-button {
        order: 1;
        display: block !important;
        text-align: center;
        padding: 8px 10px !important; /* More compact */
        margin-bottom: 10px !important;
        background: rgba(255,255,255,0.95);
        border-radius: 8px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.1);
        flex-shrink: 0;
    }
    
    .navigate-from-create-mobile {
        background: #27ae60 !important;
        color: white !important;
        font-size: 0.85rem !important; /* Smaller font */
        padding: 10px 16px !important; /* More compact */
        border-radius: 6px !important;
        border: none !important;
        cursor: pointer !important;
        transition: all 0.3s ease !important;
        box-shadow: 0 2px 8px rgba(39, 174, 96, 0.3) !important;
        width: 100% !important;
        font-weight: 600 !important;
    }
    
    /* 2. Flowchart header - COMPACT */
    .flowchart-header {
        order: 2;
        margin-bottom: 10px !important;
        padding: 8px 10px !important; /* More compact */
        background: rgba(255,255,255,0.95);
        border-radius: 8px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.1);
        flex-direction: row;
        align-items: center;
        gap: 10px;
        flex-shrink: 0;
    }
    
    .flowchart-title {
        font-size: 0.95rem !important; /* Smaller */
        text-align: left;
        margin-bottom: 0;
    }
    
    .flowchart-stats {
        text-align: right;
        margin-bottom: 0;
        font-size: 0.75rem !important; /* Smaller */
        padding: 3px 8px !important;
    }
    
    /* 3. Search container - COMPACT */
    .search-container {
        order: 3;
        margin-bottom: 10px !important;
        padding: 6px 10px !important; /* More compact */
        background: rgba(255,255,255,0.95);
        border-radius: 8px;
        box-shadow: 0 2px 6px rgba(0,0,0,0.1);
        flex-shrink: 0;
    }
    
    .search-input-wrapper input {
        padding: 6px 30px 6px 10px !important; /* More compact */
        font-size: 0.8rem !important;
    }
    
    /* 4. CANVAS - MAXIMUM AVAILABLE SPACE */
    #flowchart-canvas {
        order: 4;
        /* USE ALL REMAINING SPACE */
        flex: 1 !important;
        min-height: 0 !important;
        height: auto !important; /* Let flexbox handle height */
        
        padding: 8px !important; /* Reduced padding */
        border-radius: 6px !important;
        margin-bottom: 0 !important; /* No bottom margin */
        
        /* Enhanced scrolling */
        overflow: auto !important;
        -webkit-overflow-scrolling: touch !important;
        touch-action: auto !important;
        scroll-behavior: smooth;
        overscroll-behavior: contain;
        will-change: scroll-position;
        
        /* Ensure it doesn't shrink */
        flex-shrink: 0;
        /* Ensure proper box sizing */
        box-sizing: border-box !important;
    }
    
    /* Enhanced flowchart content - prevent overflow */
    #flowchart-content {
        min-width: 150vw !important;
        min-height: 120vh !important; /* Reduced slightly */
        touch-action: auto;
        contain: layout style paint;
        padding: 15px !important; /* Reduced padding */
        box-sizing: border-box;
        
        /* Ensure content doesn't cause overflow */
        position: relative;
        width: max-content;
        height: max-content;
    }
    
    /* Better scrollbars */
    #flowchart-canvas::-webkit-scrollbar {
        width: 6px;
        height: 6px;
        background: rgba(0,0,0,0.05);
    }
    
    #flowchart-canvas::-webkit-scrollbar-thumb {
        background: rgba(102, 126, 234, 0.7);
        border-radius: 3px;
    }
    
    #flowchart-canvas::-webkit-scrollbar-thumb:active {
        background: rgba(102, 126, 234, 0.9);
    }
    
    /* ACTIONS ARE HIDDEN ON MOBILE (per your request) */
    .flowchart-actions {
        display: none !important;
    }
}

/* Extra small devices - even more compact */
@media (max-width: 480px) {
    .container {
        padding: 65px 5px 5px 5px !important; /* Even more compact */
    }
    
    .flowchart-panel {
        padding: 8px !important;
    }
    
    #flowchart-canvas {
        padding: 6px !important;
    }
    
    #flowchart-content {
        min-width: 140vw !important;
        min-height: 110vh !important;
        padding: 12px !important;
    }
    
    .mobile-navigate-button,
    .flowchart-header,
    .search-container {
        padding: 6px 8px !important;
        margin-bottom: 8px !important;
    }
}

/* Landscape mobile - optimize for horizontal space */
@media (max-width: 768px) and (orientation: landscape) {
    .container {
        padding: 65px 8px 5px 8px !important;
    }
    
    #flowchart-content {
        min-width: 200vw !important; /* More horizontal space */
        min-height: 120vh !important;
        padding: 12px !important;
    }
    
    /* Even more compact header in landscape */
    .flowchart-header {
        padding: 6px 8px !important;
    }
    
    .search-container {
        padding: 4px 8px !important;
    }
}

/* Desktop - ensure no changes */
@media (min-width: 769px) {
    /* Desktop styles remain unchanged */
    .container {
        height: 100vh;
        overflow: hidden;
        padding: 20px;
    }
    
    .main-layout {
        height: calc(100vh - 40px);
        display: flex;
        flex-direction: row;
    }
    
    #flowchart-canvas {
        height: 100%;
        flex: 1;
        min-height: 0;
    }
}

/* Remove the min-width and fix the container width issue */
@media (max-width: 768px) {
    /* Remove any positioning or inline-block that might constrain the dropdown */
    .mobile-menu-actions .example-dropdown {
        width: 100% !important;
        display: block !important;
        position: static !important;
        /* Remove any flex or inline properties */
        flex: none !important;
        /* Ensure it behaves like other button containers */
        margin-bottom: 10px !important;
        /* Remove any max-width constraints */
        max-width: none !important;
    }
    
    /* Fix the button itself - REMOVE min-width that causes overflow */
    .mobile-menu-actions .example-dropdown-btn {
        width: 100% !important;
        /* REMOVE: min-width: 360px !important; */
        padding: 12px 16px !important;
        font-size: 0.9rem !important;
        font-weight: 600 !important;
        border-radius: 8px !important;
        display: block !important;
        text-align: center !important;
        box-sizing: border-box !important;
        margin: 0 !important;
        
        background: #f39c12 !important;
        color: white !important;
        border: none !important;
        cursor: pointer !important;
        transition: all 0.3s ease !important;
        
        /* Ensure no width constraints */
        min-width: auto !important;
        max-width: none !important;
    }
    
    /* Make sure the dropdown content doesn't interfere */
    .mobile-menu-actions .example-dropdown-content {
        position: static !important;
        width: 100% !important;
    }
}
/* Add Clear All button to canvas zoom controls */
.canvas-zoom-controls {
    position: fixed !important;
    top: 50% !important;
    right: 20px !important;
    transform: translateY(-50%) !important;
    z-index: 1001 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    background: rgba(255, 255, 255, 0.95) !important;
    padding: 8px !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    backdrop-filter: blur(5px) !important;
}

/* Add separator line before Clear button */
.canvas-zoom-controls::after {
    content: '';
    height: 1px;
    background: #e0e0e0;
    margin: 4px 0;
    order: 10; /* Place before clear button */
}

/* Style the canvas clear button */
.canvas-clear-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 6px;
    background: #e74c3c;
    color: white;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    order: 11; /* Place at bottom */
}

.canvas-clear-btn:hover {
    background: #c0392b;
    transform: scale(1.1);
}

.canvas-clear-btn:active {
    transform: scale(0.95);
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .canvas-zoom-controls {
        right: 15px !important;
        padding: 6px !important;
    }
    
    .canvas-clear-btn {
        width: 32px !important;
        height: 32px !important;
        font-size: 0.9rem !important;
    }
}

/* Hide from mobile menu */
@media (max-width: 768px) {
    .mobile-menu-actions .btn-danger {
        display: none !important;
    }
}

/* Fix mobile menu scrolling issues */
@media (max-width: 768px) {
    
    /* Ensure mobile side menu takes full height and is scrollable */
    .mobile-side-menu {
        position: fixed;
        top: 0;
        right: -100%;
        width: 90%;
        max-width: 400px;
        height: 100vh !important; /* Full viewport height */
        background: white;
        z-index: 3000;
        transition: right 0.3s ease;
        overflow-y: auto !important; /* Enable vertical scrolling */
        overflow-x: hidden !important; /* Prevent horizontal scroll */
        -webkit-overflow-scrolling: touch !important; /* iOS momentum scrolling */
        box-shadow: -2px 0 20px rgba(0,0,0,0.3);
    }
    
    .mobile-side-menu.open {
        right: 0;
    }
    
    /* Fix mobile menu content to allow proper scrolling */
    .mobile-menu-content {
        padding: 20px !important;
        padding-bottom: calc(40px + env(safe-area-inset-bottom, 0px)) !important; /* Extra bottom padding */
        min-height: calc(100vh - 80px) !important; /* Ensure content is tall enough to scroll */
        overflow: visible !important;
        display: block !important;
    }
    
    /* Ensure form elements don't get cut off */
    .mobile-menu-content form {
        margin-bottom: 30px !important;
    }
    
    /* Add space after mobile menu actions */
    .mobile-menu-actions {
        margin-bottom: 40px !important;
        padding-bottom: 20px !important;
    }
    
    /* Fix mobile menu header to not interfere with scrolling */
    .mobile-menu-header {
        position: sticky !important;
        top: 0 !important;
        z-index: 10 !important;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
        margin-bottom: 0 !important;
    }
    
    /* Ensure mobile options container is properly contained */
    .mobile-menu-content .options-container {
        margin-bottom: 20px !important;
    }
    
    /* Add visual scroll indicator */
    .mobile-side-menu::-webkit-scrollbar {
        width: 4px;
        background: rgba(0,0,0,0.1);
    }
    
    .mobile-side-menu::-webkit-scrollbar-thumb {
        background: rgba(102, 126, 234, 0.5);
        border-radius: 2px;
    }
    
    .mobile-side-menu::-webkit-scrollbar-thumb:hover {
        background: rgba(102, 126, 234, 0.8);
    }
}

/* Extra small devices need even more bottom padding */
@media (max-width: 480px) {
    .mobile-menu-content {
        padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important;
    }
    
    .mobile-menu-actions {
        margin-bottom: 50px !important;
        padding-bottom: 30px !important;
    }
}
/* Move the remove option button to top-right corner of each option box */
@media (max-width: 768px) {
    
    /* Style the option item as a positioned container */
    .option-item {
        display: block !important; /* Change from flex to block */
        position: relative !important;
        background: #f8f9fa !important;
        border: 1px solid #e0e0e0 !important;
        border-radius: 8px !important;
        padding: 15px !important;
        padding-top: 35px !important; /* Make room for the X button */
        margin-bottom: 15px !important;
    }
    
    /* Position remove button in top-right corner */
    .option-item .remove-option {
        position: absolute !important;
        top: 8px !important;
        right: 8px !important;
        background: #e74c3c !important;
        color: white !important;
        border: none !important;
        width: 24px !important;
        height: 24px !important;
        border-radius: 50% !important;
        cursor: pointer !important;
        font-size: 0.9rem !important;
        font-weight: 600 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        transition: all 0.3s ease !important;
        z-index: 10 !important;
    }
    
    .option-item .remove-option:hover {
        background: #c0392b !important;
        transform: scale(1.1) !important;
    }
    
    .option-item .remove-option:active {
        transform: scale(0.9) !important;
    }
    
    /* Stack the input fields vertically */
    .option-item input {
        width: 100% !important;
        margin-bottom: 10px !important;
        padding: 10px !important;
        border: 1px solid #ddd !important;
        border-radius: 6px !important;
        font-size: 0.9rem !important;
        box-sizing: border-box !important;
    }
    
    .option-item input:last-of-type {
        margin-bottom: 0 !important;
    }
    
    /* Add a subtle header to each option box */
    .option-item::before {
        content: 'Option ' counter(option-counter);
        counter-increment: option-counter;
        position: absolute;
        top: 8px;
        left: 12px;
        font-size: 0.75rem;
        font-weight: 600;
        color: #666;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }
    
    /* Reset counter for each options container */
    .options-container {
        counter-reset: option-counter;
        border: 2px dashed #ddd !important;
        border-radius: 8px !important;
        padding: 15px !important;
        margin-top: 10px !important;
    }
}

/* Desktop - keep existing layout but improve button positioning */
@media (min-width: 769px) {
    .option-item {
        display: flex;
        gap: 8px;
        margin-bottom: 10px;
        align-items: center;
        position: relative;
    }
    
    .option-item .remove-option {
        background: #e74c3c;
        color: white;
        border: none;
        width: 28px;
        height: 28px;
        border-radius: 50%;
        cursor: pointer;
        font-size: 1rem;
        transition: all 0.3s ease;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .option-item .remove-option:hover {
        background: #c0392b;
        transform: scale(1.1);
    }
}
/* =================================
   NAVIGATE BUTTON VISIBILITY FIX
   Add this to the END of style.css
   ================================= */

/* FORCE DESKTOP NAVIGATE BUTTON TO BE VISIBLE */
@media (min-width: 769px) {
    .sidebar .navigate-from-create {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        
        background: #27ae60 !important;
        color: white !important;
        font-size: 1rem !important;
        padding: 16px 24px !important;
        border-radius: 12px !important;
        border: none !important;
        cursor: pointer !important;
        transition: all 0.3s ease !important;
        box-shadow: 0 4px 12px rgba(39, 174, 96, 0.3) !important;
        margin-top: 15px !important;
        width: 100% !important;
        font-weight: 600 !important;
        
        /* Override any hiding styles */
        transform: none !important;
        z-index: 1 !important;
    }
    
    .sidebar .navigate-from-create:hover {
        background: #229954 !important;
        transform: translateY(-2px) !important;
        box-shadow: 0 6px 16px rgba(39, 174, 96, 0.4) !important;
    }
    
    .sidebar .navigate-from-create:disabled {
        background: #95a5a6 !important;
        cursor: not-allowed !important;
        transform: none !important;
        opacity: 0.7 !important;
    }
    
    /* Hide mobile button on desktop */
    .mobile-navigate-button {
        display: none !important;
    }
}

/* MOBILE SETTINGS */
@media (max-width: 768px) {
    /* Hide desktop button on mobile */
    .sidebar .navigate-from-create {
        display: none !important;
    }
    
    /* Show mobile button */
    .mobile-navigate-button {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .navigate-from-create-mobile {
        background: #27ae60 !important;
        color: white !important;
        font-size: 0.85rem !important;
        padding: 10px 16px !important;
        border-radius: 6px !important;
        border: none !important;
        cursor: pointer !important;
        transition: all 0.3s ease !important;
        box-shadow: 0 2px 8px rgba(39, 174, 96, 0.3) !important;
        width: 100% !important;
        font-weight: 600 !important;
    }
    
    .navigate-from-create-mobile:hover {
        background: #229954 !important;
        transform: translateY(-2px) !important;
        box-shadow: 0 5px 14px rgba(39, 174, 96, 0.4) !important;
    }
    
    .navigate-from-create-mobile:disabled {
        background: #95a5a6 !important;
        cursor: not-allowed !important;
        transform: none !important;
        opacity: 0.7 !important;
    }
}
/* Fix example dropdown z-index issues */
.example-dropdown {
    position: relative;
    z-index: 100;
}

.example-dropdown-content {
    display: none;
    position: absolute;
    background-color: white;
    min-width: 180px;
    box-shadow: 0 6px 12px rgba(0,0,0,0.2);
    border-radius: 8px;
    z-index: 1000;
    bottom: 100%;
    left: 0;
    margin-bottom: 4px;
    overflow: hidden;
    border: 1px solid #e0e0e0;
}

.example-dropdown-content.show {
    display: block;
    animation: dropdownFadeIn 0.2s ease;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.example-option {
    color: #333;
    padding: 12px 15px;
    text-decoration: none;
    display: block;
    cursor: pointer;
    transition: background-color 0.3s ease;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.85rem;
    font-weight: 500;
}

.example-option:last-child {
    border-bottom: none;
}

.example-option:hover {
    background-color: #f8f9fa;
    color: #667eea;
}

/* Mobile dropdown styling */
.mobile-side-menu .example-dropdown-content {
    position: static;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
    margin: 5px 0;
    border-radius: 6px;
}

.mobile-side-menu .example-dropdown-content.show {
    display: block;
}