:root {
    --bg-color: #0f172a;
    --text-color: #e2e8f0;
    --accent-color: #3b82f6;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --panel-bg: rgba(30, 41, 59, 0.7);
    --border-color: rgba(255, 255, 255, 0.1);
    --font-sans: 'Inter', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --success: #10b981;
    --error: #ef4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    background-image:
        radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 1) 0, transparent 50%);
    color: var(--text-color);
    font-family: var(--font-sans);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1rem;
    gap: 1rem;
}

.app-header {
    text-align: center;
    margin-bottom: 0.5rem;
}

.app-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    background: linear-gradient(to right, #60a5fa, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-header p {
    font-size: 0.875rem;
    opacity: 0.7;
}

.workspace {
    display: grid;
    grid-template-columns: 1fr 2fr 1fr;
    gap: 1rem;
    flex: 1;
    min-height: 0;
    /* Important for scroll */
}

.workspace.focus-mode {
    grid-template-columns: 1fr;
    gap: 0;
}

.workspace.focus-mode .input-panel,
.workspace.focus-mode .output-panel {
    display: none;
}

.panel {
    background: var(--panel-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.panel-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
}

.panel-header h2 {
    font-size: 0.875rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--accent-color);
}

.editor-container,
.visual-editor-content {
    flex: 1;
    overflow: auto;
    position: relative;
}

textarea#json-input,
pre#json-output {
    width: 100%;
    height: 100%;
    background: transparent;
    border: none;
    padding: 1rem;
    color: var(--text-color);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    resize: none;
    outline: none;
    line-height: 1.5;
}

textarea#json-input:focus {
    background: rgba(0, 0, 0, 0.1);
}

.btn {
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-color);
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn.primary {
    background: var(--accent-color);
    border-color: var(--accent-color);
    color: white;
}

.btn.primary:hover {
    box-shadow: 0 0 10px var(--accent-glow);
}

.btn.danger {
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.3);
}

.btn.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

.badge {
    font-size: 0.7rem;
    padding: 0.2em 0.6em;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.1);
}

.badge.neutral {
    color: #94a3b8;
}

.badge.success {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.badge.error {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
}

.hidden {
    display: none !important;
}

/* Table Styles for Visual Editor */
.json-table {
    width: max-content;
    /* Allow table to grow horizontally */
    min-width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.json-table th,
.json-table td {
    border: 1px solid var(--border-color);
    padding: 0.5rem;
    text-align: left;
    vertical-align: top;
    min-width: 80px;
    /* Reduced from 150px to fit small cols */
    white-space: nowrap;
    /* Prevent wrapping */
}

.json-table th {
    background: rgba(255, 255, 255, 0.03);
    color: #94a3b8;
    font-weight: 500;
    resize: horizontal;
    /* Native resize */
    overflow: hidden;
    position: relative;
}

.json-table input {
    background: transparent;
    border: none;
    color: #a7f3d0;
    /* Green tint for values */
    width: 100%;
    font-family: inherit;
    outline: none;
    border-bottom: 1px dashed transparent;
}

.json-table input:focus {
    border-bottom-color: var(--accent-color);
}

.nested-table-container {
    padding: 0;
    margin: 0;
}

.error-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(239, 68, 68, 0.1);
    border-top: 1px solid var(--error);
    color: var(--error);
    padding: 0.5rem;
    font-size: 0.8rem;
    backdrop-filter: blur(4px);
}

.empty-state {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #64748b;
    font-style: italic;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #1e293b;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: 400px;
    max-width: 90%;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

.modal-header {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-color);
}

.btn-icon {
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
}

.btn-icon:hover {
    color: var(--text-color);
}

.modal-body {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.8rem;
    color: #94a3b8;
}

.form-group input,
.form-group select {
    background: rgba(0, 0, 0, 0.4);
    /* Darker background for contrast */
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.5rem;
    color: #fff;
    /* Brighter text */
    font-family: var(--font-sans);
    outline: none;
}

.form-group option {
    background-color: #1e293b;
    /* Solid dark background for options */
    color: #e2e8f0;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--accent-color);
}

.modal-footer {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}