html {
    overflow-y: scroll; /* Always show vertical scrollbar to prevent layout shifts */
}

body {
    font-family: "Arial", sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f7f6;
    color: #333;
    min-height: 100vh;
}

.container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.sidebar {
    width: 250px;
    background-color: #4caf50;
    color: #ecf0f1;
    box-shadow: 2px 0 6px rgba(0, 0, 0, 0.1);
    flex-shrink: 0; /* Prevent sidebar from shrinking */
    height: 100%; /* Make sidebar span full height of its parent */
}

.sidebar nav ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.sidebar nav li {
    margin-bottom: 5px;
}

.sidebar nav a {
    padding: 15px 20px;
    display: block;
    color: #ecf0f1;
    text-decoration: none;
    font-size: 1.1em;
    transition:
        background-color 0.3s ease,
        color 0.3s ease;
}

.sidebar nav a:hover {
    background-color: #4caf90;
    color: #ffffff;
}

.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* This ensures the toggle icon is pushed to the right */
}

.collapsible-header .toggle-icon {
    margin-left: 10px;
    transition: transform 0.3s ease;
    display: inline-block; /* Ensure transform applies correctly */
}

/* Rotate the icon when the menu is collapsed (aria-expanded is false) */
.collapsible-header[aria-expanded="false"] .toggle-icon {
    transform: rotate(-90deg); /* Points right */
}

/* Reset rotation when expanded (aria-expanded is true, default) */
.collapsible-header[aria-expanded="true"] .toggle-icon {
    transform: rotate(0deg); /* Points down */
}

.sidebar nav ul ul.collapsible-submenu {
    max-height: 0;
    overflow: hidden;
    transition:
        max-height 0.3s ease-out,
        opacity 0.3s ease-out;
    opacity: 0;
    visibility: hidden; /* Hide without removing from flow */
}

.sidebar nav ul ul.collapsible-submenu.expanded {
    max-height: 500px; /* Adjust based on expected max content height */
    opacity: 1;
    visibility: visible;
}

.sidebar nav ul ul {
    margin-top: 5px; /* Add a small gap above the sub-menu */
}

.sidebar nav ul ul li a {
    font-size: 1em; /* Slightly smaller font for sub-items */
    padding: 10px 40px; /* Adjust padding for sub-items */
}

main#main-content {
    flex-grow: 1; /* Allows main content to take up remaining space */
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column; /* Allows content inside main to stack vertically */
    align-items: center; /* Center content horizontally within main */
}

#root {
    width: 100%; /* Take full width of its parent (main-content) */
    max-width: 1000px; /* Max width for the content for readability */
}

#root h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 30px;
    font-size: 2.5em;
}

#app {
    /* Renamed from #app to .json-tools-container for better semantics if needed, but keeping #app for now */
    background-color: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    margin: 20px 0; /* Adjusted margin for the new layout */
    padding: 40px; /* Increased padding for more internal space */
    width: 100%; /* Take full width of #root which has a max-width */
    box-sizing: border-box; /* Ensure padding/border are included in element's total width */
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 30px;
    font-size: 2.5em;
}

.input-section h2,
.output-section h2 {
    background-color: #ffffff;
    padding: 0 0 20px 0; /* Remove default padding */
    margin: 0; /* Remove default margin */
    /* Ensure no extra space pushes the background away */
}

.editor-container {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    /* Removed flex-wrap to keep side-by-side layout, accepting potential horizontal overflow */
    /* This ensures boxes are always vertically aligned as requested */
}

.input-section,
.output-section {
    flex: 1;
    min-width: 300px; /* Ensure a minimum width before content is compressed */
}

textarea {
    width: 100%;
    height: 400px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-family: "Consolas", "Monaco", monospace;
    font-size: 1em;
    /* Removed resize: vertical; from generic textarea */
    box-sizing: border-box;
    background-color: #ffffff;
    color: #333;
    transition: border-color 0.3s ease;
}

textarea:focus {
    border-color: #4caf50;
    outline: none;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap; /* Keep this to wrap buttons on small screens */
}

button {
    background-color: #4caf50;
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1em;
    transition:
        background-color 0.3s ease,
        transform 0.2s ease;
}

button:hover {
    background-color: #45a049;
    transform: translateY(-2px);
}

button:active {
    transform: translateY(0);
}

.validation-message {
    text-align: center;
    padding: 15px;
    margin-top: 20px;
    border-radius: 6px;
    font-size: 1.1em;
    font-weight: bold;
    box-sizing: border-box;
    max-width: 100%;
    min-height: 2.5em; /* Reserve vertical space even when hidden */
    visibility: hidden; /* Hide without removing from flow */
    opacity: 0; /* For smooth transition on visibility */
    transition:
        opacity 0.3s ease,
        visibility 0.3s ease;
}

.validation-message.visible {
    visibility: visible;
    opacity: 1;
}

.validation-message.success {
    background-color: #e6ffe6;
    color: #28a745;
    border: 1px solid #28a745;
}

.validation-message.error {
    background-color: #ffe6e6;
    color: #dc3545;
    border: 1px solid #dc3545;
}

.error-details {
    margin-top: 10px;
    font-size: 0.9em;
    color: #666;
    white-space: pre-wrap;
    overflow-wrap: break-word; /* Ensures long words break to prevent horizontal overflow */
    font-family: "Consolas", "Monaco", monospace;
    max-height: 150px;
    overflow-y: auto;
    background-color: #f8f8f8;
    padding: 10px;
    border-radius: 4px;
    border: 1px solid #eee;
    box-sizing: border-box;
    max-width: 100%;
    min-height: 1em; /* Reserve space for error details */
    visibility: hidden; /* Hide without removing from flow */
    opacity: 0; /* For smooth transition on visibility */
    transition:
        opacity 0.3s ease,
        visibility 0.3s ease;
}

.error-details.visible {
    visibility: visible;
    opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    /* .editor-container no longer has flex-direction: column; as per request */

    .input-section,
    .output-section {
        min-width: unset; /* Allow them to shrink further on smaller screens */
    }

    textarea {
        height: 300px;
    }

    #app {
        margin: 15px;
        padding: 25px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.8em;
    }

    button {
        padding: 10px 20px;
        font-size: 1em;
    }

    .controls {
        gap: 10px;
    }
}

.resizable-textarea {
    resize: vertical;
}
