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

body {
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
        'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: #f5f5f5;
    color: #333;
    font-size: 14px;
    line-height: 1.5;
    padding-top: 56px;
    padding-bottom: 60px;
    height: 100vh;
    overflow-x: hidden;
}

#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* 隐藏类 */
.hidden {
    display: none !important;
}

/* 头部样式 */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background-color: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 0 16px;
}

.header-content {
    width: 100%;
}

#page-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0;
    text-align: center;
}

/* 主内容区域 */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px 80px 16px; /* 为底部导航留出空间 */
}

.page {
    display: none;
}

.page.active {
    display: block;
}

/* 首页样式 */
.header-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
}

.generate-btn {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.generate-btn:not(:disabled):hover {
    background-color: #0056b3;
}

.generate-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.generate-btn.loading {
    background-color: #6c757d;
}

.no-report {
    text-align: center;
    padding: 40px 20px;
}

.no-report p {
    margin-bottom: 20px;
    color: #666;
    font-size: 16px;
}

.primary-btn {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.primary-btn:not(:disabled):hover {
    background-color: #0056b3;
}

.primary-btn:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* 加载样式 */
.loading-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 60vh;
    width: 100%;
}

.loading-spinner {
    text-align: center;
}

.loading-spinner p {
    margin-top: 15px;
    color: #666;
    font-size: 14px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

/* 错误样式 */
.error-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 60vh;
    width: 100%;
    padding: 20px;
}

.error-content {
    text-align: center;
    max-width: 300px;
}

.error-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.error-content h3 {
    margin: 0 0 10px 0;
    color: #dc3545;
    font-size: 18px;
}

.error-content p {
    margin: 0 0 20px 0;
    color: #666;
    font-size: 14px;
    line-height: 1.5;
}

.retry-btn {
    background-color: #007bff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.retry-btn:hover {
    background-color: #0056b3;
}

/* 报告卡片样式 */
.report-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    margin-bottom: 20px;
    padding: 20px;
}

.report-header {
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
}

.report-header h2 {
    margin: 0 0 8px 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.report-time {
    font-size: 12px;
    color: #666;
}

.report-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid #eee;
}

.report-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.report-section h3 {
    margin: 0 0 12px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.report-section p {
    margin: 0;
    line-height: 1.6;
    color: #555;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.market-content {
    color: #28a745; /* 绿色表示上涨 */
}

.news-content,
.overall-content,
.plan-content {
    color: #555;
}

.favorable-stocks-content {
    color: #28a745; /* 绿色表示利好 */
    font-weight: 500;
}

.report-content-raw {
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    max-height: 60vh;
    overflow-y: auto;
}

.raw-content {
    white-space: pre-wrap;
    font-family: 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
        'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #333;
    margin: 0;
    word-wrap: break-word;
}

/* 历史报告页面 */
.history-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
    text-align: center;
}

.no-reports {
    text-align: center;
    padding: 40px 20px;
}

.no-reports p {
    color: #666;
    font-size: 16px;
}

.reports-list .report-item {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 15px;
    overflow: hidden;
}

.report-item .report-summary {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.3s;
}

.report-item .report-summary:hover {
    background-color: #f8f9fa;
}

.report-info {
    flex: 1;
}

.report-info h3 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.report-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    font-size: 12px;
    color: #666;
}

.report-meta span {
    display: flex;
    align-items: center;
}

.report-actions .expand-icon {
    font-size: 18px;
    color: #666;
}

.report-detail {
    padding: 0 16px 16px;
    border-top: 1px solid #eee;
}

/* 设置页面 */
.settings-title {
    font-size: 20px;
    font-weight: 600;
    color: #333;
    margin-bottom: 20px;
    text-align: center;
}

.settings-section {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    margin-bottom: 20px;
    overflow: hidden;
}

.settings-section h3 {
    padding: 16px 20px;
    margin: 0;
    background-color: #f8f9fa;
    font-size: 16px;
    font-weight: 600;
    color: #333;
    border-bottom: 1px solid #eee;
}

.setting-item {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #eee;
}

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

.setting-item label {
    font-size: 14px;
    color: #333;
    margin-right: 10px;
    flex: 1;
}

.setting-item input[type="text"] {
    flex: 2;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.setting-item select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background-color: white;
}

.toggle-switch {
    display: flex;
    align-items: center;
}

.toggle-switch input[type="checkbox"] {
    margin-right: 8px;
}

.about-info {
    padding: 16px 20px;
}

.about-info p {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: #666;
}

.about-info p:last-child {
    margin-bottom: 0;
}

/* 底部导航 */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: #fff;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    display: flex;
    justify-content: space-around;
    align-items: center;
    padding: 0 10px;
}

.nav-btn {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border: none;
    background: none;
    color: #666;
    font-size: 12px;
    cursor: pointer;
    transition: color 0.3s;
    padding: 5px 0;
}

.nav-btn.active {
    color: #007bff;
}

.nav-btn span {
    margin-top: 2px;
}

/* 模态框样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
}

.close-btn {
    font-size: 24px;
    cursor: pointer;
    color: #999;
}

.close-btn:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

/* 移动端适配 */
@media (max-width: 768px) {
    body {
        font-size: 16px; /* 防止iOS Safari缩放 */
        padding-top: 56px;
        padding-bottom: 60px;
    }
    
    .main-content {
        padding: 15px 12px 70px 12px;
    }
    
    #page-title {
        font-size: 16px;
    }
    
    .header-actions {
        margin-bottom: 15px;
    }
    
    .generate-btn {
        padding: 8px 16px;
        font-size: 14px;
    }
    
    .primary-btn {
        padding: 10px 20px;
        font-size: 16px;
    }
    
    .report-content {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .report-header {
        padding: 12px;
    }
    
    .report-header h2 {
        font-size: 16px;
    }
    
    .report-time {
        font-size: 11px;
    }
    
    .report-section {
        margin-bottom: 12px;
        padding-bottom: 12px;
    }
    
    .report-section h3 {
        font-size: 15px;
        margin-bottom: 10px;
    }
    
    .report-section p {
        font-size: 14px;
        line-height: 1.5;
    }
    
    .history-title, .settings-title {
        font-size: 18px;
        margin-bottom: 15px;
    }
    
    .reports-list .report-item {
        margin-bottom: 12px;
    }
    
    .report-item .report-summary {
        padding: 12px;
    }
    
    .report-info h3 {
        font-size: 15px;
        margin-bottom: 6px;
    }
    
    .report-meta {
        font-size: 11px;
        gap: 10px;
    }
    
    .report-actions .expand-icon {
        font-size: 16px;
    }
    
    .report-detail {
        padding: 0 12px 12px;
    }
    
    .settings-section {
        margin-bottom: 15px;
    }
    
    .settings-section h3 {
        padding: 12px 15px;
        font-size: 15px;
    }
    
    .setting-item {
        padding: 12px 15px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .setting-item label {
        margin-right: 0;
        margin-bottom: 5px;
    }
    
    .setting-item input[type="text"],
    .setting-item select {
        width: 100%;
    }
    
    .toggle-switch {
        align-self: flex-end;
    }
    
    .about-info {
        padding: 12px 15px;
    }
    
    .about-info p {
        font-size: 13px;
    }
    
    .bottom-nav {
        height: 50px;
        padding: 0 5px;
    }
    
    .nav-btn {
        font-size: 10px;
        padding: 3px 0;
    }
    
    .modal {
        padding: 10px;
    }
    
    .modal-body {
        padding: 15px;
    }
}

/* 深色主题 */
body.dark-theme {
    background-color: #1a1a1a;
    color: #e0e0e0;
}

.dark-theme .app-header {
    background-color: #2d2d2d;
    color: #e0e0e0;
}

.dark-theme #page-title {
    color: #e0e0e0;
}

.dark-theme .main-content {
    background-color: #1a1a1a;
}

.dark-theme .report-content,
.dark-theme .settings-section {
    background-color: #2d2d2d;
    color: #e0e0e0;
}

.dark-theme .report-header {
    background-color: #3d3d3d;
    color: #e0e0e0;
}

.dark-theme .report-section {
    border-bottom-color: #444;
}

.dark-theme .settings-section h3 {
    background-color: #3d3d3d;
    border-bottom-color: #444;
    color: #e0e0e0;
}

.dark-theme .setting-item {
    border-bottom-color: #444;
}

.dark-theme .modal-content {
    background-color: #2d2d2d;
    color: #e0e0e0;
}

.dark-theme .modal-header {
    border-bottom-color: #444;
}