/* Base styles */
body {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
    height: 100vh;
    overflow: hidden;
}

/* Context selector */
.context-selector {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: white;
    padding: 10px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    min-width: 200px;
}

.system-view-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* System selector */
#systemSelect {
    width: 100%;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 8px;
}

/* View controls */
.view-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

#viewSelect {
    width: 100%;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
}

.view-buttons {
    display: flex;
    gap: 4px;
}

.view-button {
    flex: 1;
    padding: 5px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #f8f8f8;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
    min-width: 40px;
}

.view-button:hover {
    background: #e8e8e8;
}

.view-button:active {
    background: #d8d8d8;
}

.view-button-dirty {
    background-color: #e74c3c !important; /* Red background */
    color: white !important;
    font-weight: bold !important;
    border-color: #c0392b !important;
}

/* Left panel */
#left-panel {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0; /* Extend to bottom */
    width: 400px; /* Wider default width */
    padding: 20px;
    background: white;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    overflow-y: auto;
    z-index: 100;
    padding-bottom: 60px; /* Increased padding to account for status bar */
}

/* Panel resizer */
#panel-resizer {
    position: fixed;
    top: 0;
    bottom: 40px; /* Account for status bar */
    width: 8px;
    background: #f0f0f0;
    cursor: col-resize;
    z-index: 150;
    transition: background-color 0.2s;
}

#panel-resizer:hover,
#panel-resizer.active {
    background: #2196f3;
}

#panel-resizer::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2px;
    height: 30px;
    background: #ccc;
}

#panel-resizer:hover::after,
#panel-resizer.active::after {
    background: #fff;
}

#left-panel h1 {
    margin: 0;
    font-size: 32px;
    color: #333;
}

#left-panel .subtitle {
    margin: 0 0 20px 0;
    font-size: 18px;
    color: #666;
    font-weight: normal;
}

/* Query Input */
#querySection {
    margin-bottom: 20px;
}

.query-container {
    position: relative;
    width: 100%;
}

#queryInput {
    width: 100%;
    height: 120px;
    box-sizing: border-box;
    padding: 8px;
    padding-right: 50px; /* Make room for the button */
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fff;
    font-family: inherit;
    resize: none;
    overflow-y: auto;
    font-size: 14px;
}

.submit-button {
    position: absolute !important;
    bottom: 10px !important;
    right: 10px !important;
    background-color: #007bff !important;
    color: white !important;
    border: none !important;
    border-radius: 50% !important;
    width: 40px !important;
    height: 40px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: background-color 0.2s !important;
    z-index: 10 !important;
}

.submit-button:hover {
    background-color: #0056b3;
}

.submit-button i {
    font-size: 18px;
}

/* Right panel */
#right-panel {
    position: fixed;
    left: 340px; /* Revert to original value */
    top: 0;
    right: 0;
    bottom: 40px; /* Leave space for status bar */
    display: flex;
    overflow: hidden;
    z-index: 90; /* Ensure it's below the left panel but above other elements */
}

#editorView {
    flex: 1;
    display: none;
    padding: 20px;
    overflow: auto;
}

#cytoscapeContainer {
    flex: 1;
    position: relative;
    width: 100%;
    height: 100%;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #fff;
}

/* Terminal */
#terminal {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    font-family: 'Roboto', sans-serif;
    height: 300px;
    overflow: auto;
    margin-bottom: 20px;
    font-size: 14px;
    line-height: 1.5;
}

/* Terminal message styling */
.terminal-line {
    white-space: pre-wrap;
    padding: 4px 0;
    width: 100%;
}

.terminal-line.welcome-message {
    background-color: #e3f2fd;
    border-left: 4px solid #2196f3;
    padding: 10px;
    margin: 5px 0;
    border-radius: 0 8px 8px 0;
    font-weight: bold;
}

.terminal-line.assistant-message {
    background-color: #e3f2fd;
    border-left: 4px solid #2196f3;
    padding: 10px;
    margin: 5px 0;
    border-radius: 0 8px 8px 0;
}

.terminal-line.user-message {
    background-color: #f1f8e9;
    border-left: 4px solid #8bc34a;
    padding: 10px;
    margin: 5px 0;
    border-radius: 0 8px 8px 0;
}

/* Tool section */
#toolSection {
    margin: 20px 0;
}

/* Button section */
#buttonSection {
    margin: 20px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    position: relative;
}

/* Upload container styling */
.upload-container {
    display: inline-block;
    position: relative;
}

/* File input styling */
#uploadGraphInput {
    opacity: 0;
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    padding: 0;
    margin: 0;
    border: none;
}

/* Upload button styling */
#uploadGraphButton {
    display: inline-block;
    position: relative;
    z-index: 1;
    cursor: pointer;
    padding: 8px 16px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #f8f8f8;
}

#uploadGraphButton:hover {
    background: #e8e8e8;
}

#buttonSection button,
#buttonSection label.button {
    padding: 8px 16px;
    border: 1px solid #ccc;
    border-radius: 8px;
    background: #f8f8f8;
    cursor: pointer;
}

#buttonSection button:hover,
#buttonSection label.button:hover {
    background: #e8e8e8;
}

/* Ensure terminal lines wrap properly */
.terminal-line {
    white-space: pre-wrap;
    padding: 2px 0;
    width: 100%;
}

#terminal > div {
    width: 100%;
}

.terminal-line.error {
    color: #f44336;
}

.terminal-placeholder {
    color: #666;
    font-style: italic;
    padding: 10px;
}

/* Webkit scrollbar styling */
#terminal::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

#terminal::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#terminal::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

#terminal::-webkit-scrollbar-thumb:hover {
    background: #555;
}

#terminal {
    scrollbar-width: thin;
    scrollbar-color: #888 #f1f1f1;
}

/* Status Bar */
.status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: #f5f5f5;
    border-top: 1px solid #ddd;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0 20px;
    font-size: 12px;
    z-index: 2000; /* Ensure it stays above other elements */
}

.metrics-group {
    display: flex;
    gap: 20px;
}

.metric {
    display: flex;
    align-items: center;
    gap: 5px;
}

.metric .label {
    color: #666;
}

.metric .value {
    font-weight: bold;
    color: #333;
}

.copyright {
    margin-right: auto; /* Push to the left */
    color: #666;
    font-size: 12px;
}

/* Forms */
#nodeForm, #relationshipForm {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 3000; /* Above status bar */
}

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

/* Context menu */
.context-menu {
    display: none;
    position: absolute;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 5px 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 3000; /* Above status bar */
    min-width: 150px;
}

.menu-item {
    padding: 5px 20px;
    cursor: pointer;
    position: relative;
    white-space: nowrap;
}

.menu-item:hover {
    background: #f0f0f0;
}

.menu-item .submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: 0;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 5px 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    min-width: 150px;
}

.menu-item:hover > .submenu {
    display: block;
}

/* Add arrow for items with submenus */
.menu-item:has(.submenu) {
    padding-right: 30px;
}

.menu-item:has(.submenu)::after {
    content: '►';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
}

/* Depth Selection Dialog */
#depthSelectionDialog {
    display: none;
    position: fixed;
    background: white;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 3000; /* Above status bar */
    min-width: 250px;
}

#depthSelectionDialog h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 16px;
    color: #333;
}

#depthSelectionDialog input[type="range"] {
    width: 100%;
    margin: 10px 0;
}

#depthSelectionDialog #depthValue {
    display: inline-block;
    margin-left: 10px;
    font-weight: bold;
    color: #333;
}

#depthSelectionDialog button {
    padding: 6px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #f8f8f8;
    cursor: pointer;
    font-size: 14px;
}

#depthSelectionDialog button:hover {
    background: #e8e8e8;
}

#depthSelectionDialog button:last-child {
    background: #4CAF50;
    color: white;
    border-color: #45a049;
}

#depthSelectionDialog button:last-child:hover {
    background: #45a049;
}

/* Node Properties Dialog */
#nodePropertiesDialog {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 3000; /* Above status bar */
    min-width: 300px;
}

#nodePropertiesDialog h2 {
    margin-top: 0;
    margin-bottom: 15px;
}

#nodePropertiesDialog .form-group {
    margin-bottom: 15px;
}

#nodePropertiesDialog label {
    display: block;
    margin-bottom: 5px;
}

#nodePropertiesDialog input,
#nodePropertiesDialog textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

#nodePropertiesDialog textarea {
    height: 80px;
    resize: vertical;
}

/* References section in node properties dialog */
#nodePropertiesDialog .references-section {
    margin-top: 15px;
    margin-bottom: 15px;
    padding: 10px;
    background-color: #f9f9f9;
    border: 1px solid #eee;
    border-radius: 4px;
}

#nodePropertiesDialog .references-section h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 14px;
    color: #333;
}

#nodePropertiesDialog .reference-item {
    padding: 5px 0;
    border-bottom: 1px solid #eee;
}

#nodePropertiesDialog .reference-item:last-child {
    border-bottom: none;
}

#nodePropertiesDialog .reference-type {
    font-weight: bold;
    margin-right: 5px;
}

#nodePropertiesDialog .reference-name {
    color: #333;
}

#nodePropertiesDialog .button-group {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

#nodePropertiesDialog button {
    padding: 8px 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
}

#nodePropertiesDialog button.submit {
    background: #4CAF50;
    color: white;
    border-color: #45a049;
}

#nodePropertiesDialog button.cancel {
    background: #f8f8f8;
}

#nodePropertiesDialog button:hover {
    opacity: 0.9;
}

/* Relationship Properties Dialog */
#relationshipPropertiesDialog {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 3000; /* Above status bar */
    min-width: 300px;
}

#relationshipPropertiesDialog h2 {
    margin-top: 0;
    margin-bottom: 15px;
}

#relationshipPropertiesDialog .form-group {
    margin-bottom: 15px;
}

#relationshipPropertiesDialog label {
    display: block;
    margin-bottom: 5px;
}

#relationshipPropertiesDialog input,
#relationshipPropertiesDialog textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

#relationshipPropertiesDialog textarea {
    height: 80px;
    resize: vertical;
}

#relationshipPropertiesDialog .button-group {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

#relationshipPropertiesDialog button {
    padding: 8px 16px;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
}

#relationshipPropertiesDialog button.submit {
    background: #4CAF50;
    color: white;
    border-color: #45a049;
}

#relationshipPropertiesDialog button.cancel {
    background: #f8f8f8;
}

#relationshipPropertiesDialog button:hover {
    opacity: 0.9;
}

/* Notifications */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 4px;
    color: white;
    z-index: 3000; /* Above status bar */
    animation: slideIn 0.3s ease-out;
}

.notification.success {
    background-color: #4CAF50;
}

.notification.error {
    background-color: #f44336;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Spinner */
.spinner-container {
    display: none;
    position: fixed;
    top: 0;
    left: 340px; /* Align with right panel */
    right: 0;
    bottom: 40px; /* Account for status bar */
    background: rgba(255, 255, 255, 0.8);
    z-index: 3000;
    justify-content: center;
    align-items: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Loading indicator */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 3000; /* Above status bar */
    display: none;
}

.loading.active {
    display: block;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    #left-panel {
        width: 100%;
        height: auto;
        position: relative;
    }
    
    #right-panel {
        margin-left: 0;
        margin-top: 20px;
    }
    
    .context-selector {
        position: relative;
        top: auto;
        right: auto;
        margin-bottom: 20px;
    }
}
