
/* Mimic default browser context menu styling */
.custom-context-menu {
position: absolute;
background: #fff;
border: 1px solid #ccc;
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.2);
font-family: system-ui, sans-serif;
font-size: 13px;
color: #000;
padding: 5px 0;
border-radius: 2px;
z-index: 10000;
user-select: none;
min-width: 150px;
}
.custom-context-menu div {
padding: 5px 20px;
cursor: pointer;
white-space: nowrap;
}
.custom-context-menu div:hover {
background-color: #f5f5f5;
}

/* Dropdown styling */
.controls-container {
display: flex;
justify-content: space-between;
padding: 5px 10px;
background-color: #f8f8f8;
border-bottom: 1px solid #ddd;
width: 100%;
margin-top: 25px;
}

.dropdown {
position: relative;
display: inline-block;
flex: 1;
margin: 0 5px;
}

.dropdown:first-child {
margin-left: 0;
}

.dropdown:last-child {
margin-right: 0;
}

.dropdown-btn {
background-color: #6366f1;
color: white;
padding: 6px 10px;
font-size: 14px;
border: none;
border-radius: 4px;
cursor: pointer;
width: 100%;
text-align: center;
height: 32px;
}

.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
width: 100%;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 10;
border-radius: 4px;
}

.dropdown-content button {
color: black;
padding: 10px 16px;
text-decoration: none;
display: block;
width: 100%;
text-align: left;
border: none;
background: none;
cursor: pointer;
z-index: 4;
}

.dropdown-content button:hover {
background-color: #f1f1f1;
}

.dropdown:hover .dropdown-content {
display: block;
}

.dropdown:hover .dropdown-btn {
background-color: #6366f1;
}

/* Active button styling */
.active-resolution {
background-color: #6366f1;
font-weight: bold;
}

/* Customization Panel Styling */
.customization-panel {
position: absolute;
top: 115px;
right: -300px;
transform: translateX(-50%);
width: 600px;
min-width: 600px;
max-width: 600px;
max-height: 100vh;
background-color: #fff;
border: 1px solid #ccc;
border-radius: 8px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
z-index: 5;
overflow: hidden;
resize: both;
}

#gene-list-panel.customization-panel {
    z-index: 3;
}

#selection-results-panel.customization-panel {
    width: 370px;
    min-width: 370px;
    max-width: 370px;
    right: 1px;
    top: 120px;
    transform: none;
    z-index: 5;
    position: absolute; /* Add if not already set elsewhere */
    display: block;
    padding: 5px;
}

#selection-results-panel .panel-content {
    overflow-y: auto;
    max-height: calc(90vh - 120px);
}

.panel-title {
font-weight: bold;
font-size: 16px;
}

.panel-close {
background: none;
border: none;
font-size: 20px;
cursor: pointer;
}

.panel-tabs {
display: flex;
border-bottom: 1px solid #ddd;
background-color: #f8f8f8;
}

.panel-tab {
padding: 10px 15px;
border: none;
background: none;
cursor: pointer;
font-size: 14px;
border-bottom: 3px solid transparent;
}

.panel-tab.active {
border-bottom-color: #4CAF50;
background-color: #fff;
}


.panel-section-title {
font-weight: bold;
margin-bottom: 5px;
border-bottom: 1px solid #eee;
padding-bottom: 5px;
}

.control-group {
margin-bottom: 15px;
}

.control-label {
display: block;
margin-bottom: 5px;
font-size: 13px;
}

.control-row {
display: flex;
align-items: center;
margin-bottom: 8px;
}

.control-row label {
margin-left: 5px;
font-size: 13px;
}

.control-input {
width: 100%;
padding: 6px 8px;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 13px;
}

.control-input.region-tab-btn {
width: auto !important;
flex: 0 0 auto !important;
}

select.control-input {
height: 40px;
}

input[type="range"] {
width: 70%;
}

.range-value {
width: 30px;
text-align: center;
margin-left: 10px;
}

.control-input[type="color"] {
height: 30px;
padding: 2px;
}

.color-scheme-option {
display: inline-block;
width: 100px;
text-align: center;
margin: 5px;
cursor: pointer;
border: 2px solid transparent;
padding: 5px;
border-radius: 4px;
}

.color-scheme-option:hover,
.color-scheme-option.selected {
border-color: #4CAF50;
}

.color-scheme-preview {
height: 20px;
width: 100%;
margin-bottom: 5px;
border-radius: 2px;
overflow: hidden;
display: flex;
}

.color-band {
flex: 1;
height: 100%;
}

.button-row {
display: flex;
justify-content: flex-end;
margin-top: 15px;
}

.button-row button {
margin-left: 10px;
padding: 8px 15px;
border: none;
border-radius: 4px;
cursor: pointer;
background-color: #f0f0f0;
}

.button-row button.primary {
background-color: #4CAF50;
color: white;
}

.button-row button:hover {
opacity: 0.9;
}

.tab-content {
display: none;
padding: 5px;
}

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

/* Custom checkbox styling */
.toggle-switch {
position: relative;
display: inline-block;
width: 40px;
height: 20px;
}

.toggle-switch input {
opacity: 0;
width: 0;
height: 0;
}

.toggle-slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
transition: .4s;
border-radius: 20px;
}

.toggle-slider:before {
position: absolute;
content: "";
height: 16px;
width: 16px;
left: 2px;
bottom: 2px;
background-color: white;
transition: .4s;
border-radius: 50%;
}

input:checked + .toggle-slider {
background-color: #4CAF50;
}

input:checked + .toggle-slider:before {
transform: translateX(20px);
}

.collapsible-section {
margin-bottom: 10px;
}

.collapsible-header {
padding: 8px;
background-color: #f8f8f8;
cursor: pointer;
display: flex;
justify-content: space-between;
align-items: center;
border-radius: 4px;
}

.collapsible-header:hover {
background-color: #f0f0f0;
}

.collapsible-content {
padding: 10px;
border: 1px solid #f0f0f0;
border-top: none;
display: none;
}

.collapsible-icon {
transition: transform 0.3s;
}

.collapsible-open .collapsible-icon {
transform: rotate(180deg);
}

.collapsible-open .collapsible-content {
display: block;
}

/* Grid layout for color options */
.color-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
gap: 10px;
}

/* Sample Info Panel specific styles */
.info-table {
    width: 100%;
    border-collapse: collapse;
}

.info-table th {
    text-align: left;
    padding: 8px;
    background-color: #f5f5f5;
    font-weight: bold;
    width: 140px;
    vertical-align: top;
}

.info-table td {
    padding: 8px;
    border-bottom: 1px solid #eee;
    word-break: break-word;
    overflow-wrap: break-word;
}

.info-table tr:last-child td,
.info-table tr:last-child th {
    border-bottom: none;
}

/* Update the sample-info-panel CSS */
#sample-info-panel {
      width: 300px !important;
      min-width: 300px;
      max-width: 300px;
      left: 1px !important;
      top: 120px !important; 
      transform: none !important;
      max-height: 350px;
      min-height: 350px;
      z-index: 3;
      box-shadow: 0 4px 8px rgba(0,0,0,0.1);
      overflow-y: auto;
    }

#sample-info-panel a {
    color: #4CAF50;
    text-decoration: none;
}

#sample-info-panel a:hover {
    text-decoration: underline;
}

#resolution-selector-container {
position: absolute;
top: 120px !important;
left: 50%;
transform: translateX(calc(-50% - 25px));
background: rgba(255, 255, 255, 0.9);
padding: 10px;
border-radius: 8px;
box-shadow: 0 2px 8px rgba(0,0,0,0.2);
z-index: 2 !important;
display: flex;
flex-direction: column;
gap: 8px;
align-items: flex-start;
user-select: none;
border: 1px solid rgba(0,0,0,0.1);
transition: box-shadow 0.2s ease;
width: max-content;
}

#resolution-selector-container:hover {
box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

/* REMOVED: Drag handle (container is now fixed and centered)
.resolution-drag-handle { ... }
*/

/* Style for the plotly control buttons container */
#plotly-buttons {
display: flex;
align-items: center;
border-left: 1px solid #ddd;
margin-left: 5px;
padding-left: 10px;
}

/* Style for each control button */
.plotly-custom-btn {
background: none;
border: none;
cursor: pointer;
width: 28px;
height: 28px;
border-radius: 4px;
padding: 4px;
color: #666;
display: flex;
align-items: center;
justify-content: center;
position: relative;
}

.plotly-custom-btn:hover {
background-color: #f0f0f0;
color: #6366f1;
}

.plotly-custom-btn svg {
width: 16px;
height: 16px;
}

/* Tooltip for control buttons */
.plotly-custom-btn::after {
content: attr(data-title);
position: absolute;
bottom: -30px;
left: 50%;
transform: translateX(-50%);
padding: 4px 8px;
background-color: rgba(0,0,0,0.8);
color: white;
border-radius: 4px;
font-size: 12px;
white-space: nowrap;
opacity: 0;
visibility: hidden;
transition: opacity 0.2s, visibility 0.2s;
pointer-events: none;
z-index: 1010;
}

.plotly-custom-btn:hover::after {
opacity: 1;
visibility: visible;
}


.loading-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(255, 255, 255, 0.75);
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
z-index: 9999;
backdrop-filter: blur(3px);
-webkit-backdrop-filter: blur(3px);
}

.loading-spinner {
width: 60px;
height: 60px;
border-radius: 50%;
border: 5px solid transparent;
border-top-color: #6366f1;
border-bottom-color: #6366f1;
animation: spin 1.2s linear infinite;
}

.loading-text {
margin-top: 20px;
font-size: 18px;
color: #333;
width: 70px;
font-family: 'Arial', sans-serif;
font-weight: 500;
animation: pulse 2s ease-in-out infinite;
}

@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}

@keyframes pulse {
0%, 100% { opacity: 1; }
50% { opacity: 0.7; }
}

    .button-divider {
    width: 1px;
    height: 30px;
    background-color: #ddd;
    margin: 0 5px;
    }



    /* Collapsed state */
    #resolution-selector-container.collapsed {
    left: auto;
    right: 10px;
    top: 115px !important; /* Force override with !important */
    transform: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    padding: 0;
    justify-content: center;
    }

#resolution-selector-container.collapsed > *:not(.collapse-toggle) {
    display: none;
}

#resolution-selector-container.collapsed .collapse-toggle::after {
bottom: -30px;
left: 50%;
transform: translateX(-50%);
z-index: 2000;
white-space: nowrap;
position: absolute;
}

#resolution-selector-container.collapsed .collapse-toggle:hover::after {
opacity: 1;
visibility: visible;
}

/* Ensure the tooltips aren't clipped in collapsed state */
#resolution-selector-container.collapsed {
overflow: visible !important;
}

.collapse-toggle {
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    color: #666;
    position: relative; /* Required for absolute positioning of tooltip */
    }
    
    .collapse-toggle:hover {
    background-color: #f0f0f0;
    }
    
    /* Add tooltip to collapse button with same style as other buttons */
    .collapse-toggle::after {
    content: attr(data-title);
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background-color: rgba(0,0,0,0.8);
    color: white;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
    pointer-events: none;
    z-index: 1010;
    }
    
    .collapse-toggle:hover::after {
    opacity: 1;
    visibility: visible;
    }

#resolution-selector-container.collapsed .collapse-toggle svg {
    transform: rotate(180deg);
}

#gene-container {
    height: 150px; /* Height for approximately 5 genes */
    overflow-y: scroll;
    border: 1px solid #eee;
    border-radius: 4px;
    padding: 5px;
    margin: 5px;
    width: 290px;
}

.gene-item {
    padding: 3px 5px;
}

.gene-item:hover {
background-color: #f5f5f5;
}
#search-box {
    width: 100%;
    padding: 8px;
    margin-bottom: 10px;
}
#selected-genes {
    margin: 10px;
}

#gene-list-panel {
    width: 300px !important;
    min-width: 300px;
    max-width: 300px;
    left: 1px !important;
    top: 480px;
    transform: none !important;
    max-height: 600px; /* Maximum height before panel becomes scrollable */
    z-index: 3;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

#gene-list-panel .panel-content {
    overflow-y: auto; /* Make panel content scrollable */
    flex: 1;
    min-height: 0; /* Allow flex item to shrink below content size */
}

#analysis-summary-panel {
    width: 300px !important;
    min-width: 300px;
    max-width: 300px;
    left: 1px !important;
    transform: none !important;
    max-height: 200px;
    z-index: 3;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.panel-title {
font-weight: bold;
font-size: 16px;
flex-grow: 1;
}

.panel-controls {
display: flex;
gap: 5px;
}

.panel-button {
background: none;
border: none;
font-size: 16px;
cursor: pointer;
padding: 0 5px;
color: #666;
width: 24px;
height: 24px;
display: flex;
align-items: center;
justify-content: center;
border-radius: 3px;
}

.panel-button:hover {
background-color: rgba(0,0,0,0.1);
}

.panel-minimized .panel-content {
display: none;
}

.panel-minimized {
height: auto !important;
min-height: auto !important;
}

.panel-stuck-left {
left: 0 !important;
transform: none !important;
}

.panel-stuck-right {
right: 0 !important;
left: auto !important;
transform: none !important;
}

/* REMOVED: Vertical orientation styles (container is now always horizontal and centered) */

/* spatial_viewer-custom.css - Extracted styles from JavaScript */

/* ===========================================
   PANEL STYLES
   =========================================== */

/* Customization Panel */
.customization-panel.panel-stuck-left {
    position: absolute !important;
    left: 10px !important;
    transform: none !important;
}

.customization-panel.panel-stuck-right {
    position: absolute !important;
    right: 10px !important;
    left: auto !important;
    transform: none !important;
}

.customization-panel.panel-minimized {
    height: 60px !important;
    overflow: hidden !important;
}

/* Panel Header */
.panel-header {
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
    padding: 15px 10px !important;
    background-color: #f8f9fa !important;
    border-bottom: 1px solid #e9ecef !important;
    cursor: move !important;
    user-select: none !important;
}

.panel-title {
    font-weight: 600 !important;
    font-size: 16px !important;
    color: #333 !important;
    margin: 0 !important;
}

.panel-controls {
    display: flex !important;
    gap: 5px !important;
}

.panel-button {
    width: 24px !important;
    height: 24px !important;
    border: 1px solid #ddd !important;
    background-color: white !important;
    border-radius: 3px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 12px !important;
    transition: all 0.2s ease !important;
}

.panel-button:hover {
    background-color: #f8f9fa !important;
    border-color: #adb5bd !important;
}

.panel-close {
    font-size: 18px !important;
    font-weight: bold !important;
    color: #666 !important;
}

.panel-close:hover {
    color: #dc3545 !important;
}

/* Panel Content */
.panel-content {
    padding: 2px !important;
}

.panel-section {
    margin-bottom: 10px !important;
    margin-top: 10px !important;
}

.panel-section:last-child {
    margin-bottom: 0 !important;
}

.panel-section-title {
    font-weight: 600 !important;
    font-size: 14px !important;
    color: #333 !important;
    margin-bottom: 15px !important;
    padding-bottom: 5px !important;
    border-bottom: 1px solid #e9ecef !important;
}

/* ===========================================
   CONTROL STYLES
   =========================================== */

.control-group {
    margin-bottom: 10px !important;
    margin-top: 10px 
}

.control-label {
    display: block !important;
    font-weight: 500 !important;
    font-size: 13px !important;
    color: #555 !important;
    margin-bottom: 5px !important;
}

.control-input {
    width: 100% !important;
    padding: 8px 12px !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    font-size: 14px !important;
    transition: border-color 0.2s ease !important;
    box-sizing: border-box !important;
}

.control-input:focus {
    outline: none !important;
    border-color: #6366f1 !important;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1) !important;
}

.control-row {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
}

.range-value {
    min-width: 30px !important;
    text-align: center !important;
    font-size: 12px !important;
    color: #666 !important;
}

/* ===========================================
   BUTTON STYLES
   =========================================== */


.primary-btn:hover {
    background-color: #4f46e5 !important;
}

.button-row {
    display: flex !important;
    gap: 10px !important;
    margin-top: 15px !important;
}

.button-row button {
    flex: 1 !important;
    padding: 10px !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

.button-row button:hover {
    background-color: #e9ecef !important;
}

/* ===========================================
   PLOTLY CUSTOM CONTROLS
   =========================================== */

.plotly-custom-btn {
    width: 28px !important;
    height: 28px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border: none !important;
    background: none !important;
    cursor: pointer !important;
    padding: 4px !important;
    border-radius: 4px !important;
    color: #666 !important;
    transition: all 0.2s ease !important;
}

.plotly-custom-btn:hover {
    background-color: #f0f0f0 !important;
}

.plotly-custom-btn.active {
    background-color: #e6f7ff !important;
    color: #6366f1 !important;
}

.plotly-custom-btn svg {
    width: 16px !important;
    height: 16px !important;
}

/* Resolution Selector */
.resolution-selector-container {
    min-width: fit-content !important;
    padding-right: 15px !important;
    position: absolute !important;
    background: rgba(255, 255, 255, 0.9) !important;
    padding: 10px !important;
    border-radius: 8px !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
    z-index: 1000 !important;
    display: none !important;
    align-items: center !important;
    user-select: none !important;
    border: 1px solid rgba(0,0,0,0.1) !important;
}

.resolution-btn {
    transition: background-color 0.2s !important;
    padding: 5px 10px !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    background: #fff !important;
    cursor: pointer !important;
    min-width: 40px !important;
    text-align: center !important;
    font-size: 14px !important;
    font-family: inherit !important;
}

.resolution-btn:hover {
    background-color: #f0f0f0 !important;
}

.resolution-btn.active {
    background-color: rgba(99, 102, 241, 0.8) !important;
    font-weight: bold !important;
    border-color: #6366f1 !important;
    color: white !important;
}

.resolution-buttons {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 5px !important;
    width: max-content !important;
}

/* Collapsed state */
.resolution-selector-container.collapsed {
    left: auto !important;
    right: 10px !important;
    top: 115px !important;
    transform: none !important;
    width: 40px !important;
    height: 40px !important;
    border-radius: 50% !important;
    overflow: hidden !important;
    padding: 0 !important;
    justify-content: center !important;
}

.resolution-selector-container.collapsed > *:not(.collapse-toggle) {
    display: none !important;
}

.resolution-selector-container.collapsed .collapse-toggle {
    display: flex !important;
}

.resolution-selector-container.collapsed .collapse-toggle svg {
    transform: rotate(180deg) !important;
}

/* REMOVED: Vertical orientation (container is now always horizontal) */

/* ===========================================
   COLOR SCHEME OPTIONS
   =========================================== */

.color-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)) !important;
    gap: 10px !important;
    margin-top: 10px !important;
}

.color-scheme-option {
    border: 2px solid transparent !important;
    border-radius: 6px !important;
    padding: 8px !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    text-align: center !important;
}

.color-scheme-option:hover {
    border-color: #ddd !important;
}

.color-scheme-option.selected {
    border-color: #6366f1 !important;
    background-color: rgba(99, 102, 241, 0.05) !important;
}

.color-scheme-preview {
    height: 20px !important;
    display: flex !important;
    border-radius: 3px !important;
    overflow: hidden !important;
    margin-bottom: 5px !important;
}

.color-band {
    flex: 1 !important;
    height: 100% !important;
}

/* ===========================================
   TOGGLE SWITCHES
   =========================================== */

.toggle-switch {
    position: relative !important;
    display: inline-block !important;
    width: 40px !important;
    height: 20px !important;
}

.toggle-switch input {
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
}

.toggle-slider {
    position: absolute !important;
    cursor: pointer !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background-color: #ccc !important;
    transition: .4s !important;
    border-radius: 20px !important;
}

.toggle-slider:before {
    position: absolute !important;
    content: "" !important;
    height: 16px !important;
    width: 16px !important;
    left: 2px !important;
    bottom: 2px !important;
    background-color: white !important;
    transition: .4s !important;
    border-radius: 50% !important;
}

input:checked + .toggle-slider {
    background-color: #4CAF50 !important;
}

input:checked + .toggle-slider:before {
    transform: translateX(20px) !important;
}

/* ===========================================
   SELECTION MANAGEMENT
   =========================================== */

.selection-item {
    padding: 10px !important;
    border-bottom: 1px solid #eee !important;
    display: flex !important;
    align-items: center !important;
    cursor: pointer !important;
    transition: background-color 0.2s ease !important;
}

.selection-item:hover {
    background-color: #f5f5f5 !important;
}

.selection-item.selected {
    background-color: #f0f7ff !important;
    border-left: 3px solid #6366f1 !important;
}

.selection-color {
    width: 20px !important;
    height: 20px !important;
    border-radius: 50% !important;
    margin-right: 10px !important;
    flex-shrink: 0 !important;
}

.selection-name {
    flex-grow: 1 !important;
    font-weight: 500 !important;
}

.selection-info {
    font-size: 0.85em !important;
    color: #666 !important;
    margin-left: 5px !important;
}

.selection-analyzed-badge {
    width: 18px !important;
    height: 18px !important;
    background-color: #4CAF50 !important;
    color: white !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 12px !important;
    margin-left: 5px !important;
    flex-shrink: 0 !important;
}

/* ===========================================
   EXPRESSION TABLES
   =========================================== */

.expression-table {
    width: 100% !important;
    border-collapse: collapse !important;
}

.expression-table th, 
.expression-table td {
    padding: 8px !important;
    text-align: left !important;
    border-bottom: 1px solid #eee !important;
}

.expression-table th {
    background-color: #f5f5f5 !important;
    font-weight: bold !important;
}

.expression-table tr:nth-child(even) {
    background-color: #f9f9f9 !important;
}

.up-regulated {
    color: #4CAF50 !important;
    font-weight: bold !important;
}

.down-regulated {
    color: #F44336 !important;
    font-weight: bold !important;
}

/* ===========================================
   MODE TOGGLE BUTTONS
   =========================================== */

.mode-toggle-btn {
    flex: 1 !important;
    padding: 8px !important;
    border: none !important;
    background: none !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
}

.mode-toggle-btn:hover {
    background-color: #f0f0f0 !important;
}

.mode-toggle-btn.active-mode {
    background-color: #6366f1 !important;
    color: white !important;
    font-weight: bold !important;
}


/* ===========================================
   CUSTOM CONTEXT MENU
   =========================================== */

.custom-context-menu {
    position: fixed !important;
    background-color: white !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
    z-index: 10000 !important;
    min-width: 150px !important;
}

.custom-context-menu div {
    padding: 10px 15px !important;
    cursor: pointer !important;
    transition: background-color 0.2s ease !important;
}

.custom-context-menu div:hover {
    background-color: #f5f5f5 !important;
}

/* ===========================================
   COMPARISON PLOTS STYLES
   =========================================== */

.control-input.active-plot-btn {
    background-color: #6366f1 !important;
    color: white !important;
}

#comparison-plots-container {
    transition: all 0.3s ease !important;
    position: relative !important;
}

#comparison-selections-container button:hover {
    background-color: rgba(99, 102, 241, 0.1) !important;
}

#scatter-plot-btn, 
#volcano-plot-btn, 
#bar-chart-btn {
    transition: all 0.2s ease !important;
    border: 1px solid #ddd !important;
    min-width: 120px !important;
    font-weight: 500 !important;
}

#scatter-plot-btn:hover, 
#volcano-plot-btn:hover, 
#bar-chart-btn:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
}

.active-plot-btn {
    background-color: #6366f1 !important;
    color: white !important;
    border-color: #4f46e5 !important;
}

/* Enhanced dropdowns */
#compare_1, #compare_2 {
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    padding: 8px 12px !important;
    font-size: 14px !important;
    appearance: none !important;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23666%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E") !important;
    background-repeat: no-repeat !important;
    background-position: right 8px top 50% !important;
    background-size: 12px auto !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
}

#compare_1:hover, 
#compare_2:hover {
    border-color: #6366f1 !important;
}

/* ===========================================
   UTILITY CLASSES
   =========================================== */

.empty-state {
    padding: 20px !important;
    text-align: center !important;
    color: #666 !important;
    font-style: italic !important;
}

.text-center {
    text-align: center !important;
}

.d-none {
    display: none !important;
}

.d-block {
    display: block !important;
}

.d-flex {
    display: flex !important;
}

.resolution-selector-container {
    position: absolute;
    top: 120px;
    left: 50%;
    transform: translateX(calc(-50% - 25px));
    background: rgba(255, 255, 255, 0.9);
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    z-index: 1000;
    display: none;
    align-items: center;
    user-select: none;
    border: 1px solid rgba(0,0,0,0.1);
}


.dpi-btn:disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    background-color: #f8f9fa !important;
    color: #999 !important;
    border-color: #ddd !important;
}

.dpi-btn:disabled:hover {
    background-color: #f8f9fa !important;
    color: #999 !important;
}

/* Plot Genes Button */
#plot-multiple-genes-btn {
    width: 95%;
    padding: 10px;
    background-color: #6366f1;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 14px;
    transition: background-color 0.2s ease;
    margin: 10px 5px;
}

#plot-multiple-genes-btn:hover {
    background-color: #4f46e5;
}

#plot-multiple-genes-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Download toast notification container */
#download-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 20px;
    pointer-events: none;
}

/* Individual toast */
.download-toast {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    background: #6366f1;
    color: #fff;
    padding: 12px 18px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(99,102,241,0.35);
    font-size: 14px;
    max-width: 320px;
    min-width: 260px;
    pointer-events: auto;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.download-toast.toast-visible {
    opacity: 1;
    transform: translateY(0);
}

.download-toast .toast-icon {
    font-size: 18px;
    flex-shrink: 0;
    font-family: Arial, sans-serif;
    font-weight: 700;
    line-height: 1;
}

.download-toast .toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: #c7d2fe;
    border-radius: 0 0 8px 8px;
    width: 100%;
    transform-origin: left;
    animation: none;
}

.download-toast.toast-visible .toast-progress {
    animation: toast-shrink var(--toast-duration, 3s) linear forwards;
}

/* Coordinate system pill toggle */
.coord-pill-toggle {
    display: flex;
    align-items: center;
}

.coord-pill-track {
    position: relative;
    display: flex;
    align-items: center;
    background: #f0f0f0;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 2px;
    gap: 0;
    cursor: pointer;
    height: 35px;
    box-sizing: border-box;
}

.coord-pill-thumb {
    position: absolute;
    top: 2px;
    bottom: 2px;
    width: calc(50% - 2px);
    background: rgba(99, 102, 241, 0.85);
    border-radius: 10px;
    transition: left 0.2s ease;
    left: 2px;
    pointer-events: none;
}

.coord-pill-thumb--spatial { left: 2px; }
.coord-pill-thumb--umap    { left: calc(50%); }

.coord-pill-label {
    position: relative;
    z-index: 1;
    flex: 1;
    text-align: center;
    padding: 2px 10px;
    font-size: 13px;
    color: #555;
    user-select: none;
    transition: color 0.2s;
    white-space: nowrap;
}

/* "Which sample the toolbar controls" pill — stacked vertically (DSID on top
   of DSID) instead of side-by-side, since the two labels can be long. */
.compare-sample-pill-toggle .coord-pill-track {
    flex-direction: column;
    height: auto;
    min-width: 90px;
}

.compare-sample-pill-toggle .coord-pill-thumb {
    top: 2px;
    bottom: auto;
    left: 2px;
    right: 2px;
    width: auto;
    height: calc(50% - 2px);
    transition: top 0.2s ease;
}

.compare-sample-pill-toggle .coord-pill-label {
    padding: 4px 10px;
}

.coord-pill-label--active {
    color: #fff;
    font-weight: bold;
}

/* ===== Fullscreen mode ===== */
body.spatial-fullscreen .controls-container,
body.spatial-fullscreen #recent-spatial-samples,
body.spatial-fullscreen .navbar {
    display: none !important;
}

body.spatial-fullscreen main.pt-5 {
    padding-top: 0 !important;
}

body.spatial-fullscreen #canvas-container {
    height: 100vh !important;
}

/* Keep the floating toolbar and panels visible inside fullscreen */
body.spatial-fullscreen #resolution-selector-container {
    top: 20px !important;
}

@keyframes toast-shrink {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}


/* ===========================================
   GENE EXPRESSION BY CELL TYPE (gene list panel)
   =========================================== */

/* Bottom margin matches Bootstrap's label margin-bottom (.5rem) on the toggle
   and its text in the same row, so the row's centering lines all three up */
#gene-celltype-level {
    width: auto !important;
    height: 24px !important;
    padding: 0 4px !important;
    font-size: 12px !important;
    margin: 0 0 .5rem auto !important;
}

/* Same look as the other panels (.customization-panel); docked to the right
   of #gene-list-panel, left/top set in gene-celltype-filter.js */
#gene-celltype-side.customization-panel {
    /* fallback position if the Gene List panel is hidden when it first opens */
    left: 310px;
    top: 120px;
    width: 400px;
    min-width: 400px;
    max-width: 520px;
    right: auto;
    transform: none;
    resize: none;
    max-height: 600px;
    z-index: 3;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
}

#gene-celltype-side.multi-gene {
    width: auto;
    max-width: 680px;
}

#gene-celltype-side .panel-content {
    overflow-y: auto;
    flex: 1;
    min-height: 0;
}

.gene-celltype-note {
    font-size: 13px;
    color: #666;
    padding: 8px;
}

/* Rows reuse .info-table; header cells shouldn't take its fixed th width */
.gene-celltype-table th {
    width: auto;
    position: sticky;
    top: 0;
}

/* Number columns: fixed width (the cell type column takes the rest), header
   and values centered, tabular digits so the decimal points line up */
.gene-celltype-table .num {
    width: 72px;
    text-align: center;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.gene-celltype-table.multi .num {
    width: auto;
}

/* Keep cell type names readable however many gene columns there are */
.gene-celltype-table td:first-child,
.gene-celltype-table th:first-child {
    min-width: 150px;
}

/* Multi-gene: up to 5 gene columns, so tighter than the default info-table */
.gene-celltype-table.multi th,
.gene-celltype-table.multi td {
    padding: 6px 6px;
    font-size: 13px;
}

.gene-celltype-row {
    cursor: pointer;
}

.gene-celltype-row:hover td {
    background-color: #f3f4f6;
}

/* Too few cells for a reliable % (listed last) */
.gene-celltype-row.few-cells td {
    color: #9ca3af;
}

.gene-celltype-row.selected td {
    background-color: #e3f2fd;
    font-weight: 600;
}

.gene-celltype-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 6px;
    vertical-align: middle;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

/* Info tooltips (.stats-faq-trigger from explore.css) in the header cells:
   fixed so neither panel clips or covers them (left/top set on hover in
   gene-celltype-filter.js, opening to the right of the icon), and not
   inheriting the header's bold / nowrap / right alignment. */
.gene-celltype-table th {
    z-index: 1;
}

/* Each sticky th is its own stacking context, so the tooltip's z-index only
   counts inside it: lift the hovered/focused header above its neighbours. */
.gene-celltype-table th:hover,
.gene-celltype-table th:focus-within {
    z-index: 2;
}

#gene-celltype-breakdown .stats-faq-trigger {
    margin-left: 3px;
}

#gene-celltype-breakdown .stats-faq-tooltip {
    position: fixed;
    right: auto;
    width: 240px;
    z-index: 10000;
    font-weight: normal;
    text-align: left;
}

/* Hover tooltip for the cell-type table values: same look as the info-icon
   tooltips (.stats-faq-tooltip, explore.css), positioned in gene-celltype-filter.js */
#gene-celltype-hover-tip {
    position: fixed;
    width: auto;
    max-width: 260px;
    z-index: 10000;
    white-space: pre-line;
    pointer-events: none;
}
