/* JSON Tree Viewer Styles */

.json-tree-viewer-wrapper {
    width: 100%;
}

/* Panels */
.input-panel,
.tree-panel {
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 8px;
    overflow: hidden;
}

.panel-header {
    padding: 15px 20px;
    background: var(--bs-secondary-bg);
    border-bottom: 1px solid var(--bs-border-color);
}

.panel-header h5 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--bs-emphasis-color);
}

.panel-body {
    padding: 20px;
}

/* Input textarea */
.json-input {
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: vertical;
    min-height: 250px;
    border: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
}

.json-input:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

/* Action buttons */
.action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Tree Toolbar */
.tree-toolbar,
.tree-toolbar-modal {
    padding: 12px 20px;
    background: var(--bs-tertiary-bg);
    border-bottom: 1px solid var(--bs-border-color);
}

.toolbar-row {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

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

.toolbar-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--bs-secondary-color);
    margin: 0;
}

/* Search box */
.search-box {
    position: relative;
    min-width: 200px;
}

.search-box .search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.5;
}

.search-box input {
    padding-left: 35px;
}

/* Tree Container */
.tree-container {
    min-height: 400px;
    max-height: 800px;
    overflow: auto;
    background: var(--bs-body-bg);
    padding: 15px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.6;
}

.tree-container-fullscreen {
    height: calc(100vh - 200px);
    overflow: auto;
    background: var(--bs-body-bg);
    padding: 20px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.6;
}

.tree-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

/* Tree Nodes */
.json-tree {
    color: var(--bs-body-color);
}

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

.tree-node-line {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 2px 0;
    position: relative;
}

.tree-node-line:hover {
    background: var(--bs-secondary-bg);
    border-radius: 3px;
}

.tree-node-line:hover .tree-actions {
    opacity: 1;
}

/* Toggle button */
.tree-toggle {
    cursor: pointer;
    user-select: none;
    color: var(--bs-secondary-color);
    font-size: 10px;
    width: 14px;
    display: inline-block;
    text-align: center;
}

.tree-toggle:hover {
    color: var(--bs-primary);
}

.tree-toggle-spacer {
    width: 14px;
    display: inline-block;
}

/* Key */
.tree-key {
    color: #8b4513;
    font-weight: 600;
}

[data-bs-theme="dark"] .tree-key {
    color: #d19a66;
}

.tree-colon {
    color: var(--bs-secondary-color);
}

/* Values */
.tree-value {
    font-weight: 500;
}

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

[data-bs-theme="dark"] .tree-value-string {
    color: #98c379;
}

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

[data-bs-theme="dark"] .tree-value-number {
    color: #61afef;
}

.tree-value-boolean {
    color: #a626a4;
    font-weight: 700;
}

[data-bs-theme="dark"] .tree-value-boolean {
    color: #c678dd;
}

.tree-value-null {
    color: #e45649;
    font-weight: 700;
}

[data-bs-theme="dark"] .tree-value-null {
    color: #e06c75;
}

/* Preview */
.tree-preview {
    color: var(--bs-secondary-color);
    font-style: italic;
}

.tree-bracket {
    color: var(--bs-secondary-color);
    font-weight: 700;
}

.tree-count {
    font-size: 0.85em;
    opacity: 0.8;
}

/* Type badge */
.tree-type-badge {
    font-size: 0.7em;
    padding: 2px 6px;
    background: var(--bs-secondary-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 3px;
    margin-left: 8px;
    color: var(--bs-secondary-color);
    text-transform: uppercase;
    font-weight: 600;
}

/* Action buttons */
.tree-actions {
    opacity: 0;
    transition: opacity 0.2s;
    margin-left: auto;
    display: flex;
    gap: 5px;
}

.tree-action-btn {
    background: var(--bs-secondary-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: 3px;
    padding: 4px 6px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.tree-action-btn img {
    opacity: 0.7;
    transition: opacity 0.2s;
}

.tree-action-btn:hover {
    background: var(--bs-primary);
    border-color: var(--bs-primary);
    transform: scale(1.1);
}

.tree-action-btn:hover img {
    opacity: 1;
    filter: brightness(0) invert(1);
}

/* Children */
.tree-children {
    margin-left: 20px;
    border-left: 1px solid var(--bs-border-color);
    padding-left: 5px;
}

/* Collapsed state */
.tree-node.collapsed > .tree-children {
    display: none;
}

/* Search highlighting */
.search-match {
    background: #fff3cd;
    padding: 1px 3px;
    border-radius: 2px;
    font-weight: 700;
}

[data-bs-theme="dark"] .search-match {
    background: #664d03;
    color: #fff3cd;
}

.search-dimmed {
    opacity: 0.3;
}

.search-dimmed .search-match {
    opacity: 1;
}

/* Responsive */
@media (max-width: 991px) {
    .tree-container {
        max-height: 400px;
    }

    .toolbar-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .search-box {
        width: 100%;
    }
}

@media (max-width: 576px) {
    .panel-body {
        padding: 15px;
    }

    .tree-toolbar,
    .tree-toolbar-modal {
        padding: 10px 15px;
    }

    .json-input {
        min-height: 300px;
        font-size: 12px;
    }

    .tree-container {
        font-size: 12px;
        padding: 10px;
    }

    .tree-node {
        margin-left: 10px;
    }

    .tree-children {
        margin-left: 10px;
    }
}

/* Scrollbar styling */
.tree-container::-webkit-scrollbar,
.tree-container-fullscreen::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.tree-container::-webkit-scrollbar-track,
.tree-container-fullscreen::-webkit-scrollbar-track {
    background: var(--bs-tertiary-bg);
}

.tree-container::-webkit-scrollbar-thumb,
.tree-container-fullscreen::-webkit-scrollbar-thumb {
    background: var(--bs-border-color);
    border-radius: 4px;
}

.tree-container::-webkit-scrollbar-thumb:hover,
.tree-container-fullscreen::-webkit-scrollbar-thumb:hover {
    background: var(--bs-secondary-color);
}

/* Dark mode specific adjustments */
[data-bs-theme="dark"] .json-input {
    background: #1e1e1e;
    color: #d4d4d4;
    border-color: #404040;
}

[data-bs-theme="dark"] .tree-container,
[data-bs-theme="dark"] .tree-container-fullscreen {
    background: #1e1e1e;
}

[data-bs-theme="dark"] .tree-children {
    border-left-color: #404040;
}
