/* ============================================
   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;
}

/* Filter Dropdown (Desktop Default) */
.filter-dropdown {
    position: absolute;
    top: 50px;
    left: 140px;
    z-index: 100;
    min-width: 300px;
    background: var(--widget-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
}

@media (max-width: 768px) {
    .genome-canvas-container {
        min-height: 300px;
        overflow-y: auto !important;
        overflow-x: hidden;
        padding: 8px 8px 80px 8px;
        /* Extra bottom padding for fixed control bar */
        /* Reset transforms to prevent stacking context issues with fixed drawer */
        transform: none !important;
    }

    /* Floating control bar fixed at bottom - Scrollable Row */
    .genome-controls-bar {
        position: fixed;
        bottom: 48px;
        /* Scrolled up slightly */
        left: 12px;
        right: 12px;
        background: rgba(0, 0, 0, 0.95);
        backdrop-filter: blur(10px);
        padding: 12px 16px 12px 72px;
        /* Large left padding to clear FAB */
        border-radius: 12px;
        /* Restored border radius since it's floating again */
        z-index: 1000;
        gap: 12px !important;
        flex-wrap: nowrap !important;
        justify-content: flex-start !important;
        overflow-x: auto !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.4);
        /* Hide scrollbar for cleaner look */
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    .genome-controls-bar::-webkit-scrollbar {
        display: none;
    }

    /* Prevent items from shrinking */
    .genome-controls-bar .toggle-btn,
    .genome-controls-bar .genome-export-btn,
    .genome-controls-bar .zoom-controls,
    .genome-controls-bar .filter-dropdown-container {
        flex-shrink: 0;
    }

    /* Fix Filter Dropdown to open upwards as a bottom sheet */
    .filter-dropdown {
        position: fixed;
        bottom: 80px;
        /* Above the control bar */
        left: 12px;
        right: 12px;
        top: auto;
        width: auto;
        min-width: 0;
        margin-top: 0;
        max-height: 60vh;
        overflow-y: auto;
        border: 1px solid var(--accent-color);
        box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.5);
        z-index: 1001;
        /* Ensure above control bar */
    }

    .genome-controls-bar .toggle-btn {
        padding: 10px 14px;
        font-size: 0.8em;
        min-height: 44px;
        min-width: 44px;
    }

    .zoom-controls {
        padding: 6px 8px;
        gap: 8px;
    }

    /* Zoom buttons - 44px touch targets */
    .zoom-btn {
        width: 44px;
        height: 44px;
        font-size: 20px;
    }

    .genome-export-btn {
        padding: 10px;
        min-width: 44px;
        min-height: 44px;
    }

    /* Fullscreen button larger */
    .fullscreen-btn {
        width: 44px;
        height: 44px;
    }

    /* Info panel as bottom sheet drawer */
    /* Info panel as bottom sheet drawer */
    .genome-info-panel {
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        max-height: 75vh !important;
        margin: 0 !important;
        border-radius: 16px 16px 0 0;
        border-left: none !important;
        /* Re-apply border color to top via inline style, but base style here */
        border-top: 4px solid var(--accent-color);
        z-index: 1002 !important;
        /* Above everything */
        background: rgba(20, 20, 30, 0.98);
        backdrop-filter: blur(16px);
        box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.6);
        transform: translateY(100%);
        animation: slideUpDrawer 0.3s cubic-bezier(0.2, 0.9, 0.3, 1) forwards;
        overflow-y: auto !important;
        padding: 44px 16px 20px 16px !important;
        /* Top padding for close button */
    }

    @keyframes slideUpDrawer {
        from {
            transform: translateY(100%);
        }

        to {
            transform: translateY(0);
        }
    }

    .genome-info-placeholder {
        display: none !important;
    }

    /* Mobile Drawer toggle handle */
    .genome-info-panel::before {
        content: '';
        position: absolute;
        top: 8px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 2px;
    }

    /* Close Button */
    .mobile-drawer-close {
        display: flex !important;
        position: absolute;
        top: 16px;
        right: 16px;
        width: 32px;
        height: 32px;
        background: rgba(255, 255, 255, 0.1);
        border: none;
        border-radius: 50%;
        color: #ddd;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        z-index: 10;
        transition: background 0.2s;
    }

    .mobile-drawer-close:active {
        background: rgba(255, 255, 255, 0.2);
    }

    .mobile-drawer-close svg,
    .mobile-drawer-close svg line,
    .mobile-drawer-close svg path {
        width: 24px !important;
        height: 24px !important;
        min-width: 24px !important;
        min-height: 24px !important;
        stroke: white !important;
        stroke-width: 3px !important;
        stroke-opacity: 1 !important;
        display: block;
    }
}

.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: var(--accent-hover);
    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: var(--accent-bg);
    border: 1px solid var(--accent-bg-hover);
    border-radius: 6px;
    color: var(--accent-color);
    font-size: 0.8em;
    cursor: pointer;
    transition: all 0.2s ease;
}

.genome-export-btn:hover {
    background: var(--accent-bg-hover);
    border-color: var(--accent-color);
}

/* Genome Info Panel */
.genome-info-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    min-height: 200px;
    height: auto;
    overflow: visible;
    /* max-height: 400px; - REMOVED to allow expansion */
    /* overflow-y: auto; - REMOVED to avoid internal scroll */
    margin-top: 10px;
    background: var(--widget-bg);
    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;
    position: relative;
    /* Context for close button */
}

/* Default hidden close button */
.mobile-drawer-close {
    display: none;
}

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

.genome-info-panel .info-name {
    font-weight: bold;
    color: var(--accent-color);
}

.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: 2fr 1fr;
        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: var(--accent-bg);
    border: 1px solid var(--accent-bg-hover);
    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: var(--accent-bg-hover);
    border-color: var(--accent-hover);
    color: var(--text-color);
}

.view-mode-btn.active {
    background: var(--accent-hover);
    border-color: var(--accent-color);
    color: #fff;
    font-weight: 600;
}