/* custom.css */

.table-scroll-wrapper {
    max-height: 400px;
    overflow-y: auto;
    scrollbar-width: thin;
    /* Firefox */
    scrollbar-color: #ccc transparent;
}

.table-scroll-wrapper::-webkit-scrollbar {
    width: 6px;
}

.table-scroll-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.table-scroll-wrapper::-webkit-scrollbar-thumb {
    background-color: #bbb;
    border-radius: 3px;
}

/* 🔥 Responsive table fix */
@media (max-width: 767.98px) {
    /* Lay the table out as plain blocks: a row left in table layout (e.g. a <tfoot>
       totals row) would otherwise squeeze every stacked card to the first column's width. */
    table:not(.table-summary),
    table:not(.table-summary) > tbody,
    table:not(.table-summary) > tfoot {
        display: block;
        width: 100% !important;
    }

    table:not(.table-summary) thead {
        display: none;
    }

    table:not(.table-summary) tbody tr,
    table:not(.table-summary) tfoot tr,
    table:not(.table-summary) tbody tr.odd,
    table:not(.table-summary) tfoot tr.odd,
    table:not(.table-summary) tbody tr.even,
    table:not(.table-summary) tfoot tr.even {
        display: block;
        margin-bottom: 0.85rem;
        border: 1px solid #e2e8f0 !important;
        border-radius: 10px;
        padding: 10px 14px;
        background: #ffffff !important;
        background-color: #ffffff !important;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
        transition: box-shadow 0.2s ease, border-color 0.2s ease;
    }

    table:not(.table-summary) tbody tr:hover,
    table:not(.table-summary) tfoot tr:hover {
        border-color: #cbd5e1 !important;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.06);
    }

    table:not(.table-summary) tbody td,
    table:not(.table-summary) tfoot td,
    table:not(.table-summary) tbody tr.odd > td,
    table:not(.table-summary) tfoot tr.odd > td,
    table:not(.table-summary) tbody tr.even > td,
    table:not(.table-summary) tfoot tr.even > td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 7px 0;
        border: none !important;
        border-bottom: 1px solid #f1f5f9 !important;
        font-size: 13px;
        color: #1e293b;
        background: transparent !important;
        background-color: transparent !important;
        box-shadow: none !important;
    }

    table:not(.table-summary) tbody td:last-child,
    table:not(.table-summary) tfoot td:last-child {
        border-bottom: none !important;
    }

    /* Labels */
    table:not(.table-summary) tbody td::before,
    table:not(.table-summary) tfoot td::before {
        content: attr(data-label);
        font-weight: 600;
        color: #64748b;
        flex-basis: 45%;
        flex-shrink: 0;
        text-align: left;
        white-space: nowrap;
        margin-right: 8px;
    }

    /* Hide pseudo-element when data-label is missing or empty */
    table:not(.table-summary) tbody td:not([data-label])::before,
    table:not(.table-summary) tfoot td:not([data-label])::before,
    table:not(.table-summary) tbody td[data-label=""]::before,
    table:not(.table-summary) tfoot td[data-label=""]::before {
        display: none !important;
    }

    /* Values */
    table:not(.table-summary) tbody td,
    table:not(.table-summary) tfoot td {
        word-break: normal;
        white-space: normal;
        overflow-wrap: anywhere;
        flex-basis: 55%;
        text-align: right;
    }

    table:not(.table-summary) tbody td:not([data-label]),
    table:not(.table-summary) tfoot td:not([data-label]),
    table:not(.table-summary) tbody td[data-label=""],
    table:not(.table-summary) tfoot td[data-label=""] {
        flex-basis: 100%;
        text-align: left;
    }

    td[data-label="Fund Description"] {
        text-align: left;
        margin-bottom: 4px;
    }

    /* Dark theme support */
    [data-bs-theme="dark"] table:not(.table-summary) tbody tr,
    [data-bs-theme="dark"] table:not(.table-summary) tfoot tr,
    [data-bs-theme="dark"] table:not(.table-summary) tbody tr.odd,
    [data-bs-theme="dark"] table:not(.table-summary) tfoot tr.odd,
    [data-bs-theme="dark"] table:not(.table-summary) tbody tr.even,
    [data-bs-theme="dark"] table:not(.table-summary) tfoot tr.even {
        background: #1e2229 !important;
        background-color: #1e2229 !important;
        border-color: #2e3440 !important;
    }

    [data-bs-theme="dark"] table:not(.table-summary) tbody td,
    [data-bs-theme="dark"] table:not(.table-summary) tfoot td,
    [data-bs-theme="dark"] table:not(.table-summary) tbody tr.odd > td,
    [data-bs-theme="dark"] table:not(.table-summary) tfoot tr.odd > td,
    [data-bs-theme="dark"] table:not(.table-summary) tbody tr.even > td,
    [data-bs-theme="dark"] table:not(.table-summary) tfoot tr.even > td {
        color: #e2e8f0;
        border-bottom-color: #2a303c !important;
    }

    [data-bs-theme="dark"] table:not(.table-summary) tbody td::before,
    [data-bs-theme="dark"] table:not(.table-summary) tfoot td::before {
        color: #94a3b8;
    }
}

/* 🔥 DataTables Top Bar Single-Line Responsive Layout */
div.dataTables_wrapper > div.row:first-child {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 10px !important;
    margin-bottom: 0.85rem !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

div.dataTables_wrapper > div.row:first-child > [class*="col-"] {
    width: auto !important;
    max-width: 100% !important;
    flex: 0 1 auto !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

div.dataTables_wrapper > div.row:first-child > [class*="col-"]:last-child {
    flex: 1 1 auto !important;
    display: flex !important;
    justify-content: flex-end !important;
}

.dataTables_length,
.dataTables_filter {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0 !important;
    font-size: 13.5px;
    color: var(--bs-body-color, #374151);
}

.dataTables_length label {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    margin-bottom: 0 !important;
    font-weight: 500;
    font-size: 13px !important;
    color: var(--bs-body-color, #4b5563);
    white-space: nowrap !important;
}

.dataTables_length select {
    /* Room on the right for the .form-select dropdown arrow, or it sits on top of the number. */
    padding: 4px 28px 4px 8px !important;
    min-width: 64px;
    height: 32px !important;
    border-radius: 6px !important;
    border: 1px solid var(--bs-border-color, #d1d5db);
    background-color: var(--bs-body-bg, #ffffff);
    color: var(--bs-body-color, #1f2937);
    font-size: 13px !important;
    font-weight: 500;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.dataTables_length select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.dataTables_filter {
    display: flex !important;
    justify-content: flex-end !important;
    width: 100% !important;
}

.dataTables_filter label {
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
    margin-bottom: 0 !important;
    font-weight: 500;
    font-size: 13px !important;
    color: var(--bs-body-color, #4b5563);
    width: 100% !important;
    max-width: 240px !important;
    justify-content: flex-end !important;
}

.dataTables_filter input {
    flex: 1 !important;
    min-width: 90px !important;
    max-width: 170px !important;
    height: 32px !important;
    padding: 4px 10px !important;
    border-radius: 6px !important;
    border: 1px solid var(--bs-border-color, #d1d5db);
    background-color: var(--bs-body-bg, #ffffff);
    color: var(--bs-body-color, #1f2937);
    font-size: 13px !important;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.dataTables_filter input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.dataTables_filter input::placeholder {
    color: var(--bs-secondary-color, #9ca3af);
}

.dataTables_filter button {
    padding: 4px 12px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: #0d6efd;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s ease;
}

.dataTables_filter button:hover {
    background: #0b5ed7;
}

@media (max-width: 420px) {
    .dataTables_length label,
    .dataTables_filter label {
        font-size: 12px !important;
        gap: 4px !important;
    }
    .dataTables_filter input {
        max-width: 120px !important;
    }
}

/* Dark mode support for top controls */
[data-bs-theme="dark"] .dataTables_length label,
[data-bs-theme="dark"] .dataTables_filter label {
    color: #94a3b8;
}

[data-bs-theme="dark"] .dataTables_length select {
    background-color: #1e2229;
    border-color: #334155;
    color: #f1f5f9;
}

[data-bs-theme="dark"] .dataTables_length select:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

[data-bs-theme="dark"] .dataTables_filter input {
    background-color: #1e2229;
    border-color: #334155;
    color: #f1f5f9;
}

[data-bs-theme="dark"] .dataTables_filter input:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}
