/* ==========================================================================
   WntHub Layout System - Sidebar + Tabs + Panels
   Loaded AFTER styles.css to override layout-specific styles
   ========================================================================== */

/* Override body for app layout */
body {
    overflow: hidden;
    height: 100vh;
    margin: 0;
    padding: 0;
}

/* Hide old navbar and hero - replaced by sidebar + tabs */
body > .navbar,
.hero-section,
.site-footer {
    display: none !important;
}

/* Remove old main content padding that assumed fixed navbar */
.main-content {
    padding-top: 0;
    margin-top: 0;
}

/* ==========================================================================
   App Layout - Flexbox Shell
   ========================================================================== */

.app-layout {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* ==========================================================================
   Sidebar
   ========================================================================== */

.sidebar {
    width: 260px;
    height: 100vh;
    background: #0f172a;
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    flex-shrink: 0;
    z-index: 100;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar.collapsed {
    width: 60px;
}

/* Sidebar Header */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    color: #fff;
    font-size: 1.25rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-brand i {
    font-size: 1.25rem;
    color: #818cf8;
    flex-shrink: 0;
}

.sidebar-brand-text {
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar.collapsed .sidebar-brand-text {
    display: none;
}

.sidebar-toggle {
    background: rgba(255, 255, 255, 0.06);
    border: none;
    color: #94a3b8;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    font-size: 0.75rem;
}

.sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.12);
    color: #fff;
}

.sidebar.collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

/* Sidebar Sections */
.sidebar-section {
    padding: 0.875rem 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.sidebar.collapsed .sidebar-section {
    padding: 0.5rem;
}

.sidebar-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-label i {
    flex-shrink: 0;
    font-size: 0.75rem;
}

.sidebar.collapsed .sidebar-label span {
    display: none;
}

/* Gene Selector in Sidebar */
.sidebar-gene-select {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
    font-size: 0.8125rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    outline: none;
    transition: all 0.2s;
    cursor: pointer;
}

.sidebar-gene-select:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 2px rgba(129, 140, 248, 0.25);
}

.sidebar-gene-select option {
    background: #1e293b;
    color: #e2e8f0;
}

.sidebar.collapsed .sidebar-gene-select {
    display: none;
}

/* Gene Info Card */
.gene-info-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0;
    color: #475569;
    font-size: 0.75rem;
    text-align: center;
}

.gene-info-placeholder i {
    font-size: 1.25rem;
}

.sidebar.collapsed .gene-info-placeholder span,
.sidebar.collapsed #sidebar-gene-info .gene-info-details {
    display: none;
}

.gene-info-details {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.gene-info-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.75rem;
    gap: 0.5rem;
}

.gene-info-key {
    color: #64748b;
    font-weight: 500;
    white-space: nowrap;
}

.gene-info-value {
    color: #e2e8f0;
    font-weight: 600;
    text-align: right;
    word-break: break-all;
}

.gene-info-name {
    font-size: 1.125rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.25rem;
}

.gene-info-fullname {
    font-size: 0.6875rem;
    color: #94a3b8;
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

/* Quick Links */
.quick-links-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.375rem;
}

.quick-link {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.5rem;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    color: #94a3b8;
    font-size: 0.6875rem;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
}

.quick-link:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
}

.quick-link i {
    flex-shrink: 0;
    font-size: 0.625rem;
}

.sidebar.collapsed .quick-links-grid {
    display: none;
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem;
}

.sidebar-nav .sidebar-label {
    padding: 0 0.5rem;
}

.sidebar-nav-btn {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: none;
    background: none;
    color: #94a3b8;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-nav-btn i {
    flex-shrink: 0;
    width: 18px;
    text-align: center;
    font-size: 0.875rem;
}

.sidebar-nav-btn:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #e2e8f0;
}

.sidebar-nav-btn.active {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
}

.sidebar.collapsed .sidebar-nav-btn span {
    display: none;
}

.sidebar.collapsed .sidebar-nav-btn {
    justify-content: center;
    padding: 0.625rem;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.sidebar-logo {
    height: 44px;
    width: auto;          /* derive width from the image's intrinsic aspect ratio */
    object-fit: contain;  /* belt + suspenders: never distort */
    opacity: 0.7;
    transition: opacity 0.2s;
}

.sidebar-logo:hover {
    opacity: 1;
}

.sidebar.collapsed .sidebar-logo {
    display: none;
}

.sidebar-about-link {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    color: #64748b;
    font-size: 0.75rem;
    text-decoration: none;
    transition: color 0.2s;
}

.sidebar-about-link:hover {
    color: #e2e8f0;
}

.sidebar.collapsed .sidebar-about-link span {
    display: none;
}

/* ==========================================================================
   Main Area
   ========================================================================== */

.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0; /* prevent flex overflow */
    background: var(--light-bg, #f8fafc);
}

/* ==========================================================================
   Tab Bar
   ========================================================================== */

.wh-tab-bar {
    background: #fff;
    border-bottom: 2px solid #e2e8f0;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.wh-tab-bar-inner {
    display: flex;
    gap: 0;
    overflow-x: auto;
    padding: 0 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.wh-tab-bar-inner::-webkit-scrollbar {
    height: 3px;
}

.wh-tab-bar-inner::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.wh-tab-btn {
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    color: #64748b;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: all 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.wh-tab-btn i {
    font-size: 0.75rem;
}

.wh-tab-btn.active {
    color: #6366f1;
    border-bottom-color: #6366f1;
    font-weight: 600;
}

.wh-tab-btn:hover:not(.active) {
    color: #334155;
    background: #f8fafc;
}

/* ==========================================================================
   Tab Content & Panels
   ========================================================================== */

.wh-tab-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 #f1f5f9;
}

.wh-tab-content::-webkit-scrollbar {
    width: 6px;
}

.wh-tab-content::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.wh-tab-panel {
    display: none;
    padding: 1.5rem;
    min-height: 100%;
}

.wh-tab-panel.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Panel System (Phase 1 - Static panels with fullscreen)
   ========================================================================== */

.panel {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    margin-bottom: 1.5rem;
    overflow: hidden;
    transition: box-shadow 0.2s;
}

.panel:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    gap: 0.75rem;
}

.panel-title {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.panel-controls {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.panel-btn {
    background: none;
    border: 1px solid #e2e8f0;
    color: #64748b;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 0.75rem;
}

.panel-btn:hover {
    background: #f1f5f9;
    color: #334155;
    border-color: #cbd5e1;
}

.panel-body {
    padding: 1rem;
}

/* Panel Fullscreen Mode */
.panel.fullscreen {
    position: fixed;
    inset: 0;
    z-index: 1050;
    border-radius: 0;
    margin: 0;
    border: none;
    display: flex;
    flex-direction: column;
}

.panel.fullscreen .panel-header {
    flex-shrink: 0;
}

.panel.fullscreen .panel-body {
    flex: 1;
    overflow-y: auto;
}

.panel.fullscreen .panel-fullscreen-btn i::before {
    content: "\f066"; /* fa-compress */
}

/* Fullscreen overlay backdrop */
/* Backdrop no longer used — fullscreen cards are moved to document.body */

/* ==========================================================================
   Overview Tab
   ========================================================================== */

.overview-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 1200px) {
    .overview-grid {
        grid-template-columns: 1fr 1fr;
    }

    .overview-grid > .panel:first-child {
        grid-column: 1 / -1;
    }
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
}

.stat-card {
    text-align: center;
    padding: 1.25rem 0.75rem;
    background: linear-gradient(135deg, #f8fafc 0%, #eef2ff 100%);
    border-radius: 8px;
    border: 1px solid #e0e7ff;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #6366f1;
    line-height: 1;
    margin-bottom: 0.375rem;
}

.stat-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ==========================================================================
   Data Card Overrides (make existing cards work in panel layout)
   ========================================================================== */

/* Override category sections to remove old container padding */
.category-section {
    padding: 0 !important;
    margin: 0 !important;
}

.category-section > .container {
    max-width: 100% !important;
    padding: 0 !important;
}

/* ==========================================================================
   Loading Overlay (keep existing but adjust z-index)
   ========================================================================== */

.loading-overlay {
    z-index: 2000;
}

/* ==========================================================================
   AI Assistant Chat Widget (Floating)
   ========================================================================== */

.ai-chat-widget-btn {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    z-index: 1000;
    transition: all 0.3s;
}

.ai-chat-widget-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 20px rgba(99, 102, 241, 0.5);
}

.ai-chat-widget-btn.has-badge::after {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 12px;
    height: 12px;
    background: #10b981;
    border-radius: 50%;
    border: 2px solid #fff;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Medium screens — compact tab bar */
@media (max-width: 1100px) {
    .wh-tab-btn {
        font-size: 0.75rem;
        padding: 0.625rem 0.625rem;
        gap: 0.25rem;
    }
}

/* Small screens — icon-only tabs */
@media (max-width: 900px) {
    .wh-tab-btn span,
    .wh-tab-btn {
        font-size: 0;
    }
    .wh-tab-btn i {
        font-size: 0.875rem;
    }
    .wh-tab-btn {
        padding: 0.75rem 0.875rem;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -260px;
        z-index: 200;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
        transition: left 0.3s ease;
    }

    .sidebar.mobile-open {
        left: 0;
    }

    .sidebar.collapsed {
        left: -60px;
    }

    .main-area {
        margin-left: 0 !important;
    }

    .wh-tab-panel {
        padding: 0.75rem;
    }

    /* Mobile menu toggle */
    .mobile-menu-btn {
        display: flex;
    }

    /* Stack expression grid to single column */
    .bulk-charts-grid {
        grid-template-columns: 1fr !important;
        grid-auto-rows: 250px;
    }

    /* Overview cards single column */
    .overview-cards-grid {
        grid-template-columns: 1fr;
    }

    .overview-hero-title {
        font-size: 1.5rem;
    }
}

@media (min-width: 769px) {
    .mobile-menu-btn {
        display: none;
    }
}

/* Mobile Menu Button */
.mobile-menu-btn {
    position: fixed;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 201;
    background: #0f172a;
    color: #e2e8f0;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Mobile overlay when sidebar is open */
.mobile-sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 199;
    display: none;
}

.sidebar.mobile-open ~ .mobile-sidebar-overlay {
    display: block;
}

/* ==========================================================================
   Overview Hero Tab
   ========================================================================== */

.overview-hero {
    max-width: 1100px;
    margin: 0 auto;
}

.overview-hero-header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 1.5rem 0 0.5rem;
}

.overview-hero-title {
    font-size: 2.25rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 1rem;
    line-height: 1.2;
}

.overview-hero-subtitle {
    font-size: 1rem;
    color: #64748b;
    max-width: 700px;
    margin: 0 auto;
    line-height: 1.6;
}

.overview-cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
    margin-bottom: 2rem;
}

@media (max-width: 900px) {
    .overview-cards-grid { grid-template-columns: 1fr; }
    .overview-hero-title { font-size: 1.75rem; }
}

.overview-info-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.overview-info-card h5 {
    font-size: 0.9375rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.625rem;
}

.overview-info-card p {
    font-size: 0.8125rem;
    color: #475569;
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.overview-info-card-accent {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border: none;
}

.overview-info-card-accent h5,
.overview-info-card-accent p,
.overview-info-card-accent small,
.overview-info-card-accent strong {
    color: #fff;
}

.overview-info-card-ai {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
    color: #fff;
    border: none;
}

.overview-info-card-ai h5,
.overview-info-card-ai p,
.overview-info-card-ai small {
    color: #fff;
}

.overview-source-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.25rem 1rem;
    font-size: 0.8125rem;
    color: #475569;
}

.overview-steps {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
    margin-top: 0.5rem;
}

.overview-step {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.overview-step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    font-weight: 700;
    font-size: 0.8125rem;
    flex-shrink: 0;
}

.overview-footer {
    text-align: center;
    padding: 1.5rem 0;
    color: #94a3b8;
    font-size: 0.8125rem;
}

.overview-footer a {
    color: #6366f1;
    text-decoration: none;
}

.overview-footer a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Bulk Expression Charts Grid (kitchen-sink layout)
   ========================================================================== */

.bulk-charts-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-auto-rows: 300px;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

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

@media (max-width: 768px) {
    .bulk-charts-grid {
        grid-template-columns: 1fr;
        grid-auto-rows: 280px;
    }
}

/* Base card in grid */
.bulk-charts-grid .data-card {
    margin-bottom: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0; /* let grid control height */
}

.bulk-charts-grid .data-card .card-header {
    padding: 0.375rem 0.625rem;
    flex-shrink: 0;
}

.bulk-charts-grid .data-card .card-header h4 {
    font-size: 0.8125rem !important;
}

.bulk-charts-grid .data-card .card-body {
    padding: 0.125rem;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.bulk-charts-grid .data-card .card-body > div {
    width: 100%;
    height: 100%;
}

/* Size variants via grid span */
.bulk-charts-grid .chart-card-tall {
    grid-row: span 2;
}

.bulk-charts-grid .chart-card-wide {
    grid-column: span 2;
}

.bulk-charts-grid .chart-card-wide-tall {
    grid-column: span 2;
    grid-row: span 2;
}

/* Tall cards: scrollable body for bar charts with many labels */
.bulk-charts-grid .chart-card-tall .card-body {
    overflow-y: auto;
    overflow-x: hidden;
}

/* Plotly chart containers */
.bulk-charts-grid .js-plotly-plot {
    width: 100% !important;
}

/* Prevent Plotly SVG from overflowing card boundaries */
.bulk-charts-grid .js-plotly-plot .main-svg {
    overflow: hidden;
}

.bulk-charts-grid .plot-container {
    overflow: hidden;
}

/* Plotly modebar (toolbar) styling */
.js-plotly-plot .modebar {
    opacity: 0;
    transition: opacity 0.2s;
}

.js-plotly-plot:hover .modebar {
    opacity: 1;
}

.js-plotly-plot .modebar-btn {
    font-size: 14px !important;
}

/* ==========================================================================
   Compact Stat Bar
   ========================================================================== */

.wh-stat-bar {
    display: flex;
    gap: 0.75rem;
    padding: 0.35rem 0.75rem;
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.6875rem;
    color: #64748b;
    flex-wrap: wrap;
}

.wh-stat strong {
    font-weight: 700;
    color: #334155;
}

.wh-stat-pos strong { color: #10b981; }
.wh-stat-neg strong { color: #ef4444; }
.wh-stat-sig strong { color: #f59e0b; }

/* ==========================================================================
   Export Buttons (PNG / SVG / CSV)
   ========================================================================== */

.wh-export-group {
    display: flex;
    gap: 2px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    overflow: hidden;
}

.wh-export-btn {
    background: #fff !important;
    color: #64748b !important;
    border: none !important;
    border-radius: 0 !important;
    padding: 0.15rem 0.45rem !important;
    font-size: 0.625rem !important;
    font-weight: 500 !important;
    line-height: 1.3 !important;
    display: flex !important;
    align-items: center !important;
    gap: 3px !important;
    box-shadow: none !important;
    transition: background 0.15s, color 0.15s !important;
    cursor: pointer !important;
}

.wh-export-btn:hover {
    background: #f1f5f9 !important;
    color: #334155 !important;
}

.wh-export-btn i {
    font-size: 0.5625rem;
}

.wh-export-group .wh-export-btn + .wh-export-btn {
    border-left: 1px solid #e2e8f0 !important;
}

/* ==========================================================================
   Track Catalog (IGV.js track selector)
   ========================================================================== */

.track-cat-section {
    margin-bottom: 0.5rem;
}

.track-cat-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    padding: 0.25rem 0;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.track-cat-header i {
    font-size: 0.5rem;
    transition: transform 0.2s;
    width: 10px;
}

.track-cat-items.collapsed {
    display: none;
}

.track-cat-items.collapsed + .track-cat-header i,
.track-cat-header:has(+ .collapsed) i {
    transform: rotate(-90deg);
}

.track-cat-items {
    padding-left: 1rem;
    padding-top: 0.25rem;
}

.track-cat-item {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.6875rem;
    color: #334155;
    cursor: pointer;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    margin-right: 0.25rem;
    margin-bottom: 0.125rem;
    white-space: nowrap;
}

.track-cat-item:hover {
    background: #e2e8f0;
}

.track-cat-item input[type="checkbox"] {
    accent-color: #6366f1;
    margin: 0;
}

/* Track info tooltips */
.track-info-tip {
    color: #94a3b8;
    font-size: 0.6rem;
    margin-left: 0.2rem;
    position: relative;
    text-decoration: none;
}

.track-info-tip:hover {
    color: #6366f1;
}

.track-info-tip:hover::after {
    content: attr(data-tip);
    position: absolute;
    top: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: #f1f5f9;
    font-size: 0.625rem;
    font-weight: 400;
    line-height: 1.4;
    padding: 0.375rem 0.5rem;
    border-radius: 4px;
    white-space: normal;
    width: 220px;
    z-index: 1000;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.track-info-tip:hover::before {
    content: '';
    position: absolute;
    top: calc(100% + 2px);
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-bottom-color: #1e293b;
    z-index: 1000;
    pointer-events: none;
}

/* General info-tip icon (reusable across tables, headers, etc.)
   Uses JS-driven tooltip appended to document.body to escape all
   stacking contexts (sticky headers, overflow:hidden, etc.) */
.col-info-tip {
    color: #94a3b8;
    font-size: 0.55rem;
    margin-left: 0.2rem;
    cursor: help;
    text-decoration: none;
    vertical-align: super;
}
.col-info-tip:hover { color: #6366f1; }

/* ChIP TF grid — uniform button sizes */
#chip-tf-list {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 3px;
}

.chip-tf-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.625rem;
    color: #334155;
    cursor: pointer;
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
    border: 1px solid #e2e8f0;
    background: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-height: 22px;
}

.chip-tf-item:hover {
    border-color: #818cf8;
    background: #eef2ff;
}

.chip-tf-item:has(input:checked) {
    border-color: #6366f1;
    background: #eef2ff;
    font-weight: 600;
}

.chip-tf-unavailable {
    opacity: 0.3;
    cursor: default;
    pointer-events: none;
    background: #f8fafc;
}

.chip-tf-item input[type="checkbox"] {
    accent-color: #6366f1;
    margin: 0;
    width: 10px;
    height: 10px;
    flex-shrink: 0;
}

/* Resizable track catalog / IGV split */
.track-catalog-resize-handle {
    height: 6px;
    background: #e2e8f0;
    cursor: ns-resize;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.track-catalog-resize-handle:hover {
    background: #818cf8;
}

.track-catalog-resize-handle::after {
    content: '';
    width: 30px;
    height: 2px;
    background: #94a3b8;
    border-radius: 1px;
}

.track-catalog-resize-handle:hover::after {
    background: #fff;
}

/* IGV.js browser card — allow overflow for popups/menus */
#igv-browser-container {
    overflow: visible !important;
}

#igv-browser-container .igv-container {
    overflow: visible !important;
}

/* Ensure the IGV parent card doesn't clip menus */
#igv-browser-container ~ .data-card,
#igv-browser-container .data-card {
    overflow: visible;
}

.genomic-context-container > .mb-5:first-child .data-card {
    overflow: visible !important;
}

.genomic-context-container > .mb-5:first-child .card-body {
    overflow: visible !important;
}

/* ==========================================================================
   Gridstack Overrides
   ========================================================================== */

/* Grid container */
.grid-stack {
    min-height: 200px;
}

/* Grid items */
.grid-stack-item-content {
    background: transparent;
    overflow: visible;
    inset: 8px; /* matches gridstack margin */
}

.grid-stack-item-content > .panel,
.grid-stack-item-content > .data-card,
.grid-stack-item-content > .mb-4,
.grid-stack-item-content > .mb-5 {
    height: 100%;
    overflow-y: auto;
    margin-bottom: 0 !important;
}

/* Drag handle */
.panel-drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 24px;
    color: #cbd5e1;
    cursor: grab;
    flex-shrink: 0;
    margin-right: 0.375rem;
    border-radius: 3px;
    transition: color 0.2s, background 0.2s;
    font-size: 0.75rem;
}

.panel-drag-handle:hover {
    color: #6366f1;
    background: rgba(99, 102, 241, 0.08);
}

.panel-drag-handle:active {
    cursor: grabbing;
}

/* Gridstack placeholder (drop target) */
.grid-stack-placeholder > .placeholder-content {
    border: 2px dashed #818cf8 !important;
    border-radius: 8px;
    background: rgba(99, 102, 241, 0.05) !important;
}

/* Resize handle styling */
.grid-stack-item > .ui-resizable-se {
    width: 20px;
    height: 20px;
    bottom: 4px;
    right: 4px;
    background: none;
    cursor: se-resize;
}

.grid-stack-item > .ui-resizable-se::after {
    content: '';
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 10px;
    height: 10px;
    border-right: 2px solid #cbd5e1;
    border-bottom: 2px solid #cbd5e1;
    border-radius: 0 0 2px 0;
    transition: border-color 0.2s;
}

.grid-stack-item:hover > .ui-resizable-se::after {
    border-color: #6366f1;
}

.grid-stack-item > .ui-resizable-sw {
    width: 20px;
    height: 20px;
    bottom: 4px;
    left: 4px;
    background: none;
    cursor: sw-resize;
}

/* Active dragging state */
.grid-stack-item.ui-draggable-dragging {
    z-index: 100;
    opacity: 0.9;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.grid-stack-item.ui-draggable-dragging > .grid-stack-item-content {
    border-radius: 8px;
    outline: 2px solid #818cf8;
}

/* Panel header adjustments for drag handle */
.panel-header,
.data-card .card-header {
    user-select: none; /* prevent text selection while dragging */
}

.panel-header .panel-drag-handle,
.card-header .panel-drag-handle {
    margin-right: 0.5rem;
}

/* Fullscreen panel should escape all parent layout */
.panel.fullscreen,
.data-card.fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    z-index: 10000 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    border: none !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    background: #fff !important;
}

.panel.fullscreen .panel-header,
.data-card.fullscreen .card-header {
    flex-shrink: 0;
}

.panel.fullscreen .panel-body,
.data-card.fullscreen .card-body {
    flex: 1;
    overflow: auto;
    position: relative;
    z-index: 1;
}

/* Structure viewer: fill available space in fullscreen */
.data-card.fullscreen .card-body {
    display: flex !important;
    flex-direction: column !important;
}
.data-card.fullscreen #prot-structure-container {
    height: auto !important;
    flex: 1 !important;
    min-height: 0 !important;
}

/* Tables: fill available space in fullscreen */
.data-card.fullscreen .card-body {
    max-height: none !important;
    overflow: auto !important;
}
.data-card.fullscreen .tv-container {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 !important;
    min-height: 0 !important;
    height: 100% !important;
}
.data-card.fullscreen .tv-table-wrap {
    max-height: none !important;
    flex: 1 !important;
    min-height: 0 !important;
    overflow: auto !important;
}

/* Ensure fullscreen icon shows compress when in fullscreen mode */
.data-card.fullscreen .panel-fullscreen-btn i,
.panel.fullscreen .panel-fullscreen-btn i {
    /* Icon class is toggled by JS */
}

/* ==========================================================================
   Skeleton Loading
   ========================================================================== */

@keyframes shimmer {
    0% { background-position: -400px 0; }
    100% { background-position: 400px 0; }
}

.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 400px 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 6px;
}

.skeleton-card {
    height: 200px;
    margin-bottom: 1rem;
}

.skeleton-text {
    height: 14px;
    margin-bottom: 0.5rem;
    width: 60%;
}

.skeleton-text-short {
    height: 14px;
    margin-bottom: 0.5rem;
    width: 30%;
}

/* Chart skeleton — mimics a bar chart */
.skeleton-chart {
    padding: 1rem;
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 100%;
    min-height: 180px;
}

.skeleton-bar {
    flex: 1;
    border-radius: 3px 3px 0 0;
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 400px 100%;
    animation: shimmer 1.5s infinite;
}

/* Table skeleton */
.skeleton-table {
    padding: 0.75rem;
}

.skeleton-row {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.skeleton-cell {
    height: 14px;
    flex: 1;
    border-radius: 3px;
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 400px 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-cell-wide { flex: 2; }
.skeleton-cell-narrow { flex: 0.5; }

/* Network/circle skeleton */
.skeleton-circle {
    border-radius: 50%;
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 400px 100%;
    animation: shimmer 1.5s infinite;
}

/* Summary paragraph skeleton */
.skeleton-paragraph {
    padding: 1rem;
}

.skeleton-line {
    height: 12px;
    margin-bottom: 0.5rem;
    border-radius: 3px;
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 400px 100%;
    animation: shimmer 1.5s infinite;
}

/* ==========================================================================
   Utility: Override old styles that conflict
   ========================================================================== */

/* The old navbar is removed, but override any styles applied to body */
body.modal-open {
    overflow: hidden;
}

/* Make sure enhanced gene selectors work in sidebar context */
.sidebar .enhanced-selector-wrapper {
    width: 100%;
}

.sidebar .enhanced-selector-wrapper .selector-dropdown {
    background: #1e293b;
    border-color: rgba(255, 255, 255, 0.15);
}

.sidebar .enhanced-selector-wrapper .selector-search {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.12);
    color: #e2e8f0;
}
