/* The Dataset Definition page stays inside the viewport. Only its tree content
   receives a scroll container so the search controls and legend remain visible. */
.mud-main-content:has(.dataset-definitions-page-content) {
    overflow: hidden !important;
}

.mud-main-content:has(.dataset-definitions-page-content) > .mud-container {
    padding-top: 0 !important;
}

.dataset-definitions-page-content {
    height: calc(100dvh - 40px);
    min-height: 0;
    margin-top: 0;
    margin-bottom: 1rem;
    padding-bottom: 2rem;
    box-sizing: border-box;
    justify-content: flex-start;
    overflow: hidden;
}

.dataset-definitions-layout {
    width: 100%;
    max-width: 80vw;
    height: 100%;
    min-height: 0;
    margin: 0 auto;
    overflow: hidden;
}

.dataset-definitions-paper {
    flex: 1 1 0;
    min-height: 0;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.dataset-definitions-tree-scroll {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
}

.dataset-definitions-legend {
    flex: 0 0 auto;
}

/* ── Editoren der Datei-Exporte (CSV, Excel): Spalten per Drag & Drop wie im Bericht-Editor ── */
.export-columns {
    display: grid;
    grid-template-columns: minmax(170px, 1fr) minmax(0, 2fr);
    gap: 12px;
}

.export-columns__available,
.export-columns__file {
    display: flex;
    flex-direction: column;
    gap: 4px;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 8px;
    min-width: 0;
}

.export-columns__group {
    margin-top: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.export-columns__available-zone {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    min-height: 32px;
}

.export-columns__available-zone .mud-chip {
    margin: 0;
    max-width: 100%;
}

.export-columns__selected-zone {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-height: 120px;
    padding: 8px;
    border: 2px dashed var(--mud-palette-lines-default);
    border-radius: 8px;
}

.export-columns__selected-zone--error {
    border-color: var(--mud-palette-error);
}

.export-column-tile {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px 8px;
    border-radius: 6px;
    background-color: var(--mud-palette-background-gray);
    cursor: grab;
}

.export-column-tile__head {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.export-column-tile__position {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 24px;
    padding: 0 6px;
    border-radius: 12px;
    background-color: var(--mud-palette-primary);
    color: var(--mud-palette-primary-text);
    font-size: 0.75rem;
    font-weight: 600;
}

.export-column-tile__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.export-column-tile__fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 8px;
    padding-left: 32px;
    cursor: auto;
}

@media (max-width: 900px) {
    .export-columns {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ── Live-Vorschau eines Datei-Exports (ExportFilePreview): Datei als Text oder Tabelle, Excel als Tabellenblatt ── */
.export-preview {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.export-preview__granularity {
    width: 150px;
}

.export-preview__file {
    margin: 0;
    padding: 12px;
    overflow-x: auto;
    border-radius: 6px;
    background-color: var(--mud-palette-background-gray);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.8rem;
    line-height: 1.6;
    white-space: pre;
    tab-size: 4;
}

.export-preview__delimiter {
    color: var(--mud-palette-primary);
    font-weight: 700;
}

.export-preview__table-scroll {
    overflow-x: auto;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 6px;
}

.export-preview__table-scroll--sheet {
    border-radius: 6px 6px 0 0;
}

.export-preview__table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.export-preview__table td,
.export-preview__table th {
    padding: 4px 10px;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    text-align: left;
    white-space: nowrap;
}

.export-preview__table tr:last-child td,
.export-preview__table tr:last-child th {
    border-bottom: none;
}

.export-preview__header-row td {
    font-weight: 600;
    background-color: var(--mud-palette-background-gray);
}

/* Tabellenblatt: Gitter, Spaltenbuchstaben und Zeilennummern wie in Excel. */
.export-preview__table--sheet td,
.export-preview__table--sheet th {
    border: 1px solid var(--mud-palette-lines-default);
}

.export-preview__column-name,
.export-preview__row-number,
.export-preview__corner {
    background-color: var(--mud-palette-background-gray);
    color: var(--mud-palette-text-secondary);
    font-weight: 500;
    text-align: center !important;
}

.export-preview__row-number,
.export-preview__corner {
    width: 36px;
}

.export-preview__sheet-tabs {
    display: flex;
    padding: 0 8px;
    border: 1px solid var(--mud-palette-lines-default);
    border-top: none;
    border-radius: 0 0 6px 6px;
    background-color: var(--mud-palette-background-gray);
}

.export-preview__sheet-tab {
    padding: 4px 12px;
    border-bottom: 2px solid var(--mud-palette-success);
    background-color: var(--mud-palette-surface);
    font-size: 0.8rem;
    font-weight: 600;
}

/* JSON/NDJSON: kompakte Datensätze sind lang – umbrechen statt seitlich scrollen. */
.export-preview__file--wrap {
    white-space: pre-wrap;
    word-break: break-all;
}
