/* Base structure styles */
html {
    height: 100%;
}

body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Layout and columns */
.fullheight-container {
    display: flex;
    width: 100%;
    flex-grow: 1;
    min-height: 0;
    height: calc(100vh - 120px);
}

.column {
    padding: 20px 20px 0 20px; /* Remove bottom padding to accommodate footer */
    box-sizing: border-box;
    min-width: 200px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden; /* Prevent content from spilling */
}

/* Common container styles for all columns */
#input-container,
#conversion-container,
#output-container {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 28px; /* Match footer height exactly */
    width: 100%;
    box-sizing: border-box;
}

/* Common footer styles for all columns */
#input-footer,
#conversion-footer,
#output-footer {
    position: absolute;
    bottom: 0;
    left: 20px; /* Match column padding */
    right: 20px; /* Match column padding */
    height: 28px;
    border-top: 1px solid #ccc;
    padding: 4px 0; /* Vertical padding only */
    z-index: 10;
    font-size: 0.9em;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    transition: transform 0.3s ease;
}

.hide-column-footers #input-footer,
.hide-column-footers #conversion-footer,
.hide-column-footers #output-footer {
    transform: translateY(100%);
}

/* Footer controls styling */
.footer-controls {
    display: flex;
    gap: 12px;
    align-items: center;
}

.footer-controls label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
}

.compact-slider {
    width: 80px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #ddd;
    outline: none;
    border-radius: 2px;
    cursor: pointer;
}

.compact-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #666;
    cursor: pointer;
    transition: background .15s ease;
}

.compact-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #666;
    cursor: pointer;
    transition: background .15s ease;
    border: none;
}

.compact-slider:hover::-webkit-slider-thumb {
    background: #333;
}

.compact-slider:hover::-moz-range-thumb {
    background: #333;
}

.slider-value {
    min-width: 2.5em;
    font-size: 0.9em;
    color: #666;
}

.column-left {
    width: 33%;
    background-color: #eef2f3;
    border-right: 1px solid #ccc;
}

#input-footer {
    background-color: #eef2f3;
}

.column-center {
    width: 34%;
    background-color: #f6f7f8;
    border-right: 1px solid #ccc;
}

#conversion-footer {
    background-color: #f6f7f8;
}

.column-right {
    width: 33%;
    background-color: #eef2f3;
}

#output-footer {
    background-color: #eef2f3;
}

.column-center {
    width: 34%;
    background-color: #f6f7f8;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #ccc;
}

.column-right {
    width: 33%;
    background-color: #eef2f3;
    display: flex;
    flex-direction: column;
}

/* CodeMirror customization */
#conversion-container,
#output-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

#conversion-container .CodeMirror,
#output-container .CodeMirror {
    flex: 1;
    height: auto !important;
    border: 1px solid #ddd;
    font-size: 14px;
}

.column-left .CodeMirror {
    border: 1px solid #ddd;
    font-size: 14px;
    height: 150px;
}

/* Ensure elements before CodeMirror don't take extra space */
#conversion-container > :not(.CodeMirror),
#output-container > :not(.CodeMirror) {
    flex-shrink: 0;
}

/* Resizer styling */
.resizer {
    width: 8px;
    background: #e0e0e0;
    cursor: col-resize;
    margin: 0 -4px;
    border-left: 1px solid #ccc;
    border-right: 1px solid #ccc;
    z-index: 10;
    flex-shrink: 0;
}

.resizer:hover {
    background: #bbb;
    border-color: #999;
}

/* Editor buttons */
.editor-buttons {
    margin-bottom: 8px;
}

.editor-buttons button {
    margin-right: 8px;
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
}

.editor-buttons button svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.editor-buttons button:disabled svg {
    opacity: 0.5;
}

/* Tree container and scaling */
#json-tree-container {
    position: relative;
    width: 100%;
    overflow: hidden; /* Prevent horizontal scrolling of container */
}

/* Tree base structure */
.treejs-nodes {
    margin: 0 !important;
    padding-left: 1.5em !important;
    width: 100%;
    box-sizing: border-box;
}

.treejs-node {
    width: 100%;
    position: relative;
    overflow: hidden; /* Prevent text overflow */
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Handle indentation properly */
.treejs-nodes .treejs-nodes {
    margin-left: 0.7em !important;
    width: calc(100% - 0.7em); /* Account for margin in width */
}

/* Control spacing of tree elements */
.treejs-label {
    margin-left: 0.3em;
}

.treejs-checkbox {
    margin-right: 0.3em;
}

.treejs-toggle {
    width: 1em;
    display: inline-block;
    text-align: center;
}

/* Content wrapper for scaling */
.tree-scale-wrapper {
    transform-origin: left top;
    transition: transform 0.2s ease;
    width: 100%;
    min-width: max-content;
}

/* Basic tree styling */
#json-tree-container .treejs-nodes {
    margin: 0;
    padding: 0;
}

#json-tree-container .treejs-node {
    margin: 2px 0;
}

#json-tree-container .treejs-checkbox {
    margin-right: 4px;
}

#json-tree-container .treejs-toggle {
    margin-right: 2px;
}

/* Tree node styling */
.node-primitive {
    color: #333;
}

.node-primitive::before {
    content: "(P) ";
    font-size: 0.8em;
    color: #666;
}

.node-array {
    color: #0066cc;
    font-weight: 500;
}

.node-array::before {
    content: "[A] ";
    font-size: 0.8em;
    color: #666;
}

.node-object {
    color: #006633;
    font-weight: 500;
}

.node-object::before {
    content: "{O} ";
    font-size: 0.8em;
    color: #666;
}

/* Context boundary styling */
.context-boundary {
    border: 1px dotted #666 !important;
    border-radius: 3px;
    background-color: rgba(200, 200, 200, 0.1);
    position: relative;
    margin: 8px 4px;
    padding: 8px;
}

.context-boundary::after {
    content: '⬚√';
    position: relative;
    display: inline-block;
    margin-left: 4px;
    font-size: 12px;
    color: #666;
    background: white;
    padding: 0 4px;
    border-radius: 3px;
    border: 1px solid #ddd;
}

/* Tree and selection styles */
.tree-actions {
    margin-bottom: 8px;
    display: flex;
    gap: 8px;
    align-items: center;
}

.tree-actions button {
    padding: 4px 8px;
    cursor: pointer;
}

#selected-paths ul {
    margin: 6px 0 0 0;
    padding-left: 1rem;
}

#selected-paths li {
    margin: 2px 0;
}

#selected-paths button {
    background: #f8f9fb;
    border: 1px solid #e1e6eb;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
}

/* Selected paths styling */
.path-icon {
    background: transparent;
    padding: 3px;
    cursor: pointer;
    border: 1px solid;
}

/* Context menu */
.kintegrate-context-menu {
    background: white;
    border: 1px solid #e3e8ee;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    border-radius: 4px;
    padding: 4px;
    max-width: 300px;
    box-sizing: border-box;
    z-index: 1000;
}

.kintegrate-context-option {
    display: block;
    width: 100%;
    margin: 4px 0;
    padding: 8px 10px;
    border-radius: 4px;
    background: linear-gradient(#ffffff, #f7f9fb);
    border: 1px solid #e3e8ee;
    cursor: pointer;
    color: #222;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

.kintegrate-context-option:hover {
    background: linear-gradient(#f3f7fb, #eef4fb);
}