/* ========================================================================== */
/* Central de Exportação                                                       */
/* Regras consolidadas. Toda a Central de Exportação deve ficar neste arquivo. */
/* ========================================================================== */

/* -------------------------------------------------------------------------- */
/* Estrutura geral                                                             */
/* -------------------------------------------------------------------------- */

.export-card {
    min-width: 0;
}

.export-card .export-heading {
    align-items: center;
    margin-bottom: 8px;
}

.export-layout {
    display: grid;
    grid-template-columns: 255px minmax(0, 1fr);
    gap: 14px;
    align-items: start;
    width: 100%;
    min-width: 0;
}

.export-sidebar,
.export-data-area,
.export-block {
    width: 100%;
    min-width: 0;
}

.export-sidebar {
    display: flex;
    flex-direction: column;
    align-self: start;
}

.export-block h3 {
    margin: 0 0 3px;
    color: #34425a;
    font-size: .72rem;
    line-height: 1.25;
}

.export-block > .muted {
    margin: 4px 0 0;
    line-height: 1.35;
}

/* -------------------------------------------------------------------------- */
/* Variáveis                                                                   */
/* -------------------------------------------------------------------------- */

.variables-list {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}

.variable-row {
    display: grid;
    grid-template-columns: minmax(135px, 1fr) auto;
    gap: 8px 12px;
    align-items: center;
    padding: 9px 10px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: #fff;
}

.variable-row strong,
.variable-title {
    min-width: 0;
    color: #34425a;
    font-size: .72rem;
    line-height: 1.25;
}

.variable-title {
    grid-column: 1 / -1;
    width: 100%;
}

.mode-group {
    display: flex;
    gap: 3px;
    flex-wrap: nowrap;
}

.mode-button {
    padding: 5px 7px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: #fff;
    color: #68738a;
    font-size: .62rem;
    line-height: 1.2;
    white-space: nowrap;
    cursor: pointer;
}

.mode-button:hover:not(:disabled) {
    background: #f5f7fb;
}

.mode-button.active {
    border-color: var(--navy);
    background: var(--navy);
    color: #fff;
}

.mode-button:disabled,
.mode-button.disabled {
    cursor: not-allowed;
    opacity: .48;
}

.variable-filter-values {
    grid-column: 1 / -1;
    min-width: 0;
    padding-top: 2px;
}

.variable-filter-values[hidden] {
    display: none;
}

/* -------------------------------------------------------------------------- */
/* Select/dropdown das variáveis                                               */
/* -------------------------------------------------------------------------- */

.export-filter-select {
    position: relative;
    width: 100%;
    min-width: 0;
}

.export-filter-control {
    position: relative;
    display: block;
    width: 100%;
    min-height: 34px;
    padding: 7px 30px 7px 10px;
    border: 1px solid #c8d2e1;
    border-radius: 6px;
    background: #fff;
    color: #34425a;
    font-size: .72rem;
    line-height: 1.25;
    text-align: left;
    cursor: pointer;
}

.export-filter-control::after {
    content: "⌄";
    position: absolute;
    top: 5px;
    right: 10px;
    color: #68738a;
    font-size: 1rem;
}

.export-filter-control-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.export-filter-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 35;
    width: 100%;
    max-height: 190px;
    padding: 5px;
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid #bdc9da;
    border-radius: 6px;
    background: #fff;
    box-shadow: 0 10px 22px rgba(9, 25, 56, .18);
}

.export-filter-menu[hidden] {
    display: none;
}

.export-filter-option {
    display: flex;
    align-items: center;
    gap: 7px;
    width: 100%;
    min-width: 0;
    padding: 7px 8px;
    border: 0;
    border-radius: 4px;
    background: #fff;
    color: #34425a;
    font-size: .72rem;
    line-height: 1.25;
    text-align: left;
    cursor: pointer;
}

.export-filter-option:hover,
.export-filter-option.selected {
    background: #edf3fa;
}

.export-filter-check {
    width: 14px;
    flex: 0 0 14px;
    color: var(--navy);
    font-weight: 700;
    text-align: center;
}

.export-filter-option-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#generateExportTable {
    margin-top: 12px;
}

/* -------------------------------------------------------------------------- */
/* Cabeçalho da área de dados                                                  */
/* -------------------------------------------------------------------------- */

.export-data-area {
    align-self: start;
    padding-top: 0;
}

.export-data-header {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        ". help"
        "preview actions";
    column-gap: 14px;
    row-gap: 4px;
    align-items: end;
    min-height: 51px;
    margin-bottom: 5px;
}

.export-preview-info {
    grid-area: preview;
    min-width: 0;
    align-self: end;
}

.preview-line,
.export-data-area .preview-line {
    display: flex;
    align-items: baseline;
    justify-content: flex-start;
    gap: 8px;
    min-width: 0;
    margin: 0;
    color: #657188;
    font-size: .68rem;
    line-height: 1.25;
    white-space: nowrap;
}

.preview-line strong {
    color: #485a74;
    font-weight: 700;
}

#previewSummary {
    overflow: hidden;
    text-overflow: ellipsis;
}

.export-header-actions {
    display: contents;
}

.export-help-text {
    grid-area: help;
    justify-self: end;
    max-width: 100%;
    margin: 0;
    color: #657188;
    font-size: .66rem;
    line-height: 1.25;
    text-align: right;
    white-space: normal;
}

.export-buttons {
    grid-area: actions;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 7px;
    float: none;
}

.export-buttons .btn {
    min-height: 30px;
    padding: 6px 11px;
    gap: 5px;
    border-radius: 6px;
    font-size: .65rem;
    line-height: 1;
    white-space: nowrap;
}

.export-buttons svg {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
}

/* -------------------------------------------------------------------------- */
/* Tabela de prévia                                                            */
/* -------------------------------------------------------------------------- */

.export-data-area .table-wrap {
    width: 100%;
    max-width: 100%;
    max-height: 500px;
    margin-top: 0;
    overflow: auto;
}

#exportTable {
    width: 100%;
    min-width: max-content;
    border-collapse: collapse;
}

#exportTable thead th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: #f8fafc;
}

/* -------------------------------------------------------------------------- */
/* Responsividade                                                              */
/* -------------------------------------------------------------------------- */



@media (max-width: 1200px) {
    .export-layout {
        grid-template-columns: 235px minmax(0, 1fr);
        gap: 12px;
    }

    .mode-group {
        flex-wrap: wrap;
    }

    .export-help-text {
        white-space: normal;
        text-align: right;
    }
}

@media (max-width: 900px) {
    .export-layout {
        display: block;
    }

    .export-data-area {
        margin-top: 16px;
    }

    .export-data-header {
        min-height: 0;
    }
}

@media (max-width: 560px) {
    .export-card .export-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .variable-row {
        grid-template-columns: 1fr;
    }

    .mode-group {
        justify-content: flex-start;
    }

    .variable-filter-values {
        grid-column: 1;
    }

    .export-data-header {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 7px;
    }

    .export-preview-info {
        order: 2;
    }

    .export-header-actions {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 7px;
        order: 1;
    }

    .export-help-text {
        text-align: left;
        white-space: normal;
    }

    .export-buttons {
        width: 100%;
        justify-content: stretch;
    }

    .export-buttons .btn {
        flex: 1 1 0;
    }
}

.export-dialog {
    width: min(1100px, calc(100% - 40px));
    max-height: 90vh;
    padding: 0;
    border: 0;
    border-radius: 12px;
    overflow: auto;
}

    .export-dialog::backdrop {
        background: rgba(0, 0, 0, 0.45);
    }

    .export-dialog .export-card {
        margin: 0;
        border: 0;
    }

.export-dialog-close {
    position: absolute;
    top: 12px;
    right: 16px;
    z-index: 10;
    border: 0;
    background: transparent;
    font-size: 28px;
    cursor: pointer;
}

.btn-export-data {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-top: 16px;
    padding: 10px 20px;
    border: 0;
    border-radius: 8px;
    background: var(--navy);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    max-width:200px;
}

    .btn-export-data:hover {
        background: var(--navy-2);
    }