/* Larena UI owns the reusable collection presentation. Domain query and
   record semantics remain server-owned; the Framework controls below expose
   presentation state only. */
[data-larena-dataview-query],
[data-larena-page-assembly],
.larena-dataview,
.larena-dataview-table {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.larena-dataview-table {
    display: grid;
    gap: 12px;
}

.larena-dataview-table__title {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.larena-dataview-toolbar {
    display: grid;
    grid-template-columns: auto minmax(160px, 1fr) auto;
    gap: 8px;
    align-items: end;
    width: 100%;
    max-width: 100%;
}

.larena-dataview-toolbar > [data-larena-slot] {
    display: flex;
    min-width: 0;
    align-items: end;
    gap: 8px;
}

.larena-dataview-toolbar > [data-larena-slot="search"] {
    display: grid;
    grid-template-columns: minmax(160px, 340px);
    justify-content: end;
    order: 2;
}

.larena-dataview-toolbar > [data-larena-slot="search"] > * {
    display: block;
    width: 100%;
    min-width: 0;
}

/* Compact toolbar controls keep their label text in the accessibility tree,
   while the editable form variants continue to show labels visually. */
.larena-dataview-toolbar > [data-larena-slot="search"] .sf-input-label,
.larena-dataview-toolbar > [data-larena-slot="options"] > sf-dropdown .sf-dropdown-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
}

.larena-dataview-toolbar > [data-larena-slot="options"] { order: 1; justify-content: flex-start; }
.larena-dataview-toolbar > [data-larena-slot="actions"] { order: 3; justify-content: flex-end; }

.larena-dataview-query-options {
    position: relative;
}

.larena-dataview-query-options__title {
    display: flex;
    min-height: 40px;
    align-items: center;
    border: 1px solid var(--sf-outline-variant);
    border-radius: 8px;
    padding: 7px 12px;
    list-style: none;
    white-space: nowrap;
    cursor: pointer;
}

.larena-dataview-query-options__title::-webkit-details-marker { display: none; }
.larena-dataview-query-options__title::before,
.larena-dataview-query-options__title::after {
    font-family: "Material Symbols Outlined", sans-serif;
    font-size: 18px;
    font-weight: 400;
}
.larena-dataview-query-options__title::before { content: "filter_list"; margin-inline-end: 7px; }
.larena-dataview-query-options__title::after { content: "expand_more"; margin-inline-start: 7px; }
.larena-dataview-query-options[open] > .larena-dataview-query-options__title::after { content: "expand_less"; }

.larena-dataview-query-options[open] {
    position: relative;
    width: 100%;
    min-width: 0;
    border: 1px solid var(--sf-outline-variant);
    border-radius: 10px;
    background: var(--sf-surface-0);
    padding: 12px;
    box-shadow: 0 18px 44px rgb(15 23 42 / 16%);
}

/* Expanded filters participate in layout so fields cannot cover Search/Apply. */
.larena-dataview-toolbar:has(.larena-dataview-query-options[open]) {
    grid-template-columns: minmax(0, 1fr) auto;
}
.larena-dataview-toolbar:has(.larena-dataview-query-options[open]) > [data-larena-slot="options"] {
    grid-column: 1 / -1;
    order: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(160px, 240px);
    align-items: start;
}

.larena-dataview-query-options[open] > .larena-dataview-query-options__title {
    border: 0;
    border-bottom: 1px solid var(--sf-outline-variant);
    border-radius: 0;
    padding: 2px 0 10px;
}

.larena-dataview-query-options > [data-larena-slot] {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.larena-dataview-query-options > [data-larena-slot="pagination"] {
    grid-template-columns: minmax(160px, 220px);
}

.larena-dataview-table__content {
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scrollbar-gutter: stable;
    border: 0;
    border-radius: 0;
    background: transparent;
}

.larena-dataview-table__content:focus-within {
    outline: 2px solid color-mix(in srgb, var(--sf-focus) 65%, transparent);
    outline-offset: 2px;
}

.larena-dataview-table__content > sf-view-table {
    display: block !important;
    width: 100%;
    min-width: 100%;
}

.larena-dataview-table__content > sf-view-table > .sf-table {
    min-width: 100%;
}

.larena-dataview-table__content > sf-view-table > .sf-table thead th {
    height: 42px;
    color: var(--sf-on-surface-muted);
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.larena-dataview-table__content > sf-view-table > .sf-table tbody td {
    height: 48px;
    font-size: 13px;
    white-space: nowrap;
    /* A long value stays inside its column instead of running over the next one. */
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 22rem;
}

/* The linked record name sits flush with the column and shortens with an ellipsis. */
.larena-dataview-table__content > sf-view-table > .sf-table tbody td .sf-button--link {
    max-width: 100%;
    padding-inline: 0;
}

.larena-dataview-table__content > sf-view-table > .sf-table tbody td .sf-button--link .sf-button-text-container {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: start;
}

/* A narrow column keeps the "+N" count readable and lets the first badge shorten instead. */
.larena-dataview-table__content > sf-view-table > .sf-table tbody td sf-badge + sf-badge > .sf-badge {
    flex-shrink: 0;
}

.larena-dataview-table__content > sf-view-table > .sf-table tbody tr:hover {
    background: var(--sf-surface-container-hover);
}

.larena-dataview-table__content .sf-table-toolbar { display: none !important; }
.larena-dataview-table__content .table-wrap > div { margin-bottom: 0 !important; }

.larena-dataview-table__pagination {
    /* sf-pagination renders as display: contents, so its nav is laid out by this box and must span it. */
    display: block;
    min-width: 0;
}

/* As in the table design, "Show more" starts right under the last row with no empty band above it. */
.larena-dataview-table__content > sf-view-table table {
    margin-bottom: 0;
}

.larena-dataview-table__content + .larena-dataview-table__pagination {
    margin-top: -12px;
}

.larena-dataview-table__pagination > sf-pagination,
.larena-dataview-table__pagination nav.sf-pagination {
    display: block;
    width: 100%;
    min-width: 0;
}

.larena-dataview-table__pagination nav.sf-pagination {
    display: flex;
}

.larena-dataview-table__pagination .sf-pagination-main {
    width: 100%;
}

.larena-pagination-next {
    display: inline-flex;
    min-height: 38px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--sf-outline-variant);
    border-radius: 8px;
    padding-inline: 14px;
    color: var(--sf-primary);
    font-weight: 700;
    text-decoration: none;
}

.larena-pagination-next:focus-visible {
    outline: 3px solid var(--sf-focus);
    outline-offset: 2px;
}

.larena-admin-record-editor {
    margin: 16px 0 0;
    border-top: 1px solid var(--sf-outline-variant);
}

.larena-admin-record-editor__title {
    cursor: pointer;
    padding: 14px 0;
    font-size: 14px;
    font-weight: 750;
    list-style: none;
}

.larena-admin-record-editor__title::-webkit-details-marker { display: none; }
.larena-admin-record-editor__title::after { content: "+"; float: inline-end; color: var(--sf-on-surface-muted); font-size: 18px; font-weight: 400; }
.larena-admin-record-editor[open] > .larena-admin-record-editor__title::after { content: "\2212"; }
.larena-admin-record-editor__fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; padding: 4px 0 16px; }
.larena-admin-record-editor__actions { display: flex; justify-content: flex-end; border-top: 1px solid var(--sf-outline-variant); padding-top: 16px; }

@media (max-width: 1100px) {
    .larena-dataview-toolbar { grid-template-columns: minmax(280px, 1fr) auto; }
    .larena-dataview-toolbar > [data-larena-slot="search"] { grid-column: 1 / -1; order: 0; grid-template-columns: minmax(0, 1fr); }
    .larena-dataview-toolbar > [data-larena-slot="options"] { justify-content: flex-start; }
}

@media (max-width: 680px) {
    .larena-dataview-toolbar { grid-template-columns: minmax(0, 1fr); align-items: stretch; }
    .larena-dataview-toolbar > [data-larena-slot] { grid-column: 1; width: 100%; }
    .larena-dataview-toolbar > [data-larena-slot="search"] { grid-template-columns: minmax(0, 1fr); }
    .larena-dataview-toolbar > [data-larena-slot="options"] { justify-content: stretch; }
    .larena-dataview-toolbar > [data-larena-slot="options"] > * { width: 100%; }
    .larena-dataview-toolbar > [data-larena-slot="actions"] {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: stretch;
    }
    .larena-dataview-toolbar > [data-larena-slot="actions"] > * { width: 100%; min-width: 0; }
    .larena-dataview-query-options__title { justify-content: center; }
    .larena-dataview-toolbar:has(.larena-dataview-query-options[open]),
    .larena-dataview-toolbar:has(.larena-dataview-query-options[open]) > [data-larena-slot="options"] { grid-template-columns: minmax(0, 1fr); }
    .larena-dataview-query-options > [data-larena-slot] { grid-template-columns: 1fr; }
    .larena-dataview-table__content > sf-view-table { width: 760px; min-width: 760px; }
    .larena-dataview-table__pagination { overflow-x: auto; padding-bottom: 4px; }
    .larena-dataview-table__pagination > sf-pagination { min-width: 620px; }
    .larena-admin-record-editor__fields { grid-template-columns: 1fr; }
}
