/* Theme Variables */
[data-theme="dark"] {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #64748b;
    --background: #0f172a;
    --surface: #1e293b;
    --surface-light: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --error: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --border: #334155;
    --shadow: rgba(0, 0, 0, 0.3);
    --key-color: #a78bfa;
    --string-color: #34d399;
    --number-color: #fbbf24;
    --boolean-color: #60a5fa;
    --null-color: #94a3b8;
    --diff-added: rgba(16, 185, 129, 0.2);
    --diff-removed: rgba(239, 68, 68, 0.2);
    --diff-changed: rgba(245, 158, 11, 0.2);
}

[data-theme="light"] {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #94a3b8;
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-light: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --error: #dc2626;
    --success: #059669;
    --warning: #d97706;
    --border: #e2e8f0;
    --shadow: rgba(0, 0, 0, 0.1);
    --key-color: #7c3aed;
    --string-color: #059669;
    --number-color: #d97706;
    --boolean-color: #2563eb;
    --null-color: #64748b;
    --diff-added: rgba(16, 185, 129, 0.15);
    --diff-removed: rgba(239, 68, 68, 0.15);
    --diff-changed: rgba(245, 158, 11, 0.15);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
        'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header */
header {
    margin-bottom: 1.5rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
}

.title {
    color: var(--text-primary);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
}

.header-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.header-controls .btn {
    height: 40px;
    padding: 0 1rem;
}

/* Toolbar */
.toolbar {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    box-shadow: 0 2px 4px var(--shadow);
}

.toolbar-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Search Box */
.search-box {
    position: relative;
    flex: 1;
    min-width: 200px;
    max-width: 300px;
}

#searchInput {
    width: 100%;
    padding: 0.5rem 2rem 0.5rem 0.75rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
}

#searchInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn-clear {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 0.5rem;
    line-height: 1;
}

.btn-clear:hover {
    color: var(--text-primary);
}

/* Stats Panel */
.stats-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    box-shadow: 0 2px 4px var(--shadow);
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-color);
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

/* Dropdown */
.dropdown {
    position: relative;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow);
    min-width: 160px;
    z-index: 1000;
    overflow: hidden;
}

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

.dropdown-menu button {
    width: 100%;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    transition: background 0.2s;
}

.dropdown-menu button:hover {
    background: var(--surface-light);
}

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    flex: 1;
    margin-bottom: 2rem;
}

.input-section,
.output-section {
    background: var(--surface);
    border-radius: 12px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    box-shadow: 0 4px 6px var(--shadow);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

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

.button-group {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--surface-light);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--secondary-color);
    transform: translateY(-1px);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.lang-icon,
.theme-icon {
    font-size: 1.2rem;
}

.tab-group {
    display: flex;
    gap: 0;
    background: var(--surface-light);
    border-radius: 6px;
    padding: 2px;
}

.tab-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border-radius: 4px;
    font-family: inherit;
    white-space: nowrap;
}

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

.tab-btn:not(.active):hover {
    color: var(--text-primary);
}

/* Drop Zone */
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 1rem;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
    color: var(--primary-color);
}

.drop-zone.hidden {
    display: none;
}

/* Input Textarea */
#jsonInput {
    flex: 1;
    background: var(--background);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    resize: none;
    line-height: 1.5;
    min-height: 400px;
}

#jsonInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.error-message {
    color: var(--error);
    font-size: 0.9rem;
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: rgba(239, 68, 68, 0.1);
    border-radius: 6px;
    border-left: 3px solid var(--error);
    display: none;
}

.error-message.show {
    display: block;
}

/* JSON Path Display */
.json-path-display {
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.path-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.json-path-code {
    flex: 1;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.85rem;
    color: var(--key-color);
}

.btn-copy-path {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1rem;
    transition: color 0.2s;
}

.btn-copy-path:hover {
    color: var(--primary-color);
}

/* Output Content */
.output-content {
    flex: 1;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    overflow: auto;
    display: none;
    min-height: 400px;
}

.output-content.active {
    display: block;
}

.empty-state {
    flex: 1;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    color: var(--text-secondary);
    gap: 1rem;
    min-height: 400px;
}

.empty-state.active {
    display: flex;
}

.empty-state svg {
    opacity: 0.5;
}

.empty-state p {
    font-size: 1.1rem;
}

/* Tree View Styles */
.tree-node {
    margin-left: 0;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
}

.tree-node-content {
    display: flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    user-select: none;
    border-radius: 4px;
    transition: background 0.2s;
}

.tree-node-content:hover {
    background: rgba(99, 102, 241, 0.1);
}

.tree-node-content.highlighted {
    background: var(--warning);
    animation: highlight-pulse 0.5s;
}

@keyframes highlight-pulse {
    0%, 100% { background: var(--warning); }
    50% { background: transparent; }
}

.tree-toggle {
    width: 20px;
    display: inline-block;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: bold;
}

.tree-key {
    color: var(--key-color);
    font-weight: 500;
    margin-right: 0.5rem;
}

.tree-value {
    margin-left: 0.5rem;
}

.tree-value.string {
    color: var(--string-color);
}

.tree-value.number {
    color: var(--number-color);
}

.tree-value.boolean {
    color: var(--boolean-color);
}

.tree-value.null {
    color: var(--null-color);
}

.tree-type {
    color: var(--text-secondary);
    font-style: italic;
    margin-left: 0.5rem;
    font-size: 0.85rem;
}

.tree-children {
    margin-left: 1.5rem;
    border-left: 1px solid var(--border);
    padding-left: 0.5rem;
}

.tree-children.collapsed {
    display: none;
}

/* Formatted View Styles */
.formatted-view pre {
    margin: 0;
    overflow: auto;
}

.formatted-view code {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text-primary);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: 12px;
    width: 100%;
    max-width: 1200px;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
}

.btn-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
}

.btn-close:hover {
    color: var(--text-primary);
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Compare */
.compare-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1.5rem;
}

.compare-section h3 {
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.compare-section textarea {
    width: 100%;
    min-height: 300px;
    background: var(--background);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
    resize: vertical;
}

.compare-result {
    padding: 1.5rem;
    max-height: 400px;
    overflow: auto;
}

.diff-item {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 6px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.9rem;
}

.diff-added {
    background: var(--diff-added);
    border-left: 3px solid var(--success);
}

.diff-removed {
    background: var(--diff-removed);
    border-left: 3px solid var(--error);
}

.diff-changed {
    background: var(--diff-changed);
    border-left: 3px solid var(--warning);
}

.diff-label {
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: var(--text-primary);
}

.diff-path {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

/* Footer */
footer {
    text-align: center;
    padding-top: 2rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
}

footer a:hover {
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content,
    .compare-container {
        grid-template-columns: 1fr;
    }

    h1 {
        font-size: 2rem;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

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

    .stats-panel {
        gap: 1rem;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }

    h1 {
        font-size: 1.5rem;
        flex-direction: column;
        gap: 0.5rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }

    .modal {
        padding: 1rem;
    }
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 5px;
}

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