/* DataTable - TanStack Table styles for NiceGUI */

/* ---- Root & scroll containment ---- */

.data-table-root {
    max-width: 100%;
    box-sizing: border-box;
}

.dt-wrapper {
    max-width: 100%;
    box-sizing: border-box;
}

.dt-scroll-container {
    overflow-x: auto;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

.dt-table-container {
    overflow-x: clip;
    overflow-y: visible;
    min-width: fit-content;
}

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

.dt-table {
    border-collapse: separate;
    border-spacing: 0;
    width: max-content;
    min-width: 100%;
    font-family: inherit;
    font-size: 0.875rem;
    line-height: 1.4;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
}

/* Round corner cells so backgrounds follow the table radius */
.dt-table thead tr:first-child th:first-child {
    border-top-left-radius: 6px;
}
.dt-table thead tr:first-child th:last-child {
    border-top-right-radius: 6px;
}
.dt-table tbody tr:last-child td:first-child {
    border-bottom-left-radius: 6px;
}
.dt-table tbody tr:last-child td:last-child {
    border-bottom-right-radius: 6px;
}

/* Remove last row bottom border (table border handles it) */
.dt-table tbody tr:last-child td {
    border-bottom: none;
}

.dt-table th,
.dt-table td {
    padding: 8px 12px;
    text-align: left;
    white-space: nowrap;
    border-bottom: 1px solid #e0e0e0;
}

/* Dense mode */
.dt-dense th,
.dt-dense td {
    padding: 4px 8px;
    font-size: 0.8125rem;
}

/* ---- Header ---- */

.dt-table thead th {
    background-color: #fafafa;
    font-weight: 600;
    color: #333;
    position: sticky;
    top: 0;
    z-index: 3;
    border-bottom: 2px solid #e0e0e0;
    user-select: none;
}

.dt-header-label {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.dt-sortable {
    cursor: pointer;
}

.dt-sortable:hover {
    background-color: #f0f0f0;
}

.dt-sort-indicator {
    font-size: 0.65em;
    color: #1976d2;
}

/* ---- Grouped column headers ---- */

.dt-group-header-row th {
    text-align: center;
}

.dt-group-header {
    background-color: #e8eaf6;
    font-weight: 700;
    color: #283593;
    border-bottom: 2px solid #7986cb;
    text-align: center;
    padding: 4px 8px;
}

/* Column-level row under group headers */
.dt-group-header-row + tr th {
    border-bottom: 2px solid #e0e0e0;
    font-weight: 600;
    background-color: #fafafa;
}

/* Vertical separators between column groups */
.dt-group-border {
    border-right: 1px solid #e0e0e0;
}

/* ---- Filter row ---- */

.dt-filter-row th {
    background-color: #fafafa;
    padding: 4px 6px;
    border-bottom: 2px solid #e0e0e0;
    font-weight: normal;
}

.dt-filter-cell {
    vertical-align: middle;
}

.dt-filter-text-wrap {
    position: relative;
    width: 100%;
}

.dt-filter-text {
    width: 100%;
    box-sizing: border-box;
    padding: 3px 20px 3px 6px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 0.75rem;
    background: white;
}

.dt-filter-text:focus {
    outline: none;
    border-color: #1976d2;
}

.dt-filter-clear {
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    border: none;
    background: none;
    color: #999;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    border-radius: 50%;
}

.dt-filter-clear:hover {
    color: #333;
    background-color: #e0e0e0;
}

.dt-filter-select {
    width: 100%;
    box-sizing: border-box;
    padding: 3px 4px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 0.75rem;
    background: white;
}

.dt-filter-checkbox {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    white-space: nowrap;
    cursor: pointer;
}

.dt-filter-multi-wrap {
    position: relative;
    width: 100%;
}

.dt-filter-multi-btn {
    width: 100%;
    box-sizing: border-box;
    padding: 3px 6px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 0.75rem;
    background: white;
    text-align: left;
    cursor: pointer;
    color: #333;
}

.dt-filter-multi-btn:hover {
    border-color: #999;
}

.dt-filter-multi-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    min-width: 100%;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.12);
    z-index: 100;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px 0;
}

.dt-filter-multi-option {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    font-size: 0.75rem;
    cursor: pointer;
    white-space: nowrap;
}

.dt-filter-multi-option:hover {
    background-color: #f0f0f0;
}

/* ---- Body ---- */

.dt-row-even td {
    background-color: #ffffff;
}

.dt-row-odd td {
    background-color: #f8f9fa;
}

.dt-table tbody tr:hover td {
    background-color: #e3f2fd !important;
}

.dt-row-selected td {
    background-color: #bbdefb !important;
}

.dt-empty {
    text-align: center;
    color: #9e9e9e;
    padding: 24px 12px !important;
    font-style: italic;
}

/* ---- Sticky first column ---- */

.dt-sticky-col th:first-child,
.dt-sticky-col td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
}

.dt-sticky-col thead th:first-child {
    z-index: 4;
}

/* Explicit backgrounds for sticky cells */
.dt-sticky-col .dt-row-even td:first-child {
    background-color: #ffffff;
}

.dt-sticky-col .dt-row-odd td:first-child {
    background-color: #f8f9fa;
}

.dt-sticky-col tbody tr:hover td:first-child {
    background-color: #e3f2fd !important;
}

.dt-sticky-col .dt-row-selected td:first-child {
    background-color: #bbdefb !important;
}

/* Shadow on sticky column */
.dt-sticky-col th:first-child,
.dt-sticky-col td:first-child {
    box-shadow: 2px 0 4px -2px rgba(0,0,0,0.1);
}

/* ---- Badges ---- */

.dt-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8125em;
    font-weight: 500;
    line-height: 1.4;
    white-space: nowrap;
}

.dt-badge-wrap {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 3px;
    align-items: center;
}

.dt-gene-badge {
    padding: 2px 6px;
}

.dt-score-badge {
    padding: 2px 6px;
    font-variant-numeric: tabular-nums;
}

.dt-group-badge {
    background-color: #607d8b;
    color: white;
    font-size: 0.7em;
    padding: 1px 5px;
    border-radius: 8px;
    margin-left: 4px;
    vertical-align: middle;
}

/* ---- Validation badges ---- */

.dt-val-wrap {
    position: relative;
    display: inline-block;
}

.dt-val-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8125em;
    line-height: 1.4;
    white-space: nowrap;
    border: 1px solid rgba(0,0,0,0.08);
    cursor: default;
}

.dt-val-symbol {
    font-weight: 700;
    font-size: 1.05em;
}

.dt-val-text {
    font-weight: 600;
    font-size: 0.9em;
}

.dt-val-label {
    font-size: 0.8em;
    opacity: 0.8;
}

/* Validation tooltip (inline hidden source) */
.dt-val-tooltip {
    display: none;
}

/* Floating tooltip appended to body */
.dt-val-tooltip-floating {
    position: fixed;
    z-index: 10000;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 0;
    white-space: nowrap;
    pointer-events: none;
    overflow: hidden;
}

.dt-val-tooltip table {
    border-collapse: collapse;
    font-size: 0.75rem;
    line-height: 1.3;
}

.dt-val-tooltip th {
    background: #f5f5f5;
    font-weight: 600;
    padding: 3px 8px;
    border-bottom: 1px solid #e0e0e0;
    color: #555;
    text-align: left;
    position: static;
}

.dt-val-tooltip td {
    padding: 3px 8px;
    border-bottom: 1px solid #f0f0f0;
    color: #333;
}

/* ---- Diagnostic badges ---- */

.dt-diag-wrap {
    position: relative;
    display: inline-block;
}

.dt-diag-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8125em;
    line-height: 1.4;
    white-space: nowrap;
    border: 1px solid rgba(0,0,0,0.08);
    cursor: pointer;
}

.dt-diag-badge:hover {
    opacity: 0.85;
}

.dt-diag-symbol {
    font-weight: 700;
    font-size: 1.05em;
}

.dt-diag-text {
    font-weight: 600;
    font-size: 0.9em;
}

.dt-diag-add {
    color: #9e9e9e;
    cursor: pointer;
    font-size: 18px;
}

.dt-diag-add:hover {
    color: #616161;
}

/* ---- Action buttons ---- */

.dt-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.dt-action-btn:hover {
    background-color: rgba(0,0,0,0.08);
}

/* ---- Links ---- */

.dt-link {
    color: #1976d2;
    text-decoration: none;
    font-weight: 500;
}

.dt-link:hover {
    text-decoration: underline;
}

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

.dt-pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 8px 12px;
    gap: 16px;
    font-size: 0.8125rem;
    color: #666;
    border-top: 1px solid #e0e0e0;
}

.dt-pagination-info {
    color: #666;
}

.dt-rpp-wrap {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.dt-rpp-select {
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 2px 4px;
    font-size: 0.8125rem;
    background: white;
}

.dt-pagination-nav {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.dt-page-btn {
    background: none;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    padding: 2px;
    display: inline-flex;
    align-items: center;
    color: #333;
}

.dt-page-btn:hover:not(:disabled) {
    background-color: #f0f0f0;
}

.dt-page-btn:disabled {
    opacity: 0.4;
    cursor: default;
}

.dt-page-btn .material-icons {
    font-size: 20px;
}

.dt-page-info {
    padding: 0 4px;
    min-width: 48px;
    text-align: center;
}

/* ---- CSS Tooltips ---- */

[data-tooltip] {
    position: relative;
}

[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: calc(100% + 4px);
    left: 50%;
    transform: translateX(-50%);
    background: #424242;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: normal;
    white-space: nowrap;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* NiceGUI wrapper containment */
.overflow-x-hidden > * {
    max-width: 100%;
    box-sizing: border-box;
}
