/* Variables */
:root {
    /* Light theme (VS Code-like) */
    --bg-color: #f5f5f5;
    --text-color: #333;
    --header-bg: #00796b;
    --header-text: #fff;
    --controls-bg: #e0f2f1;
    --button-bg: #fff;
    --button-text: #00796b;
    --button-hover: #e0f2f1;
    --button-border: transparent;
    --editor-bg: #fff;
    --editor-text: #333;
    --editor-toolbar-bg: #f3f3f3;
    --editor-toolbar-border: #e0e0e0;
    --editor-btn-color: #616161;
    --editor-btn-hover: #e0e0e0;
    --dropdown-bg: #fff;
    --dropdown-hover: #f0f0f0;
    --error-line-bg: #ffdce0;
    --error-text: #d73a49;
    --footer-bg: #00796b;
    --footer-text: #fff;
    --scrollbar-track: #f1f1f1;
    --scrollbar-thumb: #c1c1c1;
    --scrollbar-thumb-hover: #a8a8a8;
    --notification-success-bg: rgba(76, 175, 80, 0.9);
    --notification-error-bg: rgba(244, 67, 54, 0.9);
    --notification-info-bg: rgba(33, 150, 243, 0.9);
    --notification-text: #fff;

    /* CodeMirror token colors (VS Code Light+) */
    --cm-key: #1f6feb;            /* property keys */
    --cm-string: #a31515;         /* strings */
    --cm-number: #098658;         /* numbers */
    --cm-boolean-null: #0000ff;   /* booleans, null (atom) */
    --cm-operator: #000000;       /* operators */
    --cm-punctuation: #000000;    /* punctuation/brackets */
    --cm-comment: #008000;        /* comments */
}

body.dark-theme {
    /* Dark theme (VS Code-like) */
    --bg-color: #1e1e1e;
    --text-color: #d4d4d4;
    --header-bg: #1a1a1a;
    --header-border: #333;
    --controls-bg: #252526;
    --button-bg: #333333;
    --button-text: #d4d4d4;
    --button-hover: #3c3c3c;
    --button-border: #555555;
    --editor-bg: #1e1e1e;
    --editor-text: #d4d4d4;
    --editor-toolbar-bg: #252526;
    --editor-toolbar-border: #3c3c3c;
    --editor-btn-color: #cccccc;
    --editor-btn-hover: #3c3c3c;
    --dropdown-bg: #252526;
    --dropdown-hover: #3c3c3c;
    --error-line-bg: #5a1d1d;
    --error-text: #f48771;
    --footer-bg: #1a1a1a;
    --scrollbar-track: #1e1e1e;
    --scrollbar-thumb: #424242;
    --scrollbar-thumb-hover: #4f4f4f;

    /* CodeMirror token colors (VS Code Dark+) */
    --cm-key: #9cdcfe;            /* property keys */
    --cm-string: #ce9178;         /* strings */
    --cm-number: #b5cea8;         /* numbers */
    --cm-boolean-null: #569cd6;   /* booleans, null (atom) */
    --cm-operator: #d4d4d4;       /* operators */
    --cm-punctuation: #d4d4d4;    /* punctuation/brackets */
    --cm-comment: #6a9955;        /* comments */
}

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

html, body {
    height: 100%;
    width: 100%;
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    line-height: 1.5;
    overflow: hidden;
}

/* Header */
.header {
    background-color: var(--header-bg);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
    height: 40px;
    border-bottom: 1px solid var(--header-border);
}

.logo {
    font-size: 16px;
    font-weight: bold;
    text-transform: lowercase;
}

.header-tools {
    display: flex;
    align-items: center;
}

.tool-links {
    display: flex;
}

.tool-links a {
    color: white;
    text-decoration: none;
    padding: 0 10px;
    font-size: 12px;
    line-height: 40px;
    text-transform: uppercase;
}

.tool-links a.active {
    background-color: #34495e;
}

.theme-toggle {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 16px;
    margin-left: 10px;
}

/* Main Content */
.main-content {
    display: flex;
    height: calc(100% - 80px); /* Header + Footer */
}

/* Editor Containers */
.editor-container {
    flex: 1;
    height: 100%;
    position: relative;
    background-color: var(--editor-bg);
    display: flex;
    flex-direction: column;
}

.editor-toolbar {
    background-color: var(--editor-toolbar-bg);
    border-bottom: 1px solid var(--editor-toolbar-border);
    padding: 5px 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Left editor toolbar - icons on the right */
.editor-container:first-child .editor-toolbar {
    justify-content: flex-end;
}

/* Right editor toolbar - icons on the left */
.editor-container:last-child .editor-toolbar {
    justify-content: flex-start;
}

.editor-btn {
    background: none;
    border: none;
    color: var(--editor-btn-color);
    cursor: pointer;
    padding: 4px 8px;
    margin-right: 5px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s;
}

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

.editor-btn svg {
    width: 16px;
    height: 16px;
}

.editor-btn span {
    margin-right: 4px;
}

.view-dropdown-container {
    position: relative;
    display: inline-block;
    margin-left: auto;
}

/* Keep left editor's buttons and view dropdown together (no auto spacing) */
.editor-container:first-child .view-dropdown-container {
    margin-left: 0;
}

/* Adjust view dropdown container for right editor */
.editor-container:last-child .view-dropdown-container {
    margin-left: 0;
    margin-right: auto;
}

.view-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: var(--dropdown-bg);
    border-radius: 3px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    display: none;
    z-index: 10;
    min-width: 120px;
}

/* Right editor dropdown positioning */
.editor-container:last-child .view-dropdown {
    right: auto;
    left: 0;
}

.view-dropdown.show {
    display: block;
}

.view-dropdown a {
    color: var(--text-color);
    display: block;
    padding: 8px 15px;
    text-decoration: none;
    transition: background-color 0.2s;
}

.view-dropdown a:hover {
    background-color: var(--dropdown-hover);
}

.editor-wrapper {
    position: relative;
    flex: 1;
    overflow: hidden;
}

/* Controls Panel */
.controls {
    width: 200px;
    background-color: var(--controls-bg);
    display: flex;
    flex-direction: column;
    padding: 15px;
    border-left: 1px solid var(--editor-toolbar-border);
    border-right: 1px solid var(--editor-toolbar-border);
}

.control-btn {
    background-color: var(--button-bg);
    color: var(--button-text);
    border: 1px solid var(--button-border);
    border-radius: 3px;
    padding: 10px;
    margin-bottom: 15px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
    text-align: center;
}

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

body.dark-theme .control-btn {
    border-color: var(--button-border);
}

/* Tab Size Select */
.tab-settings {
    margin-top: 10px;
}

.tab-size-wrapper {
    display: flex;
    align-items: center;
}

.tab-size-select {
    width: 100%;
    padding: 8px;
    border: none;
    border-radius: 3px;
    background-color: var(--button-bg);
    color: var(--text-color);
    cursor: pointer;
}

/* Convert Dropdown */
.convert-dropdown-container {
    position: relative;
    margin-bottom: 15px;
}

.convert-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--editor-bg);
    border: 1px solid var(--editor-toolbar-border);
    border-radius: 3px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    display: none;
    z-index: 10;
    overflow: hidden;
}

.convert-dropdown.show {
    display: block;
    animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.convert-dropdown a {
    color: var(--text-color);
    display: flex;
    align-items: center;
    padding: 8px 15px;
    text-decoration: none;
    transition: background-color 0.2s;
    font-size: 13px;
}

.convert-dropdown a:hover {
    background-color: var(--dropdown-hover);
}

#convert-json {
    position: relative;
    padding-right: 25px;
}

#convert-json::after {
    content: '▼';
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    opacity: 0.7;
}

/* JSON Full Form */
.json-full-form {
    color: var(--text-color);
    font-size: 12px;
    margin-top: 20px;
    text-align: center;
    opacity: 0.8;
}

/* Footer */
.footer {
    background-color: var(--header-bg);
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    height: 40px;
    font-size: 12px;
}

.footer-text {
    margin-bottom: 5px;
}

.social-links {
    display: flex;
    gap: 10px;
}

.social-link {
    color: white;
    text-decoration: none;
}

/* CodeMirror Overrides */
.CodeMirror {
    height: 100%;
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    background: var(--editor-bg);
    color: var(--editor-text);
}

.CodeMirror-gutters {
    background-color: var(--editor-bg);
    border-right: 1px solid var(--editor-toolbar-border);
}

.dark-theme .CodeMirror-gutters {
    background-color: #252525 !important;
    border-right: 1px solid #444 !important;
}

.dark-theme .CodeMirror-linenumber {
    color: #777 !important;
}

/* CodeMirror token theming mapped to variables for both themes */
.cm-s-default .cm-property { color: var(--cm-key) !important; }
.cm-s-default .cm-string { color: var(--cm-string) !important; }
.cm-s-default .cm-string.cm-property { color: var(--cm-key) !important; }
.cm-s-default .cm-number { color: var(--cm-number) !important; }
.cm-s-default .cm-atom { color: var(--cm-boolean-null) !important; } /* true, false, null */
.cm-s-default .cm-operator { color: var(--cm-operator) !important; }
.cm-s-default .cm-punctuation, 
.cm-s-default .cm-bracket { color: var(--cm-punctuation) !important; }
.cm-s-default .cm-comment { color: var(--cm-comment) !important; font-style: italic; }

/* Selection colors aligned with themes */
.CodeMirror-selected { background-color: rgba(173, 214, 255, 0.45) !important; }
.dark-theme .CodeMirror-selected { background-color: rgba(38, 79, 120, 0.5) !important; }

/* JSONEditor host container */
.jsoneditor-host {
    height: 100%;
    background: var(--editor-bg);
}

/* JSONEditor theming */
.jsoneditor {
    background: var(--editor-bg) !important;
    color: var(--editor-text) !important;
}
.jsoneditor-menu {
    background: var(--editor-toolbar-bg) !important;
    border-bottom: 1px solid var(--editor-toolbar-border) !important;
}
.jsoneditor-menu a,
.jsoneditor-menu button,
.jsoneditor-menu input,
.jsoneditor-menu select,
.jsoneditor-navigation-bar,
.jsoneditor-statusbar {
    color: var(--text-color) !important;
}
.jsoneditor-statusbar {
    background: var(--editor-toolbar-bg) !important;
    border-top: 1px solid var(--editor-toolbar-border) !important;
}
.jsoneditor-outer,
.jsoneditor-inner,
.jsoneditor-tree,
.jsoneditor-table,
.jsoneditor-text,
.jsoneditor-values,
.jsoneditor-fields {
    background: var(--editor-bg) !important;
    color: var(--editor-text) !important;
}
.jsoneditor-field,
.jsoneditor-value,
.jsoneditor-readonly {
    color: var(--editor-text) !important;
}
.jsoneditor-frame {
    border-color: var(--editor-toolbar-border) !important;
}
.jsoneditor td, .jsoneditor th {
    border-color: var(--editor-toolbar-border) !important;
}
.jsoneditor-search input,
.jsoneditor-search div,
.jsoneditor-search button {
    background: var(--button-bg) !important;
    color: var(--text-color) !important;
    border-color: var(--button-border) !important;
}

/* Ace editor (used by JSONEditor code mode) */
.ace_editor {
    background: var(--editor-bg) !important;
    color: var(--editor-text) !important;
}
.ace_gutter {
    background: var(--editor-bg) !important;
    color: var(--text-color) !important;
    border-right: 1px solid var(--editor-toolbar-border) !important;
}
.ace_cursor {
    border-left: 2px solid var(--editor-text) !important;
}
.ace_selection {
    background: rgba(173, 214, 255, 0.35) !important;
}
body.dark-theme .ace_selection {
    background: rgba(38, 79, 120, 0.4) !important;
}
.ace_marker-layer .ace_active-line {
    background: rgba(128,128,128,0.1) !important;
}
.ace_marker-layer .ace_selection {
    background: rgba(173, 214, 255, 0.35) !important;
}
body.dark-theme .ace_marker-layer .ace_selection {
    background: rgba(38, 79, 120, 0.4) !important;
}

/* Error Line Highlighting */
.error-line {
    background-color: var(--error-line-bg) !important;
}

.error-marker {
    color: var(--error-text);
    margin-left: 5px;
}

/* JSON Table View */
.json-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Fira Code', monospace;
    font-size: 14px;
}

.json-table th, .json-table td {
    border: 1px solid var(--editor-toolbar-border);
    padding: 8px;
    text-align: left;
}

.json-table th {
    background-color: var(--editor-toolbar-bg);
    font-weight: bold;
}

.json-table tr:nth-child(even) {
    background-color: var(--dropdown-hover);
}

.empty-array {
    padding: 10px;
    color: var(--text-color);
    font-style: italic;
}

/* JSON Tree View */
.json-tree {
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    padding: 10px;
}

.tree-content {
    padding-left: 20px;
}

.tree-item {
    margin: 5px 0;
}

.tree-key {
    color: var(--button-text);
    font-weight: bold;
}

.string-value {
    color: #ce9178;
}

.number-value {
    color: #b5cea8;
}

.boolean-value {
    color: #569cd6;
}

.null-value {
    color: #569cd6;
    font-style: italic;
}

.object-value {
    color: #9cdcfe;
    font-style: italic;
}

details summary {
    cursor: pointer;
    color: #9cdcfe;
}

details summary:hover {
    text-decoration: underline;
}

.dark-theme .CodeMirror-cursor {
    border-left-color: #e0e0e0 !important;
}

.dark-theme .CodeMirror-selected {
    background-color: rgba(38, 79, 120, 0.5) !important;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* Notification */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 10px 20px;
    border-radius: 4px;
    color: white;
    font-size: 14px;
    z-index: 1000;
    animation: fadeIn 0.3s, fadeOut 0.3s 2.7s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.notification-success {
    background-color: #4caf50;
}

.notification-error {
    background-color: #f44336;
}

.notification-info {
    background-color: #2196f3;
}

.fade-out {
    opacity: 0;
    transition: opacity 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateY(0); }
    to { opacity: 0; transform: translateY(-20px); }
}
/* CodeMirror styling */
.CodeMirror {
    height: 100% !important;
    font-family: 'Fira Code', monospace;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.dark-theme .CodeMirror {
    background: var(--editor-bg);
    color: var(--text-color);
}

.codemirror-host {
    display: none;
}
/* JSONEditor dark mode fix */
.dark-theme .jsoneditor {
    background-color: var(--editor-bg) !important;
    border-color: var(--border-color) !important;
}

.dark-theme .jsoneditor-menu {
    background-color: var(--editor-bg) !important;
    border-color: var(--border-color) !important;
}

.dark-theme .ace-jsoneditor .ace_gutter {
    background-color: var(--editor-bg) !important;
    color: var(--text-color) !important;
}

.dark-theme .ace-jsoneditor {
    background-color: var(--editor-bg) !important;
    color: var(--text-color) !important;
}

/* Hide JSONEditor menu bar */
.jsoneditor-menu {
    display: none !important;
}
/* Fix JSONEditor tree lines in dark mode */
.dark-theme .jsoneditor-tree .jsoneditor-tree-inner {
    background-color: var(--editor-bg) !important;
}

.dark-theme .jsoneditor-tree .jsoneditor-tree-inner .jsoneditor-tree-button {
    background-color: var(--text-color) !important;
}

.dark-theme .jsoneditor-tree .jsoneditor-tree-inner .jsoneditor-tree-button:before,
.dark-theme .jsoneditor-tree .jsoneditor-tree-inner .jsoneditor-tree-button:after {
    background-color: var(--text-color) !important;
}

/* More specific targeting for tree lines */
.dark-theme .jsoneditor-tree table.jsoneditor-tree tr td {
    border-left: 1px solid var(--border-color) !important;
}

.dark-theme .jsoneditor-tree .jsoneditor-button {
    background-color: transparent !important;
    border-color: var(--border-color) !important;
}

.dark-theme .jsoneditor-tree .jsoneditor-button:before,
.dark-theme .jsoneditor-tree .jsoneditor-button:after {
    background-color: var(--text-color) !important;
}
/* Fix JSONEditor code mode folding lines in dark mode */
.dark-theme .ace-jsoneditor .ace_fold-widget {
    background-color: var(--text-color) !important;
}

.dark-theme .ace-jsoneditor .ace_gutter-cell {
    border-right: 1px solid var(--border-color) !important;
}

.dark-theme .ace-jsoneditor .ace_indent-guide {
    background: var(--border-color) !important;
}
/* Force JSONEditor text colors in dark mode */
.dark-theme .ace-jsoneditor {
    background-color: var(--editor-bg) !important;
    color: #f8f8f2 !important;
}

.dark-theme .ace-jsoneditor .ace_scroller {
    background-color: var(--editor-bg) !important;
}

.dark-theme .ace-jsoneditor .ace_content {
    background-color: var(--editor-bg) !important;
}

.dark-theme .ace-jsoneditor .ace_string {
    color: #e6db74 !important;
}

.dark-theme .ace-jsoneditor .ace_constant.ace_numeric {
    color: #ae81ff !important;
}

.dark-theme .ace-jsoneditor .ace_constant.ace_language.ace_boolean {
    color: #ae81ff !important;
}

.dark-theme .ace-jsoneditor .ace_keyword {
    color: #f92672 !important;
}

.dark-theme .ace-jsoneditor .ace_paren {
    color: #f8f8f2 !important;
}

.dark-theme .ace-jsoneditor .ace_variable {
    color: #66d9ef !important;
}

.dark-theme .ace-jsoneditor .ace_text {
    color: #f8f8f2 !important;
}

.dark-theme .ace-jsoneditor .ace_punctuation {
    color: #f8f8f2 !important;
}
