:root {
    --primary-bg: #ffffff;
    --secondary-bg: #f9fafb;
    --border-color: #e5e8ebc4;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --button-primary: #0868b2;
    --button-primary-hover: #207dc4;
    --button-secondary: #f3f4f6;
    --button-secondary-hover: #e5e7eb;
}

[data-theme="dark"] {
    --primary-bg: #1f2937;
    --secondary-bg: #111827;
    --border-color: #374151;
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --button-primary: #3b82f6;
    --button-primary-hover: #60a5fa;
    --button-secondary: #374151;
    --button-secondary-hover: #4b5563;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--secondary-bg);
    display: flex;
    min-height: 100vh;
}

/* Use Fira Code for JSON input, line numbers, and code output */
.tree-view textarea,
.tree-view .linenumbers,
.tree-view .json-tree,
pre code,
code {
    font-family: 'Fira Code', monospace !important;
    font-size: 0.95em;
}

/* All other elements inherit Inter from body */

.sidebar {
    width: 240px;
    background-color: var(--primary-bg);
    border-right: 1px solid var(--border-color);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.044), 0 2px 6px 0 rgba(0, 0, 0, 0.049);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    flex-grow: 1;
}

.theme-toggle {
    background: transparent;
    border: none;
    padding: 0.05rem;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 0.375rem;
}

.theme-toggle:hover {
    background-color: var(--button-secondary);
}

.primary-btn {
    width: 100%;
    padding: 0.50rem 0.50rem;
    background-color: var(--button-primary);
    color: white;
    border: none;
    border-radius: 0.375rem;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.primary-btn:hover {
    background-color: var(--button-primary-hover);
}

.action-options {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.action-options label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
    cursor: pointer;
    font-weight: 100;
    font-size: 1.08rem;
    margin-bottom: 1.1rem;
}

.action-options input[type="checkbox"] {
    width: 1.15em;
    height: 1.15em;
    accent-color: var(--button-primary);
    margin-right: 0.5em;
}

.sidebar-footer {
    margin-top: auto;
    display: flex;
    gap: 1rem;
}

.help-btn,
.settings-btn {
    flex: 1;
    padding: 0.5rem;
    background-color: var(--button-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    color: var(--text-primary);
    cursor: pointer;
}

.help-btn:hover,
.settings-btn:hover {
    background-color: var(--button-secondary-hover);
}

.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

.editor-header {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: var(--primary-bg);
    border-bottom: 1px solid var(--border-color);
    gap: 1rem;
    box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.044), 0 2px 6px 0 rgba(0, 0, 0, 0.049);
}

.header-left h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.action-btn {
    padding: 0.3rem 1rem;
    background-color: var(--button-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
}

.action-btn:hover {
    background-color: var(--button-secondary-hover);
}

.switch-view-btn {
    padding: 0.3rem 1rem;
    background-color: var(--button-secondary);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    color: var(--text-primary);
    font-size: 0.875rem;
    cursor: pointer;
    margin-left: 0.2rem;
}

.switch-view-btn:hover {
    background-color: var(--button-secondary-hover);
}

.editor-content {
    flex-grow: 1;
    overflow: hidden;
    padding: 1.5rem;
}

.tree-view {
    height: 90%;
    background-color: var(--primary-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    overflow: hidden;
    max-width: 99%;
}

.tree-view pre {
    margin: 0;
    height: 100%;
    display: flex;
}

.tree-view .linenumbers {
    padding: 1rem 1.1rem;
    background-color: var(--secondary-bg);
    border-right: 1px solid var(--border-color);
    color: var(--text-secondary);
    text-align: right;
    user-select: none;
}

.tree-view textarea {
    flex-grow: 1;
    padding: 1rem;
    border: none;
    background-color: var(--primary-bg);
    color: var(--text-primary);
    font-family: 'Fira Code', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    resize: none;
}

.tree-view textarea:focus {
    outline: none;
}

.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 1rem;
    background-color: var(--primary-bg);
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    color: var(--text-primary);
    z-index: 50;
    display: none;
}

.toast.show {
    display: block;
    animation: slideIn 0.3s ease-out;
}

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

.json-key {
    color: #c586c0;
}

.json-string {
    color: #ce9178;
}

.json-number {
    color: #b5cea8;
}

.json-boolean, .json-null {
    color: #569cd6;
}

.json-bracket {
    color: #569cd6;
}

.json-punctuation {
    color: #d4d4d4;
}

.output-actions {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.7rem;
    margin-bottom: 1rem;
}

.action-options {
    display: flex;
    flex-direction: column;
    gap: 0.01rem;
    margin-bottom: 0.5rem;
    align-items: flex-start;
}

.ad-slot {
    width: 100%;
    max-width: 700px;
    margin: 0 auto 2rem auto;
    padding: 1rem 0;
    text-align: center;
    border: 2px dashed #e2e8f0;
    border-radius: 8px;
    background: rgba(220,220,220,0.04);
    color: #888;
    font-size: 1.1rem;
    letter-spacing: 0.5px;
    box-sizing: border-box;
}

.input-flex-row {
    display: flex;
    flex-direction: row;
    width: 100%;
    gap: 1.5rem;
}
.options-col {
    flex: 0 0 22%;
    max-width: 22%;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
}
.input-col, .output-col {
    flex: 0 0 50%;
    max-width: 50%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 80vh;
}

.output-flex-row {
    display: flex;
    flex-direction: row;
    width: 100%;
    gap: 1.5rem;
}
.output-col-left {
    flex: 0 0 15%;
    max-width: 15%;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    margin-top: 3rem;
}
.output-col-right {
    flex: 1 1 85%;
    max-width: 85%;
    display: flex;
    flex-direction: column;
}

.search-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.5em;
    margin-bottom: 1rem;
    justify-content: flex-end;
}
.search-row input {
    width: 220px;
    max-width: 220px;
    padding: 0.4em 0.7em;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    font-family: inherit;
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 0.9rem;
    transition: border 0.2s, background 0.2s, color 0.2s;
}
.search-row input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.output-actions .secondary-btn {
    width: 100%;
    box-sizing: border-box;
}

.sidebar-options {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
    width: 100%;
    margin-bottom: 2rem;
    align-items: stretch;
}
.action-options label {
    font-size: 0.85rem;
    margin-bottom: 0.1rem;
    display: flex;
    align-items: center;
    gap: 0.1em;
}
.sidebar-options .primary-btn {
    width: 100%;
    margin-bottom: 0.1rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    width: 100%;
}

.sidebar-nav button,
.sidebar-options .primary-btn,
.sidebar-options .secondary-btn {
    width: 100%;
    min-height: 44px;
    box-sizing: border-box;
    font-size: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    margin: 0;
    text-align: center;
}

.section-label {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 0.75rem;
    padding-left: 0.5rem;
}

.theme-toggle-container {
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    padding: 0.5rem 0.5rem;
    margin-bottom: 1rem;
    margin-top: 1rem;
    background: #f7f9fa;
    transition: background 0.2s, color 0.2s;
    cursor: pointer;
}

.theme-toggle-container:hover {
    background: #232526;
    color: #fff;
}

.theme-toggle-container:hover .theme-label,
.theme-toggle-container:hover .theme-toggle {
    color: #fff;
}

.theme-toggle-container:hover .theme-toggle svg {
    stroke: #fff;
}

#formatBtn, #updateFileBtn {
    background: #0868b2;
    color: #fff;
    border: none;
    box-shadow: 0 1px 4px rgba(37,99,235,0.10);
    font-weight: 100;
    letter-spacing: 0.02em;
}

#formatBtn:hover, #formatBtn:focus,
#updateFileBtn:hover, #updateFileBtn:focus {
    background: #207dc4;
    color: #fff;
    box-shadow: 0 4px 16px rgba(37,99,235,0.18);
    border: none;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 0.01rem;
}

.tree-output {
    background-color: var(--primary-bg);
    color: var(--text-primary);
    border-radius: 0.375rem;
    border: none;
    font-family: 'Fira Code', monospace;
    font-size: 0.95em;
    padding: 1rem;
    min-height: 100%;
    max-height: 60vh;
    overflow: auto;
    box-sizing: border-box;
    width: 100%;
    margin-top: 0;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

[data-theme="dark"] .modal-content {
    background-color: #23272f;
}

.modal-code-div {
    margin-top: 1rem;
    background-color: #f3f4f6;
    border-radius: 4px;
    padding: 1rem;
    overflow: auto;
    max-height: calc(80vh - 200px);
    min-height: 200px;
}

[data-theme="dark"] .modal-code-div {
    background-color: #23272f;
}

.modal-code {
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre;
    overflow-x: auto;
    margin: 0;
    padding: 0;
}

.modal-code.url {
    word-break: break-all;
}

.close-modal {
    position: absolute;
    top: 1.2rem;
    right: 1.5rem;
    font-size: 2rem;
    color: #888;
    cursor: pointer;
    font-weight: bold;
    transition: color 0.2s;
}
.close-modal:hover {
    color: #d32f2f;
}

.json-toggle {
    display: inline-block;
    width: 1.2em;
    height: 1.2em;
    margin-right: 0.3em;
    cursor: pointer;
    user-select: none;
    vertical-align: middle;
    text-align: center;
    font-size: 1.1em;
    color: var(--text-secondary);
    transition: color 0.2s;
}
.json-toggle:hover {
    color: var(--button-primary);
}
.json-toggle.expanded::before {
    content: '\2212'; /* Unicode minus sign (−) */
    font-weight: bold;
}
.json-toggle.collapsed::before {
    content: '\002B'; /* Unicode plus sign (+) */
    font-weight: bold;
}

.json-tree-line:hover {
    background: #e5e7eb;
    /* light gray, matches Tailwind's gray-200 */
    border-radius: 4px;
}
[data-theme="dark"] .json-tree-line:hover {
    background: #374151;
    /* dark gray, matches Tailwind's gray-700 */
}

.exanple-click {
    color: var(--text-secondary);
    text-align: center;
    font-size: 0.85rem;
    cursor: pointer;
}
