body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: #f4f7f9;
    color: #333;
}

header {
    text-align: center;
    margin-bottom: 40px;
}

header h1 {
    font-size: 2.5em;
    color: #2c3e50;
}

header p {
    font-size: 1.1em;
    color: #555;
}

main {
    max-width: 1200px;
    margin: 0 auto;
}

.controls {
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    margin-bottom: 30px;
}

.file-input-container {
    text-align: center;
}

.file-input-container h2 {
    margin-top: 0;
    color: #34495e;
}

input[type="file"] {
    margin-bottom: 10px;
}

button {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s;
}

button:hover {
    background-color: #2980b9;
}

#compare-btn {
    align-self: center;
}

.results-container {
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.results-toolbar {
    display: flex;
    gap: 10px; /* Adds space between buttons */
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 10px;
}

.results-toolbar button {
    margin-right: 10px;
    background-color: #95a5a6;
}

.results-toolbar button:hover {
    background-color: #7f8c8d;
}

#results {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    overflow: hidden; /* Prevent container overflow */
}

.json-tree {
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.9em;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: #fafafa;
    white-space: pre-wrap;
    overflow-x: auto; /* Allow horizontal scrolling if needed */
    overflow-y: auto; /* Allow vertical scrolling if needed */
    max-height: 80vh; /* Limit height to viewport */
    width: 100%; /* Ensure full width usage */
    box-sizing: border-box; /* Include padding in width calculation */
}

.diff-node {
    background-color: #fffbe6; /* Light yellow */
    border-radius: 3px;
    padding: 2px 4px;
}

.same-node {
    color: #555; /* No need for a strong highlight */
}

.added-node {
    background-color: #e8f5e9; /* Light green */
    border-radius: 3px;
    padding: 2px 4px;
    color: #2e7d32;
}

.deleted-node {
    background-color: #ffebee; /* Light red */
    border-radius: 3px;
    padding: 2px 4px;
    color: #c62828;
}

/* Simplified tree structure */
.tree-line {
    display: flex;
    align-items: flex-start;
    margin: 2px 0;
    line-height: 1.4;
    font-family: 'Courier New', Courier, monospace;
    max-width: 100%;
}

.tree-key {
    font-weight: bold;
    margin-right: 8px;
    min-width: 0;
    word-break: break-word;
    flex-shrink: 0;
}

.tree-value {
    flex-grow: 1;
    min-width: 0;
    word-break: break-all; /* More aggressive breaking for long strings */
    overflow-wrap: anywhere; /* Better wrapping support */
    white-space: pre-wrap; /* Preserve formatting but allow wrapping */
    max-width: calc(100% - 200px); /* Ensure it doesn't exceed container */
    hyphens: auto; /* Add hyphenation for better breaks */
}
