/**
 * ASD Genotype-Phenotype Analysis - Main Stylesheet
 *
 * Responsive, modern design with unified color scheme
 */

@import url('colors.css');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ==========================================================================
   RESET & BASE
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: var(--text-primary);
    background: var(--bg-secondary);
    line-height: 1.6;
    min-height: 100vh;
}

code, pre, .mono {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--color-primary-dark);
    text-decoration: underline;
}

/* ==========================================================================
   LAYOUT - Sidebar + Main Content
   ========================================================================== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
    width: 260px;
    background: var(--bg-dark);
    color: var(--text-inverse);
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
    transition: transform var(--transition-normal);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-inverse);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-logo svg {
    width: 28px;
    height: 28px;
}

.sidebar-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* Navigation */
.nav-section {
    padding: 1rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-section:last-child {
    border-bottom: none;
}

.nav-section-title {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0 1.5rem;
    margin-bottom: 0.5rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.5rem;
    color: var(--text-muted);
    font-size: 0.875rem;
    transition: all var(--transition-fast);
}

.nav-link:hover {
    color: var(--text-inverse);
    background: rgba(255, 255, 255, 0.05);
    text-decoration: none;
}

.nav-link.active {
    color: var(--text-inverse);
    background: rgba(255, 255, 255, 0.1);
    border-left: 3px solid var(--color-primary);
}

.nav-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* Main Content Area */
.main-content {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
}

/* Top Header Bar */
.top-bar {
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-light);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.breadcrumb-sep {
    color: var(--text-muted);
}

/* Search Box */
.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 0.5rem 1rem;
    width: 300px;
}

.search-box input {
    border: none;
    background: transparent;
    flex: 1;
    font-size: 0.875rem;
    outline: none;
}

.search-box svg {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    margin-right: 0.5rem;
}

/* Page Container */
.page-container {
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
}

/* ==========================================================================
   CARDS & PANELS
   ========================================================================== */
.card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    overflow: hidden;
}

.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
}

.card-body {
    padding: 1.5rem;
}

.card-footer {
    padding: 1rem 1.5rem;
    background: var(--bg-tertiary);
    border-top: 1px solid var(--border-light);
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border-light);
}

.stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-change {
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

.stat-change.positive { color: var(--color-present); }
.stat-change.negative { color: var(--color-absent); }

/* Info Box - used for "About This Page" sections */
.info-box {
    background: var(--bg-secondary);
    border-left: 4px solid var(--color-primary);
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.info-box h4 {
    margin: 0 0 0.5rem 0;
    color: var(--color-primary);
    font-weight: 600;
}

.info-box p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ==========================================================================
   TABLES
   ========================================================================== */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.875rem 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.data-table th {
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    background: var(--bg-tertiary);
}

.data-table tbody tr:hover {
    background: var(--bg-secondary);
}

.data-table td code {
    background: var(--bg-tertiary);
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
}

/* ==========================================================================
   STATUS BADGES
   ========================================================================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-present {
    background: var(--color-present-light);
    color: var(--color-present-dark);
}

.badge-absent {
    background: var(--color-absent-light);
    color: var(--color-absent-dark);
}

.badge-nr {
    background: var(--color-nr-light);
    color: var(--color-nr-dark);
}

.badge-warning {
    background: #fef3c7;
    color: #b45309;
}

/* Category badges */
.badge-cat-social { background: #ede9fe; color: #6d28d9; }
.badge-cat-rrb { background: #fce7f3; color: #be185d; }
.badge-cat-cognitive { background: #dbeafe; color: #1d4ed8; }
.badge-cat-motor { background: #ccfbf1; color: #0f766e; }
.badge-cat-emotional { background: #fef3c7; color: #b45309; }
.badge-cat-physical { background: #fee2e2; color: #b91c1c; }
.badge-cat-developmental { background: #e0e7ff; color: #4338ca; }

/* ==========================================================================
   VISUALIZATION CONTAINERS
   ========================================================================== */
.chart-container {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.chart-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.chart-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.chart-wrapper {
    width: 100%;
    min-height: 400px;
}

/* Full-width chart pages */
.chart-fullscreen {
    position: fixed;
    top: 0;
    left: 260px;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    z-index: 200;
    padding: 2rem;
}

/* ==========================================================================
   GENE REPORT CARDS (for validation reports)
   ========================================================================== */
.gene-report {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.gene-report-header {
    padding: 1rem 1.5rem;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gene-name {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-primary);
}

.paper-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.paper-card {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-light);
    border-left: 4px solid var(--color-primary);
}

.paper-card:last-child {
    border-bottom: none;
}

.paper-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.paper-title a {
    color: var(--text-primary);
}

.paper-title a:hover {
    color: var(--color-primary);
}

.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
    background: var(--bg-tertiary);
    padding: 0.875rem;
    border-radius: var(--radius-md);
    margin-bottom: 1rem;
}

.meta-item {
    text-align: center;
}

.meta-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    display: block;
    margin-bottom: 0.25rem;
}

.meta-value {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}

.phenotype-table {
    width: 100%;
    margin-top: 1rem;
}

.phenotype-table th,
.phenotype-table td {
    padding: 0.625rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.875rem;
}

.phenotype-table th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    background: var(--bg-tertiary);
}

.evidence-text {
    font-style: italic;
    color: var(--text-secondary);
    background: #fef9c3;
    padding: 0.125rem 0.375rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
}

.unmapped-findings {
    margin-top: 1rem;
    padding: 1rem;
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: var(--radius-md);
}

.unmapped-findings h5 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #b45309;
    margin-bottom: 0.5rem;
}

.unmapped-findings ul {
    margin: 0;
    padding-left: 1.5rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ==========================================================================
   TABS
   ========================================================================== */
.tab-container {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-light);
    margin-bottom: 1rem;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    border: none;
    background: none;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all var(--transition-fast);
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ==========================================================================
   LEGENDS
   ========================================================================== */
.legend {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-right: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-dot.square {
    border-radius: 2px;
}

.legend-dot.score-badge {
    width: auto;
    height: auto;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* ==========================================================================
   CLUSTER BADGES
   ========================================================================== */
.cluster-badge {
    display: inline-block;
    padding: 0.1rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    color: white;
}

.cluster-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 0.25rem;
}

/* ==========================================================================
   FILTER PANEL
   ========================================================================== */
.filter-panel {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 1rem;
    margin-bottom: 1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
}

/* ==========================================================================
   BUTTONS
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-dark);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-medium);
}

.btn-secondary:hover {
    background: var(--border-light);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
}

/* ==========================================================================
   FORMS & FILTERS
   ========================================================================== */
.filter-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.filter-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.filter-select {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-medium);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */
.mobile-nav-toggle {
    display: none;
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
}

.mobile-nav-toggle svg {
    width: 24px;
    height: 24px;
}

@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-nav-toggle {
        display: block;
    }

    .chart-fullscreen {
        left: 0;
    }
}

@media (max-width: 768px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .page-container {
        padding: 1rem;
    }

    .top-bar {
        padding: 1rem;
    }

    .search-box {
        width: 100%;
        margin-top: 1rem;
    }

    .filter-bar {
        flex-direction: column;
    }

    .meta-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-value {
        font-size: 1.5rem;
    }
}

/* Force all grids to single column on phones */
@media (max-width: 600px) {
    .page-container > div[style*="grid-template-columns"],
    .page-container div[style*="grid-template-columns"]:not(.stats-grid) {
        grid-template-columns: 1fr !important;
    }

    /* Ensure chart containers have minimum height on mobile */
    .chart-wrapper {
        min-height: 250px;
    }

    /* Tables need horizontal scroll */
    .data-table {
        display: block;
        overflow-x: auto;
    }

    /* Reduce padding on cards */
    .card, .chart-container {
        padding: 1rem;
    }

    /* Stack flex containers */
    .top-bar > div {
        flex-wrap: wrap;
    }

    .page-title {
        font-size: 1.25rem;
    }
}

/* ==========================================================================
   FOOTER
   ========================================================================== */
.site-footer {
    margin-top: 3rem;
    padding: 2rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-light);
}

.footer-content {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
}

.footer-disclaimer {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.6;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--accent-warning);
    text-align: left;
    margin-bottom: 1rem;
}

.footer-disclaimer strong {
    color: var(--text-secondary);
}

.footer-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.footer-separator {
    margin: 0 0.5rem;
    opacity: 0.5;
}

@media (max-width: 600px) {
    .site-footer {
        padding: 1.5rem 1rem;
    }

    .footer-disclaimer {
        font-size: 0.75rem;
    }
}

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.hidden { display: none; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* ==========================================================================
   Chart Explainer - "What you're seeing" blocks
   ========================================================================== */
.chart-explainer {
    background: #f0f9ff;
    border-left: 3px solid #0ea5e9;
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #334155;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.chart-explainer strong {
    color: #0369a1;
}

/* Print styles */
@media print {
    .sidebar, .top-bar, .mobile-nav-toggle {
        display: none;
    }

    .main-content {
        margin-left: 0;
    }

    .card {
        break-inside: avoid;
    }
}
