/* Keep member management controls comfortably spaced within the site's theme. */
#uehs-members .uehs-admin-toolbar > div {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
}

#uehs-members .uehs-admin-toolbar .uehs-search-input {
    flex: 1 1 320px;
    min-width: 0;
    width: auto;
    margin: 0;
}

#uehs-members .uehs-admin-toolbar .uehs-year-select {
    flex: 0 0 auto;
    margin: 0;
}

#uehs-members .uehs-admin-toolbar .uehs-btn {
    margin: 0;
    white-space: nowrap;
}

/* Long emails must not force the nine-column table beyond its container. */
#uehs-members #uehs-table {
    width: 100%;
    max-width: 100%;
    table-layout: auto;
}

#uehs-members #uehs-table th,
#uehs-members #uehs-table td {
    box-sizing: border-box;
}

#uehs-members #uehs-table td:nth-child(2) {
    overflow-wrap: anywhere;
    word-break: normal;
}

#uehs-members #uehs-table th:last-child,
#uehs-members #uehs-table td:last-child:not([colspan]) {
    width: 1%;
    min-width: 0;
    padding: 20px 20px !important;
    text-align: center;
    white-space: nowrap;
}

#uehs-members #uehs-table .uehs-edit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    min-height: 36px;
    padding: 8px 16px !important;
    line-height: 1.25;
    white-space: nowrap;
    margin: 0;
}

#uehs-members > .uehs-table-container {
    max-width: 100%;
    overflow-x: auto;
}

@media (max-width: 640px) {
    #uehs-members .uehs-admin-toolbar > div {
        gap: 12px;
        flex-direction: row;
        align-items: center;
    }

    #uehs-members .uehs-admin-toolbar .uehs-search-input {
        flex-basis: 100%;
    }

    #uehs-members .uehs-admin-toolbar .uehs-btn {
        flex: 0 0 100%;
        width: 100%;
    }
}

/* Keep the important columns inside the viewport, regardless of long member names.
   The original table cells stay in place for sorting, filtering and CSV export. */
@media (max-width: 1024px) {
    #uehs-members {
        min-width: 0;
        max-width: 100%;
        box-sizing: border-box;
    }

    #uehs-members #uehs-table,
    #uehs-members #uehs-table thead,
    #uehs-members #uehs-table tbody {
        display: block;
        width: 100%;
        min-width: 0;
    }

    #uehs-members #uehs-table tr {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 100px minmax(110px, 140px) 100px;
        align-items: center;
        gap: 12px;
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
        padding: 16px;
        border-bottom: 1px solid #e0e0e0;
    }

    #uehs-members #uehs-table thead tr {
        background: #f5f5f5;
    }

    #uehs-members #uehs-table tr > th,
    #uehs-members #uehs-table tr > td {
        display: none;
        width: auto;
        min-width: 0;
        max-width: 100%;
        padding: 0 !important;
        border: 0;
        white-space: normal;
    }

    #uehs-members #uehs-table tr > :is(th, td):nth-child(1),
    #uehs-members #uehs-table tr > :is(th, td):nth-child(6),
    #uehs-members #uehs-table tr > :is(th, td):nth-child(8),
    #uehs-members #uehs-table tr > :is(th, td):nth-child(9) {
        display: block;
    }

    #uehs-members #uehs-table tr > :is(th, td):nth-child(1) {
        overflow-wrap: anywhere;
    }

    #uehs-members #uehs-table tr > th:last-child,
    #uehs-members #uehs-table tr > td:last-child:not([colspan]) {
        width: auto;
        min-width: 0;
        padding: 0 !important;
        text-align: right;
    }

    #uehs-members #uehs-table td:nth-child(6) > span {
        display: inline-block;
        max-width: 100%;
        white-space: nowrap;
    }

    #uehs-members #uehs-table .uehs-edit-btn {
        min-height: 40px;
        min-width: 80px;
        max-width: 100%;
    }

    #uehs-members #uehs-table tr > td[colspan] {
        display: block;
        grid-column: 1 / -1;
        padding: 20px 0 !important;
    }
}

/* Each phone card has the name above a permanently visible status/action row. */
@media (max-width: 600px) {
    #uehs-members #uehs-table tr {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 12px 16px;
    }

    #uehs-members #uehs-table tr > :is(th, td):nth-child(1) {
        grid-column: 1 / -1;
    }

    #uehs-members #uehs-table tr > :is(th, td):nth-child(6) {
        grid-column: 1;
        grid-row: 2;
    }

    #uehs-members #uehs-table tr > :is(th, td):nth-child(8) {
        display: none;
    }

    #uehs-members #uehs-table tr > :is(th, td):nth-child(9) {
        grid-column: 2;
        grid-row: 2;
    }
}
