/* ═══════════════════════════════════════════════════════════
   節號 18 — 題材追蹤 Tab（theme-ui.js）
   ═══════════════════════════════════════════════════════════ */

/* ── 外框 ── */
.theme-wrap {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* ── 撥盤 Tab ── */
.theme-panel-tabs {
  display: flex;
  gap: 4px;
  padding: 10px 12px 0;
  border-bottom: 1px solid var(--bg3);
  flex-shrink: 0;
}

.theme-ptab {
  padding: 6px 14px;
  border-radius: 6px 6px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  background: var(--bg2);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  transition: color .15s, background .15s;
}

.theme-ptab:hover { color: var(--text); }

.theme-ptab.active {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--bg3);
}

.theme-ptab--admin {
  margin-left: auto;
  color: #f59e0b;
}

.theme-ptab--admin.active { color: #f59e0b; }

/* ── Panel Body ── */
.theme-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}

.theme-loading,
.theme-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  color: var(--muted);
  font-size: 14px;
  gap: 12px;
}

/* ── ETF 卡片 ── */
.theme-etf-list { display: flex; flex-direction: column; gap: 8px; }

.theme-etf-card {
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: 8px;
  overflow: hidden;
}

.theme-etf-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  cursor: pointer;
}

.theme-etf-code {
  font-weight: 600;
  font-size: 14px;
  color: var(--accent);
  min-width: 60px;
}

.theme-etf-name {
  flex: 1;
  font-size: 13px;
  color: var(--text);
}

.theme-etf-count {
  font-size: 11px;
  color: var(--muted);
  background: var(--bg3);
  padding: 2px 7px;
  border-radius: 10px;
}

.theme-etf-toggle {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
}

/* ── 股票列 ── */
.theme-etf-stocks {
  border-top: 1px solid var(--bg3);
  padding: 4px 0;
}

.theme-stock-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  transition: background .1s;
}

.theme-stock-row:hover { background: var(--bg3); }

.theme-stock-row .theme-stock-code,
.theme-etf-stock-row .theme-stock-code {
  font-size: 12px;
  color: var(--accent);
  min-width: 44px;
  font-weight: 500;
}

/* scope 限定列表列：原本的通用 .theme-stock-name { flex:1 } 會蓋掉
   theme.css 卡片版的 flex-basis:100%（股名獨佔第二行），造成卡片股名被截斷 */
.theme-stock-row .theme-stock-name,
.theme-etf-stock-row .theme-stock-name {
  flex: 1;
  font-size: 12px;
  color: var(--text);
}

.theme-stock-add {
  padding: 2px 8px;
  font-size: 11px;
  background: var(--bg3);
  border: 1px solid var(--hint);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
}

.theme-stock-row:hover .theme-stock-add { opacity: 1; }
.theme-stock-add:hover { color: var(--accent); border-color: var(--accent); }

/* ── 自訂題材 ── */
.theme-custom-toolbar {
  margin-bottom: 10px;
}

.theme-custom-list { display: flex; flex-direction: column; gap: 8px; }

.theme-custom-card {
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: 8px;
  overflow: hidden;
}

.theme-custom-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
}

.theme-custom-emoji { font-size: 16px; }

.theme-custom-name {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
}

.theme-custom-del {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 14px;
  opacity: .5;
  padding: 2px 4px;
}

.theme-custom-del:hover { opacity: 1; }

/* ── 管理員撥盤 ── */
.theme-admin-wrap {
  max-width: 680px;
}

.theme-admin-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #f59e0b;
}

.theme-admin-section {
  margin-bottom: 20px;
}

.theme-admin-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.theme-admin-etf-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.theme-admin-etf-btn {
  padding: 5px 12px;
  background: var(--bg3);
  border: 1px solid var(--hint);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  transition: border-color .15s, color .15s;
}

.theme-admin-etf-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.theme-admin-etf-new {
  border-style: dashed;
  color: var(--muted);
}

.theme-admin-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.theme-admin-input {
  flex: 1;
  padding: 6px 10px;
  background: var(--bg3);
  border: 1px solid var(--hint);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
}

.theme-admin-input:focus {
  outline: none;
  border-color: var(--accent);
}

.theme-admin-textarea {
  width: 100%;
  min-height: 120px;
  padding: 10px;
  background: var(--bg3);
  border: 1px solid var(--hint);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  font-family: monospace;
  resize: vertical;
  margin-bottom: 8px;
  box-sizing: border-box;
}

.theme-admin-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.theme-admin-import {
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

/* ── 差異比較 ── */
.theme-admin-diff {
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.theme-diff-summary {
  font-size: 13px;
  margin-bottom: 10px;
}

.theme-diff-add  { color: var(--up); font-weight: 600; }
.theme-diff-del  { color: var(--down); font-weight: 600; }
.theme-diff-keep { color: var(--muted); }

.theme-diff-group {
  margin-bottom: 8px;
}

.theme-diff-label {
  font-size: 11px;
  margin-bottom: 4px;
}

.theme-diff-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  margin: 2px 3px 2px 0;
}

.theme-diff-tag--add {
  background: rgba(38,166,154,.15);
  color: var(--up);
  border: 1px solid rgba(38,166,154,.3);
}

.theme-diff-tag--del {
  background: rgba(239,83,80,.15);
  color: var(--down);
  border: 1px solid rgba(239,83,80,.3);
  text-decoration: line-through;
}

.theme-admin-diff-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

/* ── 管理員現有成份股 ── */
.theme-admin-stocks {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 8px;
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: 6px;
  min-height: 48px;
}

.theme-admin-stock-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--bg3);
  border-radius: 4px;
  font-size: 11px;
}

.theme-admin-stock-row .theme-stock-code { color: var(--accent); min-width: auto; }
.theme-admin-stock-row .theme-stock-name { flex: none; color: var(--muted); }

/* ── 通用按鈕 ── */
.btn-sm {
  padding: 5px 12px;
  background: var(--accent);
  border: none;
  border-radius: 6px;
  color: #fff;
  cursor: pointer;
  font-size: 12px;
  white-space: nowrap;
}

.btn-sm:hover { opacity: .85; }

.btn-ghost {
  background: var(--bg3);
  color: var(--muted);
  border: 1px solid var(--hint);
}

.btn-xs {
  padding: 2px 8px;
  background: var(--bg3);
  border: 1px solid var(--hint);
  border-radius: 4px;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
}

.btn-xs:hover { color: var(--accent); border-color: var(--accent); }

/* ═══════════════════════════════════════════════════════════
   節號 18 — 題材追蹤四撥盤外層
   ═══════════════════════════════════════════════════════════ */

.theme-outer {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* 撥盤切換列 */
.theme-panel-switcher {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
  border-bottom: 1px solid var(--bg3);
  flex-shrink: 0;
}

.theme-psw-btn {
  padding: 6px 14px;
  border-radius: 6px 6px 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  background: var(--bg2);
  color: var(--muted);
  cursor: pointer;
  font-size: 13px;
  transition: color .15s, background .15s;
  white-space: nowrap;
}

.theme-psw-btn:hover { color: var(--text); }

.theme-psw-btn.active {
  background: var(--bg3);
  color: var(--text);
  border-color: var(--hint);
}

.theme-psw-btn--admin { margin-left: auto; color: #f59e0b; }
.theme-psw-btn--admin.active { color: #f59e0b; }

/* 撥盤內容區 */
.theme-panel-content {
  flex: 1;
  overflow-y: auto;
}

/* 自訂題材撥盤：讓原本的 theme-layout 撐滿 */
.theme-panel-content .theme-layout {
  height: 100%;
}

/* ETF 撥盤 */
.theme-etf-loading {
  padding: 40px;
  text-align: center;
  color: var(--muted);
}

.theme-etf-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}

.theme-etf-card {
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: 8px;
  overflow: hidden;
}

.theme-etf-card-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
}

.theme-etf-card-code {
  font-weight: 600;
  font-size: 14px;
  color: var(--accent);
  min-width: 60px;
}

.theme-etf-card-name {
  flex: 1;
  font-size: 13px;
  color: var(--text);
}

.theme-etf-card-count {
  font-size: 11px;
  color: var(--muted);
  background: var(--bg3);
  padding: 2px 7px;
  border-radius: 10px;
}

.theme-etf-card-toggle {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
}

.theme-etf-card-stocks {
  border-top: 1px solid var(--bg3);
}

.theme-etf-stock-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  transition: background .1s;
}

.theme-etf-stock-row:hover { background: var(--bg3); cursor: pointer; }

.theme-etf-stock-chart {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  opacity: 0;
  transition: opacity .15s;
}

.theme-etf-stock-row:hover .theme-etf-stock-chart { opacity: 1; }

/* 管理員撥盤 */
.theme-admin-panel {
  padding: 16px;
  max-width: 700px;
}

.theme-admin-title {
  font-size: 15px;
  font-weight: 600;
  color: #f59e0b;
  margin-bottom: 16px;
}

.theme-admin-section {
  margin-bottom: 16px;
}

.theme-admin-label {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 500;
}

.theme-admin-etf-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.theme-admin-etf-btn {
  padding: 5px 12px;
  background: var(--bg3);
  border: 1px solid var(--hint);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 12px;
  transition: border-color .15s, color .15s;
}

.theme-admin-etf-btn:hover { border-color: var(--accent); color: var(--accent); }

.theme-admin-etf-new {
  border-style: dashed;
  color: var(--muted);
}

.theme-admin-input {
  flex: 1;
  padding: 6px 10px;
  background: var(--bg3);
  border: 1px solid var(--hint);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  min-width: 0;
}

.theme-admin-input:focus { outline: none; border-color: var(--accent); }

.theme-admin-textarea {
  width: 100%;
  min-height: 110px;
  padding: 10px;
  background: var(--bg3);
  border: 1px solid var(--hint);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  font-family: monospace;
  resize: vertical;
  margin-bottom: 8px;
  box-sizing: border-box;
  display: block;
}

.theme-admin-textarea:focus { outline: none; border-color: var(--accent); }

.theme-admin-stocks-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px;
  background: var(--bg2);
  border: 1px solid var(--bg3);
  border-radius: 6px;
  min-height: 44px;
}

.theme-admin-stock-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: var(--bg3);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text);
}

.theme-admin-diff-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  margin: 2px 3px 2px 0;
}

.theme-admin-diff-tag--add {
  background: rgba(38,166,154,.15);
  color: var(--up);
  border: 1px solid rgba(38,166,154,.3);
}

.theme-admin-diff-tag--del {
  background: rgba(239,83,80,.15);
  color: var(--down);
  border: 1px solid rgba(239,83,80,.3);
  text-decoration: line-through;
}

/* 管理員 passive/active 切換 */
.theme-admin-type-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.theme-admin-type-btn {
  padding: 6px 14px;
  background: var(--bg3);
  border: 1px solid var(--hint);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  transition: all .15s;
}

.theme-admin-type-btn:hover { color: var(--text); border-color: var(--accent); }

.theme-admin-type-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
