:root {
    --bg-color: #f5f5f5;
    --container-bg: #ffffff;
    --text-color: #333333;
    --border-color: #e0e0e0;
    --button-bg: #4CAF50;
    --button-hover-bg: #45a049;
    --button-text: #ffffff;
    --json-key-color: #881391;
    --json-string-color: #1A1AA6;
    --json-number-color: #1A1AA6;
    --json-boolean-color: #1A1AA6;
    --json-null-color: #1A1AA6;
    --notification-success-bg: #4CAF50;
    --notification-error-bg: #f44336;
    --footer-text-color: #666666;
    --center-bg: #f9f9f9;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --input-bg: #ffffff;
}

.dark-theme {
    --bg-color: #1e1e1e;
    --container-bg: #2d2d2d;
    --text-color: #e0e0e0;
    --border-color: #444444;
    --button-bg: #2c7d2f;
    --button-hover-bg: #3a9a3e;
    --button-text: #ffffff;
    --json-key-color: #c792ea;
    --json-string-color: #89ddff;
    --json-number-color: #f78c6c;
    --json-boolean-color: #ff9d00;
    --json-null-color: #ff5370;
    --notification-success-bg: #2c7d2f;
    --notification-error-bg: #cf3333;
    --footer-text-color: #aaaaaa;
    --center-bg: #252525;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --input-bg: #1e1e1e;
}

body {
    font-family: 'Noto Sans KR', Arial, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: var(--bg-color);
    height: 100vh;
    box-sizing: border-box;
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

header h1 {
    margin: 0;
    font-size: 28px;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

#languageSelect {
    padding: 8px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background-color: var(--input-bg);
    color: var(--text-color);
}

.icon-button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: var(--text-color);
    padding: 5px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
}

.icon-button:hover {
    background-color: var(--border-color);
}

.container {
    display: flex;
    width: 100%;
    height: calc(100vh - 220px); /* Reduced height to account for padding, header, footer, and margins */
    margin: 0 auto 20px; /* Added bottom margin */
    background-color: var(--container-bg);
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow-color);
    overflow: hidden; /* Changed to hidden to prevent content from overflowing */
}

.input-container, .output-container {
    flex: 2;
    padding: 20px;
    margin-bottom: 0;
    height: 100%; /* Use full height of parent */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-color: var(--container-bg);
    position: relative;
    box-sizing: border-box; /* Include padding in height calculation */
}

.input-controls, .output-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.format-on-input {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 14px;
    cursor: pointer;
}

.format-on-input input[type="checkbox"] {
    cursor: pointer;
}

.small-button {
    background-color: transparent;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.2s ease;
}

.small-button:hover {
    background-color: var(--border-color);
}

.center-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    margin-bottom: 0;
    background-color: var(--center-bg);
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    position: relative;
    height: 100%; /* Use full height of parent */
    box-sizing: border-box; /* Include padding in height calculation */
}

.center-container::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background-color: var(--border-color);
    z-index: 0;
}

.center-container > * {
    position: relative;
    z-index: 1;
    background-color: var(--center-bg);
    padding: 10px;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(3px);
}

.modal-content {
    background-color: var(--container-bg);
    margin: 10% auto;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    box-shadow: 0 4px 8px var(--shadow-color);
    position: relative;
    animation: modalFadeIn 0.3s;
}

@keyframes modalFadeIn {
    from {opacity: 0; transform: translateY(-20px);}
    to {opacity: 1; transform: translateY(0);}
}

.close {
    color: var(--text-color);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    top: 10px;
    right: 20px;
}

.close:hover {
    color: var(--button-bg);
}

textarea {
    width: 100%;
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px;
    font-family: 'D2Coding', 'Consolas', monospace;
    resize: none;
    overflow: auto;
    box-sizing: border-box;
    background-color: var(--input-bg);
    color: var(--text-color);
}

h2 {
    margin-top: 0;
    color: var(--text-color);
}

#jsonOutput {
    flex: 1;
    overflow: auto;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 10px 10px 10px 30px; /* Added left padding for gutter */
    font-family: 'D2Coding', 'Consolas', monospace;
    box-sizing: border-box;
    position: relative; /* For absolute positioning of collapsible arrows */
    background-color: var(--input-bg);
    color: var(--text-color);
}

.button-container {
    text-align: center;
    margin: 20px 0;
    width: 100%;
}

button {
    background-color: var(--button-bg);
    color: var(--button-text);
    border: none;
    padding: 12px 24px;
    text-align: center;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 16px;
    margin: 15px auto;
    cursor: pointer;
    border-radius: 4px;
    width: 80%;
    box-shadow: 0 2px 5px var(--shadow-color);
    transition: all 0.3s ease;
}

button:hover {
    background-color: var(--button-hover-bg);
    box-shadow: 0 4px 8px var(--shadow-color);
    transform: translateY(-2px);
}

.center-container h3 {
    text-align: center;
    color: var(--text-color);
    margin-bottom: 20px;
    font-size: 20px;
}

.json-key {
    color: var(--json-key-color);
}

.json-string {
    color: var(--json-string-color);
}

.json-number {
    color: var(--json-number-color);
}

.json-boolean {
    color: var(--json-boolean-color);
}

.json-null {
    color: var(--json-null-color);
}

.error {
    color: var(--notification-error-bg);
    font-weight: bold;
}

.json-line {
    display: flex;
    align-items: flex-start;
    position: relative; /* For absolute positioning of collapsible arrows */
    padding-left: 20px; /* Space for the arrow */
}

.collapsible {
    cursor: pointer;
    width: 20px;
    text-align: center;
    display: inline-block;
    margin-right: 5px;
    flex-shrink: 0;
    position: absolute;
    left: 5px; /* Position in the gutter */
}

.content {
    padding-left: 20px; /* Adjusted for the new arrow positioning */
    display: none;
}

.json-content {
    flex: 1;
}

.hidden {
    display: none;
}

.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 4px;
    color: white;
    font-weight: bold;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1000;
    max-width: 300px;
    box-shadow: 0 2px 10px var(--shadow-color);
}

.notification.success {
    background-color: var(--notification-success-bg);
}

.notification.error {
    background-color: var(--notification-error-bg);
}

.notification.show {
    opacity: 1;
}

.footer {
    text-align: center;
    padding: 10px 0;
    color: var(--footer-text-color);
    font-size: 14px;
    margin-top: 10px;
    border-top: 1px solid var(--border-color);
}

.footer-links {
    margin-top: 10px;
    display: flex;
    justify-content: center;
    gap: 20px;
}

.footer-links a {
    color: var(--button-bg);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 5px;
}

.footer-links a:hover {
    text-decoration: underline;
}

/* Media queries for responsive layout */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 170px); /* Adjusted for header, footer, and margins */
        margin: 0 auto 20px; /* Consistent margins */
        width: calc(100% - 40px); /* Account for body padding */
        max-width: 100%;
        box-sizing: border-box;
    }

    .input-container, .output-container {
        flex: 1;
        width: 100%;
        min-height: 25vh; /* Reduced height to fit better */
        margin-bottom: 10px; /* Smaller margin for mobile */
        padding: 15px; /* Reduced padding for mobile */
        height: auto; /* Let height be determined by content */
    }

    .center-container {
        flex: none;
        width: 100%;
        min-height: 25vh; /* Match min-height with input and output containers */
        margin-bottom: 10px; /* Smaller margin for mobile */
        border-left: none;
        border-right: none;
        border-top: 1px solid var(--border-color);
        border-bottom: 1px solid var(--border-color);
        padding: 15px; /* Consistent padding */
        height: auto; /* Let height be determined by content */
    }

    .center-container::before {
        display: none;
    }

    textarea, #jsonOutput {
        min-height: 200px;
    }
}

/* Adjust for very large screens */
@media (min-width: 1600px) {
    .container {
        max-width: 90vw;
        margin: 0 auto 20px; /* Maintain bottom margin */
    }
}

/* Adjust for very tall screens */
@media (min-height: 1200px) {
    .container {
        max-height: 90vh;
        margin: 0 auto 20px; /* Maintain bottom margin */
    }
}
