/* Compact Heatmap Styles - Headers/Text Match Stats Table, Centered and Uniform Width */
/* CRITICAL: Rainbow colors are BASE styles, direction colors override WITHOUT !important */

.compact-heatmap-section {
    margin: 20px 0;
    padding: 15px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    overflow-x: auto;
    max-width: 100%;
}

.compact-heatmap-section h3 {
    margin: 0 0 15px 0;
    color: #495057;
    font-size: 1.1rem;
    padding-bottom: 10px;
    border-bottom: 2px solid #146DA4;
}

.compact-table-container {
    overflow-x: auto;
    margin-top: 15px;
    max-width: 100%;
}

.compact-heatmap-table {
    border-collapse: collapse;
    font-size: 0.75rem;
}

/* Headers - EXACTLY match stats table, CENTERED */
.compact-heatmap-table thead {
    background: linear-gradient(135deg, #495057 0%, #343a40 100%);
    color: white;
}

.compact-heatmap-table thead tr th {
    padding: 6px 8px;
    text-align: center;
    font-weight: 600;
    font-size: 0.7rem;
    border: 1px solid #333;
    white-space: nowrap;
    vertical-align: middle;
}

/* Group headers - BASE STYLE (no !important on background) */
.compact-heatmap-table th[colspan] {
    text-align: center;
    font-weight: 700;
    font-size: 0.7rem;
    border-left: 2px solid #333;
    border-right: 2px solid #333;
    padding: 6px 8px;
    line-height: 1.3;
    color: white;
    background: #666; /* Default gray - will be overridden by classes */
}

/* Table rows - match stats table */
.compact-heatmap-table tbody tr {
    border-bottom: 1px solid #dee2e6;
}

.compact-heatmap-table tbody tr:nth-child(even) {
    background: #f8f9fa;
}

.compact-heatmap-table tbody tr:hover {
    background: #e9ecef;
}

/* Default cell styling - CENTERED */
.compact-heatmap-table td {
    padding: 4px 6px;
    border: 1px solid #dee2e6;
    font-size: 0.7rem;
    text-align: center;
}

/* ID column - centered */
.compact-heatmap-table td:first-child {
    padding: 4px 6px;
    position: sticky;
    left: 0;
    background: white;
    z-index: 1;
    font-weight: normal;
    font-size: 0.7rem;
    white-space: nowrap;
    border-right: 1px solid #dee2e6;
    text-align: center;
}

.compact-heatmap-table tbody tr:nth-child(even) td:first-child {
    background: #f8f9fa;
}

.compact-heatmap-table tbody tr:hover td:first-child {
    background: #e9ecef;
}

/* Name column - centered */
.compact-heatmap-table td:nth-child(2) {
    padding: 4px 6px;
    font-weight: normal;
    font-size: 0.7rem;
    white-space: nowrap;
    border-right: 1px solid #dee2e6;
    text-align: center;
}

/* Hits column - centered */
.compact-heatmap-table .hits-count {
    text-align: center;
    font-weight: normal;
    color: #495057;
    padding: 4px 6px;
    font-size: 0.7rem;
    white-space: nowrap;
    border-right: 2px solid #495057;
}

/* Data cells - OVERRIDE default td styling to stay compact */
.compact-heatmap-table .data-cell {
    width: 5px !important;
    height: 12px !important;
    min-width: 5px !important;
    min-height: 12px;
    max-width: 5px !important;
    max-height: 12px;
    padding: 0 !important;
    border: 0.5px solid rgba(0, 0, 0, 0.15) !important;
    text-align: center;
    cursor: help;
    position: relative;
    overflow: hidden;
}

.compact-heatmap-table .data-cell.group-start {
    border-left: 1px solid #666 !important;
}

.compact-heatmap-table .data-cell.group-end {
    border-right: 1px solid #666 !important;
}

.compact-heatmap-table tbody tr:nth-child(odd) .data-cell[data-group="0"],
.compact-heatmap-table tbody tr:nth-child(odd) .data-cell[data-group="2"],
.compact-heatmap-table tbody tr:nth-child(odd) .data-cell[data-group="4"],
.compact-heatmap-table tbody tr:nth-child(odd) .data-cell[data-group="6"] {
    background-color: rgba(0,0,0,0.02);
}

.compact-heatmap-table tbody tr:nth-child(even) .data-cell[data-group="1"],
.compact-heatmap-table tbody tr:nth-child(even) .data-cell[data-group="3"],
.compact-heatmap-table tbody tr:nth-child(even) .data-cell[data-group="5"] {
    background-color: rgba(0,0,0,0.02);
}

.compact-heatmap-table .data-cell:hover {
    outline: 5px solid #146DA4;
    outline-offset: 0px;
    z-index: 50;
    box-shadow: 0 0 8px rgba(20, 109, 164, 0.6);
}

/* Stats table styling - CENTERED with uniform column widths */
.stats-table {
    margin-top: 20px;
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
    overflow-x: auto;
    display: block;
    border: 1px solid #dee2e6;
}

.stats-table thead {
    background: linear-gradient(135deg, #495057 0%, #343a40 100%);
    color: white;
}

.stats-table th {
    padding: 6px 8px;
    text-align: center;
    border: 1px solid #333;
    font-weight: 600;
    white-space: normal;
    font-size: 0.7rem;
    line-height: 1.3;
    vertical-align: middle;
}

.stats-table td {
    padding: 4px 6px;
    border: 1px solid #dee2e6;
    font-size: 0.7rem;
    text-align: center;
}

/* Uniform width for hit comparison columns */
.stats-table th:nth-child(10),
.stats-table th:nth-child(11),
.stats-table th:nth-child(12),
.stats-table th:nth-child(13),
.stats-table td:nth-child(10),
.stats-table td:nth-child(11),
.stats-table td:nth-child(12),
.stats-table td:nth-child(13) {
    width: 90px;
    min-width: 90px;
    max-width: 90px;
}

.stats-table tbody tr:nth-child(even) {
    background: #f8f9fa;
}

.stats-table tbody tr:hover {
    background: #e9ecef;
}

.stats-table tbody tr td:nth-child(8) strong {
    color: #28a745;
    font-weight: 700;
}

.stats-table tbody tr td:nth-child(6),
.stats-table tbody tr td:nth-child(7) {
    font-family: monospace;
}

/* Clickable group headers */
.compact-heatmap-table th[colspan].filter-active {
    position: relative;
}

.compact-heatmap-table th[colspan].filter-active::after {
    content: " ▼";
    font-size: 0.8em;
}

/* ===== RAINBOW COLORS - BASE PRIORITY (no !important) ===== */
/* These apply by default but can be overridden by direction classes */

.compact-heatmap-table th[colspan].group-color-0 {
    background: #146DA4;
}

.compact-heatmap-table th[colspan].group-color-1 {
    background: #770c19;
}

.compact-heatmap-table th[colspan].group-color-2 {
    background: #59A14D;
}

.compact-heatmap-table th[colspan].group-color-3 {
    background: #725E9C;
}

.compact-heatmap-table th[colspan].group-color-4 {
    background: #DCE77D;
}

.compact-heatmap-table th[colspan].group-color-5 {
    background: #FFD392;
}

.compact-heatmap-table th[colspan].group-color-6 {
    background: #FFA97D;
}

.compact-heatmap-table th[colspan].group-color-7 {
    background: #FF775C;
}

.compact-heatmap-table th[colspan].group-color-8 {
    background: #D4A5A5;
}

.compact-heatmap-table th[colspan].group-color-9 {
    background: #84939D;
}

.compact-heatmap-table th[colspan].group-color-10 {
    background: #AA96DA;
}

.compact-heatmap-table th[colspan].group-color-11 {
    background: #A0E2F2;
}

.compact-heatmap-table th[colspan].group-color-12 {
    background: #C06C84;
}

.compact-heatmap-table th[colspan].group-color-13 {
    background: #355C7D;
}

/* ===== DIRECTION COLORS - HIGHER PRIORITY (override rainbow) ===== */
/* These are applied by JS when specific group + direction selected */

/* NEGATIVE ASSOCIATION - First column BLUE */
.compact-heatmap-table th[colspan].focus-negative {
    background: #146DA4 !important;
}

/* NEGATIVE ASSOCIATION - Other columns RED (vs cohort) */
.compact-heatmap-table th[colspan].focus-negative-other-cohort {
    background: #770c19 !important;
}

/* NEGATIVE ASSOCIATION - Control column RED (vs control) */
.compact-heatmap-table th[colspan].focus-negative-control {
    background: #770c19 !important;
}

/* POSITIVE ASSOCIATION - First column RED */
.compact-heatmap-table th[colspan].focus-positive {
    background: #770c19 !important;
}

/* POSITIVE ASSOCIATION - Other columns BLUE (vs cohort) */
.compact-heatmap-table th[colspan].focus-positive-other-cohort {
    background: #146DA4 !important;
}

/* POSITIVE ASSOCIATION - Control column BLUE (vs control) */
.compact-heatmap-table th[colspan].focus-positive-control {
    background: #146DA4 !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .compact-heatmap-table .data-cell {
        width: 2px !important;
        min-width: 2px !important;
        max-width: 2px !important;
        height: 10px !important;
    }
}

@media print {
    .compact-heatmap-table .data-cell {
        width: 2px !important;
        min-width: 2px !important;
        max-width: 2px !important;
        border: none;
    }
    
    .compact-heatmap-table .data-cell:hover {
        transform: none;
        outline: none;
    }
}