﻿/** * Copyright (c) 2026 DNA Genics, S.L. All rights reserved.
 * 
 * Gene SNP Information Partial Styling
 * Modern, professional design for gene cards within trait reports.
 * Uses the ti-* warm palette design system.
 */

/* ========================================
   Gene Card Container
   ======================================== */
.ti-gene-info {
    background: white;
    border-radius: var(--ti-radius-lg);
    overflow: hidden;
    margin-bottom: 0;
    max-width: 100%;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

/* Allow grid/flex children to shrink (prevents horizontal overflow on mobile) */
.ti-gene-card-wrapper,
.ti-gene-card {
    min-width: 0;
}

/* ========================================
   Gene Header Section
   ======================================== */
.ti-gene-header {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--ti-cream) 0%, #F5F0EB 100%);
    border-bottom: 1px solid rgba(196, 164, 132, 0.15);
}

.ti-gene-icon-wrapper {
    flex-shrink: 0;
}

.ti-gene-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--ti-terracotta), var(--ti-terracotta-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--ti-shadow-md);
    position: relative;
    overflow: hidden;
}

.ti-gene-icon::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.2) 0%, transparent 50%);
    border-radius: 50%;
}

.ti-gene-icon img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    filter: brightness(0) invert(1);
    position: relative;
    z-index: 1;
}

.ti-gene-content {
    flex: 1;
    min-width: 0;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.ti-gene-name {
    font-family: var(--ti-font-display);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--ti-charcoal);
    margin: 0 0 0.5rem 0;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.ti-gene-link {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--ti-terracotta);
    background: rgba(196, 164, 132, 0.1);
    border: 1px solid rgba(196, 164, 132, 0.2);
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    text-decoration: none;
    transition: all var(--ti-transition);
    white-space: nowrap;
}

.ti-gene-link:hover {
    background: var(--ti-terracotta);
    color: white;
    border-color: var(--ti-terracotta);
    text-decoration: none;
}

.ti-gene-link i {
    font-size: 0.65rem;
}

/* ========================================
   Gene Description
   ======================================== */
.ti-gene-description {
    font-size: 0.9rem;
    line-height: 1.7;
    color: var(--ti-gray-700);
    margin: 0;
    padding: 0.75rem 1rem;
    padding-left: 1rem;
    border-left: 3px solid var(--ti-terracotta-light);
    background: rgba(196, 164, 132, 0.03);
    border-radius: 0 var(--ti-radius-sm) var(--ti-radius-sm) 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}

/* ========================================
   Chromosome Location Section
   ======================================== */
.ti-gene-location {
    padding: 1.25rem 1.5rem;
    background: white;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.ti-location-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.ti-location-header i {
    color: var(--ti-terracotta);
    font-size: 0.875rem;
}

.ti-location-header h5 {
    font-family: var(--ti-font-display);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ti-charcoal);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ti-location-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.ti-location-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    background: var(--ti-gray-100);
    padding: 0.5rem 0.875rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--ti-gray-700);
}

.ti-location-badge strong {
    color: var(--ti-charcoal);
    font-weight: 700;
}

.ti-location-badge.chromosome {
    background: linear-gradient(135deg, var(--ti-terracotta), var(--ti-terracotta-dark));
    color: white;
}

.ti-location-badge.chromosome strong {
    color: white;
}

/* ========================================
   Chromosome Position Indicator
   ======================================== */
.ti-chromosome-indicator {
    background: var(--ti-cream);
    border-radius: var(--ti-radius);
    padding: 1rem 1.25rem;
    border: 1px solid var(--ti-gray-200);
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.ti-chromosome-bar-container {
    position: relative;
    padding: 0.5rem 0;
}

.ti-chromosome-bar {
    height: 16px;
    background: linear-gradient(90deg, 
        var(--ti-gray-200) 0%,
        var(--ti-gray-200) 45%,
        var(--ti-gray-300) 48%,
        var(--ti-gray-300) 52%,
        var(--ti-gray-200) 55%,
        var(--ti-gray-200) 100%
    );
    border-radius: 8px;
    position: relative;
    overflow: visible;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Centromere pinch effect */
.ti-chromosome-bar::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 20px;
    background: var(--ti-cream);
    border-radius: 4px;
    z-index: 2;
}

.ti-chromosome-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 8px;
    background: linear-gradient(180deg, 
        rgba(255, 255, 255, 0.4) 0%,
        transparent 40%,
        rgba(0, 0, 0, 0.05) 100%
    );
    pointer-events: none;
}

.ti-gene-position-marker {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 100%;
    background: linear-gradient(135deg, var(--ti-sage), var(--ti-sage-dark));
    border-radius: 4px;
    min-width: 8px;
    box-shadow: 0 0 8px rgba(135, 168, 120, 0.5);
    z-index: 1;
}

.ti-gene-position-marker::before {
    content: '';
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--ti-sage);
}

.ti-chromosome-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.7rem;
    color: var(--ti-gray-500);
    font-weight: 500;
}

/* ========================================
   SNP Table Section
   ======================================== */
.ti-snp-section {
    padding: 1.25rem 1.5rem;
    background: white;
    border-top: 1px solid var(--ti-gray-100);
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.ti-snp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.ti-snp-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ti-snp-title i {
    color: var(--ti-terracotta);
    font-size: 0.875rem;
}

.ti-snp-title h5 {
    font-family: var(--ti-font-display);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ti-charcoal);
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ti-snp-count {
    font-size: 0.75rem;
    color: var(--ti-gray-500);
    background: var(--ti-gray-100);
    padding: 0.25rem 0.625rem;
    border-radius: 12px;
    font-weight: 600;
}

/* ========================================
   SNP Table
   ======================================== */
.ti-snp-table-wrapper {
    border-radius: var(--ti-radius);
    overflow-x: auto;
    overflow-y: hidden;
    border: 1px solid var(--ti-gray-200);
    max-width: 100%;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
}

.ti-snp-table {
    width: 100%;
    margin: 0;
    border-collapse: collapse;
}

.ti-snp-table thead th {
    background: linear-gradient(135deg, var(--ti-charcoal), var(--ti-charcoal-light));
    color: white;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 0.875rem 1rem;
    text-align: center;
    border: none;
    white-space: nowrap;
}

.ti-snp-table thead th:first-child {
    text-align: left;
}

.ti-snp-table tbody tr {
    border-bottom: 1px solid var(--ti-gray-100);
    transition: background-color var(--ti-transition-fast);
}

.ti-snp-table tbody tr:last-child {
    border-bottom: none;
}

.ti-snp-table tbody tr:hover {
    background: var(--ti-cream);
}

.ti-snp-table tbody td {
    padding: 0.875rem 1rem;
    font-size: 0.875rem;
    vertical-align: middle;
    border: none;
    text-align: center;
}

.ti-snp-table tbody td:first-child {
    text-align: left;
}

/* SNP Row - Summary */
.ti-snp-row {
    cursor: pointer;
    position: relative;
}

.ti-snp-row.expanded {
    background: rgba(196, 164, 132, 0.05);
}

.ti-snp-row .ti-snp-id {
    font-weight: 700;
    color: var(--ti-terracotta);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ti-snp-row .ti-snp-id i {
    font-size: 0.7rem;
    color: var(--ti-gray-400);
    transition: transform var(--ti-transition);
}

.ti-snp-row.expanded .ti-snp-id i {
    transform: rotate(90deg);
}

/* Genotype Display */
.ti-genotype {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.9rem;
    font-weight: 700;
}

.ti-genotype-allele {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    background: var(--ti-gray-100);
    color: var(--ti-charcoal);
}

.ti-genotype-allele.variant {
    background: linear-gradient(135deg, var(--ti-sage), var(--ti-sage-dark));
    color: white;
}

/* Variant Badge */
.ti-variant-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.ti-variant-badge.detected {
    background: rgba(135, 168, 120, 0.15);
    color: var(--ti-sage-dark);
}

.ti-variant-badge.detected i {
    color: var(--ti-sage);
}

.ti-variant-badge.not-detected {
    background: var(--ti-gray-100);
    color: var(--ti-gray-500);
}

/* ========================================
   Expanded Details Row
   ======================================== */
.ti-snp-details {
    display: none;
    background: var(--ti-cream);
}

.ti-snp-details.visible {
    display: table-row;
}

.ti-snp-details-cell {
    padding: 0 !important;
}

.ti-snp-details-content {
    padding: 1rem 1.5rem;
    animation: tiSlideDown 0.3s ease;
}

@keyframes tiSlideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ti-details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.ti-detail-item {
    background: white;
    border-radius: var(--ti-radius-sm);
    padding: 0.875rem;
    border: 1px solid var(--ti-gray-200);
}

.ti-detail-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ti-gray-500);
    margin-bottom: 0.25rem;
}

.ti-detail-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ti-charcoal);
}

.ti-detail-value.mono {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}

/* ========================================
   Empty State
   ======================================== */
.ti-snp-empty {
    text-align: center;
    padding: 2rem;
    color: var(--ti-gray-500);
}

.ti-snp-empty i {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    opacity: 0.5;
    color: var(--ti-terracotta-light);
}

.ti-snp-empty p {
    margin: 0;
    font-size: 0.875rem;
}

/* ========================================
   Responsive Design
   ======================================== */
@media (max-width: 991.98px) {
    .ti-gene-info {
        border-radius: var(--ti-radius);
    }
    
    .ti-gene-header {
        padding: 1.25rem 1rem;
    }
    
    .ti-gene-location,
    .ti-snp-section {
        padding: 1rem;
    }
    
    .ti-chromosome-indicator {
        padding: 0.875rem 1rem;
    }
}

@media (max-width: 767.98px) {
    .ti-gene-header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 1rem;
        gap: 1rem;
    }
    
    .ti-gene-name {
        justify-content: center;
        font-size: 1.25rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .ti-gene-description {
        border-left: none;
        border-top: 3px solid var(--ti-terracotta-light);
        border-radius: var(--ti-radius-sm);
        text-align: left;
        font-size: 0.85rem;
        padding: 0.75rem;
    }
    
    .ti-gene-location,
    .ti-snp-section {
        padding: 0.875rem;
    }
    
    .ti-location-header,
    .ti-snp-title {
        justify-content: center;
    }
    
    .ti-location-header h5,
    .ti-snp-title h5 {
        font-size: 0.75rem;
    }
    
    .ti-location-badges {
        justify-content: center;
        gap: 0.375rem;
    }
    
    .ti-location-badge {
        font-size: 0.7rem;
        padding: 0.375rem 0.625rem;
    }
    
    .ti-chromosome-indicator {
        padding: 0.75rem;
    }
    
    .ti-chromosome-bar {
        height: 12px;
    }
    
    .ti-chromosome-bar::before {
        width: 6px;
        height: 16px;
    }
    
    .ti-chromosome-labels {
        font-size: 0.65rem;
    }
    
    .ti-snp-table {
        width: 100%;
        min-width: 0;
    }
    
    .ti-snp-table thead th {
        padding: 0.625rem 0.5rem;
        font-size: 0.65rem;
        white-space: normal;
        line-height: 1.2;
    }
    
    .ti-snp-table tbody td {
        padding: 0.625rem 0.5rem;
        font-size: 0.8rem;
    }

    /* Mobile table: keep only SNP + Genotype + Status (details available on expand) */
    .ti-snp-table thead th:nth-child(3),
    .ti-snp-table thead th:nth-child(4),
    .ti-snp-table thead th:nth-child(5),
    .ti-snp-table tbody td:nth-child(3),
    .ti-snp-table tbody td:nth-child(4),
    .ti-snp-table tbody td:nth-child(5) {
        display: none;
    }
    
    .ti-genotype-allele {
        width: 20px;
        height: 20px;
        font-size: 0.75rem;
    }
    
    .ti-variant-badge {
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
    }
    
    .ti-variant-badge i {
        font-size: 0.6rem;
    }
    
    .ti-details-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
    
    .ti-snp-details-content {
        padding: 0.75rem;
    }
    
    .ti-detail-item {
        padding: 0.625rem;
    }
    
    .ti-detail-label {
        font-size: 0.6rem;
    }
    
    .ti-detail-value {
        font-size: 0.8rem;
    }
    
    .ti-snp-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: center;
        text-align: center;
    }
    
    .ti-snp-count {
        font-size: 0.7rem;
    }
}

@media (max-width: 575.98px) {
    .ti-gene-icon {
        width: 48px;
        height: 48px;
    }
    
    .ti-gene-icon img {
        width: 28px;
        height: 28px;
    }
    
    .ti-gene-name {
        font-size: 1.1rem;
    }
    
    .ti-gene-link {
        font-size: 0.7rem;
        padding: 0.25rem 0.625rem;
    }
    
    .ti-gene-description {
        font-size: 0.8rem;
        line-height: 1.6;
    }
    
    .ti-snp-table {
        width: 100%;
        min-width: 0;
    }
    
    .ti-details-grid {
        grid-template-columns: 1fr;
    }
    
    .ti-snp-row .ti-snp-id {
        font-size: 0.8rem;
    }
    
    .ti-snp-row .ti-snp-id i {
        font-size: 0.6rem;
    }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .ti-gene-info {
        page-break-inside: avoid;
        border: 1px solid var(--ti-gray-300);
    }
    
    .ti-gene-header {
        background: var(--ti-cream) !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .ti-snp-row {
        cursor: default;
    }
    
    .ti-snp-row .ti-snp-id i {
        display: none;
    }
    
    .ti-snp-details {
        display: table-row !important;
    }
    
    .ti-gene-link {
        display: none;
    }
    
    .ti-chromosome-indicator {
        border: 1px solid var(--ti-gray-300);
    }
}

/* ========================================
   Accessibility - Focus States
   ======================================== */
.ti-snp-row:focus-visible {
    outline: 3px solid var(--ti-terracotta-light);
    outline-offset: -3px;
}

.ti-gene-link:focus-visible {
    outline: 3px solid var(--ti-terracotta-light);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .ti-gene-info {
        border: 2px solid currentColor;
    }
    
    .ti-snp-table tbody tr {
        border-bottom: 1px solid currentColor;
    }
    
    .ti-variant-badge.detected {
        border: 2px solid currentColor;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .ti-snp-row .ti-snp-id i,
    .ti-snp-details-content,
    .ti-gene-link {
        transition: none;
        animation: none;
    }
}

