* {
    box-sizing: border-box;
}

:root {
    --primary-color: #0747a6;
    --secondary-color: #0065ff;
    --background-color: #f4f5f7;
    --card-color: #ffffff;
    --danger-color: #e53935;
    --warning-color: #fb8c00;
    --success-color: #43a047;
    --card-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
    --hover-shadow: 0 6px 15px rgba(0, 0, 0, 0.12);
    --border-radius: 10px;
    --transition-speed: 0.3s;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Roboto', sans-serif;
    background-color: var(--background-color);
    background-image: linear-gradient(to bottom right, rgba(7, 71, 166, 0.03), rgba(0, 101, 255, 0.02));
    color: #37474f;
    letter-spacing: 0.015em;
    font-weight: 400;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.app-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: var(--primary-color);
    background-image: linear-gradient(to right, var(--primary-color), var(--secondary-color));
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 10;
}

.main-content {
    margin-top: 64px;
    padding: 20px 24px 20px 20px; /* 保持原有内边距 */
    height: calc(100vh - 64px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    max-width: 100%;
}

/* 两栏布局 */
.two-column-layout {
    display: flex;
    gap: 0; /* 移除间距 */
    height: 100%;
    flex: 1;
    padding: 4px 0;
    justify-content: flex-start; /* 从左开始 */
}

.left-column {
    flex: 0 0 600px; /* 增加宽度 */
    width: 600px; /* 增加宽度 */
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0; /* 移除内边距 */
    margin: 0; /* 移除外边距 */
    box-sizing: border-box; /* 确保盒模型计算正确 */
}

.right-column {
    flex: 1; /* 占据剩余所有空间 */
    overflow-y: auto;
    min-width: 0; /* 防止内容溢出 */
    margin-left: 0; /* 移除左边距 */
    padding-left: 20px; /* 适当的左内边距 */
}

.dashboard-container {
    display: flex;
    flex-direction: column;
    gap: 16px; /* 减小间距 */
    height: 100%;
}

.chart-row {
    display: flex;
    gap: 16px; /* 减小间距 */
    width: 100%;
}

.chart-card {
    background-color: var(--card-color);
    border-radius: var(--border-radius);
    box-shadow: var(--card-shadow);
    padding: 14px 14px 14px 20px; /* 增加左侧内边距 */
    flex: 1;
    min-height: 320px; /* 再减小高度 */
    transition: transform var(--transition-speed), box-shadow var(--transition-speed);
    max-width: 100%; /* 确保不溢出 */
}

.chart-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--hover-shadow);
}

.wide-card {
    flex: 2;
}

.chart-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--primary-color);
    position: relative;
    padding-bottom: 8px;
    letter-spacing: 0.02em;
}

.chart-title::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 40px;
    height: 3px;
    background-color: var(--secondary-color);
    border-radius: 3px;
}

.chart-container {
    height: calc(100% - 48px);
    width: 100%;
    border-radius: 8px;
    overflow: hidden;
    transition: all var(--transition-speed);
    position: relative;
}

.chart-container::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    box-shadow: inset 0 0 0 1px rgba(7, 71, 166, 0.05);
    border-radius: 8px;
}

/* AI 建议卡片样式 */
.ai-recommendation-card {
    background-color: var(--card-color);
    border-radius: var(--border-radius) 0 0 var(--border-radius); /* 只保留左侧圆角 */
    box-shadow: var(--card-shadow);
    padding: 20px 0 0 20px; /* 移除右侧内边距 */
    width: 100%; /* 确保宽度为100% */
    height: calc(100vh - 104px); /* 视口高度减去顶部栏和内边距 */
    display: flex; /* 默认显示容器 */
    flex-direction: column;
    position: sticky;
    top: 0;
    border-left: 4px solid var(--secondary-color);
    border-right: 1px solid rgba(0, 0, 0, 0.05); /* 添加右侧边框 */
    backdrop-filter: blur(10px);
    transition: box-shadow var(--transition-speed);
    box-sizing: border-box; /* 确保内边距不会增加元素的总宽度 */
    max-width: 100%; /* 确保不超出父容器 */
    margin-right: 0; /* 移除可能的右边距 */
}

.ai-recommendation-card:hover {
    box-shadow: var(--hover-shadow);
}

.markdown-content {
    display: none; /* 默认隐藏内容 */
    opacity: 0;
}

.markdown-content.visible {
    display: block; /* 显示时可见 */
    height: 100%;
    width: 100%;
    max-width: 100%;
    overflow-y: auto;
    opacity: 1;
    animation: fadeIn 0.5s ease-in-out;
    padding-right: 5px; /* 为滚动条留出空间 */
    box-sizing: border-box;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ai-recommendation-card .card-header {
    flex-shrink: 0;
}

.ai-recommendation-card .card-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: flex-start; /* 从顶部开始 */
    height: calc(100% - 40px); /* 减去标题高度 */
    padding: 0 20px 0 0; /* 增加右侧内边距 */
    width: 100%; /* 确保宽度为100% */
    box-sizing: border-box; /* 确保盒模型计算正确 */
}

.empty-state-message {
    text-align: center;
    color: #78909c;
    font-size: 1.1rem;
    padding: 2rem 0;
    display: flex;
    align-items: center;
    justify-content: center;
    height: auto;
    min-height: 120px;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23e3f2fd' fill-opacity='0.6'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    border: 1px dashed #b0bec5;
    border-radius: var(--border-radius);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 0.7; }
    50% { opacity: 1; }
    100% { opacity: 0.7; }
}

/* 当AI建议内容显示时，隐藏空状态消息 */
.markdown-content.visible ~ .empty-state-message {
    display: none;
}

.ai-recommendation-card .card-header {
    margin-bottom: 12px;
    padding-bottom: 10px;
    padding-right: 15px; /* 添加右侧内边距 */
    position: relative;
}

.ai-recommendation-card .card-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 60px;
    height: 3px;
    background-color: var(--secondary-color);
    border-radius: 3px;
}

.ai-recommendation-card .card-header h2 {
    color: var(--primary-color);
    font-size: 1.5rem;
    margin: 0;
    font-weight: 600;
    letter-spacing: 0.02em;
    display: flex;
    align-items: center;
}

.ai-recommendation-card .card-header h2::before {
    content: '🔍';
    margin-right: 8px;
    font-size: 1.2rem;
}

/* 已合并到上面的相同选择器中 */

.markdown-content {
    font-size: 1rem;
    line-height: 1.6;
    overflow-wrap: break-word;
    height: 100%;
    width: 100%;
    padding: 8px 8px 8px 0;
    box-sizing: border-box;
    max-width: 100%;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3 {
    color: var(--primary-color);
    margin-top: 1.2em;
    margin-bottom: 0.8em;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.markdown-content h1 {
    font-size: 1.8rem;
    border-bottom: 2px solid rgba(7, 71, 166, 0.1);
    padding-bottom: 0.3em;
}

.markdown-content h2 {
    font-size: 1.5rem;
    border-bottom: 1px solid rgba(7, 71, 166, 0.1);
    padding-bottom: 0.2em;
}

.markdown-content h3 {
    font-size: 1.3rem;
}

.markdown-content p {
    margin: 0.8em 0 1em;
    line-height: 1.7;
    max-width: 100%; /* 确保段落利用全宽 */
}

.markdown-content ul,
.markdown-content ol {
    padding-left: 25px;
    margin: 1em 0;
}

.markdown-content li {
    margin: 0.4em 0;
    line-height: 1.6;
}

.markdown-content strong {
    color: #37474f;
    font-weight: 600;
}

.markdown-content em {
    color: #0747a6;
}

.markdown-content code {
    background-color: #f3f5f7;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    color: #e53935;
}

.markdown-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1.5em 0;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.07);
    border-radius: 5px;
    overflow: hidden;
}

.markdown-content th,
.markdown-content td {
    border: 1px solid #e0e0e0;
    padding: 10px 12px;
    text-align: left;
}

.markdown-content th {
    background-color: #f5f7fa;
    font-weight: 600;
    color: var(--primary-color);
}

.markdown-content tr:nth-child(even) {
    background-color: #fafbfc;
}

.markdown-content tr:hover {
    background-color: #f0f4f8;
}

/* 美化上传按钮 */
.custom-btn {
    background-color: rgba(255, 255, 255, 0.15) !important;
    border-radius: 50px !important;
    transition: all 0.3s !important;
    backdrop-filter: blur(5px);
    padding: 0 20px !important;
    height: 36px !important;
    letter-spacing: 0.02em;
}

.custom-btn:hover {
    background-color: rgba(255, 255, 255, 0.25) !important;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2) !important;
    transform: translateY(-1px);
}

.custom-btn .material-icons {
    margin-right: 6px;
    font-size: 18px !important;
}

/* 美化滚动条 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(7, 71, 166, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(7, 71, 166, 0.4);
}

/* 响应式调整 */
@media (max-width: 1800px) {
    .chart-row {
        flex-direction: column;
    }
}

@media (max-width: 1800px) and (min-width: 1501px) {
    .left-column {
        flex: 0 0 550px;
        width: 550px;
    }
}

@media (max-width: 1600px) { /* 进一步增加响应式断点阈值，适应更宽的左侧栏 */
    .two-column-layout {
        flex-direction: column;
    }
    
    .left-column {
        width: 100%;
        flex: 0 0 auto;
        height: auto;
        margin-bottom: 24px;
    }
    
    .ai-recommendation-card {
        height: 300px; /* 小屏幕上固定高度 */
        margin-bottom: 20px;
        max-width: 100%;
    }
    
    .chart-card {
        min-height: 300px;
    }
}