/* One table look for every Browse view.
 *
 * ClinVar, OMIM, mutated regions, PPI and the region browser are all DataTables over
 * the same kind of data, and each had grown its own header weights, cell padding and
 * export-button colours. This is the region browser's styling — the one that reads
 * best — applied to all of them from a single file.
 *
 * Everything is a Bootstrap theme token, so it follows light and dark. The rules that
 * came before hardcoded `#fff` / `#212529` on the export buttons, which is what made
 * Copy / CSV / Excel unreadable in dark mode.
 */

/* ---- headers ---- */
table.dataTable thead th,
table.dataTable thead td {
    background-color: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
    font-weight: 600;
    font-size: 0.78rem;
    border-bottom: 2px solid var(--bs-border-color) !important;
    white-space: nowrap;
    vertical-align: middle;
}

/* ---- cells ---- */
table.dataTable tbody td {
    font-size: 0.84rem;
    vertical-align: middle;
    color: var(--bs-body-color);
    border-color: var(--bs-border-color);
}
table.dataTable tbody tr { background-color: var(--bs-body-bg); }
table.dataTable.table-hover tbody tr:hover > * {
    background-color: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
}

/* Striping and hover come from --bs-table-* in Bootstrap 5.3; without these the
   dark theme leaves the DataTables defaults (light greys) showing through. */
[data-bs-theme="dark"] table.dataTable {
    --bs-table-color: var(--bs-body-color);
    --bs-table-bg: var(--bs-body-bg);
    --bs-table-border-color: var(--bs-border-color);
    --bs-table-striped-color: var(--bs-body-color);
    --bs-table-hover-color: var(--bs-body-color);
    color: var(--bs-body-color);
}

/* ---- export buttons (Copy / CSV / Excel) ---- */
div.dt-buttons {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}
div.dt-buttons .btn,
div.dt-buttons .dt-button,
.dt-export-btn {
    margin: 0 !important;
    padding: 0.3rem 0.75rem !important;
    font-size: 0.8rem !important;
    font-weight: 600 !important;
    line-height: 1.35 !important;
    border-radius: 0.375rem !important;
    background: var(--bs-body-bg) !important;
    background-image: none !important;
    color: var(--bs-body-color) !important;
    border: 1px solid var(--bs-border-color) !important;
    box-shadow: none !important;
}
div.dt-buttons .btn:hover,
div.dt-buttons .dt-button:hover,
div.dt-buttons .dt-button:focus,
.dt-export-btn:hover,
.dt-export-btn:focus {
    background: var(--bs-primary) !important;
    background-image: none !important;
    color: #fff !important;
    border-color: var(--bs-primary) !important;
}

/* ---- DataTables chrome (length, filter, info, paging) ---- */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_processing,
.dataTables_wrapper .dataTables_paginate {
    color: var(--bs-body-color);
    font-size: 0.85rem;
}
.dataTables_wrapper .dataTables_length select,
.dataTables_wrapper .dataTables_filter input {
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
    border: 1px solid var(--bs-border-color);
    border-radius: 0.375rem;
    padding: 0.2rem 0.5rem;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    color: var(--bs-body-color) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--bs-primary) !important;
    border-color: var(--bs-primary) !important;
    color: #fff !important;
}
.dataTables_wrapper .dataTables_processing {
    background: var(--bs-body-bg) !important;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.5rem;
}

/* --------------------------------------------------------------------------
   The Results card — one frame for every table in Browse.

   Built around whatever DataTables produced (see discanvis_table_kit.js), so the
   five views share a heading, a row count, the export buttons and the column-filter
   switch without any of them having to agree on markup first.
   -------------------------------------------------------------------------- */
.dv-results-card {
    border: 1px solid var(--bs-border-color);
    border-radius: 0.75rem;
    background: var(--bs-body-bg);
    overflow: hidden;
    box-shadow: 0 0.125rem 0.5rem rgba(0, 0, 0, .06);
}
[data-bs-theme="dark"] .dv-results-card { box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, .25); }

.dv-results-head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--bs-border-color);
    background: var(--bs-body-bg);
}
.dv-results-icon {
    font-size: 1.5rem;
    width: 2rem; height: 2rem;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 0.35rem;
    background: var(--bs-tertiary-bg);
    color: var(--bs-primary);
    flex-shrink: 0;
}
.dv-results-title { font-weight: 600; font-size: 0.95rem; }
.dv-results-count { font-size: 0.82rem; color: var(--bs-secondary-color); }
/* Facet slot. Sits with the Column-filters switch on the right of the Results header,
   so every control that changes what the table shows is in one place. */
.dv-results-facets { display: flex; align-items: center; gap: 0.5rem; }
.dv-results-facets:not(:empty) { margin-left: auto; }
.dv-results-facets .dv-facet-label {
    font-size: 0.8rem; font-weight: 600; color: var(--bs-secondary-color);
    white-space: nowrap;
}
.dv-results-facets .dv-facet-select {
    font-size: 0.82rem;
    padding: 0.2rem 1.7rem 0.2rem 0.55rem;
    width: auto; max-width: 15rem;
    border-radius: 0.4rem;
}

.dv-results-toggle { margin-left: auto !important; display: flex; align-items: center; gap: 0.4rem; }
/* When a facet is present it owns the auto margin, so the switch sits beside it. */
.dv-results-facets:not(:empty) ~ .dv-results-toggle { margin-left: 0.75rem !important; }
.dv-results-toggle .form-check-input { margin: 0; float: none; }
.dv-results-toggle .form-check-label { white-space: nowrap; }

.dv-results-body { padding: 0.85rem 1rem 1rem; }
.dv-results-body .dataTables_wrapper { margin: 0; }

/* Column filter row. Kept visually quieter than the header it sits under, so the
   column names still read as the header. */
table.dv-table thead tr.dv-col-filters th {
    border-top: 0;
    padding: 0.3rem 0.4rem;
    font-weight: normal;
    background: var(--bs-body-bg);
}
table.dv-table thead tr.dv-col-filters input {
    width: 100%;
    min-width: 4rem;
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
    border: 1px solid var(--bs-border-color);
    border-radius: 0.25rem;
    background: var(--bs-body-bg);
    color: var(--bs-body-color);
}
table.dv-table thead tr.dv-col-filters input:focus {
    outline: 0;
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.15rem rgba(var(--bs-primary-rgb), .18);
}

/* A page card that now contains only the Results card is a border around a border.
   Flattened by the kit rather than edited out of four templates by hand. */
.dv-card-flat {
    border: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    border-radius: 0 !important;
}
