/* ========================================
   PP期货交割库虚拟仿真教学平台 - 样式表
   ======================================== */

/* ===== 基础 ===== */
:root {
  --primary: #0B1C2C;
  --primary-light: #1A3348;
  --accent: #529286;
  --accent-light: #7AB8AE;
  --body: #182030;
  --gray: #506070;
  --light-gray: #E8ECEE;
  --bg: #F4F6F8;
  --white: #FFFFFF;
  --red: #e74c3c;
  --green: #27ae60;
  --orange: #e67e22;
  --blue: #2980b9;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: "Microsoft YaHei", "SimHei", "PingFang SC", sans-serif;
  background: var(--bg);
  color: var(--body);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== 头部 ===== */
.header {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  padding: 18px 32px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.header-left { display: flex; align-items: center; gap: 14px; }
.header-left .logo { font-size: 42px; }
.header-left h1 { font-size: 22px; font-weight: 700; }
.header-left p { font-size: 13px; opacity: 0.75; margin-top: 2px; }
.header-right { display: flex; gap: 10px; }
.badge {
  background: rgba(255,255,255,0.15);
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
}
.badge-online { color: #4effb8; }

/* ===== 导航标签 ===== */
.tabs {
  background: white;
  display: flex;
  gap: 2px;
  padding: 0 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  overflow-x: auto;
  position: sticky;
  top: 0;
  z-index: 100;
}
.tab {
  flex: 0 0 auto;
  padding: 14px 20px;
  border: none;
  background: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--gray);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: inherit;
}
.tab:hover { color: var(--accent); background: var(--bg); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

/* ===== 主内容 ===== */
.main-content { max-width: 1300px; margin: 0 auto; padding: 24px 20px; }
.module { display: none; }
.module.active { display: block; animation: fadeIn 0.4s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.module-header {
  background: linear-gradient(135deg, var(--primary), #1a3a50);
  color: white;
  padding: 24px 28px;
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.module-header h2 { font-size: 22px; margin-bottom: 4px; }
.module-header p { opacity: 0.8; font-size: 14px; }

/* ===== 网格 ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 900px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ===== 卡片 ===== */
.card {
  background: white;
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.card h3 {
  font-size: 17px;
  color: var(--primary);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--light-gray);
}

/* ===== 产业链 ===== */
.chain-viz {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 15px 0;
}
.chain-node {
  padding: 14px 18px;
  border-radius: 8px;
  font-weight: 700;
  text-align: center;
  font-size: 14px;
  min-width: 80px;
}
.chain-node small { font-size: 11px; opacity: 0.7; display: block; }
.chain-node.oil { background: #E8F4FD; color: #2471A3; }
.chain-node.propylene { background: #FDEBD0; color: #B9770E; }
.chain-node.pp { background: #D5F5E3; color: #1E8449; }
.chain-node.weave { background: #F5EEF8; color: #7D3C98; }
.chain-node.market { background: #FAE5D3; color: #A04000; }
.chain-arrow { font-size: 22px; color: var(--gray); }
.chain-info { margin-top: 12px; padding: 12px; background: var(--bg); border-radius: 6px; font-size: 13px; }
.chain-info p { margin-bottom: 4px; }

/* ===== 数据看板 ===== */
.data-dashboard { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.data-card {
  background: var(--bg);
  padding: 14px 10px;
  border-radius: 8px;
  text-align: center;
}
.data-card.highlight { background: #E8F6F3; border: 1px solid var(--accent); }
.data-num { font-size: 24px; font-weight: 800; color: var(--primary); }
.data-label { font-size: 12px; color: var(--gray); margin-top: 4px; }

/* ===== 痛点列表 ===== */
.pain-list { display: flex; flex-direction: column; gap: 10px; }
.pain-item {
  display: flex; gap: 12px; padding: 14px;
  border-radius: 8px; background: var(--bg);
  cursor: pointer; transition: all 0.2s;
  align-items: flex-start;
}
.pain-item:hover { background: #FEF5E7; transform: translateX(4px); }
.pain-icon { font-size: 28px; flex-shrink: 0; }
.pain-item strong { display: block; margin-bottom: 4px; color: var(--primary); }
.pain-item p { font-size: 13px; color: var(--gray); }

/* ===== 地理图（Leaflet 地图容器） ===== */
.geo-map {
  height: 340px;
  border-radius: 8px;
  border: 1px solid #d0d0d0;
  overflow: hidden;
}
/* 覆盖 Leaflet 默认样式 */
.geo-map .leaflet-container { background: #edece7; font-family: inherit; }
.geo-map .leaflet-popup-content-wrapper { border-radius: 8px; }
.geo-map .leaflet-popup-content { margin: 10px 14px; }

/* ===== 表格 ===== */
.spec-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.spec-table td {
  padding: 8px 12px; border-bottom: 1px solid var(--light-gray);
}
.spec-table td:first-child { font-weight: 600; color: var(--gray); width: 40%; }
.spec-table th { text-align: left; padding: 8px 12px; background: var(--light-gray); font-size: 12px; }
.empty-td { text-align: center; color: var(--gray); padding: 20px; }

/* ===== 行情 ===== */
.ticker-board { text-align: center; margin-bottom: 12px; }
.ticker-price { font-size: 48px; font-weight: 800; color: var(--primary); }
.ticker-change { font-size: 16px; margin: 4px 0; }
.ticker-change.positive { color: var(--red); }
.ticker-change.negative { color: var(--green); }
.ticker-info { display: flex; justify-content: center; gap: 20px; font-size: 12px; color: var(--gray); }

.chart-container { position: relative; height: 250px; margin: 10px 0; }
.chart-container canvas { width: 100% !important; }
.chart-controls { display: flex; gap: 6px; justify-content: center; }

/* ===== 按钮 ===== */
.btn-sm {
  padding: 6px 14px; border: 1px solid #d0d0d0; background: white;
  border-radius: 20px; cursor: pointer; font-size: 12px; font-family: inherit;
}
.btn-sm.active { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary {
  padding: 10px 24px; background: var(--accent); color: white;
  border: none; border-radius: 6px; cursor: pointer; font-weight: 600;
  font-size: 14px; font-family: inherit; transition: opacity 0.2s;
}
.btn-primary:hover { opacity: 0.85; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 交易终端 ===== */
.trade-terminal { display: flex; flex-direction: column; gap: 14px; }
.trade-form { background: var(--bg); padding: 14px; border-radius: 8px; }
.form-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; flex-wrap: wrap; }
.form-row label { font-weight: 600; font-size: 13px; min-width: 40px; }
.form-row input, .form-row select {
  padding: 7px 10px; border: 1px solid #d0d0d0; border-radius: 5px;
  font-size: 13px; font-family: inherit; width: 100px;
}
.btn-trade {
  padding: 8px 18px; border: none; border-radius: 5px;
  font-weight: 700; cursor: pointer; font-family: inherit; color: white;
}
.btn-trade.buy { background: var(--red); }
.btn-trade.sell { background: var(--green); }
.btn-trade.buy:hover, .btn-trade.sell:hover { opacity: 0.85; }
.trade-result { background: #FFFDE7; padding: 10px 14px; border-radius: 6px; font-size: 13px; }
.trade-positions { font-size: 13px; }

/* ===== 仓库布局 ===== */
.warehouse-map {
  display: grid;
  grid-template-areas:
    "gate gate qc qc"
    "yard yard qc qc"
    "store store load load"
    "store store office office";
  gap: 8px;
  height: 340px;
}
.wh-area {
  background: var(--bg); border: 2px solid #d0d0d0; border-radius: 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.2s; font-weight: 600; font-size: 14px;
  text-align: center; padding: 8px;
}
.wh-area:hover { background: #E8F6F3; border-color: var(--accent); transform: scale(1.02); }
.wh-area small { font-size: 11px; color: var(--gray); font-weight: 400; }
.wh-legend { text-align: center; margin-top: 8px; font-size: 12px; color: var(--gray); }

/* ===== 流程 ===== */
.process-flow { display: flex; flex-direction: column; gap: 4px; }
.process-step {
  display: flex; align-items: flex-start; gap: 12px; padding: 10px;
  border-radius: 6px; border-left: 4px solid transparent; transition: all 0.3s;
}
.process-step .step-num {
  width: 30px; height: 30px; border-radius: 50%; background: var(--light-gray);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
  font-size: 14px; flex-shrink: 0;
}
.process-step.active { border-left-color: var(--accent); background: #E8F6F3; }
.process-step.active .step-num { background: var(--accent); color: white; }
.step-content strong { display: block; margin-bottom: 2px; }
.step-content p { font-size: 12px; color: var(--gray); }

/* ===== 监控面板 ===== */
.monitor-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 14px; }
.monitor-item { text-align: center; padding: 12px 8px; background: var(--bg); border-radius: 8px; }
.monitor-value { font-size: 26px; font-weight: 800; color: var(--primary); }
.monitor-value.green { color: var(--accent); }
.monitor-label { font-size: 11px; color: var(--gray); margin-top: 4px; }

/* ===== 计算器 ===== */
.calc-form { background: var(--bg); padding: 14px; border-radius: 8px; margin-bottom: 14px; }
.compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 10px; }
.compare-col { padding: 14px; background: var(--bg); border-radius: 8px; text-align: center; }
.compare-col h4 { margin-bottom: 8px; font-size: 14px; }
.compare-val { font-size: 22px; font-weight: 800; color: var(--primary); margin: 4px 0; }
.compare-val.highlight-green { color: var(--accent); font-size: 26px; }
.compare-col p { font-size: 12px; color: var(--gray); margin: 3px 0; }
.compare-conclusion { margin-top: 14px; padding: 12px; background: #FFFDE7; border-radius: 6px; font-size: 14px; text-align: center; }

/* ===== 仓单流转 ===== */
.receipt-flow { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.rflow-step { padding: 12px 20px; background: var(--bg); border-radius: 8px; cursor: pointer; width: 100%; text-align: center; transition: all 0.2s; }
.rflow-step:hover { background: #E8F6F3; }
.rflow-icon { font-size: 28px; }
.rflow-step strong { display: block; }
.rflow-step p { font-size: 12px; color: var(--gray); }
.rflow-arrow { font-size: 20px; color: var(--accent); }
.receipt-timeline { margin-top: 10px; padding: 12px; background: var(--bg); border-radius: 6px; font-size: 13px; }

/* ===== 套保 ===== */
.scenario-box { background: #FFF8E1; padding: 16px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; }
.scenario-box h4 { margin-bottom: 8px; }
.scenario-box p { margin: 3px 0; }
.hedge-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.hedge-actions select { padding: 7px 10px; border-radius: 5px; border: 1px solid #d0d0d0; }
.hedge-result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.hedge-result-card { padding: 12px; background: var(--bg); border-radius: 6px; text-align: center; }
.hedge-result-card h4 { font-size: 13px; margin-bottom: 4px; }
.hedge-result-card div { font-size: 20px; font-weight: 800; }
.hedge-result-card p { font-size: 11px; color: var(--gray); }
.hedge-result-card.highlight-green { background: #E8F6F3; }

/* ===== 风险 ===== */
.risk-simulator { display: flex; flex-direction: column; gap: 14px; }
.risk-event-display { padding: 18px; background: var(--bg); border-radius: 8px; min-height: 100px; }
.risk-event-display h4 { margin-bottom: 6px; }
.risk-choices { display: flex; gap: 8px; flex-wrap: wrap; }
.risk-choice-btn { padding: 8px 16px; border: 2px solid #d0d0d0; background: white; border-radius: 6px; cursor: pointer; font-family: inherit; transition: all 0.2s; }
.risk-choice-btn:hover { border-color: var(--accent); }
.risk-feedback { padding: 12px; border-radius: 6px; font-size: 14px; }
.risk-feedback.good { background: #D5F5E3; color: #1E8449; }
.risk-feedback.bad { background: #FADBD8; color: #C0392B; }
.risk-vocab { display: grid; gap: 10px; }
.risk-type { padding: 12px; border-radius: 8px; border-left: 4px solid #d0d0d0; }
.risk-type.market { border-left-color: var(--red); background: #FFF5F5; }
.risk-type.credit { border-left-color: var(--orange); background: #FFF8F0; }
.risk-type.oper { border-left-color: var(--blue); background: #F0F8FF; }
.risk-type.compliance { border-left-color: #7D3C98; background: #F8F0FF; }
.risk-type strong { display: block; margin-bottom: 4px; }
.risk-type p { font-size: 13px; color: var(--gray); }
.risk-tip { margin-top: 6px; font-size: 12px; color: var(--accent); font-weight: 600; }

/* ===== 沙盘 ===== */
.role-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.role-card {
  padding: 18px 12px; text-align: center; border: 2px solid #d0d0d0; border-radius: 10px;
  cursor: pointer; transition: all 0.2s; background: white;
}
.role-card:hover { border-color: var(--accent); box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.role-card.selected { border-color: var(--accent); background: #E8F6F3; }
.role-icon { font-size: 32px; display: block; margin-bottom: 8px; }
.role-card strong { display: block; margin-bottom: 4px; font-size: 14px; }
.role-card p { font-size: 12px; color: var(--gray); }
.sandbox-status { padding: 12px; background: var(--bg); border-radius: 6px; font-size: 14px; }
.market-news { display: flex; flex-direction: column; gap: 8px; }
.news-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px; background: var(--bg); border-radius: 6px; font-size: 13px; }
.news-tag { padding: 2px 8px; border-radius: 4px; font-size: 11px; font-weight: 700; color: white; flex-shrink: 0; }
.news-tag.macro { background: var(--blue); }
.news-tag.supply { background: var(--orange); }
.news-tag.demand { background: var(--green); }
.scoreboard { margin-top: 12px; padding: 12px; background: var(--bg); border-radius: 6px; }
.scoreboard h4 { margin-bottom: 6px; }

/* ===== 弹窗 ===== */
.modal-overlay {
  display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; }
.modal-content {
  background: white; border-radius: 12px; padding: 28px; max-width: 600px;
  width: 90%; max-height: 80vh; overflow-y: auto; position: relative;
}
.modal-close { position: absolute; top: 12px; right: 16px; font-size: 22px; cursor: pointer; color: var(--gray); }

/* ===== 页脚 ===== */
.footer {
  text-align: center; padding: 20px; font-size: 12px; color: var(--gray);
  border-top: 1px solid var(--light-gray); margin-top: 20px;
}
.footer p { margin: 4px 0; }

/* ===== 仪表盘模块全屏嵌入 ===== */
#module-8 { display: none !important; }
#module-8.active {
  display: flex !important; flex-direction: column;
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  z-index: 200; background: var(--bg);
  animation: fadeIn 0.3s;
}
#module-8 .module-header { flex-shrink: 0; padding: 10px 20px !important; margin: 0 !important; border-radius: 0 !important; }
#module-8 iframe { flex: 1; border: none; width: 100%; }
#module-8 .module-close-bar {
  position: absolute; top: 10px; right: 20px;
  z-index: 300; display: flex; gap: 10px; align-items: center;
}
@media (max-width: 768px) {
  .data-dashboard { grid-template-columns: repeat(2, 1fr); }
  .monitor-grid { grid-template-columns: repeat(3, 1fr); }
  .role-grid { grid-template-columns: repeat(2, 1fr); }
  .compare-grid { grid-template-columns: 1fr; }
  .hedge-result-grid { grid-template-columns: 1fr; }
  .warehouse-map { height: 260px; }
  .tab { font-size: 12px; padding: 10px 12px; }
}
