/* ============================================
   COReD Clinical Search - Shared Styles
   共享样式文件 - 用于 search_clinical.php 和 search_clinical_GWAS.php
   ============================================ */

/* 基础重置和全局样式 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, input, button, select, textarea, 
.highcharts-axis-labels, .highcharts-title, .highcharts-legend-item {
    font-family: 'Segoe UI', 'Arial', sans-serif;
}

/* ===== 数据模块容器 ===== */
.data-modules-container {
    display: none;
}

.data-modules-container.active {
    display: block;
}

/* ===== 搜索区域样式 ===== */
.search-container {
    max-width: 800px;
    margin: 2rem auto;
    text-align: center;
}

.search-box {
    width: 60%;
    padding: 12px 20px;
    border: 1px solid #ddd;
    border-radius: 25px;
    font-size: 16px;
    outline: none;
    font-family: 'Segoe UI', 'Arial', sans-serif;
    transition: all 0.3s ease;
}

.search-box:focus {
    border-color: #007bff;
    box-shadow: 0 0 8px rgba(0, 123, 255, 0.2);
}

.search-btn {
    padding: 12px 25px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 16px;
    margin-left: 10px;
    font-weight: bold;
    font-family: 'Segoe UI', 'Arial', sans-serif;
    transition: all 0.2s ease;
}

.search-btn:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.search-btn:active {
    transform: translateY(0);
}

/* ===== 图片容器 ===== */
.image-container {
    max-width: 800px;
    margin: 0 auto;
    text-align: center;
}

.scheme-image {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
}

/* ===== 模式切换按钮 ===== */
.modification-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin: 15px 0;
    flex-wrap: wrap;
}

.mod-btn {
    padding: 10px 25px;
    background-color: #f8f9fa;
    border: 1px solid #007bff;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    color: #007bff;
    font-family: 'Segoe UI', 'Arial', sans-serif;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
}

.mod-btn:hover {
    background-color: #e9ecef;
    transform: translateY(-1px);
}

.mod-btn.active {
    background-color: #007bff;
    color: white;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

/* ===== 组织/病毒选择按钮 ===== */
.tissue-buttons-container {
    display: none;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 15px 0;
    padding: 10px 0;
}

.tissue-buttons-container.active {
    display: flex;
}

.tissue-btn {
    padding: 10px 20px;
    background-color: #f8f9fa;
    border: 1px solid #007bff;
    border-radius: 5px;
    cursor: pointer;
    color: #007bff;
    font-weight: bold;
    font-family: 'Segoe UI', 'Arial', sans-serif;
    transition: all 0.2s ease;
}

.tissue-btn:hover {
    background-color: #e9ecef;
    transform: translateY(-1px);
}

.tissue-btn.active {
    background-color: #007bff;
    color: white;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

/* ===== GWAS选择器样式 ===== */
.gwas-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    margin: 20px auto;
    padding: 15px 25px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 50px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    width: fit-content;
    flex-wrap: wrap;
}

.gwas-selector label {
    font-size: 0.95rem;
    font-weight: bold;
    color: #2c3e50;
    font-family: 'Segoe UI', 'Arial', sans-serif;
}

.gwas-selector select {
    padding: 10px 20px;
    border-radius: 30px;
    border: 2px solid #007bff;
    background: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    outline: none;
    color: #007bff;
    font-family: 'Segoe UI', 'Arial', sans-serif;
    transition: all 0.2s ease;
    min-width: 220px;
}

.gwas-selector select:hover {
    background-color: #f0f7ff;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.2);
}

.gwas-selector select:focus {
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

.gwas-load-btn {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 28px;
    border-radius: 30px;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.9rem;
    font-family: 'Segoe UI', 'Arial', sans-serif;
    transition: all 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 123, 255, 0.3);
}

.gwas-load-btn:hover {
    background-color: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
}

.gwas-status {
    font-size: 0.85rem;
    font-weight: bold;
    color: #2c3e50;
    font-family: 'Segoe UI', 'Arial', sans-serif;
    background: white;
    padding: 6px 15px;
    border-radius: 30px;
    background: #e8f4f8;
}

/* ===== 主内容区域布局 ===== */
.main-content-area {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 15px;
    margin: 0 auto 20px;
    width: 79%;
    max-width: 1600px;
}

.gwas-main-content {
    max-width: 1400px;
    margin: 20px auto;
    padding: 0 20px;
}

/* 病毒按钮侧边栏 */
.virus-buttons-sidebar {
    width: 180px;
    flex-shrink: 0;
}

.virus-buttons-sidebar .button-virus {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.virus-buttons-sidebar .virus-btn {
    width: 100%;
    padding: 10px 8px;
    text-align: center;
    background-color: #f8f9fa;
    border: 1px solid #007bff;
    border-radius: 5px;
    cursor: pointer;
    color: #007bff;
    font-weight: bold;
    font-size: 14px;
    font-family: 'Segoe UI', 'Arial', sans-serif;
    transition: all 0.2s ease;
}

.virus-buttons-sidebar .virus-btn:hover {
    background-color: #e9ecef;
    transform: translateY(-1px);
}

.virus-buttons-sidebar .virus-btn.active {
    background-color: #007bff;
    color: white;
}

.virus-buttons-sidebar .virus-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #f8f9fa;
    color: #6c757d;
    border-color: #dee2e6;
}

/* ===== 图表区域 ===== */
.chart-area {
    flex: 1;
    min-width: 0;
}

.chart-container {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 12px;
    background-color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    min-height: 700px;
}

.chart-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 10px;
    padding: 5px 10px;
    background-color: #f8f9fa;
    border-radius: 3px;
}

.download-btn {
    padding: 8px 15px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 5px;
    font-weight: bold;
    font-family: 'Segoe UI', 'Arial', sans-serif;
    transition: all 0.2s ease;
}

.download-btn:hover {
    background-color: #218838;
    transform: translateY(-1px);
}

.download-btn:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    transform: none;
}

#boxplot-container {
    width: 100%;
    min-height: 700px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.chart-content {
    text-align: center;
    padding: 50px;
    color: #666;
    font-size: 16px;
    font-family: 'Segoe UI', 'Arial', sans-serif;
}

/* ===== 箱线图网格样式 ===== */
.boxplot-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    margin-top: 20px;
    width: 100%;
    box-sizing: border-box;
}

.boxplot-cell {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px;
    background-color: #fff;
    position: relative;
    min-height: 560px;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    overflow: visible;
    box-sizing: border-box;
    break-inside: avoid;
    page-break-inside: avoid;
    transition: box-shadow 0.2s ease;
}

.boxplot-cell:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.cell-header {
    flex-shrink: 0;
    margin-bottom: 10px;
    padding-bottom: 0;
    position: relative;
    border-bottom: none;
}

.cell-title {
    text-align: center;
    font-weight: bold;
    font-size: 16px;
    color: #333;
    padding: 8px 5px;
    background-color: transparent;
    border-radius: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: none;
    font-family: 'Segoe UI', 'Arial', sans-serif;
}

.cell-chart {
    width: 100%;
    height: 460px;
    flex-shrink: 0;
}

.single-download-icon {
    position: absolute;
    bottom: 8px;
    right: 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 12px;
    color: #888;
    padding: 5px 8px;
    border-radius: 4px;
    transition: all 0.2s ease;
    z-index: 15;
    opacity: 0.7;
}

.single-download-icon:hover {
    opacity: 1;
    color: #007bff;
    background: rgba(0, 123, 255, 0.1);
}

.single-download-icon i {
    font-size: 12px;
}

/* ===== GWAS图表样式 ===== */
.plot-area {
    position: relative;
    padding: 20px;
    margin-bottom: 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.gwas-plot-container {
    width: 100%;
    height: 600px;
    border-radius: 16px;
}

/* ===== GWAS表格样式 ===== */
.gwas-tables-section {
    margin-top: 20px;
}

.table-card {
    background: #ffffff;
    border-radius: 20px;
    margin-top: 20px;
    border: 1px solid #eef2f8;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: #f9fbfe;
    border-bottom: 1px solid #eef2f8;
    flex-wrap: wrap;
    gap: 12px;
}

.table-header h3 {
    font-size: 1.2rem;
    font-weight: bold;
    color: #1f5e4b;
    margin: 0;
    font-family: 'Segoe UI', 'Arial', sans-serif;
}

.table-info {
    font-size: 0.75rem;
    font-weight: bold;
    color: #4b5563;
    background: #eef2ff;
    padding: 4px 12px;
    border-radius: 20px;
    font-family: 'Segoe UI', 'Arial', sans-serif;
}

.pagination-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px;
    background: #ffffff;
    border-bottom: 1px solid #eef2f8;
}

.pagination-buttons {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.pagination-buttons button,
.page-size-select {
    background: white;
    border: 1px solid #cbd5e1;
    padding: 5px 12px;
    border-radius: 24px;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: bold;
    transition: 0.2s;
    font-family: 'Segoe UI', 'Arial', sans-serif;
}

.pagination-buttons button:hover:not(:disabled) {
    background: #2c7a64;
    color: white;
    border-color: #2c7a64;
}

.pagination-buttons button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-size-select {
    cursor: pointer;
    background: #f8fafc;
    font-weight: bold;
}

.table-wrapper {
    max-height: 480px;
    overflow-y: auto;
    font-size: 0.8rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Segoe UI', 'Arial', sans-serif;
    font-size: 0.85rem;
}

th, td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #edf2f7;
}

th {
    background: #f1f5f9;
    position: sticky;
    top: 0;
    font-weight: bold;
    color: #1e293b;
    cursor: pointer;
    user-select: none;
    font-family: 'Segoe UI', 'Arial', sans-serif;
    z-index: 10;
}

th:hover {
    background: #e2e8f0;
}

tbody tr:hover {
    background-color: #fefce8;
}

tr.snp-significant-genome {
    background-color: #fee2e2 !important;
}

tr.snp-significant-suggestive {
    background-color: #fff3e0 !important;
}

.csv-btn {
    background: #2c7a64;
    color: white;
    border: none;
    padding: 6px 16px;
    border-radius: 30px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: bold;
    transition: 0.2s;
    font-family: 'Segoe UI', 'Arial', sans-serif;
}

.csv-btn:hover {
    background: #1f5e4b;
    transform: translateY(-1px);
}

/* ===== 信息面板 ===== */
.info-panel {
    max-width: 1200px;
    margin: 20px auto;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 5px;
    border-left: 4px solid #007bff;
}

.info-panel h3 {
    margin-top: 0;
    color: #007bff;
    font-weight: bold;
    font-family: 'Segoe UI', 'Arial', sans-serif;
}

.data-summary {
    display: flex;
    justify-content: space-around;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: 15px;
}

.data-item {
    text-align: center;
    padding: 10px;
    min-width: 150px;
}

.data-value {
    font-size: 24px;
    font-weight: bold;
    color: #2c3e50;
    font-family: 'Segoe UI', 'Arial', sans-serif;
}

.data-label {
    font-size: 12px;
    font-weight: bold;
    color: #7f8c8d;
    margin-top: 5px;
    font-family: 'Segoe UI', 'Arial', sans-serif;
}

/* ===== 加载和状态样式 ===== */
.loading {
    text-align: center;
    padding: 40px;
    color: #666;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-message {
    text-align: center;
    padding: 40px;
    color: #e74c3c;
    font-size: 18px;
    background-color: #ffe6e6;
    border-radius: 5px;
    margin: 20px;
    font-weight: bold;
    font-family: 'Segoe UI', 'Arial', sans-serif;
}

.progress-container {
    width: 100%;
    max-width: 600px;
    margin: 40px auto;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 10px;
    text-align: center;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background-color: #e9ecef;
    border-radius: 15px;
    overflow: hidden;
    margin: 15px 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #007bff, #0056b3);
    width: 0%;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.progress-text {
    font-size: 16px;
    font-weight: bold;
    color: #333;
    margin: 10px 0;
    font-family: 'Segoe UI', 'Arial', sans-serif;
}

/* ===== 调试面板 ===== */
.debug-panel {
    max-width: 1200px;
    margin: 20px auto;
    padding: 15px;
    background-color: #1e1e1e;
    border-radius: 5px;
    font-family: monospace;
    font-size: 11px;
    max-height: 400px;
    overflow-y: auto;
    color: #d4d4d4;
    display: none;
}

.debug-panel h3 {
    color: #4ec9b0;
    margin-top: 0;
    font-weight: bold;
}

.debug-toggle {
    background-color: #007acc;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 12px;
    margin-bottom: 10px;
    font-weight: bold;
    font-family: 'Segoe UI', 'Arial', sans-serif;
}

.debug-toggle:hover {
    background-color: #005a9e;
}

.debug-content {
    display: none;
    white-space: pre-wrap;
    background-color: #252526;
    padding: 10px;
    border-radius: 3px;
}

.debug-content.active {
    display: block;
}

.debug-line {
    border-bottom: 1px solid #3c3c3c;
    padding: 2px 0;
}

/* ===== 提示和覆盖层 ===== */
.db-repair-alert {
    max-width: 1200px;
    margin: 20px auto;
    padding: 15px;
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 5px;
    color: #856404;
}

.loading-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px 30px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    z-index: 10001;
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    color: #333;
    font-family: 'Segoe UI', 'Arial', sans-serif;
}

.loading-overlay i {
    margin-right: 8px;
    color: #007bff;
}

/* ===== 下载菜单样式 ===== */
.download-menu {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    z-index: 10002;
    min-width: 280px;
    padding: 20px;
    font-family: 'Segoe UI', 'Arial', sans-serif;
}

.download-menu h4 {
    margin: 0 0 15px 0;
    font-weight: bold;
}

.download-option {
    display: block;
    width: 100%;
    padding: 10px;
    margin: 8px 0;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-family: 'Segoe UI', 'Arial', sans-serif;
    transition: all 0.2s ease;
}

.download-option:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.download-option.green {
    background: #28a745;
}

.download-option.green:hover {
    background: #218838;
}

.cancel-btn {
    display: block;
    width: 100%;
    padding: 10px;
    margin: 8px 0;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-family: 'Segoe UI', 'Arial', sans-serif;
    transition: all 0.2s ease;
}

.cancel-btn:hover {
    background: #5a6268;
}

.download-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 10001;
}

/* ===== 响应式布局 ===== */
@media (max-width: 1400px) {
    .boxplot-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .main-content-area {
        width: 90%;
    }
}

@media (max-width: 1100px) {
    .boxplot-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .search-box {
        width: 100%;
        margin-bottom: 10px;
    }
    
    .search-btn {
        width: 100%;
        margin-left: 0;
    }
    
    .boxplot-grid {
        grid-template-columns: 1fr;
    }
    
    .main-content-area {
        flex-direction: column;
        align-items: center;
        width: 95%;
    }
    
    .virus-buttons-sidebar {
        width: 100%;
        max-width: 100%;
    }
    
    .virus-buttons-sidebar .button-virus {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .virus-buttons-sidebar .virus-btn {
        width: auto;
        min-width: 100px;
    }
    
    .gwas-selector {
        flex-direction: column;
        width: 90%;
        border-radius: 20px;
    }
    
    .gwas-selector select {
        width: 100%;
    }
    
    .table-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .pagination-controls {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .modification-buttons {
        gap: 10px;
    }
    
    .mod-btn {
        padding: 8px 18px;
        font-size: 14px;
    }
}