/* 移除了对外部字体的导入 */
@font-face {
    font-family: 'Microsoft YaHei';
    src: url('https://font-static.com/fonts/msyh.woff2') format('woff2');
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: 'Microsoft YaHei';
    src: url('https://font-static.com/fonts/msyhbd.woff2') format('woff2');
    font-weight: bold;
    font-style: normal;
}

:root {
    --font-main: "Microsoft YaHei", sans-serif;
    --font-serif: "Microsoft YaHei", serif;
    --font-fancy: "Microsoft YaHei", sans-serif;
    --color-primary: #1a3c5a; /* 深蓝，专业感 */
    --color-secondary: #c9a473; /* 金色，点缀，高级感 */
    --color-text-main: #333333;
    --color-text-light: #666666;
    --color-border: #e0e0e0;
    --color-background: #fdfdfd;
    --color-background-alt: #f7f9fc;
    --container-max-width: 900px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    -webkit-text-size-adjust: 100%;
    font-feature-settings: 'rlig' 1, 'calt' 1;
}

body {
    font-family: var(--font-main);
    background-color: var(--color-background);
    color: var(--color-text-main);
    line-height: 1.6;
    position: relative;
}

/* --- 水印 --- */
body::before {
    content: "前方量化内部参考";
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-35deg);
    font-size: 6vw;
    font-family: var(--font-fancy);
    color: rgba(0, 0, 0, 0.04);
    font-weight: bold;
    pointer-events: none;
    z-index: -1;
    white-space: nowrap;
}

.container {
    width: 100%;
    max-width: var(--container-max-width);
    margin: 0 auto;
    padding: 2rem 1.5rem; 
}

/* --- 页头 --- */
.report-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: #fff;
    padding: 1rem 1.5rem;
    border-bottom: 2px solid var(--color-primary);
    position: sticky;
    top: 0;
    z-index: 100;
}

.report-header .logo-container {
    display: flex;
    align-items: center;
}

.report-header .logo-container img {
    width: 40px;
    height: 40px;
    margin-right: 12px;
}

.report-header .header-title {
    font-family: var(--font-fancy);
    font-size: 24px;
    color: var(--color-primary);
    font-weight: 700;
}

.report-header .controls {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.report-header .controls input,
.report-header .controls button {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    font-size: 14px;
    background-color: #fff;
    transition: all 0.2s ease;
}

.report-header .controls button {
    background-color: var(--color-primary);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.report-header .controls button[hidden] {
    display: none;
}
#history-btn {
    display: none;
}
.report-header .controls button:hover:not(:disabled) {
    background-color: #2c5a8c;
}
.report-header .controls button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
}
.report-header .controls button.loading .button-text {
    display: none;
}
.report-header .controls button .button-icon {
    display: block;
}
.report-header .controls button.loading .button-loader {
    display: block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.5);
    border-top-color: white;
    border-radius: 50%;
    animation: button-spin 0.8s linear infinite;
}
@keyframes button-spin {
    to { transform: rotate(360deg); }
}

.report-header .controls button.button-secondary {
    background-color: #f0f0f0;
    color: var(--color-text-main);
    border: 1px solid var(--color-border);
}

.report-header .controls button.button-secondary:hover:not(:disabled) {
    background-color: #e0e0e0;
}

/* --- 主报告区 --- */
#report-container {
    background-color: #fff;
    padding: 2rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border: 1px solid var(--color-border);
}

.main-title {
    font-family: var(--font-fancy);
    font-size: 32px;
    text-align: center;
    margin-bottom: 12px;
    color: var(--color-text-main);
}

.report-meta {
    display: flex;
    justify-content: center;
    gap: 24px;
    font-size: 14px;
    color: var(--color-text-light);
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--color-border);
}

.report-section {
    margin-bottom: 24px;
}

.report-section h2 {
    font-family: var(--font-fancy);
    font-size: 22px;
    color: var(--color-primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--color-secondary);
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.report-section p, .report-section li {
    font-family: var(--font-fancy);
    font-size: 18px; /* 稍稍增大字体以提高行楷的可读性 */
    line-height: 1.9;
    text-align: justify;
    color: var(--color-text-main);
}

.key-takeaways ul {
    list-style: none;
    padding-left: 0;
}

.key-takeaways li {
    padding-left: 20px;
    position: relative;
    margin-bottom: 10px;
}

.key-takeaways li::before {
    content: "•";
    color: var(--color-secondary);
    font-size: 24px;
    position: absolute;
    left: 0;
    top: -2px;
}

.data-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.data-cell {
    background: var(--color-background-alt);
    padding: 16px;
    border-radius: 4px;
    border-left: 4px solid var(--color-secondary);
}

.data-cell strong {
    font-family: var(--font-main);
    font-size: 16px;
    font-weight: 700;
    color: var(--color-primary);
    display: block;
    margin-bottom: 8px;
}

.data-cell p {
    font-family: var(--font-serif);
    font-size: 15px;
    line-height: 1.7;
    margin: 0;
}
.data-cell .implication {
    margin-top: 8px;
    color: #b38b58; /* 暗金色 */
}

/* --- 新增：市场情绪计样式 --- */
.sentiment-gauge-container {
    padding: 1rem 0;
}
.sentiment-meter {
    height: 20px;
    width: 100%;
    background: linear-gradient(to right, #e74c3c, #f1c40f, #2ecc71);
    border-radius: 10px;
    position: relative;
    border: 1px solid #ddd;
}
.sentiment-needle {
    width: 4px;
    height: 28px;
    background-color: var(--color-primary);
    border-radius: 2px;
    border: 2px solid white;
    position: absolute;
    top: -5px;
    left: calc(var(--sentiment-score, 50) * 1%);
    transform: translateX(-50%);
    transition: left 0.5s ease-in-out;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.sentiment-labels {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: var(--color-text-light);
    padding: 0 5px;
    margin-top: 8px;
}
.sentiment-mood-text {
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
}
.mood-fear { background-color: #e74c3c20; color: #c0392b; }
.mood-greed { background-color: #2ecc7120; color: #27ae60; }
.mood-neutral { background-color: #f1c40f20; color: #f39c12; }


/* --- 加载与错误状态 --- */
.loader, .error-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 2rem;
    min-height: 400px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid var(--color-secondary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1.5rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.error-message {
    color: #c0392b;
    font-weight: 500;
}

.error-message h2 {
    color: #c0392b; /* A reddish color for errors */
    margin-bottom: 1rem;
}

/* 增强的错误信息样式 */
.error-message-detailed {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    background-color: var(--color-background-alt);
    overflow: hidden;
}

.error-message-detailed .icon {
    font-size: 3rem;
    line-height: 1;
    animation: glitch 1.5s infinite linear;
    color: #e74c3c;
}

.error-message-detailed h2 {
    font-family: var(--font-fancy);
    color: var(--color-primary);
    margin: 1rem 0 0.5rem;
}

.error-message-detailed .reason {
    font-style: italic;
    color: var(--color-text-light);
    margin-bottom: 1.5rem;
}

.error-message-detailed .suggestion {
    font-size: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 4px;
    background-color: rgba(201, 164, 115, 0.1);
    color: #b38b58;
    display: inline-block;
}

@keyframes glitch {
    2%, 64% { transform: translate(2px, 0) skew(0deg); }
    4%, 60% { transform: translate(-2px, 0) skew(0deg); }
    62% { transform: translate(0, 0) skew(5deg); }
}


/* --- 页脚 --- */
.report-footer {
    padding-top: 24px;
    margin-top: 24px;
    border-top: 2px solid var(--color-primary);
    text-align: center;
}

.report-footer .disclaimer {
    font-family: var(--font-serif);
    font-size: 12px;
    color: #999999;
    line-height: 1.6;
}

.report-footer .org-info {
    font-family: var(--font-main);
    font-size: 14px;
    color: var(--color-text-light);
    margin-top: 8px;
}

.report-footer::before {
    content: '';
    display: block;
    height: 1px;
    width: 80%;
    background: var(--color-border);
    margin: 0 auto 2rem;
}

/* 历史报告样式 */
.cached-reports-container {
    max-width: 800px;
    margin: 40px auto;
    padding: 20px;
    background-color: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-family: "PingFang SC";
    color: #333;
    display: none; /* Initially hidden, shown by JS if there are reports */
}

.cached-reports-container h2 {
    text-align: center;
    color: var(--header-color);
    margin-bottom: 20px;
    font-size: 1.5em;
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 10px;
}

#cached-reports-list {
    list-style-type: none;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

#cached-reports-list li {
    background-color: #fff;
    padding: 15px;
    border-radius: 5px;
    border: 1px solid #e9ecef;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s;
}

#cached-reports-list li:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08);
}

#cached-reports-list a {
    text-decoration: none;
    color: var(--header-color);
    font-weight: bold;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

#cached-reports-list .eye-icon {
    font-size: 2em;
    color: var(--accent-color);
}

#cached-reports-list .report-date {
    font-size: 0.9em;
}

/* 移除历史记录侧边栏，因为报告是主要内容 */
#history-section {
    display: none;
} 

/* --- 历史报告侧边栏 --- */
.cached-reports-container {
    position: fixed;
    top: 0;
    right: -320px; /* Start off-screen */
    width: 300px;
    height: 100vh;
    background: #fff;
    border-left: 1px solid var(--color-border);
    box-shadow: -5px 0 20px rgba(0,0,0,0.08);
    padding: 1.5rem;
    padding-top: 4rem; /* Space for close button */
    overflow-y: auto;
    z-index: 200;
    transition: right 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.cached-reports-container.is-visible {
    right: 0;
}

.cached-reports-container h2 {
    font-family: var(--font-fancy);
    font-size: 20px;
    color: var(--color-primary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-secondary);
}

#cached-reports-list {
    list-style: none;
    padding: 0;
}

#cached-reports-list li {
    margin-bottom: 0.5rem;
}

#cached-reports-list li:hover {
    background-color: var(--color-background-alt);
    border-radius: 4px;
}

#cached-reports-list a {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    text-decoration: none;
    color: var(--color-text-main);
    border-radius: 4px;
    transition: background-color 0.2s;
}

#cached-reports-list .eye-icon {
    width: 16px;
    height: 16px;
    margin-right: 12px;
    color: var(--color-secondary);
}

#cached-reports-list .report-date {
    font-size: 14px;
}

#history-section {
    margin-top: 20px;
}

.close-btn {
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 2rem;
    font-weight: bold;
    color: var(--color-text-light);
    background: none;
    border: none;
    cursor: pointer;
    line-height: 1;
    padding: 0;
}

.close-btn:hover {
    color: var(--color-primary);
} 

/* --- 响应式设计 --- */
@media (max-width: 768px) {
    .container {
        padding: 1.5rem 1rem;
    }

    .report-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
        padding: 1rem;
    }

    .report-header .controls {
        flex-wrap: wrap;
        gap: 0.5rem;
        width: 100%;
    }

    .report-header .controls button,
    .report-header .controls input {
        flex-grow: 1; /* 让按钮能填充可用空间 */
        min-width: calc(50% - 0.5rem); /* 保证一行最多两个按钮 */
    }
    .report-header .controls button span {
        display: none; /* 在小屏幕上只显示图标 */
    }
    .report-header .controls button i {
        margin-right: 0; /* 移除图标和文字之间的间距 */
    }
    #generate-btn span {
        display: inline; /* 保留“生成报告”按钮的文字 */
    }


    .main-title {
        font-size: 26px;
    }

    .report-meta {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }

    #report-container {
        padding: 1.5rem;
    }

    .report-section h2 {
        font-size: 20px;
    }
    .report-section p, .report-section li {
        font-size: 16px;
    }

    .data-grid {
        grid-template-columns: 1fr;
    }

    /* 历史记录侧边栏在手机上从小变为全屏模式 */
    .cached-reports-container {
        width: 100%;
        height: 100%;
        right: -100%;
        border-left: none;
        box-shadow: none;
        transition: right 0.3s ease-in-out;
    }
    .cached-reports-container.is-visible {
        right: 0;
    }

    body::before {
        font-size: 12vw;
    }
}

@media (max-width: 480px) {
    .report-header .header-title {
        font-size: 20px;
    }
    .report-header .logo-container img {
        width: 32px;
        height: 32px;
    }

    .main-title {
        font-size: 22px;
    }

    #report-container {
        padding: 1rem;
    }
} 