/* 1) Global reset & layout for sticky footer */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    background-color: #fff;
    color: #000;
}

.container {
    flex: 1;
    display: flex;
    width: 100%;
}

/* Utility classes */
.mb-20 {
    margin-bottom: 20px;
}

/* 2) Split layout: left-pane & right-pane */
.left-pane {
    flex: 2;
    padding: 20px;
    border-right: 1px solid #ccc;
    display: flex;
    flex-direction: column;
}

.right-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

/* Left pane styles */
.left-pane .richTextInput {
    flex: 1;
    width: 100%;
    padding: 10px;
    font-size: 14px;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    resize: none;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #f9f9f9;
    color: #212529;
    transition: font-size 0.2s ease;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
    min-height: 200px;
}

.left-pane .richTextInput:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.2);
}

.left-pane .richTextInput[data-placeholder]:empty::before {
    content: attr(data-placeholder);
    color: #777;
    pointer-events: none;
}

.left-pane .richTextInput img {
    max-width: 100%;
    height: auto;
    display: inline-block;
}

.inputStats {
    margin-top: 10px;
    font-size: 12px;
    color: #555;
}

.error {
    color: red;
    font-size: 12px;
    margin-top: 5px;
}

/* Right pane & controls */
.upper-right-pane {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    align-items: center;
}

/* Now let the lower-right-pane flex to fill remaining space */
.lower-right-pane {
    flex: 1;
    overflow-y: auto;
    padding-top: 10px;
    position: relative;
}

.button-group,
.custom-control {
    width: 90%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Reserve 2px border to avoid shifting when active */
button {
    background-color: #007bff;
    color: #fff;
    padding: 10px;
    font-size: 14px;
    border: 2px solid transparent;
    border-radius: 4px;
    height: 40px;
    cursor: pointer;
    transition: background-color 0.3s, border-color 0.3s;
}

button:hover {
    background-color: #0056b3;
}

.button-group button {
    width: 100%;
}

.custom-control {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.custom-control button {
    margin-right: 10px;
    flex: 1;
}

.custom-control input {
    width: 80px;
    height: 40px;
    font-size: 14px;
    padding: 6px;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: center;
}

.toggle-sentence-break {
    width: 90%;
    max-width: 600px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 5px;
    justify-content: space-between;
}

.toggle-sentence-break .toggle-options {
    display: flex;
    gap: 12px;
    align-items: center;
}

.toggle-sentence-break label {
    font-size: 14px;
    user-select: none;
}

/* Output pane */
.threadWrapper {
    position: relative;
    margin-bottom: 20px;
}

.threadWrapper::before {
    content: "";
    position: absolute;
    top: 0;
    left: 20px;
    width: 2px;
    height: 100%;
    background-color: #ccc;
}

.chunkContainer {
    position: relative;
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
    padding-left: 40px;
}

.chunkContainer::before {
    content: "";
    position: absolute;
    top: 0;
    left: 11px;
    width: 18px;
    height: 18px;
    background-color: #fff;
    border: 2px solid #007bff;
    border-radius: 50%;
    z-index: 1;
}

.chunkContainer .chunkContent {
    width: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: #f9f9f9;
    color: #212529;
    white-space: pre-wrap;
    word-wrap: break-word;
    min-height: 40px;
}

.left-pane .richTextInput *,
.chunkContainer .chunkContent * {
    font-family: inherit !important;
}

.chunkContainer .chunkContent img {
    display: block;
    max-width: 100%;
    height: auto;
    margin-top: 10px;
}

.chunkInfo {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 5px;
}

.chunkInfo.imageOnly {
    justify-content: flex-end;
}

.stats {
    font-size: 12px;
    color: #555;
}

.copyButton {
    background-color: #28a745;
}

.copyButton:hover {
    background-color: #218838;
}

.copyButton.success {
    background-color: #28a745;
    cursor: default;
}

.copyButton.error {
    background-color: #dc3545;
}

.chunkContainer.copied::before {
    content: attr(data-copied-order);
    background-color: #28a745;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
}

.chunkContainer.copyError::before {
    content: "!";
    background-color: #dc3545;
    border-color: #dc3545;
    color: #fff;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
}

/* Responsive layout */
@media (max-width: 800px) {
    .container {
        flex-direction: column;
    }

    .left-pane {
        border-right: none;
        border-bottom: 1px solid #ccc;
        padding-bottom: 20px;
        order: 0;
    }

    .right-pane {
        width: 100%;
        height: auto;
    }

    .upper-right-pane {
        order: 1;
        width: 100%;
    }

    .lower-right-pane {
        order: 2;
        width: 100%;
        overflow-y: auto;
    }

    .threadWrapper::before {
        left: 15px;
    }

    .chunkContainer {
        padding-left: 35px;
    }

    .chunkContainer::before {
        left: 6px;
    }
}

/* Footer styling */
footer {
    text-align: center;
    padding: 20px;
    border-top: 1px solid #ccc;
}

/* Active button state – uses the same border width to avoid layout shifts */
button.active {
    background-color: #004085;
    border-color: #002752;
    font-weight: bold;
    box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.2);
}

/* Special handling for copy button - don't show pressed state */
.copyButton.active {
    background-color: #28a745;
    border: none;
    box-shadow: none;
    font-weight: normal;
}

.testHarnessWrapper {
    width: 90%;
    max-width: 800px;
    margin: 40px auto;
    padding-top: 20px;
    border-top: 1px solid #ccc;
}

.testHarnessWrapper ul {
    list-style: none;
    padding-left: 0;
    margin-top: 20px;
}

.testHarnessWrapper li {
    margin-bottom: 8px;
}
