/*
 * Styles for /csv-whitespace-cleaner/ only. Colors and spacing follow
 * styles.css; the whitespace badges (.ws-badge, .ws-tab, .ws-eol) and the
 * sample chips come from there too.
 */

.csv-tool {
    max-width: 1100px;
}

/* Several components set their own display (flex, inline-flex, grid), which
   would otherwise win over the hidden attribute and leave controls showing. */
.csv-tool [hidden] {
    display: none;
}

.csv-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ---- Steps ------------------------------------------------------------- */

.csv-step {
    margin: 0 0 26px;
    padding: 24px 0 0;
    border-top: 1px solid #e3eaf3;
}

.csv-step:first-of-type {
    padding-top: 0;
    border-top: 0;
}

.csv-step-title {
    scroll-margin-top: 96px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 14px;
    color: #1f2937;
    font-size: 1.2rem;
    line-height: 1.3;
}

.csv-step-num {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: #fff;
    background: #0066d6;
    font-size: 0.9rem;
    font-weight: 800;
}

.csv-note {
    margin: 8px 0 0;
    color: #667386;
    font-size: 0.85rem;
    line-height: 1.5;
}

.csv-note-flush {
    margin-top: 12px;
}

fieldset.csv-group {
    min-width: 0;
    margin: 0 0 16px;
    padding: 0;
    border: 0;
}

.csv-group-spaced {
    margin-top: 16px;
}

.csv-group legend {
    margin-bottom: 8px;
    padding: 0;
    color: #253246;
    font-size: 0.94rem;
    font-weight: 700;
}

/* ---- Format choices ---------------------------------------------------- */

.csv-formats {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.csv-choice {
    position: relative;
    display: block;
    flex: 1 1 200px;
}

.csv-choice input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.csv-choice span {
    display: block;
    height: 100%;
    padding: 12px 16px;
    border: 2px solid #dce4ee;
    border-radius: 12px;
    background: #fff;
    color: #253246;
    font-weight: 700;
    cursor: pointer;
}

.csv-choice small {
    display: block;
    margin-top: 2px;
    color: #667386;
    font-size: 0.8rem;
    font-weight: 500;
}

.csv-choice input:checked + span {
    border-color: #0066d6;
    background: rgba(0, 122, 255, 0.06);
    color: #005bbf;
}

.csv-choice input:focus-visible + span,
.csv-file-button:focus-within,
.csv-secondary-button:focus-visible,
.csv-table-scroll:focus-visible {
    outline: 3px solid rgba(0, 122, 255, 0.4);
    outline-offset: 2px;
}

/* ---- Input ------------------------------------------------------------- */

.csv-input {
    min-height: 170px;
    white-space: pre;
    overflow: auto;
    tab-size: 8;
}

.csv-input-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
}

.csv-secondary-button,
.csv-file-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 9px 18px;
    border: 1px solid #aebdce;
    border-radius: 10px;
    color: #1f2937;
    background: #fff;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
}

.csv-secondary-button:hover:not(:disabled),
.csv-file-button:hover {
    border-color: #0066d6;
    background: #f1f7ff;
}

.csv-secondary-button:disabled {
    color: #8a96a6;
    background: #f1f4f8;
    cursor: not-allowed;
}

.csv-file-button input {
    position: absolute;
    inset: 0;
    width: 100%;
    opacity: 0;
    cursor: pointer;
}

.csv-file-status {
    margin: 10px 0 0;
    padding: 10px 14px;
    border-radius: 10px;
    color: #253246;
    background: #f1f6fc;
    font-size: 0.88rem;
    line-height: 1.5;
}

.csv-error {
    margin: 12px 0 0;
    padding: 12px 14px;
    border: 1px solid #f3b6af;
    border-left: 4px solid #b42318;
    border-radius: 10px;
    color: #7a1a12;
    background: #fff4f2;
    font-size: 0.92rem;
    line-height: 1.55;
}

/* ---- Settings ---------------------------------------------------------- */

.csv-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid #e3eaf3;
    border-radius: 10px;
    background: #fff;
    cursor: pointer;
}

.csv-check input {
    flex: none;
    width: 20px;
    height: 20px;
    margin-top: 2px;
    accent-color: #0066d6;
}

.csv-check strong {
    display: block;
    color: #1f2937;
    font-size: 0.94rem;
}

.csv-check small {
    display: block;
    color: #667386;
    font-size: 0.82rem;
    line-height: 1.45;
}

.csv-rules {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.csv-rules .csv-check {
    margin: 0;
}

.csv-col-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 10px;
}

.csv-col-actions .csv-secondary-button {
    min-height: 38px;
    padding: 6px 14px;
    font-size: 0.88rem;
}

.csv-columns {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 6px 12px;
    max-height: 11rem;
    padding: 10px 12px;
    overflow: auto;
    border: 1px solid #e3eaf3;
    border-radius: 10px;
    background: #fbfdff;
}

.csv-columns:empty {
    display: none;
}

.csv-column {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    min-height: 32px;
    color: #253246;
    font-size: 0.9rem;
    cursor: pointer;
}

.csv-column input {
    flex: none;
    width: 18px;
    height: 18px;
    accent-color: #0066d6;
}

.csv-column span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.csv-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-top: 18px;
}

.csv-actions .remove-button {
    margin-right: 0;
}

.csv-actions .remove-button:disabled {
    background: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
}

/* ---- Review ------------------------------------------------------------ */

.csv-summary {
    margin: 0 0 12px;
    color: #253246;
    font-size: 0.95rem;
    line-height: 1.55;
}

.csv-results {
    margin: 0 0 16px;
    padding: 16px;
}

.csv-metrics {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.csv-review-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 18px;
    margin: 0 0 12px;
}

.csv-inline-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 32px;
    color: #253246;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
}

.csv-inline-check input {
    width: 18px;
    height: 18px;
    accent-color: #0066d6;
}

.csv-inline-check input:disabled + span {
    color: #8a96a6;
}

.csv-table-scroll {
    /* Containing block for the visually hidden captions and spoken summaries
       inside the table; without it they sit outside the scroll box and widen
       the whole page. */
    position: relative;
    max-height: 30rem;
    overflow: auto;
    border: 1px solid #dce6f2;
    border-radius: 12px;
    background: #fff;
}

.csv-table-scroll:empty {
    display: none;
}

.csv-table {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.86rem;
    line-height: 1.5;
}

.csv-table th,
.csv-table td {
    min-width: 7rem;
    max-width: 20rem;
    padding: 7px 10px;
    border-right: 1px solid #edf1f6;
    border-bottom: 1px solid #edf1f6;
    text-align: left;
    vertical-align: top;
    overflow-wrap: anywhere;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-weight: 500;
}

.csv-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #eef4fb;
    color: #1f2937;
    font-weight: 700;
}

.csv-table th.csv-skipped,
.csv-table td.csv-skipped {
    color: #667386;
    background: #f6f7f9;
}

.csv-table thead th.csv-skipped {
    background: #e9ecf0;
}

.csv-table .csv-rownum {
    min-width: 3rem;
    max-width: 4rem;
    color: #667386;
    background: #f8fafc;
    text-align: right;
}

.csv-colstate {
    display: block;
    margin-top: 2px;
    color: #667386;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.csv-sp {
    color: #7f8ea3;
    background: rgba(0, 122, 255, 0.1);
    border-radius: 2px;
}

.csv-more {
    color: #667386;
    font-family: inherit;
    font-size: 0.75rem;
    font-style: italic;
}

.csv-empty {
    color: #8a96a6;
    font-family: inherit;
    font-size: 0.75rem;
    font-style: italic;
}

.csv-changed {
    padding: 0;
    border-left: 3px solid #0b6b3a;
}

.csv-was,
.csv-now {
    padding: 6px 10px;
}

.csv-was {
    background: #fff4f2;
    color: #7a1a12;
}

.csv-now {
    background: #effaf3;
    color: #0b4f2b;
}

.csv-tag {
    display: inline-block;
    margin-right: 6px;
    padding: 0 5px;
    border-radius: 4px;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 0.66rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.csv-was .csv-tag {
    background: #b42318;
}

.csv-now .csv-tag {
    background: #0b6b3a;
}

/* ---- Export ------------------------------------------------------------ */

.csv-export-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 16px;
}

.csv-export-actions .copy-button,
.csv-export-actions .remove-button {
    margin: 0;
}

.csv-export-actions .remove-button:disabled {
    background: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
}

.csv-status {
    min-height: 1.5em;
    margin: 10px 0 0;
    color: #0b4f2b;
    font-size: 0.92rem;
    font-weight: 600;
}

.csv-status-error {
    color: #b42318;
}

/* ---- Narrow screens ---------------------------------------------------- */

@media (max-width: 768px) {
    .csv-rules {
        grid-template-columns: 1fr;
    }

    .csv-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .csv-table-scroll {
        max-height: 24rem;
    }
}

@media (max-width: 480px) {
    .csv-input-actions > *,
    .csv-actions > *,
    .csv-export-actions > .copy-button,
    .csv-export-actions > .remove-button {
        width: 100%;
    }

    .csv-choice {
        flex-basis: 100%;
    }
}
