/* Sidebar Layout */
.editor-container {
    display: flex;
    gap: 0;
    height: calc(100vh - 140px);
    min-height: 500px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 180px;
    min-width: 180px;
    background: #2d3748;
    display: flex;
    flex-direction: column;
    padding: 0;
}

.sidebar-header {
    padding: 20px 15px;
    border-bottom: 1px solid #4a5568;
}

.sidebar-title {
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.sidebar-buttons {
    display: flex;
    flex-direction: column;
    padding: 10px;
    gap: 4px;
}

.sidebar-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: transparent;
    color: #e2e8f0;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
    text-align: left;
    width: 100%;
}

.sidebar-btn:hover {
    background: #4a5568;
    color: white;
}

.sidebar-btn:active {
    background: #3182ce;
}

.sidebar-btn .btn-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

.sidebar-divider {
    height: 1px;
    background: #4a5568;
    margin: 8px 10px;
}

.sidebar-footer {
    margin-top: auto;
    padding: 15px;
    border-top: 1px solid #4a5568;
}

.sidebar-footer-text {
    color: #718096;
    font-size: 0.75rem;
    text-align: center;
}

/* Main Editor Area */
.editor-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    min-width: 0;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    background: #f7fafc;
    border-bottom: 1px solid var(--border-color);
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.toolbar-btn {
    padding: 6px 10px;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
}

.toolbar-btn:hover {
    background: white;
    color: var(--primary-color);
    border-color: var(--primary-color);
}

.toolbar-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.char-count {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Editor Content */
.editor-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    min-height: 0;
}

.editor-content textarea {
    flex: 1;
    width: 100%;
    height: 100%;
    min-height: 500px;
    border: none;
    padding: 20px;
    font-family: 'Fira Code', monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    resize: none;
    background: white;
}

.editor-content textarea:focus {
    outline: none;
}

/* Tree View */
.tree-view {
    flex: 1;
    font-family: 'Fira Code', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    padding: 20px;
    background: #f8f9fa;
    overflow: auto;
    min-height: 500px;
    display: none;
}

.tree-view.active {
    display: block;
}

.tree-node {
    margin-left: 20px;
    position: relative;
}

/* JSON Tree View Specific Styles */
.tree-key {
    color: #2c5aa0;
    font-weight: 500;
}

.tree-string {
    color: #22863a;
}

.tree-number {
    color: #005cc5;
}

.tree-boolean {
    color: #d73a49;
}

.tree-null {
    color: #6f42c1;
}

.tree-bracket {
    color: #6a737d;
    font-weight: 600;
}

.tree-toggle {
    cursor: pointer;
    user-select: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 12px;
    height: 12px;
    border: 1px solid var(--text-secondary); /* Darker border */
    border-radius: 2px;
    background-color: var(--input-bg); /* Keep light background */
    color: var(--text-primary); /* Darker text */
    font-weight: bold;
    font-size: 10px;
    line-height: 1;
    vertical-align: middle;
    margin-right: 4px;
}

.tree-toggle:hover {
    color: white;
    border-color: var(--primary-color);
    background-color: var(--primary-color);
}

.tree-collapsed {
    display: none;
}

.tree-line {
    display: block;
}

.tree-expandable {
    cursor: pointer;
}

.tree-expandable:hover {
    background: rgba(49, 130, 206, 0.1);
}

/* Specific styling for the closing bracket/brace to appear on the same line visually */
.tree-closing-delimiter {
    margin-top: -1.6em; /* Pull it up by one line-height */
    text-align: right;  /* Push the content to the right */
    padding-right: 20px; /* Ensure it's not cut off by tree-view padding */
}


/* Hidden file input */
.hidden-input {
    display: none;
}

/* Status Bar */
.status-bar {
    padding: 8px 15px;
    background: #f7fafc;
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
    min-height: 20px;
}

.status-bar.success {
    background: var(--success-bg);
    color: var(--success-text);
}

.status-bar.error {
    background: var(--error-bg);
    color: var(--error-text);
}

/* Fullscreen Overlay */
.fullscreen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    padding: 20px;
    box-sizing: border-box;
    animation: fadeIn 0.2s ease-out;
}

.fullscreen-overlay[hidden] {
    display: none;
}

.fullscreen-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: white;
    border-radius: 8px 8px 0 0;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    z-index: 10;
    flex-shrink: 0;
}

.fullscreen-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.fullscreen-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fullscreen-close-btn {
    padding: 8px 16px;
    background: var(--secondary-bg);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s;
}

.fullscreen-close-btn:hover {
    background: var(--error-bg);
    color: var(--error-text);
    border-color: var(--error-border);
}

.fullscreen-content {
    flex: 1;
    background: white;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.fullscreen-content textarea {
    flex: 1;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 0 0 8px 8px;
    resize: none;
    padding: 20px;
    font-family: 'Fira Code', monospace;
    font-size: 1rem;
    line-height: 1.6;
}

.fullscreen-content .tree-view {
    flex: 1;
    overflow: auto;
    min-height: unset;
    border: none;
    border-radius: 0 0 8px 8px;
    margin: 0;
    padding: 20px;
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

body.fullscreen-active {
    overflow: hidden;
}

/* Responsive */
@media (max-width: 768px) {
    .editor-container {
        flex-direction: column;
        min-height: auto;
    }

    .sidebar {
        width: 100%;
        min-width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        padding: 10px;
    }

    .sidebar-header {
        width: 100%;
        padding: 10px 15px;
        border-bottom: none;
    }

    .sidebar-buttons {
        flex-direction: row;
        flex-wrap: wrap;
        width: 100%;
        gap: 8px;
    }

    .sidebar-btn {
        flex: 0 0 auto;
        padding: 8px 12px;
    }

    .sidebar-divider {
        display: none;
    }

    .sidebar-footer {
        display: none;
    }

    .editor-content textarea,
    .tree-view {
        min-height: 400px;
    }

    .fullscreen-overlay {
        padding: 10px;
    }
}