<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>资金与行业估值大屏</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <link rel="stylesheet" href="/static/css/bootstrap.min.css">
    <style>
        html, body { 
            height: 100%; 
            padding-left: 5px;
            padding-right: 5px;
            padding-top: 5px;
        }
        body { 
            background: #f7f7fa; 
            color: #222; 
            min-height: 100vh; 
        }
        .container-fluid { 
            min-height: 100vh; 
            padding: 0; 
        }
        .row.d-flex { 
            height: 28vh; 
            margin-left: 0; 
            margin-right: 0; 
        }
        .row.d-flex2 { 
            height: 69vh; 
            margin-left: 0; 
            margin-right: 0; 
        }
        .col-3.d-flex {
            padding-left: 2px; 
            padding-right: 2px;
            border: 1.5px solid #c7c6c6;
            border-radius: 8px;
            box-sizing: border-box;
        }
        .chart-box {
            background: #fff;
            border-radius: 8px;
            padding: 4px 4px 2px 4px;
            box-shadow: 0 2px 8px #e0e0e0;
            height: 100%;
            display: flex;
            flex-direction: column;
            justify-content: flex-start;
        }
        .tight-box { 
            margin: 0; 
            padding: 2px 2px 1px 2px; 
        }
        .chart-title { 
            font-size: 0.95rem; 
            color: #333; 
            margin-bottom: 2px; 
            text-align: center; 
        }
        .small-title { 
            font-size: 0.85rem; 
            margin-bottom: 2px; 
            margin-top: 2px; 
            text-align: center; 
            color: #666;
        }
        .chart-container { 
            width: 100%; 
            flex: 1 1 0; 
            min-height: 0; 
            background: #f9f9fb; 
        }
        
        /* 点击后的左侧容器样式 */
        .col-3.d-flex .chart-box.tight-box {
            height: 100%;
        }
        
        .col-3.d-flex .chart-container {
            height: 45%;
            min-height: 200px;
        }

        .holdings-container {
            width: 100%;
            height: 75px;
            background: #f9f9fb;
            padding: 4px;
            overflow-y: auto;
            font-size: 11px;
            line-height: 1.3;
        }

        .holding-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 3px 4px;
            margin-bottom: 2px;
            background: #fff;
            border-radius: 3px;
            border-left: 3px solid #5470c6;
        }

        .holding-item:nth-child(odd) {
            background-color: #f8f9fa;
        }

        .holding-item:nth-child(even) {
            background-color: #ffffff;
        }

        .holding-name {
            font-weight: bold;
            color: #333;
            flex: 1;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-size: 11px;
        }

        .holding-amount {
            color: #666;
            font-size: 10px;
            margin-left: 4px;
        }

        .notice-container {
            width: 100%;
            flex: 1 1 0;
            min-height: 0;
            background: #f9f9fb;
            overflow-y: auto; /* 改为垂直滚动 */
            position: relative;
            scrollbar-width: thin; /* Firefox */
            scrollbar-color: #c1c1c1 #f1f1f1; /* Firefox */
        }
        
        /* Webkit浏览器的滚动条样式 */
        .notice-container::-webkit-scrollbar {
            width: 6px;
        }
        
        .notice-container::-webkit-scrollbar-track {
            background: #f1f1f1;
            border-radius: 3px;
        }
        
        .notice-container::-webkit-scrollbar-thumb {
            background: #c1c1c1;
            border-radius: 3px;
        }
        
        .notice-container::-webkit-scrollbar-thumb:hover {
            background: #a8a8a8;
        }

        .notice-content {
            padding: 10px;
            /* 移除自动滚动动画 */
        }

        .notice-item {
            padding: 8px 0;
            border-bottom: 1px solid #eee;
            font-size: 12px;
            color: #333;
            line-height: 1.4;
        }

        .notice-item:nth-child(odd) {
            background-color: #f8f9fa;
            padding: 8px 10px;
            margin: 0 -10px;
            border-radius: 4px;
        }

        .notice-item:nth-child(even) {
            background-color: #ffffff;
            padding: 8px 10px;
            margin: 0 -10px;
            border-radius: 4px;
        }

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

        /* 移除自动滚动动画 */
        /* @keyframes scrollNotice {
            0% {
                transform: translateY(0);
            }
            100% {
                transform: translateY(-100%);
            }
        } */

        /* 弹窗样式 */
        .modal-overlay {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.7);
            z-index: 1000;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .modal-content {
            background: white;
            border-radius: 8px;
            width: 80%;
            max-width: 800px;
            max-height: 80%;
            display: flex;
            flex-direction: column;
            box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
        }

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

        .modal-header h3 {
            margin: 0;
            color: #333;
            font-size: 18px;
        }

        .modal-close {
            background: none;
            border: none;
            font-size: 24px;
            cursor: pointer;
            color: #666;
            padding: 0;
            width: 30px;
            height: 30px;
            display: flex;
            align-items: center;
            justify-content: center;
        }

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

        .modal-body {
            flex: 1;
            overflow: hidden;
            padding: 0;
        }

        .modal-notice-content {
            height: 100%;
            overflow-y: auto;
            padding: 20px;
        }

        .modal-notice-item {
            padding: 12px 0;
            border-bottom: 1px solid #f0f0f0;
            font-size: 14px;
            line-height: 1.6;
            color: #333;
        }

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

        .modal-holdings-content {
            height: 100%;
            overflow-y: auto;
            padding: 20px;
            max-height: 70vh;
        }

        .holdings-table {
            width: 100%;
            border-collapse: collapse;
            font-size: 14px;
        }

        .holdings-table th,
        .holdings-table td {
            padding: 8px 12px;
            text-align: left;
            border-bottom: 1px solid #eee;
        }

        .holdings-table th {
            background-color: #f8f9fa;
            font-weight: bold;
            color: #333;
            position: sticky;
            top: 0;
            z-index: 10;
        }

        .holdings-table tr:hover {
            background-color: #f5f5f5;
        }

        .stock-row {
            cursor: pointer;
            background-color: #f8f9fa;
        }

        .stock-row:hover {
            background-color: #e9ecef !important;
        }

        .detail-row {
            background-color: #fafafa;
            display: none;
        }

        .detail-row.show {
            display: table-row;
        }

        .detail-content {
            padding: 10px;
            background-color: #fff;
            border-left: 3px solid #5470c6;
            margin: 5px 0;
        }

        .expand-icon {
            margin-right: 5px;
            transition: transform 0.3s;
        }

        .expand-icon.expanded {
            transform: rotate(90deg);
        }

        .holdings-summary {
            margin-bottom: 20px;
            padding: 15px;
            background-color: #f8f9fa;
            border-radius: 5px;
            border-left: 4px solid #5470c6;
        }

        .holdings-summary h4 {
            margin: 0 0 10px 0;
            color: #333;
        }

        .holdings-summary p {
            margin: 5px 0;
            color: #666;
        }

        /* 平板响应式 */
        @media (max-width: 1200px) {
            .row.d-flex { height: auto; }
            .chart-box { height: auto; min-height: 180px; }
        }

        /* 移动端响应式 */
        @media (max-width: 768px) {
            html, body {
                padding: 2px;
            }
            .container-fluid {
                padding: 0;
            }
            .row.d-flex, .row.d-flex2 {
                flex-direction: column !important;
                height: auto !important;
                margin: 0;
            }
            .col-3.d-flex {
                width: 100% !important;
                max-width: 100% !important;
                min-width: 0 !important;
                margin-bottom: 8px;
                padding: 1px 0;
            }
            .chart-box, .tight-box {
                min-height: 200px;
                height: auto !important;
                padding: 2px;
            }
            .chart-title {
                font-size: 0.9rem;
                margin-bottom: 1px;
            }
            .small-title {
                font-size: 0.8rem;
                margin-bottom: 1px;
                margin-top: 1px;
            }
            .chart-container {
                min-height: 180px;
            }
            /* 调整概念卡片的布局 */
            .tight-box .chart-container {
                min-height: 150px;
                min-width: 0;
                width: 100%;
                box-sizing: border-box;
            }
            /* 优化图表间距 */
            .tight-box .chart-title {
                padding: 1px 0;
            }
        }

        /* 小屏手机响应式 */
        @media (max-width: 480px) {
            .chart-box, .tight-box {
                min-height: 180px;
            }
            .chart-container {
                min-height: 160px;
            }
            .tight-box .chart-container {
                min-height: 130px;
            }
            .chart-title {
                font-size: 0.85rem;
            }
            .small-title {
                font-size: 0.75rem;
            }
        }
        
        /* 标的详情容器样式 */
        .stock-detail-container {
            height: 100%;
            overflow-y: auto;
            padding: 8px;
            background: #f9f9fb;
            border-radius: 5px;
        }
        
        /* 合并后的标的详情容器样式 */
        .stock-detail-container-merged {
            height: 600px;
            overflow-y: auto;
            padding: 15px;
            background: #f9f9fb;
            border-radius: 5px;
        }
        
        .stock-details-list {
            display: flex;
            flex-direction: column;
            gap: 10px;
        }
        
        .stock-detail-container-merged .stock-details-list {
            display: flex;
            flex-direction: column;
            gap: 15px;
        }
        
        .stock-detail-item {
            background: #fff;
            border-radius: 6px;
            padding: 12px;
            box-shadow: 0 1px 4px rgba(0,0,0,0.1);
            border-left: 3px solid #5470c6;
            margin-bottom: 10px;
        }
        
        .stock-detail-item h4 {
            margin: 0 0 10px 0;
            color: #333;
            font-size: 14px;
            font-weight: bold;
            border-bottom: 1px solid #f0f0f0;
            padding-bottom: 5px;
        }
        
        .stock-detail-container-merged .stock-detail-item h4 {
            font-size: 16px;
            margin-bottom: 15px;
            padding-bottom: 8px;
            color: #2c3e50;
            border-bottom: 2px solid #3498db;
        }
        
        /* 新增：持仓和因子的左右布局容器 */
        .factor-holding-row {
            display: flex;
            gap: 15px;
            margin-bottom: 10px;
        }
        
        .holding-section, .factor-section {
            flex: 1;
            min-width: 0; /* 防止内容溢出 */
        }
        
        .correction-section {
            margin-bottom: 10px;
        }
        
        .correction-section:last-child {
            margin-bottom: 0;
        }
        
        /* 标题样式 */
        .factor-section h5, .holding-section h5, .correction-section h5 {
            margin: 0 0 5px 0;
            color: #555;
            font-size: 12px;
            font-weight: bold;
            background: #f8f9fa;
            padding: 3px 6px;
            border-radius: 3px;
            border-left: 2px solid #007bff;
        }
        
        .stock-detail-container-merged .factor-section h5,
        .stock-detail-container-merged .holding-section h5,
        .stock-detail-container-merged .correction-section h5 {
            font-size: 14px;
            padding: 6px 10px;
            margin-bottom: 10px;
            background: #ecf0f1;
            border-radius: 4px;
        }
        
        /* 保留原有的detail-section样式用于其他地方 */
        .detail-section {
            margin-bottom: 10px;
        }
        
        .detail-section:last-child {
            margin-bottom: 0;
        }
        
        .detail-section h5 {
            margin: 0 0 5px 0;
            color: #555;
            font-size: 12px;
            font-weight: bold;
            background: #f8f9fa;
            padding: 3px 6px;
            border-radius: 3px;
            border-left: 2px solid #007bff;
        }
        
        .stock-detail-container-merged .detail-section h5 {
            font-size: 14px;
            padding: 6px 10px;
            margin-bottom: 10px;
            background: #ecf0f1;
            border-radius: 4px;
        }
        
        .factor-details, .holding-details, .correction-details {
            padding: 5px;
            background: #fafafa;
            border-radius: 3px;
            margin-top: 3px;
        }
        
        .factor-details p, .holding-details p, .correction-details p {
            margin: 2px 0;
            font-size: 11px;
            color: #666;
            line-height: 1.3;
        }
        
        .stock-detail-container-merged .factor-details p,
        .stock-detail-container-merged .holding-details p,
        .stock-detail-container-merged .correction-details p {
            font-size: 13px;
            margin: 4px 0;
            line-height: 1.5;
            color: #34495e;
        }
        
        /* 因子箭头样式 */
        .factor-arrow {
            display: inline-block;
            font-weight: bold;
            margin-right: 8px;
            font-size: 14px;
        }
        
        .factor-arrow.buy {
            color: #ff4444;
        }
        
        .factor-arrow.sell {
            color: #44cc44;
        }
        
        .holding-detail-item {
            margin-bottom: 3px;
            padding: 3px;
            background: #f0f8ff;
            border-radius: 2px;
            border-left: 2px solid #17a2b8;
        }
        
        .correction-detail-item {
            margin-bottom: 5px;
            padding: 5px;
            background: #fff3cd;
            border-radius: 2px;
            border-left: 2px solid #ffc107;
        }
        
        .correction-detail-item p {
            margin: 1px 0;
            font-size: 10px;
            color: #856404;
        }
        
        /* 响应式调整 */
        @media (max-width: 768px) {
            .stock-detail-container-merged {
                height: 500px;
                padding: 10px;
            }
            
            .col-3.d-flex .chart-container {
                height: 40%;
                min-height: 150px;
            }
            
            .stock-detail-item {
                padding: 10px;
            }
            
            .stock-detail-item h4 {
                font-size: 14px;
            }
            
            .detail-section h5 {
                font-size: 12px;
            }
            
            .factor-details, .holding-details, .correction-details {
                padding: 5px;
            }
            
            .factor-details p, .holding-details p, .correction-details p {
                font-size: 11px;
            }
            
            /* 移动端：因子和持仓改为上下布局 */
            .factor-holding-row {
                flex-direction: column;
                gap: 10px;
            }
            
            .factor-section, .holding-section {
                flex: none;
            }
        }
        
        /* 重置按钮样式 */
        #resetViewBtn {
            background: rgba(255, 255, 255, 0.9);
            border: 1px solid #007bff;
            color: #007bff;
            font-size: 12px;
            padding: 5px 10px;
            border-radius: 15px;
            box-shadow: 0 2px 5px rgba(0,0,0,0.2);
            transition: all 0.3s ease;
        }
        
        #resetViewBtn:hover {
            background: #007bff;
            color: white;
            transform: translateY(-1px);
            box-shadow: 0 3px 8px rgba(0,0,0,0.3);
        }
        
        /* 强制第一个容器占据全宽 */
        .col-3.d-flex.expanded {
            width: 100% !important;
            max-width: 100% !important;
            flex: 1 !important;
            flex-grow: 1 !important;
            flex-shrink: 0 !important;
        }
    </style>
</head>
<body>
<div class="container-fluid">

<!-- 添加重置按钮 -->
<div style="position: fixed; top: 10px; right: 10px; z-index: 1000;">
    <button id="resetViewBtn" class="btn btn-sm btn-outline-primary" style="display: none;">
        返回默认视图
    </button>
</div>

<div class="row d-flex">
        <div class="col-3 d-flex">
            <div class="chart-box w-100">
                <div class="chart-title">行业持仓占比</div>
                <div id="portfolioChart" class="chart-container"></div>
            </div>
        </div>
        <div class="col-3 d-flex">
            <div class="chart-box w-100">
                <div class="chart-title">重要提醒</div>
                <div id="noticeBox" class="notice-container" style="cursor: pointer;">
                    <div class="notice-content">
                        <div class="notice-item">加载数据中...</div>
                    </div>
                </div>
            </div>
        </div>
        <div class="col-3 d-flex">
            <div class="chart-box w-100">
                <div class="chart-title">融资融券数据监控</div>
                <div id="rzrqChart" class="chart-container"></div>
            </div>
        </div>
        <div class="col-3 d-flex">
            <div class="chart-box w-100">
                <div class="chart-title">市场恐贪指数</div>
                <div id="fearGreedChart" class="chart-container"></div>
            </div>
        </div>
    </div>
    <div class="row d-flex2">
        <div class="col-3 d-flex">
            <div class="chart-box tight-box w-100">
                <div class="chart-title small-title">行业1-历史PE分析</div>
                <div id="peChart_xjfz" class="chart-container"></div>
                <div class="chart-title small-title" style="margin-top:2px;">行业1-拥挤度</div>
                <div id="crowdChart_xjfz" class="chart-container"></div>
                <!-- <div class="chart-title small-title" style="margin-top:2px;">行业1-持仓标的</div> -->
                <div id="holdings_xjfz" class="holdings-container"></div>
            </div>
        </div>
        <div class="col-3 d-flex">
            <div class="chart-box tight-box w-100">
                <div class="chart-title small-title">行业2-历史PE分析</div>
                <div id="peChart_xp" class="chart-container"></div>
                <div class="chart-title small-title" style="margin-top:2px;">行业2-拥挤度</div>
                <div id="crowdChart_xp" class="chart-container"></div>
                <!-- <div class="chart-title small-title" style="margin-top:2px;">行业2-持仓标的</div> -->
                <div id="holdings_xp" class="holdings-container"></div>
            </div>
        </div>
        <div class="col-3 d-flex">
            <div class="chart-box tight-box w-100">
                <div class="chart-title small-title">行业3-历史PE分析</div>
                <div id="peChart_xfdz" class="chart-container"></div>
                <div class="chart-title small-title" style="margin-top:2px;">行业3-拥挤度</div>
                <div id="crowdChart_xfdz" class="chart-container"></div>
                <!-- <div class="chart-title small-title" style="margin-top:2px;">行业3-持仓标的</div> -->
                <div id="holdings_xfdz" class="holdings-container"></div>
            </div>
        </div>
        <div class="col-3 d-flex">
            <div class="chart-box tight-box w-100">
                <div class="chart-title small-title">行业4-历史PE分析</div>
                <div id="peChart_jqr" class="chart-container"></div>
                <div class="chart-title small-title" style="margin-top:2px;">行业4-拥挤度</div>
                <div id="crowdChart_jqr" class="chart-container"></div>
                <!-- <div class="chart-title small-title" style="margin-top:2px;">行业4-持仓标的</div> -->
                <div id="holdings_jqr" class="holdings-container"></div>
            </div>
        </div>
    </div>
</div>

<!-- 弹窗结构 -->
<div id="noticeModal" class="modal-overlay" style="display: none;">
    <div class="modal-content">
        <div class="modal-header">
            <h3>重要提醒详情</h3>
            <button class="modal-close" onclick="closeNoticeModal()">&times;</button>
        </div>
        <div class="modal-body">
            <div id="modalNoticeContent" class="modal-notice-content">
                <!-- 动态内容 -->
            </div>
        </div>
    </div>
</div>

<!-- 行业持仓详情弹窗 -->
<div id="industryHoldingsModal" class="modal-overlay" style="display: none;">
    <div class="modal-content">
        <div class="modal-header">
            <h3 id="industryHoldingsTitle">行业持仓详情</h3>
            <button class="modal-close" onclick="closeIndustryHoldingsModal()">&times;</button>
        </div>
        <div class="modal-body">
            <div id="industryHoldingsContent" class="modal-holdings-content">
                <!-- 动态内容 -->
            </div>
        </div>
    </div>
</div>

<script src="/static/js/echarts.min.js"></script>
<script src="/static/js/jquery.min.js"></script>
<script src="/static/js/bigscreen_v2.js"></script>
</body>
</html>
