/* TCGA Hotspot Mutations Styling - CSS-Only Version */

.hotspot-table-container {
    width: 100%;
    overflow-x: auto;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    background: white;
    position: relative;
}

.hotspot-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
    font-size: 14px;
    margin: 0 auto;
}

.hotspot-table thead th {
    background: #495057;
    color: white;
    padding: 10px 8px;
    text-align: center;
    font-weight: 600;
    font-size: 13px;
    border: 1px solid #dee2e6;
    position: sticky;
    top: 0;
    z-index: 10;
}

.hotspot-table tbody tr {
    transition: background-color 0.2s ease;
}

.hotspot-table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

.hotspot-table tbody tr:hover {
    background-color: #e3f2fd;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Enhanced hover effect for mutation highlights */
.hotspot-table tbody tr:hover .aa.mutation-pos {
    transform: scale(1.1);
    box-shadow: 0 0 3px rgba(0, 0, 0, 0.3);
}

.hotspot-table td {
    padding: 6px 8px;
    border: 1px solid #dee2e6;
    vertical-align: middle;
    line-height: 1.3;
    text-align: center;
}

/* Column-specific styling - UPDATED for new column order */
.hotspot-table td:nth-child(1) { /* Gene */
    font-weight: 700;
    color: #2c5aa0;
    font-size: 1.15em;
}

.hotspot-table td:nth-child(2) { /* Transcript */
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #666;
}

.hotspot-table td:nth-child(3) { /* Variant */
    text-align: center;
}

.hotspot-table td:nth-child(4) { /* Frequency */
    font-weight: 600;
    color: #333;
    font-size: 0.95em;
}

.hotspot-table td:nth-child(5) { /* Cancer Types */
    font-size: 11px;
    min-width: 180px;
    max-width: 250px;
    word-wrap: break-word;
    word-break: break-word;
}

.hotspot-table td:nth-child(8) { /* Peptide Sequences */
    font-family: 'Courier New', monospace;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
    min-width: 380px;
    width: 380px;
    max-width: 380px;
    white-space: nowrap;
    position: relative;
    overflow: visible;
}

/* Variant cell styling */
.variant-cell {
    text-align: center;
    line-height: 1.4;
}

.variant-cell strong {
    font-size: 1.1em;
    color: #2c5aa0;
}

/* Peptide stack styling */
.peptide-stack {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.peptide-row {
    width: 100%;
    padding: 3px 6px;
    border-radius: 3px;
    font-size: 12px;
    font-family: 'Courier New', monospace;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    position: relative;
    box-sizing: border-box;
}

.peptide-row.normal {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
}

.peptide-row.mutated {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
}

/* Individual amino acid styling - NO PADDING to maintain character width */
.peptide-row .aa {
    display: inline;
    font-family: 'Courier New', monospace;
    font-size: inherit;
    font-weight: inherit;
    letter-spacing: normal;
    transition: all 0.2s ease;
}

/* Mutation position highlighting - NO PADDING, use background only */
.peptide-row.normal .aa.mutation-pos {
    background-color: #c8e6c9;
    color: #2e7d32;
    border-radius: 2px;
    font-weight: bold;
    outline: 1px solid #c8e6c9;
    outline-offset: -1px;
}

.peptide-row.mutated .aa.mutation-pos {
    background-color: #ffcdd2;
    color: #c62828;
    border-radius: 2px;
    font-weight: bold;
    outline: 1px solid #ffcdd2;
    outline-offset: -1px;
}

/* Highlight other differences (non-GGGS) - SAME colors as primary mutation */
.peptide-row.normal .aa.diff {
    background-color: #c8e6c9;
    color: #2e7d32;
    font-weight: 600;
    border-radius: 2px;
    outline: 1px solid #c8e6c9;
    outline-offset: -1px;
}

.peptide-row.mutated .aa.diff {
    background-color: #ffcdd2;
    color: #c62828;
    font-weight: 600;
    border-radius: 2px;
    outline: 1px solid #ffcdd2;
    outline-offset: -1px;
}

/* CSS-Only Expand/Collapse Functionality - FIXED */
.hotspot-expand-checkbox {
    display: none;
}

.hotspot-expand-label {
    display: block;
    text-align: center;
    background: #146DA4;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    margin: 10px auto;
    max-width: 300px;
    cursor: pointer;
    user-select: none;
}

.hotspot-expand-label .expand-text {
    display: inline;
}

.hotspot-expand-label .collapse-text {
    display: none;
}

.hotspot-expand-label .expand-icon {
    display: inline-block;
    margin-left: 8px;
    transition: transform 0.3s ease;
}

/* Hide extra rows by default */
.hotspot-row.hidden {
    display: none;
}

/* When checkbox is checked, show hidden rows */
.hotspot-expand-checkbox:checked ~ .hotspot-table .hotspot-row.hidden {
    display: table-row;
    animation: fadeIn 0.3s ease;
}

/* Update button appearance when expanded */
.hotspot-expand-checkbox:checked ~ .hotspot-expand-label {
    background: #EEAF94;
}

/* Swap text when expanded */
.hotspot-expand-checkbox:checked ~ .hotspot-expand-label .expand-text {
    display: none;
}

.hotspot-expand-checkbox:checked ~ .hotspot-expand-label .collapse-text {
    display: inline;
}

/* Rotate icon when expanded */
.hotspot-expand-checkbox:checked ~ .hotspot-expand-label .expand-icon {
    transform: rotate(180deg);
}

/* Hover effects for expand button */
.hotspot-expand-label:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.hotspot-expand-label:active {
    transform: translateY(0);
}

/* Animation for showing rows */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Legend for mutations */
.hotspot-legend {
    display: flex;
    justify-content: center;
    gap: 30px;
    margin: 15px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.hotspot-legend .legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: #495057;
}

.mutation-highlight-demo {
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-weight: bold;
}

.mutation-highlight-demo.normal {
    background-color: #c8e6c9;
    color: #2e7d32;
}

.mutation-highlight-demo.mutated {
    background-color: #ffcdd2;
    color: #c62828;
}

/* No data message */
.no-data {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 40px 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .hotspot-table-container {
        border-radius: 0;
        margin: 10px -15px;
    }
    
    .hotspot-table {
        font-size: 11px;
        min-width: 1050px;
    }
    
    .hotspot-table thead th,
    .hotspot-table td {
        padding: 6px 4px;
    }
    
    .hotspot-table td:nth-child(5) { /* Cancer Types */
        min-width: 200px;
        max-width: 280px;
        font-size: 10px;
    }
    
    .hotspot-table td:nth-child(8) { /* Peptide */
        font-size: 10px;
        min-width: 380px;
        width: 380px;
        max-width: 380px;
    }
    
    .peptide-row {
        font-size: 10px;
        padding: 2px 4px;
    }
    
    .hotspot-legend {
        flex-direction: column;
        gap: 10px;
        align-items: center;
    }
    
    .hotspot-expand-label {
        font-size: 12px;
        padding: 10px 18px;
        max-width: 250px;
    }
}

/* Cancer types cell styling with tooltip support */
.cancer-types {
    color: #495057;
    line-height: 1.3;
    position: relative;
}

.cancer-types[title] {
    cursor: help;
}

.cancer-types[title]:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 11px;
    white-space: normal;
    max-width: 300px;
    z-index: 100;
    pointer-events: none;
}

/* Peptide sequence styling */
.peptide-sequence {
    background: #f8f9fa;
    border-left: 3px solid #667eea;
    padding-left: 12px !important;
}

/* Loading state */
.hotspot-loading {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

.hotspot-loading::before {
    content: "⏳";
    display: inline-block;
    animation: spin 1s linear infinite;
    margin-right: 8px;
    font-size: 18px;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Print styles */
@media print {
    .hotspot-expand-checkbox,
    .hotspot-expand-label {
        display: none !important;
    }
    
    .hotspot-row.hidden {
        display: table-row !important;
    }
    
    .hotspot-table {
        font-size: 10px;
    }
    
    .peptide-row {
        font-size: 10px;
        padding: 2px 4px;
    }
}