/* --- 1. Global Reset & Base Styles --- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #f5f7fa;
    color: #333;
    line-height: 1.6;
    padding: 20px;
}
.container {
    max-width: 1200px;
    margin: 0 auto;
}

/* --- 2. Header Style --- */
header {
    text-align: center;
    margin-bottom: 30px;
    padding: 10px 0;
}
header h1 {
    font-size: 2rem;
    color: #2c3e50;
}

/* --- 3. Desktop Workspace Layout (Flexbox) --- */
.workspace {
    display: flex;
    gap: 20px;
}

/* Split screen into equal columns */
.panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

/* --- 4. Controls Section --- */
.panel-ctrl {
    margin-bottom: 15px;
    min-height: 40px; /* Aligns both textareas perfectly on desktop */
    display: flex;
    align-items: center;
}
.panel-ctrl-merge-short {
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.panel-ctrl-output-format {
    align-items: stretch;
    gap: 16px;
}
.output-format-left {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 170px;
}
.output-format-right {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
}
.output-format-row {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.placeholder-text {
    color: #7f8c8d;
    font-style: italic;
}
.option-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: #2c3e50;
    font-size: 14px;
    user-select: none;
}
.option-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
}
.option-toggle input[type="radio"] {
    width: 16px;
    height: 16px;
}
.option-input {
    display: inline-flex;
    flex-direction: column;
    gap: 4px;
    color: #2c3e50;
    font-size: 13px;
}
.option-input input[type="number"] {
    width: 140px;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 13px;
}
.option-input input[type="number"]:disabled {
    background-color: #f4f6f8;
    color: #98a3ad;
}
.btn-convert {
    background-color: #3498db;
    color: white;
    border: none;
    padding: 8px 16px;
    font-size: 14px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-convert:hover {
    background-color: #2980b9;
}

/* --- 4.5. Options Box --- */
.options-box {
    margin-bottom: 15px;
    border: 1px solid #ddd;
    border-radius: 4px;
    background-color: #fafbfc;
}
.options-box > summary {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    user-select: none;
    font-weight: 500;
    color: #2c3e50;
}
.options-box > summary::before {
    content: "";
    width: 6px;
    height: 6px;
    display: inline-block;
    border-right: 2px solid #666;
    border-bottom: 2px solid #666;
    transform: rotate(-45deg);
    transition: transform 0.2s;
}
.options-box[open] > summary::before {
    transform: rotate(45deg);
}
.options-box[open] > summary {
    border-bottom: 1px solid #ddd;
    margin-bottom: 12px;
    background-color: #fff;
}
.options-box > .panel-ctrl {
    padding: 0 16px;
}
.options-box > .panel-ctrl:last-of-type {
    padding-bottom: 12px;
}
.options-box > .panel-ctrl:first-of-type {
    gap: 12px;
    flex-wrap: wrap;
}

/* --- 5. Textareas Configuration --- */
textarea {
    width: 100%;
    height: 400px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace; /* Monospace font helps preview string structures clearly */
    font-size: 14px;
    resize: vertical;
    outline: none;
}
textarea:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.2);
}
textarea[readonly] {
    background-color: #fcfcfc;
    color: #555;
}

#userOutput {
    overflow: auto;
    white-space: pre;
}

/* --- 6. Mobile Responsive Adjustments --- */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    header {
        margin-bottom: 15px;
    }
    header h1 {
        font-size: 1.5rem;
    }
    .workspace {
        flex-direction: column; /* Shifts layouts from row to column stacked order */
        gap: 15px;
    }
    textarea {
        height: 200px;
    }
    .panel-ctrl {
        min-height: auto;
        margin-bottom: 10px;
    }
    .panel-ctrl-output-format {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .output-format-left,
    .output-format-right {
        width: 100%;
    }
}
