/* Global Layout Reset for Resizable Editors */
body {
    margin: 0;
    padding: 0;
}

#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Main container should fill available space */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Resizable Editor Layout Styles */
.resizable-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    padding: 15px;
    box-sizing: border-box;
    gap: 15px;
}

.resizable-header {
    flex-shrink: 0;
}

.editors-container {
    display: grid;
    grid-template-columns: 1fr 5px 1fr 5px 1fr;
    grid-template-rows: 1fr;
    flex: 1;
    gap: 0;
    min-height: 0; /* Important for proper flex behavior */
}

.resizable-panel {
    display: flex;
    flex-direction: column;
    min-width: 200px;
    overflow: hidden;
}

.panel-input { grid-column: 1; }
.panel-script { grid-column: 3; }
.panel-output { grid-column: 5; }

.resizer {
    background: #e9ecef;
    cursor: col-resize;
    position: relative;
    user-select: none;
    grid-row: 1;
}

.resizer:hover {
    background: #6c757d;
}

.resizer::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 3px;
    height: 30px;
    background: #6c757d;
    transform: translate(-50%, -50%);
    border-radius: 2px;
}

.resizer:hover::before {
    background: #495057;
}

.resizer:nth-of-type(2) { grid-column: 2; }
.resizer:nth-of-type(4) { grid-column: 4; }

.editor-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    background: white;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    overflow: hidden;
}

.editor-card-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #dee2e6;
    background-color: #f8f9fa;
    border-radius: 0.375rem 0.375rem 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    height: 50px;
}

.editor-card-body {
    flex: 1;
    padding: 0;
    position: relative;
    overflow: hidden;
}

.editor-card-footer {
    padding: 0.5rem 1rem;
    border-top: 1px solid #dee2e6;
    background-color: #f8f9fa;
    border-radius: 0 0 0.375rem 0.375rem;
    flex-shrink: 0;
    min-height: 50px;
}

.editor-container-resizable {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* Override the fixed 500px heights from app.css for resizable editors */
.editor-container-resizable,
.editor-container-resizable > div,
.editor-container-resizable .monaco-editor,
.editor-container-resizable .monaco-editor .view-lines {
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
}

.editor-container-resizable .monaco-editor {
    border: none !important;
    border-radius: 0 !important;
}

.examples-section {
    flex-shrink: 0;
    max-height: 200px;
}

/* JSON Tree View Styles */
.json-tree-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.875rem;
    line-height: 1.4;
}

.json-tree-view {
    flex: 1;
    height: 300px; /* Fixed height for testing */
    overflow-y: auto;
    overflow-x: auto;
    min-height: 0;
    max-height: 100%;
    display: block;
    box-sizing: border-box;
}

.tree-container {
    padding: 10px;
    /* Remove min-height: 100% to allow natural content height */
}

.tree-node {
    margin: 2px 0;
    user-select: none;
}

.node-content {
    display: flex;
    align-items: center;
    padding: 2px 4px;
    border-radius: 3px;
    transition: background-color 0.15s ease;
    cursor: pointer;
}

.node-content:hover {
    background-color: var(--bs-secondary-bg);
}

.expand-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    cursor: pointer;
    color: var(--bs-secondary-color);
    font-size: 12px;
    transition: transform 0.15s ease;
}

.expand-icon:hover {
    color: var(--bs-body-color);
}

.expand-icon.expanded {
    transform: none;
}

.expand-icon.collapsed {
    transform: rotate(-90deg);
}

.leaf-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-right: 4px;
    font-size: 6px;
    color: var(--bs-secondary-color);
}

.node-label {
    font-weight: 500;
    margin-right: 4px;
}

.node-label.object {
    color: #0969da;
}

.node-label.array {
    color: #8250df;
}

.node-label.string,
.node-label.number,
.node-label.boolean {
    color: var(--bs-body-color);
}

.node-separator {
    color: var(--bs-secondary-color);
    margin: 0 2px;
}

.node-value {
    font-weight: 400;
    font-style: normal;
}

.node-value.string {
    color: #0a3069;
}

.node-value.number {
    color: #0550ae;
}

.node-value.boolean {
    color: #8250df;
}

.node-value.null {
    color: #656d76;
    font-style: italic;
}

.no-data {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-style: italic;
}

/* Dark theme for tree view */
[data-bs-theme="dark"] .node-label.object {
    color: #58a6ff;
}

[data-bs-theme="dark"] .node-label.array {
    color: #d2a8ff;
}

[data-bs-theme="dark"] .node-value.string {
    color: #a5d6ff;
}

[data-bs-theme="dark"] .node-value.number {
    color: #79c0ff;
}

[data-bs-theme="dark"] .node-value.boolean {
    color: #d2a8ff;
}

[data-bs-theme="dark"] .node-value.null {
    color: #8b949e;
}

[data-bs-theme="dark"] .expand-icon,
[data-bs-theme="dark"] .leaf-icon,
[data-bs-theme="dark"] .node-separator {
    color: #8b949e;
}

[data-bs-theme="dark"] .expand-icon:hover {
    color: #f0f6fc;
}

[data-bs-theme="dark"] .node-content:hover {
    background-color: #21262d;
}

[data-bs-theme="dark"] .json-tree-container {
    background: var(--bs-dark);
    border-color: #30363d;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .editors-container {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr 1fr;
        gap: 15px;
    }
    
    .panel-input { 
        grid-column: 1; 
        grid-row: 1;
    }
    .panel-script { 
        grid-column: 1; 
        grid-row: 2;
    }
    .panel-output { 
        grid-column: 1; 
        grid-row: 3;
    }
    
    .resizer {
        display: none;
    }
}