:root {
    /* Light Mode Theme */
    --bg-primary: #F8F9FA;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f8f9fa;
    --text-primary: #333;
    --text-secondary: #666;
    --text-tertiary: #999;
    --border-color: #e0e0e0;
    --shadow-color: rgba(0,0,0,0.05);
    --shadow-color-hover: rgba(0,0,0,0.12);
}

body.dark-mode {
    /* Dark Mode Theme */
    --bg-primary: #1a1d23;
    --bg-secondary: #23262d;
    --bg-tertiary: #2c2f38;
    --text-primary: #e8eaed;
    --text-secondary: #b8bbc1;
    --text-tertiary: #888b92;
    --border-color: #3a3d45;
    --shadow-color: rgba(0,0,0,0.3);
    --shadow-color-hover: rgba(0,0,0,0.5);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: var(--bg-primary);
    overflow: hidden;
    transition: background-color 0.3s ease;
}

#root {
    width: 100vw;
    height: 100vh;
    display: flex;
}

/* Sidebar Styles */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    padding: 20px;
    overflow-y: auto;
    box-shadow: 2px 0 8px var(--shadow-color);
    transition: all 0.3s ease;
}

.sidebar h2 {
    font-size: 18px;
    margin-bottom: 20px;
    color: var(--text-primary);
    font-weight: 600;
}

.sidebar h3 {
    font-size: 14px;
    margin: 20px 0 10px 0;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.node-palette {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.draggable-node {
    padding: 12px 16px;
    background: var(--primary-color);
    color: white;
    border-radius: 8px;
    cursor: grab;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.draggable-node:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    filter: brightness(1.1);
}

.draggable-node:active {
    cursor: grabbing;
    transform: scale(0.98);
}

.draggable-node.person { background: var(--node-person); }
.draggable-node.entity { background: var(--node-entity); }
.draggable-node.thing { background: var(--node-thing); }
.draggable-node.process { background: var(--node-process); }
.draggable-node.api { background: var(--node-api); }
.draggable-node.other { background: var(--node-other); }
.draggable-node.note { background: var(--node-note); color: #333; }

.connection-types {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.connection-type {
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    cursor: pointer;
}

.connection-type:hover {
    border-color: var(--primary-color);
    background: var(--bg-secondary);
    transform: translateX(2px);
}

.connection-type.selected {
    border-color: var(--primary-color);
    background: var(--primary-color);
    color: white;
}

.connection-indicator {
    width: 30px;
    height: 3px;
    border-radius: 2px;
}

/* Pages */
.pages-container {
    margin: 15px 0;
}

.pages-tabs {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.page-tab {
    position: relative;
    padding: 8px 10px;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 13px;
    color: var(--text-primary);
    transition: all 0.2s;
    user-select: none;
}

.page-tab:hover {
    border-color: var(--primary-color);
    background: var(--bg-tertiary);
}

.page-tab.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
    font-weight: 600;
}

.page-tab span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-name-input {
    flex: 1;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid var(--primary-color);
    border-radius: 4px;
    padding: 2px 6px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text-primary);
    outline: none;
}

.page-tab.active .page-name-input {
    background: rgba(255, 255, 255, 0.95);
    color: #333;
}

body.dark-mode .page-name-input {
    background: rgba(40, 44, 52, 0.9);
    color: var(--text-primary);
}

body.dark-mode .page-tab.active .page-name-input {
    background: rgba(255, 255, 255, 0.15);
    color: white;
}

.page-copy-btn,
.page-delete-btn {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 18px;
    line-height: 1;
    padding: 0 4px;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.page-copy-btn {
    font-size: 14px;
}

.page-copy-btn:hover,
.page-delete-btn:hover {
    opacity: 1;
}

.page-tab.active .page-copy-btn,
.page-tab.active .page-delete-btn {
    color: white;
}

.copy-page-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: var(--bg-primary);
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
    z-index: 10000;
    min-width: 200px;
}

.copy-brand-option {
    display: block;
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: none;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.2s;
    margin-bottom: 4px;
}

.copy-brand-option:hover {
    background: var(--primary-color);
    color: white;
    transform: translateX(4px);
}

.copy-menu-cancel {
    display: block;
    width: 100%;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    text-align: center;
    cursor: pointer;
    border-radius: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    transition: all 0.2s;
    margin-top: 8px;
}

.copy-menu-cancel:hover {
    background: var(--bg-hover);
    border-color: var(--text-secondary);
}

.add-page-btn {
    width: 100%;
    padding: 8px;
    background: transparent;
    border: 2px dashed var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

.add-page-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: var(--bg-secondary);
}

/* Main Canvas */
.main-canvas {
    flex: 1;
    position: relative;
    background: var(--bg-primary);
    transition: background-color 0.3s ease;
}

.react-flow__node {
    background: transparent !important;
    border: none;
    border-radius: 8px;
    padding: 0;
    min-width: 160px;
    box-shadow: none;
    transition: all 0.2s;
    cursor: move;
}

.react-flow__node:hover {
    box-shadow: none;
    transform: translateY(-1px);
}

.react-flow__node.selected {
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
}

.custom-node {
    padding: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px var(--shadow-color);
    transition: all 0.2s;
    max-width: 250px;
    width: 100%;
}

.custom-node:hover {
    box-shadow: 0 4px 12px var(--shadow-color-hover);
}

.node-header {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 600;
}

.node-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    cursor: text;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.node-title:hover {
    background: var(--bg-tertiary);
}

/* Connection Handles */
.react-flow__handle {
    width: 12px;
    height: 12px;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.2s;
}

.react-flow__handle:hover {
    width: 16px;
    height: 16px;
    box-shadow: 0 3px 8px rgba(102, 126, 234, 0.4);
}

.react-flow__handle-connecting {
    background: #38f9d7 !important;
}

.react-flow__handle-valid {
    background: #43e97b !important;
}

/* Edge Styles */
.react-flow__edge-path {
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* Make edges easier to interact with */
.react-flow__edge {
    pointer-events: all;
}

.react-flow__edge:hover .react-flow__edge-path {
    stroke-width: 3.5;
}

/* Show circular handles at edge endpoints when hovering */
.react-flow__edge.selected .react-flow__edge-path,
.react-flow__edge:hover .react-flow__edge-path {
    opacity: 1;
}

/* Edge Labels - ensure clean rendering */
.react-flow__edge-text {
    fill: #555 !important;
    font-weight: 500 !important;
    font-size: 12px !important;
    stroke: none !important;
    stroke-width: 0 !important;
}

.react-flow__edge-textbg {
    fill: white !important;
    fill-opacity: 0.9 !important;
    stroke: none !important;
}

/* Pulse animation for other use cases */
@keyframes pulse {
    0%, 100% { 
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
    50% { 
        opacity: 0.9;
        transform: translateX(-50%) scale(1.02);
    }
}

/* Edge Updater Handles (for reconnection) */
.react-flow__edgeupdater {
    width: 12px;
    height: 12px;
    background: #fff;
    border: 2px solid #667eea;
    border-radius: 50%;
    cursor: grab;
    pointer-events: all;
}

.react-flow__edgeupdater:hover {
    width: 16px;
    height: 16px;
    background: #667eea;
    border-color: #43e97b;
    border-width: 3px;
    cursor: grabbing;
}

/* Toolbar */
.toolbar {
    position: absolute;
    top: 20px;
    right: 20px;
    background: var(--bg-secondary);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 12px var(--shadow-color);
    border: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
    z-index: 10;
    transition: all 0.3s ease;
}

.toolbar button {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--primary-color);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.toolbar button:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.toolbar button:active {
    transform: translateY(0);
}

.toolbar button.primary {
    background: var(--primary-color);
    color: white;
}

.toolbar button.primary:hover {
    filter: brightness(1.1);
}

.toolbar button.secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.toolbar button.secondary:hover {
    background: var(--bg-secondary);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal {
    background: var(--bg-secondary);
    border-radius: 16px;
    padding: 30px;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: slideIn 0.3s ease-out;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal h2 {
    margin-bottom: 20px;
    color: #333;
    font-size: 24px;
}

.modal pre {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.6;
    border: 1px solid #e0e0e0;
}

.modal-actions {
    margin-top: 20px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.modal button.primary {
    background: var(--primary-color);
    color: white;
}

.modal button.primary:hover {
    filter: brightness(1.1);
}

.modal button.secondary {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #e0e0e0;
}

.modal button.secondary:hover {
    background: #e9ecef;
}

/* Edge Context Menu */
.edge-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    background: rgba(0,0,0,0.1);
}

.edge-menu {
    background: var(--bg-secondary);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    border: 1px solid var(--border-color);
    width: 280px;
    max-height: 85vh;
    overflow-y: auto;
    overflow-x: hidden;
    animation: slideIn 0.2s ease-out;
}

.edge-menu-header {
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1;
}

.edge-menu-header strong {
    font-size: 15px;
    font-weight: 600;
}

.close-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    font-size: 20px;
    color: white;
    cursor: pointer;
    padding: 4px 8px;
    width: 28px;
    height: 28px;
    line-height: 1;
    border-radius: 6px;
    transition: all 0.2s;
}

.close-btn:hover {
    background: rgba(255,255,255,0.3);
    transform: scale(1.1);
}

.edge-menu-content {
    padding: 16px;
}

.edge-menu-section {
    margin-bottom: 20px;
}

.edge-menu-section:last-child {
    margin-bottom: 0;
}

.edge-menu-label {
    font-size: 11px;
    color: var(--primary-color);
    padding: 0 0 8px 0;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.edge-notes-input {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    font-family: inherit;
    resize: vertical;
    transition: all 0.2s;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.edge-notes-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-secondary);
    box-shadow: 0 0 0 3px rgba(240, 94, 62, 0.1);
}

.edge-notes-input::placeholder {
    color: #aaa;
}

.edge-menu-item {
    width: 100%;
    padding: 12px 14px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    margin-bottom: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    font-size: 13px;
    color: #555;
    transition: all 0.2s;
    font-weight: 500;
}

.edge-menu-item:hover {
    background: #f8f9fa;
    border-color: #667eea;
    transform: translateX(2px);
}

.edge-menu-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-color: #667eea;
    color: white;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.edge-menu-item .connection-indicator {
    width: 32px;
    height: 4px;
    border-radius: 2px;
    flex-shrink: 0;
    margin-right: 10px;
}

.edge-menu-item.active .connection-indicator {
    background: white !important;
    opacity: 0.9;
}

.edge-menu-reconnect {
    width: 100%;
    padding: 12px 14px;
    background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(67, 233, 123, 0.3);
}

.edge-menu-reconnect:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(67, 233, 123, 0.4);
}

.edge-menu-delete {
    width: 100%;
    padding: 12px 14px;
    background: white;
    border: 2px solid #ffcdd2;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    color: #d32f2f;
    font-weight: 600;
    transition: all 0.2s;
}

.edge-menu-delete:hover {
    background: #ffebee;
    border-color: #ef5350;
    transform: translateX(2px);
}


/* React Flow Custom Controls */
.react-flow__controls {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-radius: 8px;
    overflow: hidden;
}

.react-flow__controls-button {
    background: white;
    border-bottom: 1px solid #e0e0e0;
}

.react-flow__controls-button:hover {
    background: #f8f9fa;
}

/* Instructions Panel */
.instructions {
    background: #f0f2ff;
    border: 1px solid #d4d9ff;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 20px;
    font-size: 13px;
    color: #555;
    line-height: 1.6;
}

.instructions strong {
    color: #667eea;
    display: block;
    margin-bottom: 4px;
}
