/* === StockWall Layout System — UX 3.0 === */
/* === T02: 三栏布局+响应式断点+底部导航 === */
/* === 依赖: styles.css 的 :root 变量 === */

/* === App Container === */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: var(--max-w);
  min-width: var(--min-w);
  margin: 0 auto;
  padding: 0 var(--container-padding);
}

/* === Header (sticky) === */
.header {
  height: var(--header-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-xl);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.header-left {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
}

.header-logo {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--color-accent);
  white-space: nowrap;
  cursor: pointer;
  letter-spacing: -0.02em;
  margin: 0;
  display: inline-block;
}

.header-search {
  position: relative;
  flex: 0 1 auto;
}

.header-search input {
  background: var(--color-input);
  border: 1px solid var(--color-border);
  border-radius: var(--search-radius);
  padding: 6px var(--space-lg) 6px 32px;
  font-size: var(--text-sm);
  color: var(--color-text);
  width: 240px;
  max-width: var(--search-max-w);
  font-family: var(--font-sans);
  transition: border-color var(--duration-fast) var(--ease-out), width var(--duration-normal) var(--ease-out);
}

.header-search input:focus {
  outline: none;
  border-color: var(--color-accent);
  width: 300px;
}

.header-search input::placeholder {
  color: var(--color-text-disabled);
}

.header-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-disabled);
  pointer-events: none;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.header-nav a {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-decoration: none;
  padding: var(--space-xs) 0;
  border-bottom: 2px solid transparent;
  transition: all var(--duration-fast) var(--ease-out);
}

.header-nav a:hover {
  color: var(--color-text);
}

.header-nav a.active {
  color: var(--color-accent);
  border-bottom-color: var(--color-accent);
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
}

.header-time {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
}

/* === Flash Ticker Bar (快讯滚动条) === */
.flash-ticker {
  height: var(--ticker-h);
  display: flex;
  align-items: center;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  overflow: hidden;
  position: sticky;
  top: var(--header-h);
  z-index: var(--z-ticker);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.flash-ticker-label {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 0 var(--space-lg);
  height: 100%;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-up);
  border-right: 1px solid var(--color-border);
  background: var(--color-surface);
  white-space: nowrap;
}

.flash-ticker-track {
  flex: 1;
  overflow: hidden;
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
}

.flash-ticker-content {
  display: flex;
  align-items: center;
  gap: var(--space-2xl);
  white-space: nowrap;
  animation: ticker-scroll var(--ticker-scroll-duration) linear infinite;
  padding-left: 100%;
}

.flash-ticker:hover .flash-ticker-content {
  animation-play-state: paused;
}

@keyframes ticker-scroll {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.flash-ticker-more {
  flex-shrink: 0;
  padding: 0 var(--space-lg);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  cursor: pointer;
  border-left: 1px solid var(--color-border);
  background: var(--color-surface);
  white-space: nowrap;
  transition: color var(--duration-fast);
}

.flash-ticker-more:hover {
  color: var(--color-accent);
}

/* === Macro Bar (sticky) === */
.macro-bar {
  display: flex;
  align-items: center;
  gap: var(--space-lg);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  padding: var(--space-md) var(--space-xl);
  min-height: var(--macro-h);
  position: sticky;
  top: calc(var(--header-h) + var(--ticker-h));
  z-index: var(--z-macro);
  overflow-x: auto;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.macro-bar .macro-item {
  flex-shrink: 0;
  min-width: 140px;
}

/* === Three Column Layout === */
.three-column {
  display: grid;
  grid-template-columns: var(--col-left) var(--col-center) var(--col-right);
  gap: var(--space-lg);
  flex: 1;
  align-items: start;
}

/* === Column Wrappers === */
.col-left {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  min-width: 0;
}

.col-center {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  min-width: 0;
}

.col-right {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  min-width: 0;
}

/* === Bottom Section (涨停板+K线图，三栏下方全宽) === */
.bottom-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  margin-top: var(--space-lg);
}

/* === Bottom Nav (移动端底部导航) === */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-h);
  background: var(--color-glass);
  border-top: 1px solid var(--color-border);
  z-index: var(--z-bottom-nav);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  justify-content: space-around;
  align-items: center;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  height: 100%;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--duration-fast) var(--ease-out);
  text-decoration: none;
}

.bottom-nav-item:hover,
.bottom-nav-item.active {
  color: var(--color-accent);
}

.bottom-nav-icon {
  font-size: 20px;
  line-height: 1;
}

.bottom-nav-label {
  font-size: var(--text-2xs);
  font-weight: 500;
}

/* === Page Container (路由页面挂载点) === */
.page-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  min-height: 0;
}

/* === Main Content Area === */
.main {
  flex: 1;
  padding: var(--space-lg) 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  overflow-y: auto;
}

/* === Two Column Fallback (中等屏幕) === */
.two-column {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  align-items: start;
}

.two-column .col-left-wide {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  min-width: 0;
}

.two-column .col-right-narrow {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
  min-width: 0;
}

/* === Single Column (移动端) === */
.single-column {
  display: flex;
  flex-direction: column;
  gap: var(--space-lg);
}

/* === Responsive Breakpoints === */

/* ≥1280px: 三栏布局 */
@media (min-width: 1280px) {
  .three-column {
    display: grid;
    grid-template-columns: var(--col-left) var(--col-center) var(--col-right);
  }
  .two-column { display: none; }
  .single-column { display: none; }
}

/* 768px - 1279px: 两栏布局 */
@media (min-width: 768px) and (max-width: 1279px) {
  .three-column { display: none; }
  .two-column {
    display: grid;
    grid-template-columns: 60% 40%;
  }
  .single-column { display: none; }

  .header-nav { display: none; }
  .bottom-nav { display: none; }

  .macro-bar {
    position: static;
  }

  .flash-ticker {
    position: static;
  }

  /* 中栏新闻移到右栏下方 */
  .col-right .news-center {
    order: 99;
  }
}

/* <768px: 单栏布局 + 底部导航 */
@media (max-width: 767px) {
  .three-column { display: none; }
  .two-column { display: none; }
  .single-column {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
  }

  /* Header 简化 */
  .header {
    height: 52px;
    padding: 0 var(--space-md);
  }
  .header-nav { display: none; }
  .header-logo { font-size: var(--text-base); }
  .header-search { flex: 1; }
  .header-search input { width: 100%; }
  .header-search input:focus { width: 100%; }
  .header-time { display: none; }
  .color-mode-btn { display: none; }

  /* 快讯条 */
  .flash-ticker {
    position: static;
    height: 32px;
  }
  .flash-ticker-label { display: none; }
  .flash-ticker-more { display: none; }

  /* 宏观条横向滚动 */
  .macro-bar {
    position: static;
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: var(--space-sm) var(--space-md);
    gap: var(--space-md);
    scrollbar-width: none;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
  }
  .macro-bar::-webkit-scrollbar { display: none; }
  .macro-bar .macro-item {
    min-width: 100px;
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* App padding */
  .app {
    padding: 0 var(--space-md);
    min-width: 0;
  }

  /* Main padding */
  .main {
    padding: var(--space-sm) 0;
    padding-bottom: calc(var(--bottom-nav-h) + var(--space-md));
  }

  /* 底部导航显示 */
  .bottom-nav {
    display: flex;
  }

  /* K线图高度限制 */
  .chart-container {
    min-height: 240px;
  }

  /* Table 字体缩小 */
  .table th, .table td {
    padding: 2px var(--space-sm);
    font-size: var(--text-xs);
  }

  /* === 移动端增强: 表格横向滚动 === */
  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .table-wrap::-webkit-scrollbar { display: none; }

  /* 行情列表表头 Tab 横向滚动 */
  .quote-list-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }
  .quote-list-tabs::-webkit-scrollbar { display: none; }
  .quote-list-tabs button {
    flex-shrink: 0;
    white-space: nowrap;
  }

  /* 板块热力图容器限制高度 */
  .heatmap-container {
    min-height: 200px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* 涨停板表格行高+触控 */
  .board-table tbody tr {
    min-height: 44px;
  }
  .board-table td, .board-table th {
    padding: 6px 4px;
  }

  /* 搜索框触控 */
  .header-search input {
    height: 36px;
    font-size: 16px;  /* iOS 防止缩放 */
  }

  /* 行情列表行触控目标 */
  .quote-list-table tbody tr {
    min-height: 44px;
  }

  /* 卡片间距 */
  .card {
    margin-bottom: var(--space-md);
  }
}

/* === Landscape Mobile === */
@media (max-width: 1024px) and (orientation: landscape) and (max-height: 500px) {
  .header { height: 44px; }
  .flash-ticker { display: none; }
  .macro-bar { position: static; min-height: 40px; padding: var(--space-xs) var(--space-md); }
}

/* === Print === */
@media print {
  .header, .flash-ticker, .bottom-nav, .chart-toolbar { display: none; }
  .macro-bar { position: static; }
}

/* === Reduced Motion === */
@media (prefers-reduced-motion: reduce) {
  .flash-ticker-content {
    animation: none;
  }
}
