/* JSON Editor Styles */
.json-editor-container {
    background-color: var(--white);
    padding: 1rem;
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    max-width: 50rem;
    height: 30rem;
    margin: 1rem 1rem; /* Adjust margin as needed for spacing */
}

.json-editor-container h2 {
    text-align: center;
    font-size: 1.1rem;
}

.json-editor-container p {
    text-align: center;
    margin-bottom: 25px;
    color: var(--secondary-color);
}

.json-editor-controls {
    margin-bottom: 10px;
    text-align: center;
}

.json-editor-ui {
    border: 1px solid var(--medium-gray);
    border-radius: var(--border-radius);
    padding: 15px;
    height: 25rem;
    margin-bottom: 1rem;
    background-color: var(--light-gray);
    overflow-x: auto; /* Allows horizontal scrolling for very long lines */
}

.editor-placeholder {
    color: #999;
    text-align: center;
    margin-top: 50px;
}

.json-property {
    display: flex;
    flex-wrap: wrap; /* Allows elements to wrap to the next line */
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--medium-gray);
}

.json-property:last-of-type {
    border-bottom: none; /* No border for the last property in a group */
}

.json-property input[type="text"],
.json-property select { /* Keep styles for key input and type select */
    padding: 8px 10px;
    border: 1px solid var(--medium-gray);
    border-radius: var(--border-radius);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    color: var(--dark-gray);
    flex-grow: 1; /* Allows inputs to grow */
    min-width: 60px; /* Minimum width to prevent squishing too much */
}

.json-property input[type="text"].prop-key-input {
    flex-basis: 120px; /* Base width for key input */
    max-width: 200px; /* Max width for key input */
    flex-grow: 0.8;
}

.json-property .prop-type-select {
    flex-basis: 90px; /* Base width for type select */
    flex-grow: 0.6;
}

/* Remove styles for .prop-value-input, .prop-value-boolean as they are gone */
/* .json-property .prop-value-input,
.json-property .prop-value-boolean {
    flex-grow: 1.5;
} */

/* NEW: Styles for the value display span */
.json-property .prop-value-display {
    padding: 8px 10px;
    border: 1px dashed var(--medium-gray); /* Dashed border to indicate not directly editable */
    border-radius: var(--border-radius);
    background-color: #f0f0f0; /* Slightly different background */
    color: #777; /* Lighter text color */
    font-size: 0.95rem;
    flex-grow: 1.5; /* Allow it to grow, similar to where the input was */
    white-space: nowrap; /* Prevent breaking line too early */
    overflow: hidden;
    text-overflow: ellipsis; /* Add ellipsis for overflow */
}


.json-property .remove-prop-btn,
.json-property .add-nested-prop-btn {
    padding: 8px 12px;
    border-radius: var(--border-radius);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap; /* Prevent button text wrap */
    border: none; /* Remove default button border */
}

.json-property .remove-prop-btn {
    background-color: #e74c3c; /* Red for remove */
    color: var(--white);
}
.json-property .remove-prop-btn:hover {
    background-color: #c0392b;
    transform: translateY(-1px);
}

.json-property .add-nested-prop-btn {
    background-color: var(--primary-color);
    color: var(--white);
}
.json-property .add-nested-prop-btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
}

.nested-properties {
    margin-left: 20px; /* Indent nested properties */
    padding-left: 10px;
    border-left: 1px dashed var(--medium-gray);
    flex-basis: 100%; /* Take full width below key/value/type elements */
    margin-top: 10px;
    padding-top: 5px; /* Little extra top padding */
}

.json-array-item {
    background-color: #f7f7f7; /* Slightly different background for array items */
    padding: 10px; /* More padding for array items */
    border-radius: var(--border-radius);
    margin-top: 5px;
    margin-bottom: 5px;
    border: 1px solid var(--medium-gray); /* Border for array items */
    /* Array items don't have key input, so style alignment */
    justify-content: flex-start;
}
/* Adjust flex-grow for value display in array items */
.json-array-item .prop-type-select,
.json-array-item .prop-value-display { /* Use prop-value-display here */
    flex-grow: 1; /* Allow type/value to take full width */
}

.json-array-item .remove-prop-btn,
.json-array-item .add-nested-prop-btn {
    margin-left: auto; /* Push buttons to the right */
}


.json-output-area {
    margin-top: 30px;
}

.json-output-area textarea {
    width: 100%;
    height: 200px;
    padding: 15px;
    border: 1px solid var(--medium-gray);
    border-radius: var(--border-radius);
    font-family: 'Fira Code', 'monospace', monospace; /* Monospaced font for JSON */
    font-size: 0.9rem;
    color: var(--dark-gray);
    background-color: #fcfcfc;
    resize: vertical;
    outline: none;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.05); /* Subtle inner shadow */
}

.json-output-area h3 {
    margin-bottom: 10px;
    text-align: left;
    font-size: 1.2rem;
    color: var(--dark-gray);
}

/* Responsive adjustments for editor */
@media (max-width: 768px) {
    .json-editor-container {
        padding: 20px;
        margin: 30px auto;
    }
    .json-property {
        flex-direction: column; /* Stack elements vertically */
        align-items: stretch; /* Stretch to fill container */
    }
    .json-property input[type="text"].prop-key-input,
    .json-property .prop-type-select,
    .json-property .prop-value-display, /* Apply to the new span */
    .json-property .remove-prop-btn,
    .json-property .add-nested-prop-btn {
        width: 100%; /* Full width when stacked */
        max-width: none;
        flex-basis: auto;
    }
    .json-property .add-nested-prop-btn {
        margin-top: 5px; /* Add space between buttons */
    }
    .json-array-item .remove-prop-btn,
    .json-array-item .add-nested-prop-btn {
        margin-left: 0; /* Reset margin from 'auto' */
    }
}

@media (max-width: 480px) {
    .json-editor-container {
        padding: 15px;
    }
    .json-editor-container h2 {
        font-size: 1.8rem;
    }
    .json-editor-ui {
        min-height: 100px;
        padding: 10px;
    }
    .json-property input,
    .json-property select,
    .json-property button,
    .json-property .prop-value-display { /* Also apply to display span */
        padding: 6px 8px;
        font-size: 0.9rem;
    }
    .json-output-area textarea {
        height: 150px;
    }
}

/* Structured Output Popup */
.popup-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.35);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: popup-fade-in 0.25s;
    overflow-y: auto;
}
/* Popup Content */
.popup-content {
    background: #fff;
    border-radius: 10px;
    padding: 2rem 1.5rem 1.5rem 1.5rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    min-width: 300px;
    width: 50rem;
    max-width: 90vw;
    animation: popup-scale-in 0.25s;
    position: relative;
    text-align: center;
}
.popup-close {
    position: absolute;
    top: 0.7rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.7rem;
    color: #888;
    cursor: pointer;
    transition: color 0.2s;
}
.popup-close:hover {
    color: var(--primary-color, #0078ff);
}
@keyframes popup-fade-in {
    0% { opacity: 0; }
    100% { opacity: 1; }
}
@keyframes popup-scale-in {
    0% { transform: scale(0.85); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}