/**
 * Element Replicator — data tables.
 *
 * The table itself inherits the theme's `.entry table` styles (dark rows,
 * #323141 dividers, rounded corners). This file adds the toolbar, sortable
 * headers and pagination built by data-table.js, and matches the header row
 * to the theme's hand-built tables (centered, with a divider below).
 * Selectors are prefixed with `.eld-dt` to win over Foundation's form styles.
 */

.eld-dt {
    margin: 16px 0 24px;
}

/* ---- Toolbar ---- */

.eld-dt__toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px 16px;
    margin-bottom: 16px;
}

.eld-dt__control {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    color: #BFBBD4;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.2;
}

.eld-dt__control--search {
    flex: 1 1 240px;
    max-width: 360px;
}

.eld-dt__control--size {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.eld-dt .eld-dt__search,
.eld-dt .eld-dt__select {
    height: 42px;
    margin: 0;
    padding: 2px 16px;
    border: 2px solid #323141;
    border-radius: 16px;
    background-color: #2A2A37;
    box-shadow: none;
    color: #fff;
    font-family: inherit;
    font-size: 16px;
    line-height: normal;
}

.eld-dt .eld-dt__search {
    width: 100%;
    padding-left: 44px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23BFBBD4' stroke-width='2.5' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 16px center;
    background-size: 16px 16px;
}

.eld-dt .eld-dt__search::placeholder {
    color: #8B88A0;
}

.eld-dt .eld-dt__select {
    width: auto;
    min-width: 96px;
    max-width: 100%;
    padding-right: 40px;
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23BFBBD4' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-origin: padding-box;
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 10px 6px;
    cursor: pointer;
}

.eld-dt .eld-dt__search:focus,
.eld-dt .eld-dt__select:focus {
    outline: none;
    border-color: #FFC950;
    background-color: #2A2A37;
    box-shadow: none;
}

/* ---- Table ---- */

.eld-dt table {
    width: 100%;
    margin: 0;
}

/* Sideways scrolling on narrow screens. Rendered with the table, because the
   theme's own .table-scroll wrap (main.js) only runs on page load and misses
   articles appended by infinite scroll. */
.eld-dt__scroll {
    overflow-x: auto;
}

/* On first load main.js still wraps the table; keep that wrap flat. */
.eld-dt .table-scroll {
    margin: 0;
}

.entry .eld-dt thead th {
    border-bottom: 2px solid #323141;
    text-align: center;
    vertical-align: middle;
}

.entry .eld-dt tbody td {
    vertical-align: middle;
}

/* Rows off the current page stay in the table, hidden (see data-table.js). */
.eld-dt tbody tr[hidden] {
    display: none;
}

/* With hidden rows after it, the last shown row isn't the tbody's :last-child,
   so it takes over the theme's last-row styles: no divider, rounded corners. */
.entry .eld-dt tbody tr.eld-dt__last td {
    border-bottom: 0;
}

.entry .eld-dt tbody tr.eld-dt__last td:first-child {
    border-bottom-left-radius: 16px;
}

.entry .eld-dt tbody tr.eld-dt__last td:last-child {
    border-bottom-right-radius: 16px;
}

/* The theme rounds the first body row for tables without a <thead>; here the
   header owns the top corners, and the rounding would notch the row background. */
.entry .eld-dt tbody tr:first-child td:first-child,
.entry .eld-dt tbody tr:first-child td:last-child {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
}

.entry .eld-dt .eld-dt__image img {
    display: inline-block;
    width: 72px;
    height: 72px;
    margin: 0;
    border-radius: 0;
    object-fit: contain;
    vertical-align: middle;
}

.entry .eld-dt tbody .eld-dt__empty td {
    padding: 24px 16px;
    color: #BFBBD4;
    font-weight: 400;
}

/* ---- Sortable headers ---- */

.eld-dt .eld-dt__sort {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    line-height: inherit;
    text-align: inherit;
    cursor: pointer;
}

.eld-dt .eld-dt__sort:focus-visible {
    outline: 2px solid #FFC950;
    outline-offset: 4px;
    border-radius: 4px;
}

.eld-dt__sort-icon {
    position: relative;
    flex: 0 0 auto;
    width: 8px;
    height: 12px;
}

.eld-dt__sort-icon::before,
.eld-dt__sort-icon::after {
    content: '';
    position: absolute;
    left: 0;
    border-right: 4px solid transparent;
    border-left: 4px solid transparent;
    opacity: .35;
}

.eld-dt__sort-icon::before {
    top: 0;
    border-bottom: 5px solid currentColor;
}

.eld-dt__sort-icon::after {
    bottom: 0;
    border-top: 5px solid currentColor;
}

.eld-dt__sort:hover .eld-dt__sort-icon::before,
.eld-dt__sort:hover .eld-dt__sort-icon::after {
    opacity: .7;
}

.eld-dt th[aria-sort="ascending"] .eld-dt__sort-icon::before {
    border-bottom-color: #FFC950;
    opacity: 1;
}

.eld-dt th[aria-sort="descending"] .eld-dt__sort-icon::after {
    border-top-color: #FFC950;
    opacity: 1;
}

/* ---- Footer: count + pagination ---- */

.eld-dt__footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
    margin-top: 16px;
}

.eld-dt__info {
    color: #BFBBD4;
    font-size: 14px;
}

.eld-dt__pages {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}

.eld-dt__pages[hidden] {
    display: none;
}

.eld-dt .eld-dt__page {
    min-width: 40px;
    height: 40px;
    margin: 0;
    padding: 0 12px;
    border: 2px solid #323141;
    border-radius: 12px;
    background: #2A2A37;
    color: #fff;
    font-family: inherit;
    font-size: 15px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.eld-dt .eld-dt__page:hover:not(:disabled) {
    border-color: #FFC950;
}

.eld-dt .eld-dt__page[aria-current="page"] {
    border-color: #FFC950;
    background: #FFC950;
    color: #0E0E11;
}

.eld-dt .eld-dt__page:disabled {
    cursor: default;
    opacity: .4;
}

.eld-dt .eld-dt__page:focus-visible {
    outline: 2px solid #FFC950;
    outline-offset: 2px;
}

.eld-dt__gap {
    min-width: 20px;
    color: #8B88A0;
    text-align: center;
}

@media screen and (max-width: 639px) {
    .eld-dt__control--search,
    .eld-dt__control--filter {
        flex: 1 1 100%;
        max-width: none;
    }

    .eld-dt__control--size {
        margin-left: 0;
    }

    .eld-dt .eld-dt__control--filter .eld-dt__select {
        width: 100%;
    }

    .entry .eld-dt thead th {
        padding: 12px 8px;
        font-size: 14px;
    }

    .entry .eld-dt .eld-dt__image img {
        width: 48px;
        height: 48px;
    }

    .eld-dt__footer {
        justify-content: center;
    }
}
