:root {
    --primary: #0984E3;
    --primary-hover: #076dbb;
    --secondary: #74B9FF;
    --accent: #E17055;
    --background: #0D1B2A;
    --surface: #1B263B;
    --surface-light: #415A77;
    --text: #E0E1DD;
    --text-muted: #778DA9;
    --border: rgba(255, 255, 255, 0.1);
    --glass: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --radius: 12px;
    --transition: all 0.3s ease;

    /* JSON Colors */
    --json-key: #74B9FF;
    --json-string: #00B894;
    --json-number: #FDCB6E;
    --json-boolean: #6C5CE7;
    --json-null: #D63031;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--background);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

.app-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-height: 100vh;
}

/* Glassmorphism Styles */
.glass-header, .glass-panel {
    background: var(--glass);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
}

/* Header */
.glass-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    color: white;
}

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

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

.btn-secondary {
    background-color: var(--surface-light);
}

.btn-secondary:hover {
    background-color: var(--text-muted);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    background: var(--border);
    color: var(--text);
}

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

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--border);
    color: var(--text);
}

/* Main Content Layout */
.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 1.5rem;
    flex-grow: 1;
}

@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }
}

/* Input Section */
.input-section {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
    height: fit-content;
    max-height: calc(100vh - 200px);
    transition: var(--transition);
}

.input-section.collapsed .input-wrapper,
.input-section.collapsed .input-actions {
    display: none;
}

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

.panel-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--secondary);
}

.input-wrapper {
    flex-grow: 1;
    padding: 0;
}

#json-input {
    width: 100%;
    height: 400px;
    background: transparent;
    border: none;
    color: var(--text);
    padding: 1rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    resize: vertical;
    outline: none;
}

.input-actions {
    padding: 1rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
}

/* Viewer Section */
.viewer-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 500px;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
}

.search-container {
    position: relative;
    flex-grow: 1;
    max-width: 400px;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: var(--text-muted);
}

#search-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem 0.5rem 0.5rem 2.2rem;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
    transition: var(--transition);
}

#search-input:focus {
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.3);
}

.viewer-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.divider {
    width: 1px;
    height: 24px;
    background: var(--border);
    margin: 0 0.5rem;
}

/* Breadcrumb */
.breadcrumb {
    padding: 0.6rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.path-icon {
    width: 14px;
    height: 14px;
    color: var(--accent);
}

#current-path {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Viewer Container */
.viewer-container {
    flex-grow: 1;
    padding: 1.5rem;
    overflow: auto;
    position: relative;
    max-height: calc(100vh - 300px);
}

.tree-content {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    user-select: none;
}

.raw-content {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text);
    tab-size: 4;
}

.hidden {
    display: none;
}

/* Tree Nodes */
.tree-node {
    margin-left: 1.5rem;
    position: relative;
}

.tree-node::before {
    content: '';
    position: absolute;
    left: -1rem;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(255, 255, 255, 0.05);
}

.node-item {
    display: flex;
    align-items: flex-start;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    transition: background 0.2s ease;
    cursor: default;
    position: relative;
}

.node-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.node-item.selected {
    background: rgba(9, 132, 227, 0.15);
}

.toggle-icon {
    width: 16px;
    height: 16px;
    margin-right: 0.25rem;
    margin-top: 0.2rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: transform 0.2s ease;
}

.toggle-icon.collapsed {
    transform: rotate(-90deg);
}

.node-key {
    color: var(--json-key);
    font-weight: 500;
}

.node-colon {
    margin-right: 0.5rem;
    color: var(--text-muted);
}

.node-value {
    word-break: break-all;
}

.node-value.string { color: var(--json-string); }
.node-value.number { color: var(--json-number); }
.node-value.boolean { color: var(--json-boolean); }
.node-value.null { color: var(--json-null); }

.node-meta {
    margin-left: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

.copy-btn {
    opacity: 0;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    margin-left: 0.5rem;
    padding: 2px;
    transition: var(--transition);
}

.node-item:hover .copy-btn {
    opacity: 1;
}

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

.highlight {
    background: rgba(225, 112, 85, 0.3);
    border-radius: 2px;
    padding: 0 2px;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    padding: 4rem 0;
}

.empty-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 1.5rem;
    opacity: 0.3;
}

/* Footer */
.app-footer {
    padding: 1.5rem 0;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
}

/* Notifications */
#notification-container {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75rem;
    pointer-events: none;
}

.notification {
    background: var(--surface);
    color: var(--text);
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    border-left: 4px solid var(--primary);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    animation: slideIn 0.3s ease forwards;
    pointer-events: auto;
    min-width: 200px;
    max-width: 400px;
}

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

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

::-webkit-scrollbar-track {
    background: transparent;
}

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

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