/* ==========================================================================
   Resources — Frontend styles (light theme only)
   ========================================================================== */

.rsr-wrapper {
    --rsr-bg:           #ffffff;
    --rsr-bg-alt:       #f9fafb;
    --rsr-border:       #e5e7eb;
    --rsr-border-soft:  #f3f4f6;
    --rsr-text:         #1f2937;
    --rsr-text-soft:    #6b7280;
    --rsr-text-strong:  #111827;
    --rsr-accent:       #2563eb;
    --rsr-accent-hover: #1d4ed8;
    --rsr-radius:       8px;
    --rsr-shadow:       0 1px 3px rgba( 0, 0, 0, 0.05 );

    margin: 1.5rem 0;
    color: var( --rsr-text );
    font-family: inherit;
    line-height: 1.5;
}

.rsr-title {
    margin: 0 0 0.25rem;
    font-size: 1.5rem;
    font-weight: 600;
    color: var( --rsr-text-strong );
}

.rsr-subtitle {
    margin: 0 0 1rem;
    color: var( --rsr-text-soft );
    font-size: 0.95rem;
}

.rsr-empty {
    padding: 1rem;
    background: var( --rsr-bg-alt );
    border: 1px dashed var( --rsr-border );
    border-radius: var( --rsr-radius );
    color: var( --rsr-text-soft );
    text-align: center;
}

/* ---------- Controls (search) ---------- */

.rsr-controls {
    display: flex;
    justify-content: flex-end;
    margin: 0 0 0.75rem;
}

.rsr-search-input {
    padding: 8px 12px;
    border: 1px solid var( --rsr-border );
    border-radius: 6px;
    font-size: 0.875rem;
    background: var( --rsr-bg );
    color: var( --rsr-text );
    min-width: 220px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.rsr-search-input:focus {
    outline: none;
    border-color: var( --rsr-accent );
    box-shadow: 0 0 0 3px rgba( 37, 99, 235, 0.12 );
}

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

.rsr-table-wrap {
    overflow-x: auto;
    border-radius: var( --rsr-radius );
    border: 1px solid var( --rsr-border );
    box-shadow: var( --rsr-shadow );
    background: var( --rsr-bg );
    -webkit-overflow-scrolling: touch;
}

.rsr-table {
    width: 100%;
    border-collapse: collapse;
    background: var( --rsr-bg );
    margin: 0;
}

/* thead colours come from inline <style> emitted by PHP per resource */
.rsr-table thead {
    background: var( --rsr-bg-alt );
}

.rsr-table th {
    text-align: left;
    padding: 14px 16px;
    font-weight: 600;
    color: var( --rsr-text-strong );
    border-bottom: 2px solid var( --rsr-border );
    white-space: nowrap;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.rsr-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var( --rsr-border-soft );
    vertical-align: middle;
    font-size: 0.9375rem;
}

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

.rsr-table tbody tr:hover {
    background: var( --rsr-bg-alt );
}

/* ---------- Striped option ---------- */

.rsr-striped .rsr-table tbody tr:nth-child( even ) {
    background: var( --rsr-bg-alt );
}

.rsr-striped .rsr-table tbody tr:nth-child( even ):hover {
    background: var( --rsr-border-soft );
}

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

.rsr-table th.rsr-sortable {
    cursor: pointer;
    user-select: none;
    padding-right: 28px;
    position: relative;
}

.rsr-table th.rsr-sortable:hover {
    background: rgba( 0, 0, 0, 0.04 );
}

.rsr-sort-indicator {
    position: absolute;
    right: 12px;
    top: 50%;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    transform: translateY( -50% );
    opacity: 0.3;
    transition: opacity 0.15s;
}

.rsr-sort-indicator::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 6px;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid currentColor;
}

.rsr-sort-indicator {
    border-bottom: 5px solid currentColor;
    color: currentColor;
}

.rsr-table th.rsr-sortable.rsr-sorted-asc .rsr-sort-indicator {
    opacity: 1;
}
.rsr-table th.rsr-sortable.rsr-sorted-asc .rsr-sort-indicator::before {
    display: none;
}
.rsr-table th.rsr-sortable.rsr-sorted-desc .rsr-sort-indicator {
    opacity: 1;
    border-bottom: none;
    border-top: 5px solid currentColor;
    height: 0;
}

/* Per-column visual tweaks */

.rsr-table th[data-type="sr_no"],
.rsr-table td[data-type="sr_no"] {
    width: 64px;
    text-align: center;
    font-weight: 500;
    color: var( --rsr-text-soft );
}

.rsr-table th[data-type="size"],
.rsr-table td[data-type="size"],
.rsr-table th[data-type="type"],
.rsr-table td[data-type="type"],
.rsr-table th[data-type="date"],
.rsr-table td[data-type="date"] {
    white-space: nowrap;
    color: var( --rsr-text-soft );
    font-size: 0.875rem;
    width: 1%;
}

.rsr-table th[data-type="download"],
.rsr-table td[data-type="download"] {
    width: 1%;
    white-space: nowrap;
}

.rsr-text {
    line-height: 1.55;
}

.rsr-meta-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 8px;
    margin-top: 8px;
}

.rsr-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    background: var( --rsr-bg-alt );
    border: 1px solid var( --rsr-border );
    border-radius: 999px;
    font-size: 0.75rem;
    color: var( --rsr-text-soft );
    line-height: 1.4;
}

.rsr-chip strong {
    color: var( --rsr-text-strong );
    font-weight: 600;
}

.rsr-no-file,
.rsr-empty-results td {
    color: var( --rsr-text-soft );
    text-align: center;
}

.rsr-empty-results td {
    padding: 24px !important;
    font-style: italic;
}

.rsr-file-link {
    color: var( --rsr-accent );
    text-decoration: none;
    font-weight: 500;
    word-break: break-all;
}

.rsr-file-link:hover {
    text-decoration: underline;
}

/* ---------- Download button ---------- */

.rsr-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 8px 16px;
    background: var( --rsr-accent );
    color: #fff !important;
    text-decoration: none !important;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.2;
    transition: background-color 0.15s ease, transform 0.05s ease;
    white-space: nowrap;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba( 0, 0, 0, 0.06 );
}

.rsr-btn:hover,
.rsr-btn:focus {
    background: var( --rsr-accent-hover );
    color: #fff !important;
    text-decoration: none !important;
}

.rsr-btn:focus-visible {
    outline: 2px solid var( --rsr-accent );
    outline-offset: 2px;
}

.rsr-btn:active {
    transform: translateY( 1px );
}

.rsr-icon {
    display: inline-flex;
    align-items: center;
    line-height: 0;
}

.rsr-svg {
    display: block;
}

/* ---------- Pagination ---------- */

.rsr-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 1rem;
}

.rsr-pagination button {
    padding: 6px 14px;
    background: var( --rsr-bg );
    border: 1px solid var( --rsr-border );
    border-radius: 6px;
    color: var( --rsr-text );
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.rsr-pagination button:hover:not( :disabled ) {
    background: var( --rsr-bg-alt );
    border-color: var( --rsr-text-soft );
}

.rsr-pagination button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.rsr-page-info {
    color: var( --rsr-text-soft );
    font-size: 0.875rem;
    min-width: 100px;
    text-align: center;
}

/* ==========================================================================
   Responsive — switch to card layout on small screens
   ========================================================================== */

@media ( max-width: 640px ) {

    .rsr-table-wrap {
        overflow: visible;
        border: none;
        background: transparent;
        box-shadow: none;
        border-radius: 0;
    }

    .rsr-table,
    .rsr-table thead,
    .rsr-table tbody,
    .rsr-table tr,
    .rsr-table th,
    .rsr-table td {
        display: block;
        width: 100%;
    }

    .rsr-table thead {
        position: absolute;
        left: -9999px;
        top: -9999px;
        visibility: hidden;
    }

    .rsr-table tbody tr {
        background: var( --rsr-bg );
        border: 1px solid var( --rsr-border );
        border-radius: var( --rsr-radius );
        margin-bottom: 12px;
        padding: 4px 0;
        box-shadow: var( --rsr-shadow );
    }

    .rsr-striped .rsr-table tbody tr:nth-child( even ) {
        background: var( --rsr-bg );
    }

    .rsr-table tbody tr:hover {
        background: var( --rsr-bg );
    }

    .rsr-table td {
        border-bottom: 1px solid var( --rsr-border-soft );
        padding: 10px 14px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        width: auto;
    }

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

    .rsr-table td::before {
        content: attr( data-label );
        font-weight: 600;
        color: var( --rsr-text-soft );
        font-size: 0.7rem;
        text-transform: uppercase;
        letter-spacing: 0.06em;
        flex-shrink: 0;
        min-width: 90px;
    }

    .rsr-table td .rsr-cell-value {
        text-align: right;
        word-break: break-word;
    }

    .rsr-table td[data-type="textarea"],
    .rsr-table td[data-type="text"] {
        flex-direction: column;
        align-items: stretch;
    }

    .rsr-table td[data-type="textarea"]::before,
    .rsr-table td[data-type="text"]::before {
        margin-bottom: 6px;
    }

    .rsr-table td[data-type="textarea"] .rsr-text,
    .rsr-table td[data-type="text"] .rsr-text {
        text-align: left;
    }

    .rsr-table td[data-type="sr_no"] {
        background: var( --rsr-bg-alt );
        border-top-left-radius: var( --rsr-radius );
        border-top-right-radius: var( --rsr-radius );
    }

    .rsr-controls {
        justify-content: stretch;
    }

    .rsr-search-input {
        width: 100%;
        min-width: 0;
    }
}

@media ( max-width: 380px ) {

    .rsr-table td[data-type="download"] {
        flex-direction: column;
        align-items: stretch;
    }

    .rsr-table td[data-type="download"]::before {
        margin-bottom: 6px;
    }

    .rsr-btn {
        width: 100%;
    }
}
