/* Global Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 0.9375rem;
    line-height: 1.7;
    color: #212529;
    background-color: #ffffff;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

p {
    margin-bottom: 16px;
    line-height: 1.7;
}

ul, ol {
    margin-bottom: 20px;
    padding-left: 24px;
}

li {
    margin-bottom: 8px;
    line-height: 1.7;
}

.container-fluid {
    padding: 0;
    margin: 0;
    width: 100%;
    max-width: 100%;
}

/* Sidebar Styles */
.sidebar {
    background-color: #ffffff;
    border-right: 1px solid #e9ecef;
    padding: 0;
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    align-self: flex-start; /* 确保sticky在flex布局中正常工作 */
    height: 100vh;
    overflow-y: auto;
    flex-shrink: 0; /* 防止侧边栏被压缩 */
}

.sidebar-sticky {
    padding: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sidebar-header {
    padding: 32px 24px;
    border-bottom: 1px solid #e9ecef;
    background-color: #ffffff;
}

.sidebar-header h2 {
    font-size: 1.75rem;
    color: #1f77b4;
    margin: 0;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.sidebar .nav {
    padding: 16px 12px;
    flex: 1;
    list-style: none;
    margin: 0;
}

.sidebar .nav-item {
    margin: 6px 0;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #495057;
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    border-radius: 8px;
    margin: 0 4px;
    transition: background-color 0.15s ease, color 0.15s ease;
    border: 1px solid transparent;
}

.sidebar .nav-link:hover {
    background-color: #f5f5f5;
    color: #1f77b4;
}

.sidebar .nav-link.active {
    background-color: #1f77b4;
    color: white;
    font-weight: 600;
}

.sidebar .nav-link.active:hover {
    background-color: #1565a0;
    color: white;
}

.sidebar .nav-link i {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.sidebar-info {
    padding: 24px 20px;
    margin-top: auto;
    border-top: 1px solid #e9ecef;
    background-color: #ffffff;
    font-size: 0.875rem;
}

.sidebar-info h6 {
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: #1f77b4;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 11px;
}

.sidebar-info p {
    margin: 8px 0;
    font-size: 0.8125rem;
    color: #6c757d;
    line-height: 1.6;
}

.sidebar-info p strong {
    color: #495057;
    font-weight: 600;
}

/* Main Content Styles */
.main-content {
    padding: 48px 56px;
    background-color: #ffffff;
    min-height: 100vh;
    max-width: 1400px;
    margin: 0 auto;
}

@media (max-width: 1200px) {
    .main-content {
        padding: 40px 48px;
    }
}

@media (max-width: 992px) {
    .main-content {
        padding: 32px 40px;
    }
}

/* Ensure row and columns work properly */
.row {
    display: flex;
    flex-direction: row;
    margin-left: 0;
    margin-right: 0;
    gap: 2rem;
    align-items: flex-start;
}


.main-content {
    flex: 1; 
    min-width: 0; 
}


h1 {
    font-size: 2.25rem !important;
    color: #1f77b4;
    margin-bottom: 32px;
    font-weight: 600;
    letter-spacing: -0.5px;
    line-height: 1.2;
}

h2 {
    font-size: 1.75rem;
    color: #1f77b4;
    margin-top: 48px;
    margin-bottom: 24px;
    font-weight: 600;
    letter-spacing: -0.3px;
    line-height: 1.3;
}

h3 {
    font-size: 1.375rem !important;
    color: #212529;
    margin-top: 36px;
    margin-bottom: 20px;
    font-weight: 600;
    line-height: 1.4;
}

h4 {
    font-size: 1.125rem;
    color: #495057;
    margin-top: 28px;
    margin-bottom: 16px;
    font-weight: 600;
}

h5 {
    font-size: 1rem;
    color: #6c757d;
    margin-top: 24px;
    margin-bottom: 12px;
    font-weight: 600;
}

/* Button Styles */
.btn {
    padding: 10px 20px;
    border-radius: 6px;
    border: 1px solid transparent;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background-color: #1f77b4;
    color: white;
    border-color: #1f77b4;
    transition: background-color 0.15s ease;
}

.btn-primary:hover {
    background-color: #1565a0;
    color: white;
}

.btn-primary:disabled {
    background-color: #e9ecef;
    border-color: #e9ecef;
    color: #adb5bd;
    cursor: not-allowed;
}

.btn-secondary {
    background-color: #6c757d;
    color: white;
    transition: background-color 0.15s ease;
}

.btn-secondary:hover {
    background-color: #5a6268;
    color: white;
}

.btn-outline-primary {
    border-color: #1f77b4;
    color: #1f77b4;
    background-color: transparent;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.btn-outline-primary:hover {
    background-color: #1f77b4;
    color: white;
    border-color: #1f77b4;
}

.btn-outline-secondary {
    border-color: #ced4da;
    color: #495057;
    background-color: transparent;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.btn-outline-secondary:hover {
    background-color: #fafafa;
    color: #495057;
    border-color: #ced4da;
}

.btn-check:checked + .btn-outline-primary {
    background-color: #1f77b4;
    color: white;
    border-color: #1f77b4;
}

.btn-check:checked + .btn-outline-secondary {
    background-color: #6c757d;
    color: white;
    border-color: #6c757d;
}

/* Form Styles */
.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #495057;
    font-size: 0.9375rem;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 0.9375rem;
    transition: border-color 0.15s ease;
    background-color: #ffffff;
}

.form-control:focus {
    outline: none;
    border-color: #1f77b4;
}

.form-control::placeholder {
    color: #adb5bd;
}

textarea.form-control {
    resize: vertical;
    min-height: 120px;
    font-family: 'Courier New', monospace;
}

/* Card Styles */
.card {
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 32px;
    margin-bottom: 32px;
}

.card-header {
    font-weight: 600;
    font-size: 1.125rem;
    margin-bottom: 24px;
    color: #1f77b4;
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 16px;
    letter-spacing: -0.2px;
}

/* Metric Cards */
.metric-card {
    text-align: center;
    padding: 24px 20px;
    background: #ffffff;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    transition: background-color 0.15s ease;
}

.metric-card:hover {
    background: #fafafa;
}

.metric-label {
    font-size: 0.875rem;
    color: #6c757d;
    margin-bottom: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 2rem;
    font-weight: 600;
    color: #1f77b4;
    line-height: 1.2;
}

/* Alert Styles */
.alert {
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 24px;
    border-left: 4px solid;
    font-size: 0.9375rem;
    line-height: 1.6;
}

.alert-success {
    background-color: #d1f2eb;
    border-color: #28a745;
    color: #155724;
}

.alert-warning {
    background-color: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

.alert-error {
    background-color: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

.alert-info {
    background-color: #d1ecf1;
    border-color: #17a2b8;
    color: #0c5460;
}

/* Table Styles */
.table-container {
    overflow-x: auto;
    margin: 20px 0;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

table th,
table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

table th {
    background-color: #fafafa;
    font-weight: 600;
    color: #1f77b4;
}

table tr:hover {
    background-color: #fafafa;
}

/* Tabs */
.tabs {
    border-bottom: 1px solid #e9ecef;
    margin-bottom: 20px;
}

.tab-button {
    padding: 12px 24px;
    background: none;
    border: none;
    border-bottom: 1px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    color: #6c757d;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.tab-button:hover {
    color: #1f77b4;
}

.tab-button.active {
    color: #1f77b4;
    border-bottom-color: #1f77b4;
    font-weight: 600;
}

.tab-content {
    display: none;
}

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

/* Expandable Section */
.expandable {
    margin: 32px 0;
}

.expandable-header {
    padding: 16px 20px;
    background-color: #fafafa;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    color: #495057;
    transition: background-color 0.15s ease;
}

.expandable-header:hover {
    background-color: #f5f5f5;
}

.expandable-content {
    padding: 24px 28px;
    border: 1px solid #e9ecef;
    border-top: none;
    border-radius: 0 0 8px 8px;
    background-color: #fafafa;
    display: none;
}

.expandable-content.expanded {
    display: block;
}

/* Loading Spinner */
.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #1f77b4;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

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

/* Plotly Chart Container */
.plotly-chart {
    margin: 20px 0;
    width: 100%;
    min-height: 400px;
    position: relative;
    background-color: #ffffff;
}

.plotly-chart > div {
    width: 100% !important;
    height: 100% !important;
}

/* Responsive */
@media (max-width: 767.98px) {
    .sidebar {
        position: relative;
        height: auto;
        min-height: auto;
        border-right: none;
        border-bottom: 1px solid #e9ecef;
    }
    
    .sidebar-sticky {
        height: auto;
    }
    
    .sidebar-info {
        margin-top: 0;
    }
    
    .main-content {
        padding: 24px 20px;
    }
    
    h1 {
        font-size: 1.875rem !important;
        margin-bottom: 24px;
    }
    
    h2 {
        font-size: 1.5rem;
        margin-top: 32px;
        margin-bottom: 20px;
    }
    
    .card {
        padding: 24px;
        margin-bottom: 24px;
    }
    
    .row {
        flex-direction: column;
    }
}

/* GitHub link styles */
.sidebar .nav-link[href*="github"] {
    color: #0366d6;
}

.sidebar .nav-link[href*="github"]:hover {
    color: #024ea2;
}

/* Links in content */
a {
    color: #1f77b4;
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover {
    color: #1565a0;
    text-decoration: underline;
}

hr {
    border: none;
    border-top: 1px solid #e9ecef;
    margin: 32px 0;
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.mt-3 {
    margin-top: 1rem;
}

.mb-3 {
    margin-bottom: 1rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

.mb-4 {
    margin-bottom: 1.5rem;
}

/* Multiselect tag styles (for future use) */
.tag {
    display: inline-block;
    padding: 4px 8px;
    background-color: #1f77b4;
    color: white;
    border-radius: 4px;
    font-size: 0.85rem;
    margin: 2px;
}

.tag:hover {
    background-color: #1565a0;
}

/* Dropdown multiselect styles */
.dropdown-multiselect {
    position: relative;
    margin-bottom: 0;
}

/* Spacing between dropdown containers */
#filter_systems_container,
#filter_species_container,
#dl_systems_container,
#dl_species_container {
    margin-bottom: 0;
}

.form-group {
    margin-bottom: 1rem;
}

/* Search Parameters Grid Layout */
.search-params-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 0;
}

.search-params-grid .form-group {
    margin-bottom: 0;
}

@media (max-width: 768px) {
    .search-params-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
}

/* 强制覆盖Bootstrap的dropdown-menu深色样式 */
.dropdown-multiselect .dropdown-menu,
.dropdown-multiselect .dropdown-menu.show,
.dropdown-multiselect .dropdown-menu[data-bs-popper],
.dropdown-multiselect .dropdown-menu.show[data-bs-popper] {
    width: 100% !important;
    padding: 4px 0 !important;
    max-height: 300px !important;
    overflow-y: auto !important;
    background-color: #ffffff !important;
    background: #ffffff !important;
    border: 1px solid #e9ecef !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
    color: #212529 !important;
}

.dropdown-multiselect .dropdown-menu li {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background-color: #ffffff !important;
    background: #ffffff !important;
}

.dropdown-multiselect .dropdown-item,
.dropdown-multiselect .dropdown-item:not(:disabled):not(.disabled),
.dropdown-multiselect .dropdown-item:not(.disabled):not(:disabled) {
    padding: 8px 16px !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    white-space: normal !important;
    border: none !important;
    width: 100% !important;
    background-color: #ffffff !important;
    background: #ffffff !important;
    color: #212529 !important;
}

.dropdown-multiselect .dropdown-item:hover,
.dropdown-multiselect .dropdown-item:focus,
.dropdown-multiselect .dropdown-item:hover:not(:disabled):not(.disabled),
.dropdown-multiselect .dropdown-item:focus:not(:disabled):not(.disabled) {
    background-color: #f8f9fa !important;
    background: #f8f9fa !important;
    color: #212529 !important;
    outline: none !important;
}

.dropdown-multiselect .dropdown-item:active,
.dropdown-multiselect .dropdown-item.active,
.dropdown-multiselect .dropdown-item:active:not(:disabled):not(.disabled) {
    background-color: #e9ecef !important;
    background: #e9ecef !important;
    color: #212529 !important;
}

.dropdown-multiselect .form-check-input {
    margin-top: 0.25rem;
    cursor: pointer;
    flex-shrink: 0;
}

.dropdown-multiselect .form-check-label {
    cursor: pointer;
    user-select: none;
    width: 100%;
    margin: 0;
    padding-left: 0.5rem;
}

.dropdown-multiselect .dropdown-toggle {
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dropdown-multiselect .dropdown-toggle::after {
    margin-left: auto;
    margin-top: 0;
}

.dropdown-multiselect .btn-outline-secondary {
    border-color: #ced4da;
    color: #495057;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.dropdown-multiselect .btn-outline-secondary:hover {
    background-color: #fafafa;
    border-color: #ced4da;
    color: #495057;
}

.dropdown-multiselect .btn-outline-secondary:focus {
    box-shadow: none;
    border-color: #1f77b4;
}

/* 额外确保所有dropdown相关元素都是浅色 */
.dropdown-multiselect * {
    color: #212529 !important;
}

.dropdown-multiselect .dropdown-menu * {
    background-color: transparent !important;
    color: #212529 !important;
}

.dropdown-multiselect .dropdown-item * {
    color: #212529 !important;
}

/* 确保checkbox和label也是浅色 */
.dropdown-multiselect .form-check-input {
    background-color: #ffffff !important;
    border-color: #ced4da !important;
}

.dropdown-multiselect .form-check-label {
    color: #212529 !important;
}

/* 自定义多选下拉框样式 */
.custom-multiselect {
    position: relative;
    width: 100%;
}

.multiselect-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    background-color: #ffffff;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.9375rem;
    color: #495057;
    user-select: none;
}

.multiselect-trigger:hover {
    border-color: #adb5bd;
    background-color: #fafafa;
}

.multiselect-trigger:focus {
    outline: none;
    border-color: #1f77b4;
    box-shadow: 0 0 0 3px rgba(31, 119, 180, 0.1);
}

.custom-multiselect.open .multiselect-trigger {
    border-color: #1f77b4;
    box-shadow: 0 0 0 3px rgba(31, 119, 180, 0.1);
}

.multiselect-text {
    flex: 1;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.multiselect-text.has-selection {
    color: #212529;
    font-weight: 500;
}

.multiselect-arrow {
    margin-left: 12px;
    color: #6c757d;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.custom-multiselect.open .multiselect-arrow {
    transform: rotate(180deg);
}

.multiselect-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background-color: #ffffff;
    border: 1px solid #ced4da;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    overflow: hidden;
    max-height: 300px;
    display: flex;
    flex-direction: column;
}

.multiselect-search {
    position: relative;
    padding: 8px;
    border-bottom: 1px solid #e9ecef;
    background-color: #fafafa;
}

.multiselect-search input {
    width: 100%;
    padding: 8px 32px 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.875rem;
}

.multiselect-search input:focus {
    outline: none;
    border-color: #1f77b4;
    box-shadow: 0 0 0 2px rgba(31, 119, 180, 0.1);
}

.multiselect-search i {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-size: 0.875rem;
}

.multiselect-actions {
    display: flex;
    gap: 8px;
    padding: 8px;
    border-bottom: 1px solid #e9ecef;
    background-color: #fafafa;
}

.multiselect-actions button {
    flex: 1;
    padding: 6px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background-color: #ffffff;
    color: #495057;
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.multiselect-actions button:hover {
    background-color: #f8f9fa;
    border-color: #adb5bd;
}

.multiselect-actions .btn-select-all:hover {
    background-color: #e7f3ff;
    border-color: #1f77b4;
    color: #1f77b4;
}

.multiselect-actions .btn-clear:hover {
    background-color: #fff5f5;
    border-color: #dc3545;
    color: #dc3545;
}

.multiselect-options {
    max-height: 240px;
    overflow-y: auto;
    padding: 4px 0;
}

.multiselect-options::-webkit-scrollbar {
    width: 8px;
}

.multiselect-options::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.multiselect-options::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.multiselect-options::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.multiselect-option {
    padding: 0;
    margin: 0;
}

.multiselect-option-label {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    margin: 0;
    user-select: none;
}

.multiselect-option-label:hover {
    background-color: #f8f9fa;
}

.multiselect-option.selected .multiselect-option-label {
    background-color: #e7f3ff;
}

.multiselect-option.selected .multiselect-option-label:hover {
    background-color: #d0e7ff;
}

.multiselect-checkbox {
    margin-right: 10px;
    cursor: pointer;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    accent-color: #1f77b4;
}

.multiselect-option-text {
    flex: 1;
    color: #212529;
    font-size: 0.9375rem;
    line-height: 1.5;
}

.multiselect-no-results {
    padding: 20px;
    text-align: center;
    color: #6c757d;
    font-size: 0.875rem;
}

