/* =============================================
   Project Bid Database – Table Styles
   UA Brand Colors | WCAG 2.1 AA compliant
   
   UA Brand Reference:
     Crimson:      #9e1b32
     Crimson dark: #7a1526  (hover/active)
     Gray light:   #f0f0f0
     Gray mid:     #d0d0d0
     Gray text:    #333333
     White:        #ffffff
   ============================================= */

/* Wrapper */
.pbd-table-wrapper {
    margin: 1.5rem 0;
    font-family: inherit;
}

/* ── Controls row ── */
.pbd-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.pbd-search-group,
.pbd-rows-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.pbd-search-label,
.pbd-rows-group label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #333333;
}

.pbd-search-input {
    padding: 0.45rem 0.65rem;
    font-size: 1rem;
    border: 2px solid #767676;
    border-radius: 4px;
    min-width: 220px;
    color: #333333;
    background: #ffffff;
}

.pbd-search-input:focus {
    outline: 3px solid #9e1b32;
    outline-offset: 1px;
    border-color: #9e1b32;
}

.pbd-rows-select {
    padding: 0.4rem 0.6rem;
    font-size: 1rem;
    border: 2px solid #767676;
    border-radius: 4px;
    background: #ffffff;
    color: #333333;
    cursor: pointer;
}

.pbd-rows-select:focus {
    outline: 3px solid #9e1b32;
    outline-offset: 1px;
}

/* ── Scrollable region for overflow ── */
.pbd-table-scroll {
    overflow-x: auto;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
}

.pbd-table-scroll:focus {
    outline: 3px solid #9e1b32;
    outline-offset: 2px;
}

/* ── Table ── */
.pbd-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.97rem;
    background: #ffffff;
}

/* Caption – hidden from visual display, retained for screen readers */
.pbd-caption {
    display: none;
}

/* Header cells – UA Crimson */
.pbd-table thead th {
    background: #9e1b32;
    color: #ffffff;
    text-align: left;
    padding: 0.65rem 0.85rem;
    font-size: 0.9rem;
    font-weight: 700;
    white-space: nowrap;
    border-right: 1px solid #7a1526;
}

.pbd-table thead th:last-child {
    border-right: none;
}

/* Body rows */
.pbd-table tbody tr {
    border-bottom: 1px solid #d0d0d0;
}

.pbd-table tbody tr:nth-child(even) {
    background: #f0f0f0;
}

.pbd-table tbody tr:hover,
.pbd-table tbody tr:focus-within {
    background: #f9e8eb;
    outline: 2px solid #9e1b32;    /* non-color indicator for hover/focus state (1.4.11) */
    outline-offset: -2px;
}

.pbd-table tbody td {
    padding: 0.6rem 0.85rem;
    vertical-align: top;
    color: #333333;
    border-right: 1px solid #e8e8e8;
}

.pbd-table tbody td:last-child {
    border-right: none;
}

/* Links inside table – UA Crimson */
.pbd-table a {
    color: #9e1b32;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.pbd-table a:hover {
    color: #7a1526;
    text-decoration-thickness: 2px;
}

.pbd-table a:focus {
    outline: 3px solid #9e1b32;
    outline-offset: 2px;
    border-radius: 2px;
}

.pbd-table a:visited {
    color: #6b006b;
}

/* ── No results row ── */
.pbd-no-results {
    text-align: center;
    padding: 1.5rem;
    color: #555555;
    font-style: italic;
}

/* ── Row count ── */
.pbd-count {
    font-size: 0.88rem;
    color: #555555;
    margin-top: 0.5rem;
}

/* ── Pagination ── */
.pbd-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    align-items: center;
    margin-top: 0.75rem;
}

.pbd-pagination button {
    padding: 0.6rem 0.85rem;       /* ensures ~44px tall touch target (2.5.5) */
    font-size: 0.9rem;
    border: 2px solid #767676;
    border-radius: 4px;
    background: #ffffff;
    color: #333333;
    cursor: pointer;
    min-width: 44px;               /* minimum 44px wide (2.5.5) */
    min-height: 44px;              /* minimum 44px tall  (2.5.5) */
    text-align: center;
    line-height: 1.2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.pbd-pagination button:hover {
    background: #f9e8eb;
    border-color: #9e1b32;         /* border change = non-text contrast indicator (1.4.11) */
    border-width: 3px;
    color: #7a1526;
}

.pbd-pagination button:focus {
    outline: 3px solid #9e1b32;
    outline-offset: 2px;
}

.pbd-pagination button[aria-current="page"],
.pbd-pagination button.pbd-page-active {
    background: #9e1b32;
    color: #ffffff;
    border-color: #9e1b32;
    font-weight: 700;
    cursor: default;
}

.pbd-pagination button[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ── Screen-reader only utility ── */
.pbd-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ── Hidden rows (filtered/paginated out) ── */
.pbd-row-hidden {
    display: none;
}

/* =============================================
   Responsive: stack table on small screens
   ============================================= */
@media (max-width: 680px) {

    .pbd-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .pbd-search-input {
        min-width: unset;
        width: 100%;
    }

    /* Switch to card layout */
    .pbd-table,
    .pbd-table thead,
    .pbd-table tbody,
    .pbd-table thead th,
    .pbd-table tbody td,
    .pbd-table tbody tr {
        display: block;
    }

    .pbd-table thead tr {
        display: none; /* headers become data-label attributes */
    }

    .pbd-table tbody tr {
        margin-bottom: 1rem;
        border: 1px solid #d0d0d0;
        border-radius: 4px;
        overflow: hidden;
    }

    .pbd-table tbody td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 0.5rem;
        border-right: none;
        border-bottom: 1px solid #e8e8e8;
        padding: 0.5rem 0.75rem;
    }

    .pbd-table tbody td::before {
        content: attr(data-label);
        font-weight: 700;
        color: #9e1b32;
        flex-shrink: 0;
        min-width: 110px;
        font-size: 0.85rem;
        padding-top: 1px;
    }

    .pbd-table tbody td:last-child {
        border-bottom: none;
    }

    .pbd-pagination {
        justify-content: center;
    }
}
