/**
 * Chart Bottom Panel Styles
 * 底部订单/持仓面板样式
 */

/* ========== 底部调整器 ========== */
.bottom-resizer {
  width: 100%;
  height: 4px;
  background: var(--border-color, #30363d);
  cursor: ns-resize;
  position: relative;
  z-index: 200; /* ⭐ 提高层级，覆盖副图调整条(z-index: 100) */
  transition: background 0.2s;
  flex-shrink: 0; /* ⭐ 不允许缩小 */
}

/* ⭐ 隐藏状态 */
.bottom-resizer.hidden {
  display: none;
}

.bottom-resizer:hover {
  background: var(--primary-color, #1890ff);
}

.bottom-resizer:active {
  background: var(--primary-color, #1890ff);
}

/* ========== 底部面板 ========== */
.bottom-panel {
  width: 100%;
  min-height: 100px;
  max-height: 60vh;
  background: var(--bg-secondary, #161b22);
  border-top: 1px solid var(--border-color, #30363d);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0; /* ⭐ 不允许缩小，保持设定的高度 */
  /* ⭐ 默认没有过渡，拖动时不卡顿 */
}

/* ⭐ 正在切换状态时才应用过渡动画 */
.bottom-panel.transitioning {
  transition: height 0.3s ease, opacity 0.3s ease;
}

/* ⭐ 底部面板隐藏状态 */
.bottom-panel.hidden {
  height: 0 !important;
  min-height: 0;
  opacity: 0;
  border-top: none;
}

/* 标签页导航 */
.bottom-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-color, #30363d);
  background: var(--bg-primary, #0d1117);
  flex-shrink: 0;
  align-items: center; /* ⭐ 垂直居中对齐 */
}

.bottom-tab-btn {
  padding: 3px 10px;
  border: 1px solid var(--border-color, #30363d);
  background: transparent;
  color: var(--text-secondary, #8b949e);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-size: 12px;
  font-weight: normal;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 6px;
}

.bottom-tab-btn:hover {
  border-color: #58a6ff;
  color: var(--text-primary, #c9d1d9);
}

.bottom-tab-btn.active {
  background: rgba(88, 166, 255, 0.1);
  color: #58a6ff;
  border: 1px solid #58a6ff;
}

/* ⭐ 快速展开按钮 */
.btn-expand-bottom {
  margin-left: auto; /* 推到右侧 */
  padding: 6px 8px;
  border: 1px solid var(--border-color, #30363d);
  background: transparent;
  color: var(--text-secondary, #8b949e);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
}

.btn-expand-bottom:hover {
  background: var(--bg-hover, rgba(110, 118, 129, 0.1));
  color: var(--primary-color, #1890ff);
  border-color: var(--primary-color, #1890ff);
}

.btn-expand-bottom svg {
  transition: transform 0.3s;
}

/* ⭐ 展开状态下的图标旋转 */
.bottom-panel.expanded .btn-expand-bottom svg {
  transform: rotate(180deg);
}

/* ⭐ 底部面板展开状态 */
.bottom-panel.expanded {
  height: calc(100vh - 60px) !important; /* 预留 header 高度 */
  transition: height 0.3s ease;
}

/* ⭐ 展开状态下，压缩图表区域到最小 */
.bottom-panel.expanded ~ * .chart-area,
body:has(.bottom-panel.expanded) .chart-area {
  max-height: 60px !important;
  min-height: 60px !important;
  overflow: hidden;
  transition: max-height 0.3s ease, min-height 0.3s ease;
}

/* 徽章计数 */
.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.bottom-tab-btn.active .tab-badge {
  background: rgba(88, 166, 255, 0.25);
  color: #58a6ff;
}

/* 面板内容容器 */
.bottom-content {
  flex: 1;
  overflow: hidden;
  position: relative;
  background: var(--bg-primary, #0d1117); /* ⭐ 添加背景色 */
}

/* 标签页内容 */
.bottom-tab-content {
  display: none;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: auto;
  background: var(--bg-primary, #0d1117); /* ⭐ 添加背景色 */
}

.bottom-tab-content.active {
  display: block;
}

/* 自定义滚动条 */
.bottom-tab-content::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.bottom-tab-content::-webkit-scrollbar-track {
  background: var(--bg-primary, #0d1117);
}

.bottom-tab-content::-webkit-scrollbar-thumb {
  background: var(--border-color, #30363d);
  border-radius: 4px;
}

.bottom-tab-content::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary, #8b949e);
}

/* ========== 流動性配對視圖 ========== */
.liq-mode-badge { padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.liq-mode-badge.pct { background: rgba(31,111,235,0.2); color: #58a6ff; border: 1px solid #1f6feb; }
.liq-mode-badge.level { background: rgba(35,134,54,0.3); color: #3fb950; border: 1px solid #2ea043; }
.liq-status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.liq-status-dot.active { background: #3fb950; }
.liq-status-dot.inactive { background: var(--text-muted, #6e7681); }

/* ========== 订单表格 ========== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: auto;
  background: var(--bg-primary, #0d1117); /* ⭐ 添加背景色 */
}

.data-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
}

.data-table th {
  background: var(--bg-primary, #0d1117);
  color: var(--text-secondary, #8b949e);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  border-bottom: 1px solid var(--border-color, #30363d);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color, #30363d);
  color: var(--text-primary, #c9d1d9);
  white-space: nowrap;
  background: var(--bg-primary, #0d1117); /* ⭐ 添加背景色 */
}

.data-table tbody tr {
  transition: background 0.2s;
  background: var(--bg-primary, #0d1117); /* ⭐ 添加背景色 */
}

.data-table tbody tr:hover {
  background: var(--bg-hover, rgba(110, 118, 129, 0.05));
}

/* ✅ 可点击字段样式 */
.data-table td.clickable-field {
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  user-select: none;
}

.data-table td.clickable-field:hover {
  background: rgba(88, 166, 255, 0.1) !important;
  color: #58a6ff;
  text-decoration: underline;
}

.data-table td.clickable-field:active {
  background: rgba(88, 166, 255, 0.2) !important;
}

/* 可点击字段的提示图标 */
.data-table td.clickable-field::after {
  content: ' ✏️';
  opacity: 0;
  transition: opacity 0.2s ease;
  font-size: 10px;
  margin-left: 4px;
}

.data-table td.clickable-field:hover::after {
  opacity: 0.6;
}

/* 空消息 */
.empty-message {
  text-align: center;
  color: var(--text-secondary, #8b949e);
  padding: 40px 12px !important;
  font-size: 14px;
  background: var(--bg-primary, #0d1117) !important; /* ⭐ 强制设置背景色 */
}

/* 加载和错误消息 */
.loading-message,
.error-message {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-secondary, #8b949e);
  font-size: 14px;
}

.error-message {
  color: var(--error-color, #ff4d4f);
}

/* ⭐ 按钮样式（使用 CSS 类而非内联样式） */
.btn-action {
  font-size: 12px;
  padding: 4px 8px;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-action:hover {
  opacity: 0.8;
}

.btn-detail {
  background: var(--primary-color, #0969da);
}

.btn-protect {
  background: var(--success-color, #10a37f);
}

.btn-modify {
  background: var(--text-secondary, #6e7681);
}

.btn-cancel,
.btn-close {
  background: var(--error-color, #da3633);
}

/* ⭐ 文本样式 */
.expiry-text.expired {
  color: var(--text-secondary, #8b949e);
}

.expiry-text.warning {
  color: var(--error-color, #f85149);
}

.margin-value {
  color: var(--error-color, #f85149);
  font-weight: bold;
}

/* ⭐ 订单明细样式 */
.order-details-header {
  background: var(--bg-secondary, #161b22);
}

.order-details-title {
  padding: 8px 16px;
  border-left: 3px solid var(--primary-color, #58a6ff);
}

.order-details-label {
  color: var(--primary-color, #58a6ff);
  font-weight: bold;
  font-size: 13px;
}

.order-detail-row {
  background: var(--bg-primary, #0d1117);
  border-bottom: 1px solid var(--border-color, #21262d);
}

.order-detail-cell {
  padding: 8px;
  font-size: 12px;
  color: var(--text-primary, #c9d1d9);
}

.order-id-cell {
  color: var(--text-secondary, #8b949e);
}

.order-pnl {
  font-weight: bold;
}

.order-pnl.positive {
  color: var(--success-color, #26a641);
}

.order-pnl.negative {
  color: var(--error-color, #f85149);
}

/* ⭐ 小尺寸按钮（订单明细中使用） */
.btn-action-sm {
  font-size: 11px;
  padding: 3px 8px;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-action-sm:hover {
  opacity: 0.8;
}

.btn-order-detail {
  background: var(--primary-color, #0969da);
}

.btn-order-protect {
  background: var(--success-color, #10a37f);
}

.btn-order-close {
  background: var(--error-color, #da3633);
}

.btn-toggle-orders {
  background: var(--text-secondary, #6e7681);
}

/* 方向标识徽章 */
.side-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 12px;
  font-weight: 600;
}

.side-badge.buy {
  background: rgba(82, 196, 26, 0.1);
  color: var(--green-color, #52c41a);
}

.side-badge.sell {
  background: rgba(255, 77, 79, 0.1);
  color: var(--red-color, #ff4d4f);
}

/* ✅ 方向颜色（非徽章形式，直接文本颜色） */
.buy {
  color: var(--green-color, #52c41a);
  font-weight: 600;
}

.sell {
  color: var(--red-color, #ff4d4f);
  font-weight: 600;
}

/* 状态标识徽章 */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 500;
}

.status-badge.filled {
  background: rgba(82, 196, 26, 0.1);
  color: var(--green-color, #52c41a);
}

.status-badge.cancelled {
  background: rgba(139, 148, 158, 0.1);
  color: var(--text-secondary, #8b949e);
}

/* 盈亏显示 */
.profit {
  color: var(--green-color, #52c41a);
  font-weight: 600;
}

.loss {
  color: var(--red-color, #ff4d4f);
  font-weight: 600;
}

/* 订单ID */
.order-id {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--text-secondary, #8b949e);
}

/* 操作按钮 */
.btn-cancel,
.btn-close {
  padding: 4px 12px;
  border: 1px solid var(--border-color, #30363d);
  background: transparent;
  color: var(--text-primary, #c9d1d9);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-cancel:hover,
.btn-close:hover {
  border-color: var(--red-color, #ff4d4f);
  color: var(--red-color, #ff4d4f);
  background: rgba(255, 77, 79, 0.1);
}

/* ========== 加载状态 ========== */
.panel-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-secondary, #8b949e);
}

.panel-loading::after {
  content: '';
  width: 20px;
  height: 20px;
  margin-left: 10px;
  border: 2px solid var(--border-color, #30363d);
  border-top-color: var(--primary-color, #1890ff);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}


/* 🆕 流动性子 tab */
.liquidity-sub-tabs {
  display: flex;
  gap: 4px;
  padding: 6px 8px 0;
  border-bottom: 1px solid var(--border-color, #30363d);
}

.liquidity-sub-tab {
  padding: 4px 12px;
  border: none;
  background: transparent;
  color: var(--text-secondary, #8b949e);
  cursor: pointer;
  font-size: 12px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.liquidity-sub-tab.active {
  color: var(--primary-color, #1890ff);
  border-bottom-color: var(--primary-color, #1890ff);
}

.liquidity-sub-tab:hover {
  color: var(--text-primary, #e6edf3);
}

/* 🆕 收益统计面板 */
.liquidity-stats-panel {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.stats-summary {
  display: flex;
  gap: 16px;
  padding: 8px 12px;
  background: var(--bg-secondary, #161b22);
  border-radius: 6px;
  flex-wrap: wrap;
}

.stats-summary-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 90px;
}

.stats-summary-label {
  font-size: 11px;
  color: var(--text-secondary, #8b949e);
}

.stats-summary-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary, #e6edf3);
}

.stats-summary-value.positive { color: #3fb950; }
.stats-summary-value.negative { color: #f85149; }

.stats-filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.stats-filters label {
  font-size: 11px;
  color: var(--text-secondary, #8b949e);
}

.stats-filters input,
.stats-filters select {
  background: var(--bg-secondary, #161b22);
  border: 1px solid var(--border-color, #30363d);
  color: var(--text-primary, #e6edf3);
  border-radius: 4px;
  padding: 3px 7px;
  font-size: 12px;
}

.stats-table-wrap {
  overflow-x: auto;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.stats-table th {
  text-align: left;
  padding: 5px 8px;
  color: var(--text-secondary, #8b949e);
  border-bottom: 1px solid var(--border-color, #30363d);
  white-space: nowrap;
}

.stats-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border-color, #30363d);
  color: var(--text-primary, #e6edf3);
  white-space: nowrap;
}

.stats-table tr:hover td {
  background: var(--bg-hover, #1c2128);
}

/* 🆕 stats 查询按钮 + 批量掛單按鈕 */
.stats-filters .stats-btn,
.stats-btn {
  padding: 4px 12px;
  background: rgba(88, 166, 255, 0.15);
  color: #58a6ff;
  border: 1px solid rgba(88, 166, 255, 0.4);
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}

.stats-filters .stats-btn:hover,
.stats-btn:hover {
  background: rgba(88, 166, 255, 0.25);
  border-color: #58a6ff;
}


/* ========== 狀態篩選按鈕（統一規範）========== */
.filter-btn {
  padding: 3px 10px;
  background: transparent;
  border: 1px solid var(--border-color, #30363d);
  border-radius: 6px;
  color: var(--text-secondary, #8b949e);
  font-size: 12px;
  font-weight: normal;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.filter-btn:hover {
  border-color: #58a6ff;
  color: var(--text-primary, #c9d1d9);
}

.filter-btn.active {
  background: rgba(88, 166, 255, 0.1);
  color: #58a6ff;
  border: 1px solid #58a6ff;
}

/* ========== 對沖視圖切換按鈕（統一規範）========== */
.hedge-view-btn {
  padding: 3px 10px;
  background: transparent;
  border: 1px solid var(--border-color, #30363d);
  border-radius: 6px;
  color: var(--text-secondary, #8b949e);
  font-size: 12px;
  font-weight: normal;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.hedge-view-btn:hover {
  border-color: #58a6ff;
  color: var(--text-primary, #c9d1d9);
}

.hedge-view-btn.active {
  background: rgba(88, 166, 255, 0.1);
  color: #58a6ff;
  border: 1px solid #58a6ff;
}

/* ===== 操作按鈕統一樣式 ===== */
.btn-action-detail {
  background: transparent;
  color: #58a6ff;
  border: 1px solid #58a6ff;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.15s;
  margin-right: 4px;
}
.btn-action-detail:hover {
  background: rgba(88, 166, 255, 0.1);
}

.btn-action-cancel {
  background: transparent;
  color: #f85149;
  border: 1px solid #f85149;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.15s;
  margin-right: 4px;
}
.btn-action-cancel:hover {
  background: rgba(248, 81, 73, 0.1);
}

/* ==================== 底部面板高度控制 ==================== */

/* 快速收起按鈕 */
.btn-panel-height {
  margin-right: 4px;
  padding: 0;
  width: 26px;
  height: 26px;
  border: 1px solid var(--border-color, #30363d);
  background: transparent;
  color: var(--text-secondary, #8b949e);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-panel-height:hover {
  border-color: #58a6ff;
  color: #58a6ff;
  background: rgba(88, 166, 255, 0.08);
}

.btn-panel-height.active {
  border-color: #58a6ff;
  color: #58a6ff;
  background: rgba(88, 166, 255, 0.12);
}

/* 最小狀態：只顯示 Tab bar，內容隱藏 */
.bottom-panel.minimized {
  height: 44px !important;
  min-height: 0 !important;
  overflow: hidden !important;
  transition: height 0.25s ease !important;
}

.bottom-panel.minimized .bottom-content {
  display: none !important;
}

/* 確保 Tab bar 在 minimized 時仍顯示 */
.bottom-panel.minimized .bottom-tabs {
  display: flex !important;
}

/* 窗口很小時 bottom-resizer 也縮小 */
@media (max-height: 699px) {
  .bottom-resizer {
    display: none;
  }
}
