/* css/multi-period.css
 * ============================================================================
 * Phase 7.4 — 多週期共振 Tab 樣式(改版:Ab 並排頂部 + Bc 展開式表格)
 * ============================================================================
 * 上方雙欄:燈燈總結(左)+ 共振矩陣(右),桌機並排、手機堆疊
 * 下方表格:各週期細節,點任一列展開(可同時展開多列)
 *
 * 沿用 main.css 變數:--bg / --bg2 / --bg3 / --border / --border2
 *                  --text / --muted / --hint / --up / --down / --accent
 *                  --radius / --radius-sm
 * ============================================================================ */

/* ─── 主容器 ─── */
.mp-panel {
  padding: 14px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  /* 不再限制 max-width,讓桌機可以利用寬螢幕 */
}

.mp-empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ─── 頁首 ─── */
.mp-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 2px;
}
.mp-header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.mp-header-sub {
  font-size: 11px;
  color: var(--muted);
}

/* ============================================================================
   上方雙欄:燈燈總結(左) + 共振矩陣(右)
   ============================================================================ */
.mp-top-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: stretch;
}

/* ─── 燈燈總結卡 ─── */
.mp-deng-card {
  background: linear-gradient(135deg,
              rgba(59, 130, 246, 0.06),
              rgba(167, 139, 250, 0.06));
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 14px 18px 12px;
  display: flex;
  flex-direction: column;
}

.mp-deng-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.mp-deng-emoji {
  font-size: 18px;
}
.mp-deng-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.mp-copy-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px 9px;
  cursor: pointer;
  font-size: 11px;
  color: var(--muted);
  transition: all 0.15s;
}
.mp-copy-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.mp-deng-headline {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.5;
}

.mp-deng-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
  flex: 1;
}
.mp-deng-line {
  font-size: 12px;
  color: var(--text);
  line-height: 1.55;
  opacity: 0.92;
}

.mp-deng-foot {
  font-size: 10.5px;
  color: var(--hint);
  font-style: italic;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}

/* ─── 共振矩陣卡 ─── */
.mp-matrix-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
}

.mp-matrix-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
  letter-spacing: 0.5px;
}

.mp-matrix-table {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.mp-matrix-row {
  display: grid;
  grid-template-columns: 48px 32px 1fr 40px;
  align-items: center;
  gap: 10px;
  padding: 5px 6px;
  font-size: 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s;
}
.mp-matrix-row:hover {
  background: rgba(255,255,255,0.04);
}
.mp-row-empty {
  opacity: 0.5;
}
.mp-row-empty:hover {
  background: rgba(255,255,255,0.02);
}

.mp-matrix-label {
  color: var(--muted);
  font-weight: 500;
}
.mp-matrix-arrow {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.mp-matrix-arrow.mp-dir-up   { color: var(--up); }
.mp-matrix-arrow.mp-dir-down { color: var(--down); }
.mp-matrix-arrow.mp-dir-flat { color: var(--hint); font-size: 11px; }

.mp-matrix-bar {
  position: relative;
  display: block;
  height: 8px;
  border-radius: 4px;
  background: rgba(255,255,255,0.06);
  overflow: hidden;
}
.mp-matrix-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  border-radius: 4px;
  transition: width 0.4s ease;
}
.mp-matrix-bar-fill.mp-dir-up   { background: linear-gradient(90deg, var(--up), #4dd0c1); }
.mp-matrix-bar-fill.mp-dir-down { background: linear-gradient(90deg, var(--down), #ff7a78); }
.mp-matrix-bar-fill.mp-dir-flat { background: linear-gradient(90deg, var(--hint), var(--muted)); }

.mp-matrix-health {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

/* 共振狀態總結 */
.mp-matrix-bias {
  margin-top: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.mp-bias-label  { flex: 1; }
.mp-matrix-avg  {
  margin-left: auto;
  font-size: 11px;
  font-weight: 500;
  opacity: 0.75;
}
.mp-bias-bull {
  background: rgba(38, 166, 154, 0.12);
  border: 1px solid rgba(38, 166, 154, 0.3);
  color: var(--up);
}
.mp-bias-bear {
  background: rgba(239, 83, 80, 0.12);
  border: 1px solid rgba(239, 83, 80, 0.3);
  color: var(--down);
}
.mp-bias-mixed {
  background: rgba(245, 158, 11, 0.10);
  border: 1px solid rgba(245, 158, 11, 0.28);
  color: #f59e0b;
}
.mp-bias-flat {
  background: rgba(96, 165, 250, 0.10);
  border: 1px solid rgba(96, 165, 250, 0.28);
  color: var(--accent);
}
.mp-bias-unknown {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--muted);
}

/* ============================================================================
   下方表格:各週期細節 (Bc 多列可同時展開)
   ============================================================================ */
.mp-detail-section {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.mp-detail-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  padding: 11px 18px 9px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.3px;
}
.mp-detail-hint {
  font-size: 10.5px;
  color: var(--hint);
  font-weight: 400;
  margin-left: auto;
}

.mp-detail-table {
  display: flex;
  flex-direction: column;
}

/* 每列 */
.mp-detail-row {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.mp-detail-row:last-child {
  border-bottom: none;
}

/* 標題列(永遠顯示) */
.mp-detail-head {
  display: grid;
  grid-template-columns: 22px 56px 50px 70px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.mp-detail-head:hover {
  background: rgba(255,255,255,0.025);
}

.mp-detail-chevron {
  color: var(--muted);
  font-size: 9px;
  transition: transform 0.18s ease;
  text-align: center;
}
.mp-row-expanded .mp-detail-chevron {
  transform: rotate(90deg);
  color: var(--accent);
}

.mp-detail-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.mp-detail-dir {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 3px;
  text-align: center;
}
.mp-detail-dir.mp-dir-up   { background: rgba(38, 166, 154, 0.15); color: var(--up); }
.mp-detail-dir.mp-dir-down { background: rgba(239, 83, 80, 0.15);  color: var(--down); }
.mp-detail-dir.mp-dir-flat { background: rgba(255,255,255,0.06);   color: var(--hint); }

.mp-detail-health {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: left;
}

.mp-detail-summary {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 跳 K 線按鈕 */
.mp-jump-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.mp-jump-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(59, 130, 246, 0.06);
}

/* 展開內容(預設收起) */
.mp-detail-body {
  display: none;
  padding: 4px 18px 16px 52px;
  background: rgba(0,0,0,0.12);
  border-top: 1px dashed var(--border);
}
.mp-row-expanded .mp-detail-body {
  display: block;
  animation: mp-fade-in 0.18s ease;
}
@keyframes mp-fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 從矩陣點過來的高亮閃光 */
.mp-row-flash {
  animation: mp-flash 1s ease;
}
@keyframes mp-flash {
  0%, 100% { background: transparent; }
  30%      { background: rgba(59, 130, 246, 0.12); }
}

/* meta 列(焦點、K 棒數、收盤) */
.mp-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 11px;
  color: var(--hint);
  padding: 10px 0;
  border-bottom: 1px dashed var(--border);
  margin-bottom: 10px;
}
.mp-detail-meta-item {
  white-space: nowrap;
}

/* 區塊(趨勢、量價、支撐壓力、箱型) */
.mp-detail-block {
  margin-top: 10px;
}
.mp-detail-block:first-of-type {
  margin-top: 0;
}
.mp-detail-block-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.mp-detail-block-line {
  font-size: 11.5px;
  color: var(--text);
  line-height: 1.55;
  margin-bottom: 2px;
}
.mp-detail-block-advice {
  color: var(--muted);
  padding-left: 4px;
}

/* 空資料列 */
.mp-detail-empty {
  opacity: 0.65;
}
.mp-detail-empty .mp-detail-label {
  color: var(--muted);
}
.mp-detail-empty-text {
  font-size: 11.5px;
  color: var(--hint);
  font-style: italic;
  padding: 10px 0;
}

/* ─── 錯誤態 ─── */
.mp-error {
  padding: 40px 20px;
  text-align: center;
}
.mp-error-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 8px;
}
.mp-error-msg {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 14px;
  line-height: 1.6;
}
.mp-retry-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 6px 18px;
  font-size: 12px;
  cursor: pointer;
}
.mp-retry-btn:hover {
  background: var(--accent2);
}

/* ─── inline loading 容器(燈燈塞進來)─── */
#mpLoadingTarget {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
}

/* ============================================================================
   響應式 — 手機版自動堆疊
   ============================================================================ */
@media (max-width: 800px) {
  .mp-top-grid {
    grid-template-columns: 1fr;   /* 上下堆疊 */
  }
}

@media (max-width: 600px) {
  .mp-panel {
    padding: 12px 12px 20px;
    gap: 10px;
  }
  .mp-matrix-card,
  .mp-deng-card {
    padding: 11px 13px;
  }
  .mp-matrix-row {
    grid-template-columns: 36px 28px 1fr 32px;
    gap: 8px;
    font-size: 11px;
  }
  .mp-deng-headline {
    font-size: 13px;
  }
  .mp-deng-line {
    font-size: 11.5px;
  }

  /* 表格手機版:把 health 隱藏節省空間 */
  .mp-detail-head {
    grid-template-columns: 18px 50px 46px 1fr auto;
    gap: 8px;
    padding: 10px 12px;
  }
  .mp-detail-health {
    display: none;
  }
  .mp-detail-summary {
    font-size: 11px;
  }
  .mp-jump-btn {
    padding: 3px 8px;
    font-size: 10.5px;
  }
  .mp-detail-body {
    padding: 4px 14px 14px 32px;
  }
  .mp-detail-block-line {
    font-size: 11px;
  }
}
