/* Bquan 行情工作台 - 全局样式 */

:root {
  --bq-bg: #09090b;
  --bq-surface: #121214;
  --bq-card: #18181b;
  --bq-border: #27272a;
  --bq-hover: #1f1f23;
  --bq-text: #fafafa;
  --bq-muted: #a1a1aa;
  --bq-dim: #71717a;
  --bq-green: #22c55e;
  --bq-red: #ef4444;
  --bq-orange: #f97316;
  --bq-blue: #3b82f6;
  --bq-purple: #a855f7;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background-color: var(--bq-bg);
  color: var(--bq-text);
  font-family: 'Inter', 'Noto Sans SC', system-ui, sans-serif;
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #3f3f46;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #52525b;
}

.scrollbar-hide {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.scrollbar-hide::-webkit-scrollbar {
  display: none;
}

/* 侧边栏导航项 */
.nav-item {
  display: flex;
  align-items: center;
  padding: 0.5rem;
  border-radius: 0.5rem;
  color: var(--bq-muted);
  transition: all 0.2s ease;
  cursor: pointer;
  position: relative;
}

.nav-item:hover {
  background-color: var(--bq-hover);
  color: var(--bq-text);
}

.nav-item.active {
  background-color: rgba(59, 130, 246, 0.15);
  color: var(--bq-blue);
}

.nav-item.active::before {
  content: '';
  position: absolute;
  left: -0.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background-color: var(--bq-blue);
  border-radius: 0 2px 2px 0;
}

.nav-badge {
  margin-left: auto;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.375rem;
  border-radius: 9999px;
  background-color: var(--bq-red);
  color: white;
  font-size: 0.65rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 资产标签 */
.asset-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.asset-tag:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

.asset-tag .name {
  margin-right: 0.375rem;
}

.asset-tag .score {
  font-weight: 600;
}

/* 时间周期按钮 */
.timeframe-btn {
  padding: 0.25rem 0.625rem;
  border-radius: 0.375rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--bq-muted);
  transition: all 0.2s ease;
  cursor: pointer;
  border: 1px solid transparent;
}

.timeframe-btn:hover {
  color: var(--bq-text);
  background-color: var(--bq-hover);
}

.timeframe-btn.active {
  color: var(--bq-text);
  background-color: var(--bq-card);
  border-color: var(--bq-border);
}

/* 筛选芯片 */
.filter-chip[data-active="true"] {
  background-color: rgba(59, 130, 246, 0.15);
  color: var(--bq-blue);
  border-color: rgba(59, 130, 246, 0.3);
}

/* 视图按钮 */
.view-btn.active {
  background-color: rgba(59, 130, 246, 0.15);
  color: var(--bq-blue);
}

/* 资产卡片 */
.asset-card {
  background-color: var(--bq-card);
  border: 1px solid var(--bq-border);
  border-radius: 0.75rem;
  padding: 1rem;
  transition: all 0.2s ease;
}

.asset-card:hover {
  border-color: #3f3f46;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.asset-symbol {
  display: flex;
  align-items: center;
  font-weight: 600;
  font-size: 1rem;
}

.asset-icon {
  width: 1.75rem;
  height: 1.75rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  margin-right: 0.5rem;
}

.signal-pill {
  padding: 0.125rem 0.5rem;
  border-radius: 0.25rem;
  font-size: 0.65rem;
  font-weight: 600;
}

.signal-pill.bullish {
  background-color: rgba(34, 197, 94, 0.15);
  color: var(--bq-green);
}

.signal-pill.bearish {
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--bq-red);
}

.signal-pill.neutral {
  background-color: rgba(161, 161, 170, 0.15);
  color: var(--bq-muted);
}

/* 价格显示 */
.price-main {
  font-size: 1.875rem;
  font-weight: 700;
  font-family: 'JetBrains Mono', Menlo, monospace;
  letter-spacing: -0.02em;
}

.price-change {
  font-size: 0.875rem;
  font-weight: 500;
  margin-left: 0.5rem;
}

/* 评分标签 */
.score-tabs {
  display: flex;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.score-tab {
  flex: 1;
  padding: 0.375rem 0;
  border-radius: 0.375rem;
  background-color: var(--bq-surface);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.score-tab:hover {
  background-color: var(--bq-hover);
}

.score-tab .label {
  display: block;
  font-size: 0.65rem;
  color: var(--bq-dim);
  margin-bottom: 0.125rem;
}

.score-tab .value {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: 'JetBrains Mono', Menlo, monospace;
}

.score-tab.highlight .value {
  color: var(--bq-blue);
}

/* 分析文本 */
.analysis-section {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--bq-border);
}

.analysis-line {
  font-size: 0.75rem;
  line-height: 1.6;
  margin-bottom: 0.25rem;
}

.analysis-line .label {
  color: var(--bq-dim);
  margin-right: 0.375rem;
}

.analysis-line .value {
  color: var(--bq-text);
}

.analysis-line .highlight {
  color: var(--bq-green);
}

.analysis-line .warning {
  color: var(--bq-red);
}

.analysis-line .info {
  color: var(--bq-blue);
}

/* 市场概览条 */
.market-stat {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.market-stat .label {
  color: var(--bq-dim);
  margin-right: 0.25rem;
}

.market-stat .value {
  color: var(--bq-text);
  font-weight: 500;
}

.market-stat .value.up {
  color: var(--bq-green);
}

.market-stat .value.down {
  color: var(--bq-red);
}

/* 图表容器 */
.chart-container {
  position: relative;
  width: 100%;
  height: 320px;
  border-radius: 0.5rem;
  overflow: hidden;
  background-color: var(--bq-card);
}

/* Toast */
#toast {
  pointer-events: none;
}

#toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* 选择框下拉箭头 */
select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.5rem center;
  padding-right: 1.5rem;
}

/* 响应式调整 */
@media (max-width: 1280px) {
  .chart-container {
    height: 280px;
  }
}

@media (max-width: 768px) {
  .asset-card {
    padding: 0.875rem;
  }
  
  .price-main {
    font-size: 1.5rem;
  }
  
  .chart-container {
    height: 240px;
  }
}

/* 加载骨架屏 */
.skeleton {
  background: linear-gradient(90deg, var(--bq-surface) 25%, var(--bq-hover) 50%, var(--bq-surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 0.375rem;
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* 动画 */
@keyframes pulse-dot {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.pulse-dot {
  animation: pulse-dot 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* 隐藏滚动条但保持滚动 */
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.no-scrollbar::-webkit-scrollbar {
  display: none;
}

/* ============================================================
 * Feature 通用样式（复用既有 --bq-* 变量，不引入浅色硬编码）
 * ============================================================ */

/* 功能视图根容器（与 #market-view 同级切换） */
.feature-root {
  width: 100%;
  height: 100%;
}

/* 通用表格（配合 BQHelpers.table 使用；Tailwind 类已处理大部分样式，这里补充基础） */
.bq-table {
  width: 100%;
  border-collapse: collapse;
}

.bq-table th,
.bq-table td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-size: 0.875rem;
}

.bq-table thead tr {
  border-bottom: 1px solid var(--bq-border);
}

.bq-table tbody tr {
  border-top: 1px solid var(--bq-border);
}

.bq-table tbody tr:hover {
  background-color: rgba(31, 31, 35, 0.5);
}

/* 空状态 */
.bq-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  color: var(--bq-dim);
}

.bq-empty svg {
  width: 2.5rem;
  height: 2.5rem;
  margin-bottom: 0.75rem;
  opacity: 0.5;
}

/* 加载态 */
.bq-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  color: var(--bq-dim);
}

/* 角标计数（如提醒未读数） */
.badge-count {
  margin-left: auto;
  min-width: 1.25rem;
  height: 1.25rem;
  padding: 0 0.375rem;
  border-radius: 9999px;
  background-color: var(--bq-blue);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.badge-count.danger {
  background-color: var(--bq-red);
}

.badge-count.muted {
  background-color: var(--bq-muted);
}

/* 进度环（SVG 圆环，用于诊断/训练等评分展示） */
.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring__bg {
  stroke: var(--bq-border);
}

.progress-ring__fg {
  stroke: var(--bq-blue);
  transition: stroke-dashoffset 0.4s ease;
}

.progress-ring__fg.green { stroke: var(--bq-green); }
.progress-ring__fg.red { stroke: var(--bq-red); }
.progress-ring__fg.orange { stroke: var(--bq-orange); }
.progress-ring__fg.purple { stroke: var(--bq-purple); }

/* 模态遮罩（二维码 / 详情弹窗等通用） */
.modal-mask {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}

.modal-mask.hidden {
  display: none;
}

.modal-card {
  background-color: var(--bq-card);
  border: 1px solid var(--bq-border);
  border-radius: 1rem;
  padding: 1.5rem;
  width: 100%;
  max-width: 28rem;
  margin: 1rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* ============================================================
 * 数字跳动反馈动画（价格/盈亏变化时高亮）
 * ============================================================ */
@keyframes flash-up {
  0% { background: rgba(34, 197, 94, 0.35); }
  100% { background: transparent; }
}
@keyframes flash-down {
  0% { background: rgba(239, 68, 68, 0.35); }
  100% { background: transparent; }
}
.flash-up { animation: flash-up 0.6s ease-out; }
.flash-down { animation: flash-down 0.6s ease-out; }

/* ============================================================
 * 响应式卡片网格（不依赖 Tailwind 生成时序的兜底；纯 CSS 媒体查询）
 * feature 多卡区块统一包一层 .bq-grid，禁止写死固定宽度，保证不横向溢出。
 * ============================================================ */
.bq-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 1rem;
}
@media (min-width: 768px) {
  .bq-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1280px) {
  .bq-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ============================================================
 * 移动端 / 窄屏响应式调整（保证无整页横向溢出）
 * ============================================================ */
@media (max-width: 640px) {
  #feature-root { padding: 0.75rem; }
  .bq-grid { gap: 0.75rem; }
  .price-main { font-size: 1.25rem; }
  .asset-card { padding: 0.75rem; }
  /* 窄屏隐藏次要列/次要控件，避免横向溢出 */
  .hide-xs { display: none; }
  /* 顶部工具栏允许横向滚动（已 overflow-x-auto），这里收紧间距 */
  #timeframes { gap: 0.25rem; }
}

/* 平板（sidebar 折叠）主区占满，避免卡片被挤压换行异常 */
@media (max-width: 1023px) {
  #sidebar:not(.fixed) { /* JS 切换 -translate-x-full 控制显隐 */ }
}

/* 输入框/下拉在窄屏下不溢出容器 */
input, select, textarea {
  max-width: 100%;
}

/* ============================================================
 * T21 新增：数字跳动 flash 反馈 + 响应式网格
 * ============================================================ */

/* 价格/盈亏变化时的短暂高亮（约 600ms 淡出） */
@keyframes flash-up {
  0% { background-color: rgba(34, 197, 94, 0.35); }
  100% { background-color: transparent; }
}
@keyframes flash-down {
  0% { background-color: rgba(239, 68, 68, 0.35); }
  100% { background-color: transparent; }
}
.flash-up { animation: flash-up 0.6s ease-out; }
.flash-down { animation: flash-down 0.6s ease-out; }

/* 响应式卡片网格（纯 CSS 兜底，不依赖 Tailwind 生成时序） */
.bq-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 1rem;
}
@media (min-width: 768px) {
  .bq-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1280px) {
  .bq-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* 功能视图：防止子元素撑破导致横向溢出 */
#feature-root { min-width: 0; }
.overflow-x-auto { overflow-x: auto; }

/* 移动端/平板：功能视图内弹性容器换行，避免横向溢出 */
@media (max-width: 1023px) {
  #feature-root .flex { flex-wrap: wrap; }
  #feature-root .flex > * { min-width: 0; }
}

/* 移动端隐藏次要元素 + 收窄间距 */
.hide-xs { display: inline; }
@media (max-width: 640px) {
  #feature-root { padding: 0.75rem; }
  .bq-grid { gap: 0.75rem; }
  .price-main { font-size: 1.25rem; }
  .asset-card { padding: 0.75rem; }
  .hide-xs { display: none; }
  .market-stat { font-size: 0.7rem; }
}

/* ============================================================
 * T-A4 新增：强度榜（横向滚动标签栏）+ 来源标注
 * 复用既有 --bq-* 设计令牌，不引入浅色硬编码；不影响 B/C 既有 class。
 * ============================================================ */

/* 强度榜单标签（替代原静态 asset-tag） */
.bq-strength-tag {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid transparent;
}

.bq-strength-tag:hover {
  filter: brightness(1.15);
  transform: translateY(-1px);
}

.bq-strength-tag .name {
  margin-right: 0.375rem;
}

.bq-strength-tag .score {
  font-weight: 700;
  font-family: 'JetBrains Mono', Menlo, monospace;
}

.bq-strength-active {
  box-shadow: 0 0 0 1px var(--bq-blue);
}

/* 来源标注（新闻 / ETF / 降级 / 估算提示共用） */
.bq-source-label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: var(--bq-muted);
}

.bq-source-label a {
  color: var(--bq-blue);
  text-decoration: none;
}

.bq-source-label a:hover {
  text-decoration: underline;
}

.bq-source-label .bq-dot {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 9999px;
  background: var(--bq-green);
  flex-shrink: 0;
}

.bq-source-label.degraded .bq-dot,
.bq-source-label.estimated .bq-dot {
  background: var(--bq-orange);
}

/* 降级 / 估算徽标 */
.bq-degrade-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.1rem 0.4rem;
  border-radius: 0.25rem;
  font-size: 0.65rem;
  font-weight: 600;
  background-color: rgba(249, 115, 22, 0.15);
  color: var(--bq-orange);
  border: 1px solid rgba(249, 115, 22, 0.3);
}

/* === v2.1 asset-card two-pane + tabs === */
.asset-card-body {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}
@media (min-width: 768px) {
  .asset-card-body {
    grid-template-columns: 1fr 1fr;
  }
}

.asset-detail-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin: 0.5rem 0 0.25rem;
}

.asset-detail-tab {
  font-size: 0.7rem;
  padding: 0.2rem 0.6rem;
  border-radius: 0.375rem;
  border: 1px solid var(--bq-border);
  color: var(--bq-dim);
  cursor: pointer;
  background: transparent;
}

.asset-detail-tab.active {
  color: var(--bq-text);
  border-color: var(--bq-blue);
  background: rgba(59, 130, 246, 0.12);
}

.asset-detail-search {
  width: 100%;
  font-size: 0.75rem;
  padding: 0.3rem 0.6rem;
  border-radius: 0.375rem;
  border: 1px solid var(--bq-border);
  background: var(--bq-bg);
  color: var(--bq-text);
  margin-bottom: 0.4rem;
}

.asset-detail-search::placeholder {
  color: var(--bq-dim);
}

.asset-spark {
  width: 100%;
  height: 36px;
}

/* ============================================================
 * 行情视图：左右两栏等高布局（左分析卡 / 右 K 线）
 * 桌面端 flex-row + 默认 align-items:stretch => 左右等高；
 * 移动端 flex-col 自然堆叠。compact 态仅保留分析卡。
 * ============================================================ */
#market-split {
  flex-direction: column;
}
@media (min-width: 1024px) {
  #market-split {
    flex-direction: row;
    align-items: stretch;
  }
}
#market-split.compact {
  flex-direction: column;
}
#market-split.compact #chart-pane {
  display: none;
}
#market-split.compact #analysis-pane {
  width: 100% !important;
}

/* 左栏宽度：移动端占满，桌面端固定（保证右图有足够空间） */
#analysis-pane {
  width: 100%;
}
@media (min-width: 1024px) {
  #analysis-pane {
    width: 460px;
    flex-shrink: 0;
  }
}
@media (min-width: 1280px) {
  #analysis-pane {
    width: 520px;
  }
}

/* 左栏分析卡填满整栏高度，详情区内部滚动（与右图严格等高一致） */
#analysis-pane .asset-card {
  height: 100%;
  display: flex;
  flex-direction: column;
}
#analysis-pane .asset-card-body {
  flex: 0 0 auto;
}
#analysis-pane .asset-detail {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
#analysis-pane .asset-detail-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
