/* public/styles/dashboard.css */

/* --- 1. 基础导航栏 --- */
.dash-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(5, 7, 18, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.dash-nav-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 60px;
}
.brand-badge.small { width: 24px; height: 24px; }

.dash-search {
  position: relative;
  width: 320px;
  margin-left: 20px;
}
.dash-search input {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 8px 12px 8px 36px;
  color: white;
  font-size: 14px;
}
.dash-search input:focus {
  border-color: var(--accent);
  background: rgba(0,0,0,0.4);
  outline: none;
}
.dash-search svg {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  opacity: 0.5;
}
.dash-search .results.dropdown {
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: #0b0e1b;
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  z-index: 101;
}

.dash-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-home {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 16px;
  border-radius: 20px; /* 圆角胶囊型 */
  background: rgba(255, 255, 255, 0.05); /* 默认微透背景 */
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-home svg {
  opacity: 0.7;
}

.btn-home:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text);
  transform: translateY(-1px);
}

.btn-home:active {
  transform: translateY(0);
}

/* --- 2. 核心布局 Grid --- */
.dash-container {
  display: grid;
  /* 桌面端：左侧固定260px，右侧撑满剩余空间 */
  grid-template-columns: 260px 1fr;
  min-height: calc(100vh - 60px);
}

/* --- 3. 侧边栏 (Sidebar) --- */
.sidebar {
  position: sticky;
  top: 60px;
  height: calc(100vh - 60px);
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding: 20px;
  background: rgba(255,255,255,0.01);
  display: flex;
  flex-direction: column;
}

.sidebar-header { margin-bottom: 30px; }
.ticker-box { display: flex; align-items: center; gap: 12px; }
.sidebar-logo { width: 48px; height: 48px; border-radius: 10px; background: white; padding: 4px; object-fit: contain; }
.ticker-box h1 { margin: 0; font-size: 24px; line-height: 1; }
.price { font-family: 'ui-monospace', monospace; color: var(--muted); display: block; margin-top: 4px; }
.price .green { color: #4ade80; margin-left: 6px; }

/* 菜单样式 */
.sidebar-menu { list-style: none; padding: 0; margin: 0; flex: 1; }

.menu-label {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--faint);
  margin: 24px 0 10px;
  font-weight: 600;
}
.menu-label:first-child { margin-top: 0; } 

.sidebar-menu li a {
  display: block;
  padding: 10px 12px;
  color: var(--muted);
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.2s;
  cursor: pointer;
  border-left: 3px solid transparent; /* 左侧指示条预留 */
}
.sidebar-menu li a:hover {
  background: rgba(255,255,255,0.05);
  color: white;
}
/* 选中状态样式 */
.sidebar-menu li a.active {
  background: rgba(110,231,255,0.08);
  color: var(--accent);
  border-left-color: var(--accent); /* 高亮左边框 */
  font-weight: 600;
}

/* Unlock 按钮 */
.unlock-btn {
  margin-top:20px;
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 12px;
  background: linear-gradient(135deg, rgba(167,139,250,0.1), rgba(167,139,250,0.05));
  border: 1px solid rgba(167,139,250,0.3);
  color: var(--accent2); border-radius: 8px; cursor: pointer; text-align: left; transition: 0.2s;
}
.unlock-btn:hover { background: rgba(167,139,250,0.15); transform: translateY(-1px); }

/* --- 4. 右侧内容区 (Main Content) --- */
.main-content {
  padding: 30px 40px; 
  width: 100%;        /* 强制占满 */
  overflow-x: hidden; /* 防止表格撑破页面 */
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 60px); 
}

/* Tab 切换逻辑的核心 CSS */
.panel-section {
  display: none; /* 默认隐藏所有板块 */
  animation: fadeIn 0.3s ease-in-out;
}
.panel-section.active {
  display: block; /* 只有加了 active 才显示 */
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px; padding-bottom: 12px; border-bottom: 1px solid var(--border);
}
.section-header h2 { margin: 0; font-size: 22px; }

/* 表格容器 - 允许横向滚动但占满宽度 */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(0,0,0,0.2);
}
table { width: 100%; border-collapse: collapse; min-width: 600px; /* 防止在手机上过度挤压 */ }
th, td { padding: 14px 18px; border-bottom: 1px solid rgba(255,255,255,0.05); }
th { background: rgba(255,255,255,0.03); font-weight: 600; color: var(--muted); }
.text-left { text-align: left; }
.text-right { text-align: right; }
.num { font-family: 'ui-monospace', monospace; text-align: right; letter-spacing: -0.5px; }
.row-head { color: var(--text); font-weight: 500; }
.indented { padding-left: 32px; color: var(--muted); font-size: 13px; }
.summary-row { background: rgba(255,255,255,0.03); font-weight: 600; }
.highlight-row { background: rgba(110,231,255,0.05); font-weight: 700; border-top: 2px solid rgba(255,255,255,0.1); }
.muted { color: var(--faint); }


/* KPI Grid */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-top: 20px; }
.kpi-card { background: var(--panel); border: 1px solid var(--border); padding: 20px; border-radius: 12px; }
.kpi-card span { display: block; font-size: 13px; color: var(--muted); }
.kpi-card strong { font-size: 24px; display: block; margin-top: 8px; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(5px); z-index: 200;
  display: flex; align-items: center; justify-content: center;
}
.hidden { display: none; }
.modal {
  background: #0e1224; border: 1px solid var(--border); width: 400px; padding: 30px;
  border-radius: 20px; text-align: center; position: relative; box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.close-modal {
  position: absolute; top: 10px; right: 15px; background: none; border: none;
  color: var(--muted); font-size: 24px; cursor: pointer;
}
.modal-icon { font-size: 40px; margin-bottom: 16px; }
.modal-actions { margin-top: 20px; }
.tiny { font-size: 12px; color: var(--faint); margin-top: 8px; }

/* --- Locked Column Styles (Future Year) --- */

/* 1. 列头样式：给未来年份加深色背景 */
th.future-col {
  background: rgba(167, 139, 250, 0.1) !important; /* 淡紫色背景 */
  color: var(--accent2);
  border-left: 1px solid rgba(255,255,255,0.05);
}

/* 2. 锁定单元格样式 */
.locked-cell {
  background: 
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.02),
      rgba(255, 255, 255, 0.02) 10px,
      rgba(255, 255, 255, 0.04) 10px,
      rgba(255, 255, 255, 0.04) 20px
    ); /* 斜纹背景 */
  text-align: center !important;
  cursor: pointer;
  border-left: 1px solid rgba(255,255,255,0.05);
  position: relative;
  transition: background 0.2s;
}

.locked-cell:hover {
  background: rgba(167, 139, 250, 0.15); /* 悬停变亮 */
}

/* 3. 单元格内的文字 (Unlock) */
.lock-icon {
  font-size: 12px;
  margin-right: 4px;
  opacity: 0.7;
}

.lock-text {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent2); /* 紫色文字 */
  opacity: 0.8;
}

/* 手机适配：未来年份如果不重要可以隐藏，或者保持显示 */
@media (max-width: 768px) {
  .lock-text { display: none; } /* 手机上只显示锁图标，省空间 */
  .locked-cell { padding: 10px 4px; }
}

/* Dashboard Footer */
.dash-footer {
  margin-top: auto;
  margin-left: -40px;    
  margin-right: -40px;
  margin-bottom: -30px;  /* 抵消底部的 padding */
  padding: 20px 40px;    /* 重新补上内部的 padding */
  
  border-top: 1px solid var(--border);
  color: var(--faint);
  font-size: 13px;
  background: rgba(255,255,255,0.01); /* 稍微加点背景色区分 */
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
}

.footer-links {
  display: flex;
  gap: 12px;
  align-items: center;
}

.sep { opacity: .35; }

/* 手机端适配：让 Footer 稍微紧凑点 */
@media (max-width: 900px) {
  .dash-footer {
    margin-top: 40px;
    padding-bottom: 20px; /* 底部留白，防止贴底太紧 */
  }
}

/* --- 5. 移动端适配 (Media Queries) --- */
/* --- 5. 手机端优化 (汉堡菜单 + 侧滑抽屉) --- */
@media (max-width: 900px) {
  
  /* 1. 整体布局：变成单列，Sidebar 不占位 */
  .dash-container {
    display: block; /* 从左右两列变成上下堆叠 */
    position: relative;
  }

  /* 2. Sidebar 变身：侧滑抽屉 */
  .sidebar {
    position: fixed;        /* 固定在屏幕上 */
    top: 60px;              /* 在顶部导航栏下面 */
    left: -100%;            /* 默认藏在屏幕左边外面 */
    width: 280px;           /* 抽屉宽度 */
    height: calc(100vh - 60px); /* 高度撑满 */
    background: #0b0e1b;    /* 深色背景 */
    border-right: 1px solid var(--border);
    transition: left 0.3s ease-in-out; /* 滑动动画 */
    z-index: 99;            /* 在最上层 */
    padding: 20px;
    overflow-y: auto;       /* 内容多了可以滚动 */
    box-shadow: 20px 0 50px rgba(0,0,0,0.5); /* 加个阴影更有立体感 */
    display: flex;          /* 确保里面内容垂直排列 */
    flex-direction: column;
  }

  /* 当加上 .show 类时，Sidebar 滑出来 */
  .sidebar.show {
    left: 0;
  }

  /* 3. 顶部导航栏调整 */
  .dash-nav-inner {
    padding: 0 16px;
    gap: 12px;
  }

  /* 搜索框在手机上缩小一点 */
  .dash-search {
    width: auto;
    flex: 1; /* 自动占据剩余空间 */
    margin-left: 0;
  }
  .dash-search input {
    padding-left: 32px;
  }

  /* 隐藏 "Back Home" 的文字，只留图标，省空间 */
  .btn-home span { 
    display: none; 
  }
  .btn-home {
    padding: 0 10px; /* 按钮变窄 */
  }

  /* 4. 显示汉堡菜单按钮 (三道杠) */
  .mobile-menu-toggle {
    display: flex !important; /* 强制显示 */
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 32px;
    height: 32px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    padding: 6px;
    margin-right: 10px;
  }
  /* 三道杠的线条样式 */
  .mobile-menu-toggle span {
    display: block;
    height: 2px;
    width: 100%;
    background: var(--muted);
    border-radius: 2px;
    transition: 0.2s;
  }

  /* 5. 内容区域调整 */
  .main-content {
    padding: 20px 16px;
    width: 100%;
  }

  /* 表格允许横向滚动 */
  .table-wrap {
    margin: 0 -16px; /* 让表格贴边 */
    width: calc(100% + 32px);
    border-left: none;
    border-right: none;
    border-radius: 0;
  }
  
  /* KPI 卡片在手机上显示两列 */
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
  }

  /* 确保解锁按钮在手机抽屉里也能看到 */
  .unlock-btn {
    display: flex; 
    margin-top: 30px;
  }
  
  /* 在抽屉里也显示股票代码，方便用户知道看的是谁 */
  .sidebar-header {
    display: block; 
    margin-bottom: 20px;
  }
}

/* 默认状态：在电脑上隐藏汉堡按钮 */
.mobile-menu-toggle {
  display: none;
}

/* public/styles/dashboard.css */

/* Sidebar 上的小锁图标 */
.lock-tag {
  font-size: 10px;
  opacity: 0.6;
  margin-left: 6px;
  float: right; /* 靠右对齐，看起来更整齐 */
  margin-top: 3px;
}

/* 右侧锁定视图容器 */
.locked-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px dashed var(--border);
  border-radius: 12px;
  text-align: center;
  margin-top: 20px;
}

.lock-icon-large {
  font-size: 48px;
  margin-bottom: 20px;
  opacity: 0.8;
}

.locked-view h3 {
  font-size: 20px;
  margin: 0 0 10px 0;
  color: var(--text);
}

.locked-view p {
  color: var(--muted);
  max-width: 400px;
  margin: 0 auto 24px auto;
  line-height: 1.5;
}