/* 
 * 通用样式文件 - A股量化分析系统
 * 所有HTML报告共享的样式
 */

/* ========== 基础样式 ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
    /* 滚动优化 */
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* ========== 容器样式 ========== */
.container {
    max-width: 1400px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    backdrop-filter: blur(10px);
}

/* ========== 标题样式 ========== */
h1 {
    color: #4a5568;
    text-align: center;
    margin-bottom: 10px;
    font-size: 2.5em;
    background: linear-gradient(135deg, #667eea, #764ba2);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

h2 {
    color: #2d3748;
    margin: 30px 0 20px;
    font-size: 1.8em;
}

h3 {
    color: #4a5568;
    margin: 20px 0 15px;
    font-size: 1.4em;
}

.subtitle {
    text-align: center;
    color: #718096;
    margin-bottom: 40px;
    font-size: 1.2em;
}

/* ========== 统计卡片 ========== */
.stats-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 15px;
    border: 1px solid #f0f0f0;
    text-align: center;
}

.stat-card:hover {
    transform: translate3d(0, -2px, 0);
    border-color: #e0e0e0;
}

.stat-value {
    font-size: 2em;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
}

.stat-label {
    color: #718096;
    font-size: 0.9em;
}

/* ========== 股票行样式 ========== */
.stocks-container {
    margin-top: 30px;
}

.stock-row {
    background: white;
    margin-bottom: 30px;
    border-radius: 15px;
    padding: 20px;
    border: 1px solid #f0f0f0;
    /* 优化滚动性能 */
    content-visibility: auto;
    contain-intrinsic-size: 0 500px;
    contain: layout style paint;
}

/* 简化 hover 效果 */
.stock-row:hover {
    border-color: #e0e0e0;
    transform: translate3d(0, -1px, 0);
}

.stock-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
    position: relative;
}

.stock-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.stock-code {
    font-size: 1.4em;
    font-weight: bold;
    color: #2d3748;
}

.stock-name {
    color: #718096;
    font-size: 1.1em;
}

.rank-badge {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: 500;
    font-size: 0.9em;
}

/* ========== 质量徽章 ========== */
.quality-badge {
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.85em;
    min-width: 80px;
    text-align: center;
}

/* 优质股票样式 */
.quality-premium .quality-badge {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

/* 普通股票不显示徽章 */
.quality-normal .quality-badge {
    display: none;
}

/* 优质股票行的特殊样式 */
.stock-row.quality-premium {
    border: 1px solid rgba(245, 158, 11, 0.2);
    background: linear-gradient(to right, rgba(255, 251, 235, 0.5), white);
}

/* ========== 图表布局 ========== */
.three-column-layout {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
    align-items: start;
}

.chart-column, .analysis-column {
    background: #f8f9fa;
    border-radius: 12px;
    padding: 15px;
    border: 1px solid #e9ecef;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chart-column {
    max-height: 420px; /* 固定图表列高度 */
}

.analysis-column {
    max-height: 420px; /* 与图表列保持一致 */
    overflow-y: auto; /* 内容超出时可滚动 */
}

.column-title h3 {
    margin: 0 0 5px 0;
    font-size: 1.2em;
    color: #2d3748;
}

.column-title p {
    color: #718096;
    font-size: 0.85em;
    margin: 0 0 15px 0;
}

.chart-container {
    background: white;
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.chart-image {
    width: 100%;
    height: auto;
    max-height: 300px;
    object-fit: contain;
    display: block;
    border-radius: 4px;
    /* 优化图片加载 */
    loading: lazy;
    decoding: async;
}

/* ========== 分析内容样式 ========== */
.analysis-content {
    background: white;
    padding: 15px;
    border-radius: 8px;
    font-size: 0.85em;
    line-height: 1.6;
    color: #4a5568;
    flex: 1;
    overflow-y: auto;
    max-height: 340px;
}

/* 优化滚动条 */
.analysis-content::-webkit-scrollbar {
    width: 6px;
}

.analysis-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.analysis-content::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.analysis-content::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

.metric-group {
    margin-bottom: 15px;
    padding: 12px;
    background: #f7fafc;
    border-radius: 8px;
    border-left: 3px solid #667eea;
}

.metric-group h4 {
    color: #2d3748;
    margin-bottom: 8px;
    font-size: 1em;
    font-weight: 600;
}

.metric-item {
    display: flex;
    justify-content: space-between;
    margin: 6px 0;
    padding: 4px 0;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.9em;
}

.metric-item:last-child {
    border-bottom: none;
}

.metric-label {
    color: #718096;
    font-weight: 500;
}

.metric-value {
    color: #2d3748;
    font-weight: 600;
}

/* ========== 分页控件 ========== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 40px 0;
    gap: 10px;
}

.pagination button {
    padding: 10px 20px;
    border: none;
    background: white;
    color: #667eea;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.pagination button:hover:not(:disabled) {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-info {
    padding: 10px 20px;
    color: #4a5568;
    font-weight: 500;
}

/* ========== 响应式设计 ========== */
@media (max-width: 1200px) {
    .three-column-layout {
        grid-template-columns: 1fr;
    }
    
    .container {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 15px;
        border-radius: 15px;
    }
    
    h1 {
        font-size: 2em;
    }
    
    .stock-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
    
    .stats-container {
        grid-template-columns: 1fr 1fr;
    }
    
    .pagination button {
        padding: 8px 15px;
        font-size: 0.9em;
    }
}

/* ========== 性能优化 ========== */
/* 启用快速滚动 */
html {
    scroll-behavior: auto; /* 避免 smooth 导致的卡顿 */
}

/* 图片预加载优化 */
img {
    content-visibility: auto;
}

.page {
    /* 移除动画以提升初始加载速度 */
}

/* ========== 工具类 ========== */
.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mt-30 {
    margin-top: 30px;
}

.mb-20 {
    margin-bottom: 20px;
}

.mb-30 {
    margin-bottom: 30px;
}

/* ========== 加载动画 ========== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ========== 打印样式 ========== */
@media print {
    body {
        background: white;
        padding: 0;
    }
    
    .container {
        box-shadow: none;
        padding: 20px;
        max-width: 100%;
    }
    
    .pagination {
        display: none;
    }
    
    .stock-row {
        page-break-inside: avoid;
    }
}
