/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #ffffff;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* 头部样式 */
header {
    background: linear-gradient(135deg, #2c3e50, #1a2a3a);
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
    text-align: center;
    font-size: 2.2rem;
    font-weight: 600;
}

/* 主要内容区域 */
main {
    padding: 2rem 0;
}

h2 {
    color: #2c3e50;
    margin-bottom: 1.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #CD1818;
    font-size: 1.8rem;
}

/* 策略卡片样式 */
.top-strategies {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 3rem;
}

.strategy-card {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
    border: 1px solid #e1e8ed;
}

.strategy-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.strategy-card h3 {
    color: #2c3e50;
    margin-bottom: 1rem;
    font-size: 1.4rem;
}

.strategy-card p {
    margin: 0.8rem 0;
    font-size: 1.1rem;
}

.strategy-card .label {
    font-weight: 500;
    color: #2c3e50;
}

.strategy-card .detail-link {
    display: inline-block;
    background: #3498db;
    color: white;
    padding: 0.6rem 1.2rem;
    border-radius: 5px;
    text-decoration: none;
    font-weight: 500;
    transition: background 0.3s;
    margin-top: 1rem;
}

.strategy-card .detail-link:hover {
    background: #2980b9;
}

/* 表格样式 */
.table-container {
    overflow-x: auto;
    background: white;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    margin-bottom: 2rem;
    -webkit-overflow-scrolling: touch;
}

.strategy-table, .positions-table, .transactions-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px; /* 确保表格在小屏幕上也能正常显示 */
}

.strategy-table th, .positions-table th, .transactions-table th {
    background-color: #8B0000;
    color: white;
    text-align: left;
    padding: 2.25rem; /* 从1.5rem调整为2.25rem (1.5 * 1.5) */
    font-weight: 500;
    white-space: nowrap;
}

.strategy-table td, .positions-table td, .transactions-table td {
    padding: 2.025rem; /* 从1.35rem调整为2.025rem (1.35 * 1.5) */
    border-bottom: 1px solid #eee;
    white-space: nowrap;
}

.strategy-table tr:hover, .positions-table tr:hover, .transactions-table tr:hover {
    background-color: #f8f9fa;
}

.strategy-table tr:nth-child(even), .positions-table tr:nth-child(even), .transactions-table tr:nth-child(even) {
    background-color: #f8f9fa;
}

/* 策略详情页样式 */
.update-time {
    background: #ffebee;
    color: #CD1818;
    padding: 0.8rem 1.2rem;
    border-radius: 5px;
    margin-bottom: 1.5rem;
    font-weight: 500;
    text-align: right;
    white-space: nowrap !important; /* 确保更新时间不换行，使用!important提高优先级 */
}

.strategy-overview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 2rem;
}

.overview-item {
    background: white;
    padding: 1.2rem;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.overview-item .label {
    font-weight: 500;
    color: #2c3e50;
}

.chart-container {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    margin-bottom: 2rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.chart-wrapper {
    min-width: 800px;
    width: 100%;
}

.strategy-description {
    background: white;
    padding: 1.5rem;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
}

.strategy-description p {
    font-size: 1.1rem;
    line-height: 1.8;
}

.description-content {
    font-size: 1.1rem;
    line-height: 1.8;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.description-content p {
    margin-bottom: 1rem;
}

.description-content ul, 
.description-content ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.description-content li {
    margin-bottom: 0.5rem;
}

.description-content h3, 
.description-content h4 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    color: #2c3e50;
}

.description-content h3 {
    font-size: 1.4rem;
}

.description-content h4 {
    font-size: 1.2rem;
}

.description-content strong {
    font-weight: 600;
}

.description-content em {
    font-style: italic;
}

/* 颜色类 - 按照金融行业惯例，红色表示正向/买入，绿色表示负向/卖出 */
.positive {
    color: #e74c3c; /* 红色 */
    font-weight: 600;
}

.negative {
    color: #27ae60; /* 绿色 */
    font-weight: 600;
}

.red {
    color: #e74c3c; /* 红色 */
    font-weight: 600;
}

.green {
    color: #27ae60; /* 绿色 */
    font-weight: 600;
}

/* 页脚样式 */
footer {
    background: #2c3e50;
    color: white;
    text-align: center;
    padding: 1.5rem 0;
    margin-top: 2rem;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .top-strategies {
        grid-template-columns: 1fr;
    }
    
    .strategy-overview {
        grid-template-columns: 1fr;
    }
    
    header h1 {
        font-size: 1.8rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    .strategy-table th, 
    .strategy-table td, 
    .positions-table th, 
    .positions-table td,
    .transactions-table th,
    .transactions-table td {
        padding: 1.35rem; /* 移动端保持较小的内边距 从0.9rem调整为1.35rem (0.9 * 1.5) */
        font-size: 0.9rem;
    }
    
    .overview-item {
        padding: 1rem;
    }
    
    /* 在小屏幕上允许表格内容换行以适应屏幕，但保持日期和时间字段不换行 */
    .strategy-table, .positions-table, .transactions-table {
        min-width: auto;
    }
    
    /* 保持日期和时间字段不换行 - 使用!important提高优先级 */
    .positions-table td:nth-child(1),   /* 买入日期 */
    .transactions-table td:nth-child(6), /* 交易时间 */
    .strategy-table td:nth-child(10),   /* 首页策略目录最大回撤时间 */
    .strategy-table td:nth-child(13),   /* 首页策略目录更新时间 */
    .update-time {  /* 更新时间 */
        white-space: nowrap !important;
    }
    
    /* 其他字段在小屏幕上可以换行 */
    .strategy-table td:not(:nth-child(1)):not(:nth-child(10)):not(:nth-child(13)), 
    .positions-table td:not(:nth-child(1)),
    .transactions-table td:not(:nth-child(6)) {
        white-space: normal;
    }
    
    /* 移动端表格优化 */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .strategy-table, .positions-table, .transactions-table {
        display: block;
        font-size: 0.8rem;
    }
    
    /* 仅对持仓明细表格应用宽度调整 */
    .positions-table {
        width: 100%; /* 调整为100%宽度 */
    }
    
    /* 移动端表格每列宽度减少1% */
    .positions-table th:nth-child(1),
    .positions-table td:nth-child(1) { /* 股票代码 */
        width: calc(20% - 1%);
    }
    
    .positions-table th:nth-child(2),
    .positions-table td:nth-child(2) { /* 股票名称 */
        width: calc(20% - 1%);
    }
    
    .positions-table th:nth-child(3),
    .positions-table td:nth-child(3) { /* 持仓成本 */
        width: calc(20% - 1%);
    }
    
    .positions-table th:nth-child(4),
    .positions-table td:nth-child(4) { /* 持仓盈亏 */
        width: calc(20% - 1%);
    }
    
    .positions-table th:nth-child(5),
    .positions-table td:nth-child(5) { /* 仓位占比 */
        width: calc(20% - 1%);
    }
    
    /* 移动端表格标题优化 */
    .strategy-table th, .positions-table th, .transactions-table th {
        font-size: 0.85rem;
        padding: 1.125rem; /* 移动端也按1.5倍调整 从0.75rem调整为1.125rem (0.75 * 1.5) */
    }
    
    .strategy-table td, .positions-table td, .transactions-table td {
        padding: 1.125rem; /* 移动端也按1.5倍调整 从0.75rem调整为1.125rem (0.75 * 1.5) */
        font-size: 0.8rem;
    }
    
    /* 图表容器在移动端的优化 */
    .chart-container {
        padding: 1rem;
        overflow-x: auto;
        width: 100%;
    }
    
    .chart-wrapper {
        min-width: 100%;
        width: max-content;
    }
    
    /* 确保Canvas元素在移动端也能正确滚动 */
    #returnChart {
        min-width: 100%;
        width: 800px;
        height: 400px; /* 调整为400px */
    }
    
    /* 移动端图表优化 */
    .chart-container {
        padding: 0.8rem;
    }
    
    .chart-wrapper {
        min-width: 100%;
    }
    
    #returnChart {
        min-width: 100%;
        width: 800px;
    }
}

/* 分页样式 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.page-link, .current-page {
    padding: 8px 12px;
    margin: 0 4px;
    text-decoration: none;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.page-link {
    color: #3498db;
    background-color: #fff;
}

.page-link:hover {
    background-color: #f5f5f5;
}

.current-page {
    background-color: #3498db;
    color: white;
    font-weight: bold;
}

.page-info {
    margin-left: 20px;
    color: #666;
}

@media (max-width: 768px) {
    .page-info {
        margin-left: 0;
        margin-top: 10px;
        width: 100%;
        text-align: center;
    }
}

/* AJAX加载指示器 */
.loading {
    text-align: center;
    padding: 20px;
}

.loading:after {
    content: "加载中...";
    color: #3498db;
    font-weight: bold;
}

/* 策略概述桌面端优化样式 */
@media (min-width: 769px) {
    .strategy-overview {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
        gap: 25px;
        margin: 30px 0;
        padding: 25px;
        background: linear-gradient(135deg, #f8f9fa, #e9ecef);
        border-radius: 15px;
        box-shadow: 0 8px 25px rgba(0,0,0,0.1);
    }
    
    .overview-item {
        background: white;
        padding: 25px 20px;
        border-radius: 12px;
        box-shadow: 0 4px 15px rgba(0,0,0,0.08);
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        transition: all 0.3s ease;
        border: 1px solid #e9ecef;
    }
    
    .overview-item:hover {
        transform: translateY(-8px);
        box-shadow: 0 12px 25px rgba(0,0,0,0.15);
    }
    
    .overview-item .label {
        font-size: 1.2rem;
        font-weight: 600;
        color: #495057;
        margin-bottom: 15px;
    }
    
    .overview-item .value {
        font-size: 1.6rem;
        font-weight: 700;
    }
    
    .overview-item .positive {
        color: #e74c3c;
    }
    
    .overview-item .negative {
        color: #27ae60;
    }
}