:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;

    --bg-color: #f9fafb;
    --surface-color: #ffffff;
    --border-color: #e5e7eb;
    --text-color: #111827;
    --text-muted: #6b7280;

    --header-bg: #1e293b;
    --header-text: #f1f5f9;

    --editor-bg: #ffffff;
    --line-number-bg: #f3f4f6;
    --line-number-text: #9ca3af;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] {
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --border-color: #334155;
    --text-color: #f1f5f9;
    --text-muted: #94a3b8;

    --header-bg: #0f172a;
    --header-text: #f1f5f9;

    --editor-bg: #1e293b;
    --line-number-bg: #0f172a;
    --line-number-text: #64748b;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

/* Header */
header {
    background: var(--header-bg);
    color: var(--header-text);
    padding: 1rem 2rem;
    box-shadow: var(--shadow-md);
}

.header-content {
    max-width: 1800px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.subtitle {
    font-size: 0.875rem;
    opacity: 0.8;
}

nav {
    display: flex;
    gap: 0.5rem;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--header-text);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1.25rem;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Language Switcher */
.language-switcher {
    position: relative;
    display: inline-block;
}

.lang-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem 0.75rem;
}

.lang-text {
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.lang-dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 1000;
}

.lang-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.2s;
    border-bottom: 1px solid var(--border-color);
}

.lang-option:last-child {
    border-bottom: none;
}

.lang-option:hover {
    background: var(--bg-color);
}

.lang-option.active {
    background: var(--primary-color);
    color: white;
}

.lang-option.active:hover {
    background: var(--primary-hover);
}

.lang-option .flag {
    font-size: 1.25rem;
}

.lang-option span:last-child {
    font-size: 0.9rem;
    font-weight: 500;
}

/* Main Container */
main.container {
    flex: 1;
    max-width: 1800px;
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* Editor Panels */
.editor-panel {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    height: 70vh;
    min-height: 500px;
    min-width: 0;
    overflow: hidden;
}

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

.panel-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.panel-actions {
    display: flex;
    gap: 0.5rem;
}

.icon-btn {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s;
    padding: 0.25rem;
}

.icon-btn:hover {
    opacity: 1;
}

/* Editor Wrapper */
.editor-wrapper {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
    min-width: 0;
}

.code-editor {
    flex: 1;
    min-width: 0;
    padding: 1rem;
    padding-left: 5.5rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.6;
    background: var(--editor-bg);
    color: var(--text-color);
    border: none;
    resize: none;
    outline: none;
    overflow-x: auto;
    overflow-y: auto;
    white-space: pre;
    tab-size: 2;
    box-sizing: border-box;
}

.code-editor.output {
    overflow: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.line-numbers {
    position: absolute;
    left: 0;
    top: 0;
    width: auto;
    min-width: 2.5rem;
    max-width: 4.5rem;
    height: 100%;
    background: var(--line-number-bg);
    color: var(--line-number-text);
    padding: 1rem 0.75rem;
    text-align: right;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.6;
    white-space: pre;
    user-select: none;
    border-right: 1px solid var(--border-color);
    overflow: hidden;
    box-sizing: border-box;
}

/* Error Message */
.error-message {
    padding: 0.75rem 1.25rem;
    background: #fef2f2;
    border-top: 1px solid var(--border-color);
    color: var(--error-color);
    font-size: 0.875rem;
    display: none;
}

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

[data-theme="dark"] .error-message {
    background: #7f1d1d;
    color: #fca5a5;
}

/* Control Panel */
.control-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1rem 0;
    width: 240px;
    min-width: 240px;
    max-width: 240px;
}

.controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    background: var(--surface-color);
    padding: 1.5rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
}

.control-btn {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--surface-color);
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.control-btn:hover {
    background: var(--bg-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

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

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

.divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.25rem 0;
}

.indent-selector {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.indent-selector select {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--editor-bg);
    color: var(--text-color);
    cursor: pointer;
}

/* Status Info */
.status-info {
    padding: 1rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.875rem;
    color: var(--text-muted);
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 400px;
    overflow-y: auto;
}

.status-info.success {
    background: #f0fdf4;
    border-color: var(--success-color);
    color: var(--success-color);
}

.status-info.error {
    background: #fef2f2;
    border-color: var(--error-color);
    color: var(--error-color);
}

[data-theme="dark"] .status-info.success {
    background: #14532d;
    color: #86efac;
}

[data-theme="dark"] .status-info.error {
    background: #7f1d1d;
    color: #fca5a5;
}

/* Footer */
footer {
    background: var(--surface-color);
    border-top: 1px solid var(--border-color);
    padding: 3rem 2rem;
    color: var(--text-muted);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-about,
.footer-features,
.footer-keywords {
    margin-bottom: 2rem;
    text-align: left;
}

.footer-about h2,
.footer-features h3 {
    color: var(--text-color);
    font-size: 1.125rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
}

.footer-about p,
.footer-features ul {
    line-height: 1.8;
    font-size: 0.9rem;
}

.footer-features ul {
    list-style: none;
    padding: 0;
}

.footer-features li {
    margin-bottom: 0.5rem;
    padding-left: 1.5rem;
    position: relative;
}

.footer-features li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success-color);
    font-weight: bold;
}

.footer-keywords {
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 6px;
    text-align: center;
}

.footer-keywords p {
    margin: 0;
    line-height: 1.6;
    color: var(--text-muted);
}

.footer-copyright {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.footer-copyright p {
    margin: 0.25rem 0;
    font-size: 0.875rem;
}

.footer-copyright a {
    color: var(--text-muted);
    text-decoration: none;
    transition: color 0.2s;
}

.footer-copyright a:hover {
    color: var(--primary-color);
}

.footer-note {
    font-size: 0.8rem;
    opacity: 0.7;
}

.copyright-notice {
    margin-top: 1rem;
    padding: 0.75rem;
    background: var(--bg-color);
    border-left: 3px solid var(--warning-color);
    font-size: 0.85rem;
    color: var(--text-color);
}

/* Syntax Highlighting for JSON */
.json-key {
    color: #0066cc;
}

.json-string {
    color: #22863a;
}

.json-number {
    color: #e3116c;
}

.json-boolean {
    color: #b31d28;
}

.json-null {
    color: #6f42c1;
}

[data-theme="dark"] .json-key {
    color: #79c0ff;
}

[data-theme="dark"] .json-string {
    color: #a5d6ff;
}

[data-theme="dark"] .json-number {
    color: #ff7b72;
}

[data-theme="dark"] .json-boolean {
    color: #ffa657;
}

[data-theme="dark"] .json-null {
    color: #d2a8ff;
}

/* Responsive Design */
@media (max-width: 1400px) {
    main.container {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }

    .control-panel {
        order: 2;
        width: 100%;
        max-width: 100%;
        min-width: auto;
        padding: 1rem 0;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .controls {
        width: 100%;
        max-width: 800px;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.5rem;
    }

    .control-btn {
        flex: 1 1 calc(33.333% - 0.5rem);
        min-width: 140px;
    }

    .divider {
        width: 100%;
    }

    .indent-selector {
        width: 100%;
    }

    .status-info {
        width: 100%;
        max-width: 800px;
    }

    .right-panel {
        order: 3;
    }
}

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

    header {
        padding: 1rem;
    }

    .logo h1 {
        font-size: 1.25rem;
    }

    .subtitle {
        font-size: 0.75rem;
    }

    nav {
        gap: 0.25rem;
    }

    .nav-btn {
        padding: 0.4rem 0.6rem;
        font-size: 1rem;
    }

    .lang-btn {
        padding: 0.4rem 0.5rem;
    }

    .lang-text {
        font-size: 0.75rem;
    }

    .editor-panel {
        height: 50vh;
        min-height: 300px;
    }

    .control-btn {
        flex: 1 1 calc(50% - 0.5rem);
        min-width: 120px;
    }
}

@media (max-width: 480px) {
    .control-btn {
        flex: 1 1 100%;
        min-width: auto;
    }

    .controls {
        max-width: 100%;
    }

    .status-info {
        max-width: 100%;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.status-info {
    animation: fadeIn 0.3s ease;
}
