/* ============================================
   GENOME PANEL
   Synergy visualization canvas and controls
   ============================================ */

/* Genome Canvas Container */
.genome-canvas-container {
    display: flex;
    flex-direction: column;
    padding: 10px 0;
    width: 100%;
    flex: 1 1 0%;
    min-height: 0;
    height: 100%;
    /* CRITICAL: Propagate height from parent */
    justify-content: flex-start;
    justify-content: flex-start;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

@media (max-width: 768px) {
    .genome-canvas-container {
        /* Ensure canvas has minimum height in stacked layout */
        min-height: 350px;
        /* Allow scrolling to see info panel below canvas */
        overflow-y: auto !important;
        overflow-x: hidden;
    }

    /* Larger, more tappable genome controls */
    .genome-controls-bar {
        gap: 6px;
        padding: 0 8px;
        flex-wrap: wrap;
    }

    .genome-controls-bar .toggle-btn {
        padding: 8px 12px;
        font-size: 0.75em;
        min-height: 36px;
    }

    .zoom-controls {
        padding: 4px 6px;
    }

    .zoom-btn {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }

    .genome-export-btn {
        padding: 8px;
        min-width: 36px;
        min-height: 36px;
    }
}

.genome-canvas {
    width: 100%;
    flex: 1 1 0%;
    min-height: 0;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.genome-canvas.interactive {
    cursor: grab;
}

.genome-canvas.interactive:active {
    cursor: grabbing;
}

.genome-canvas.fullscreen {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 1000;
    border-radius: 0;
}

.genome-hint {
    text-align: center;
    font-size: 0.75em;
    color: #666;
    margin: 0 0 8px 0;
    font-style: italic;
}

/* Canvas Wrapper */
.canvas-wrapper {
    position: relative;
    width: 100%;
    flex: 1 1 0%;
    display: flex;
    /* Use viewport-based min-height to ensure canvas never collapses */
    min-height: max(200px, 50vw);
    /* On wider screens, cap the min-height */
    max-height: 60vh;
}

/* Genome Controls Bar */
.genome-controls-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    width: 100%;
    padding: 0 10px;
    margin-bottom: 8px;
    box-sizing: border-box;
}

.genome-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 580px;
    padding: 0 10px;
    margin-bottom: 8px;
}

.genome-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.genome-toggle-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Zoom Controls */
.zoom-controls {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    padding: 4px 8px;
    border-radius: 6px;
}

.zoom-btn {
    width: 24px;
    height: 24px;
    border: 1px solid var(--button-border);
    background: transparent;
    color: var(--text-muted);
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.zoom-btn:hover {
    background: var(--accent-hover);
    color: var(--text-color);
    border-color: var(--accent-color);
}

.zoom-btn.reset {
    font-size: 12px;
}

.zoom-level {
    font-size: 0.75em;
    color: #888;
    min-width: 40px;
    text-align: center;
}

/* Floating Fullscreen Button */
.floating-fullscreen-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    width: 32px;
    height: 32px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 1.2em;
    transition: all 0.2s ease;
}

.floating-fullscreen-btn:hover {
    background: rgba(158, 158, 255, 0.4);
    border-color: var(--accent-color);
}

/* Fullscreen Controls */
.fullscreen-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 1001;
}

.fullscreen-action-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 18px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.fullscreen-action-btn:hover {
    transform: scale(1.1);
}

.fullscreen-action-btn.export:hover {
    background: rgba(100, 150, 255, 0.8);
}

.fullscreen-action-btn.close:hover {
    background: rgba(255, 100, 100, 0.8);
}

.fullscreen-close-btn {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    font-size: 20px;
    border-radius: 50%;
    cursor: pointer;
    z-index: 1001;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.fullscreen-close-btn:hover {
    background: rgba(255, 100, 100, 0.8);
    transform: scale(1.1);
}

/* Export Button */
.genome-export-btn {
    padding: 6px 12px;
    background: rgba(158, 158, 255, 0.15);
    border: 1px solid rgba(158, 158, 255, 0.4);
    border-radius: 6px;
    color: var(--accent-color);
    font-size: 0.8em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.genome-export-btn:hover {
    background: rgba(158, 158, 255, 0.25);
    border-color: var(--accent-color);
}

/* Genome Info Panel */
.genome-info-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    min-height: 200px;
    /* max-height: 400px; <-- REMOVED to allow expansion */
    /* overflow-y: auto;  <-- REMOVED to avoid double scroll */
    margin-top: 10px;
    background: rgba(0, 0, 0, 0.6);
    border-left: 4px solid var(--accent-color);
    padding: 12px 16px;
    border-radius: 8px;
    box-sizing: border-box;
    /* Allow it to shrink if needed, but preferably expand */
    flex-shrink: 0;
}

.genome-info-panel .info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.genome-info-panel .info-name {
    font-weight: bold;
    color: #fff;
}

.genome-info-panel .info-synergies {
    color: #aaa;
    font-size: 0.9em;
}

.info-connected-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.connected-card {
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-size: 0.75em;
    color: #ccc;
}

.genome-info-placeholder {
    height: 44px;
    margin-top: 12px;
}

.info-synergies-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.info-section-label {
    font-size: 0.7em;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* Panel Description */
.panel-description {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    color: #ccc;
    font-size: 0.9em;
    line-height: 1.5;
    white-space: pre-wrap;
    font-style: italic;
}

/* Combo List */
.combo-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
    margin-top: 15px;
}

.combo-container {
    border-bottom: 1px solid rgba(255, 215, 0, 0.2);
}

/* Combo Scanning Indicator */
.combo-scanning-indicator {
    background: var(--scanning-bg);
    border: 1px solid var(--accent-color);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 4px 12px var(--popup-shadow);
    color: var(--scanning-text);
    animation: slideIn 0.3s ease-out;
    margin-bottom: 10px;
}

.scanning-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.scanning-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--divider-border);
    border-top: 2px solid var(--accent-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.scanning-text {
    font-size: 0.9em;
    font-weight: 500;
    color: var(--scanning-text);
}

.scanning-progress-bar {
    width: 100%;
    height: 4px;
    background: var(--divider-border);
    border-radius: 2px;
    overflow: hidden;
}

.scanning-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-color), #fff);
    transition: width 0.3s ease;
    box-shadow: 0 0 10px var(--accent-color);
}

@media (min-width: 1600px) {
    .genome-canvas-container {
        display: grid;
        grid-template-areas:
            "controls controls"
            "scanning scanning"
            "canvas panel";
        grid-template-columns: 1fr 420px;
        grid-template-rows: auto auto 1fr;
        overflow: hidden;
    }

    .genome-controls-bar {
        grid-area: controls;
    }

    .scanning-wrapper {
        grid-area: scanning;
    }

    .canvas-wrapper {
        grid-area: canvas;
        height: 100%;
        min-height: 0;
        max-height: none;
    }

    .genome-info-panel {
        grid-area: panel;
        width: 100%;
        height: 100%;
        border-top: none;
        border-left: 1px solid var(--border-color);
        overflow-y: auto;
    }

    .genome-info-placeholder {
        grid-area: panel;
        display: none;
    }
}

/* ============================================
   VIEW MODE SECTION (in Filter Dropdown)
   ============================================ */

.filter-section {
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.filter-section-label {
    font-size: 0.7em;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    font-weight: 600;
}

.view-mode-options {
    display: flex;
    gap: 6px;
}

.view-mode-btn {
    flex: 1;
    padding: 8px 12px;
    background: rgba(158, 158, 255, 0.1);
    border: 1px solid rgba(158, 158, 255, 0.3);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 0.75em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.view-mode-btn:hover {
    background: rgba(158, 158, 255, 0.2);
    border-color: rgba(158, 158, 255, 0.5);
    color: var(--text-color);
}

.view-mode-btn.active {
    background: rgba(158, 158, 255, 0.3);
    border-color: var(--accent-color);
    color: #fff;
    font-weight: 600;
}