/**
 * Sub-chart and Main-chart Styles (matching Demo structure)
 */

/* ==================== Main Chart Wrapper ==================== */

.main-chart-wrapper {
  position: relative;  /* 为absolute子元素提供定位上下文 */
  height: 400px;  /* 固定高度 */
  flex-shrink: 0;  /* 不缩小 */
  display: flex;
  flex-direction: column;
}

.main-chart {
  width: 100%;
  height: 100%;
  position: relative;
  flex: 1;
  min-height: 0;
}

/* ==================== Main Chart Resize Handle ==================== */
/* ⭐ 悬浮调整条：不占用空间，悬浮在图表边界上 */

.chart-main-resize-handle,
.chart-sub-resize-handle {
  position: absolute;  /* ⭐ 绝对定位，不占用空间 */
  left: 0;
  right: 0;
  height: 12px;  /* ⭐ 增加可点击区域 */
  cursor: ns-resize;
  z-index: 100;
  transition: all 0.2s ease;
  pointer-events: auto;  /* ⭐ 确保可以点击 */
}

/* ⭐ 主图调整条：位于主图底部 */
.chart-main-resize-handle {
  bottom: -6px;  /* ⭐ 向下偏移，跨越边界 */
}

/* ⭐ 副图调整条：位于副图底部 */
.chart-sub-resize-handle {
  bottom: -13px;  /* ⭐ 向下偏移超过自身高度(12px)，确保完全进入底部区域被z-index覆盖 */
}

/* 平常状态：不可见细线 */
.chart-main-resize-handle::before,
.chart-sub-resize-handle::before {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 1px;
  background: transparent;  /* ⭐ 默认透明 */
  transition: all 0.2s ease;
}

/* 平常状态：隐藏的小标记 */
.chart-main-resize-handle::after,
.chart-sub-resize-handle::after {
  content: '⋮⋮⋮';
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(13, 17, 23, 0.95);
  color: var(--text-secondary, #8b949e);
  font-size: 10px;
  padding: 2px 10px;
  border-radius: 4px;
  opacity: 0;  /* ⭐ 默认隐藏 */
  transition: all 0.2s ease;
  pointer-events: none;
  letter-spacing: 2px;
  border: 1px solid var(--border-color, #30363d);
}

/* ⭐ 悬停状态：显示高亮效果 */
.chart-main-resize-handle:hover::before {
  height: 3px;
  background: linear-gradient(to bottom, 
    transparent 0%, 
    #58a6ff 50%, 
    transparent 100%);
  box-shadow: 0 0 8px rgba(88, 166, 255, 0.4);
}

.chart-main-resize-handle:hover::after {
  opacity: 1;
  color: #58a6ff;
  font-weight: bold;
  background: rgba(13, 17, 23, 0.98);
  border-color: #58a6ff;
}

/* ⭐ 拖动中状态 */
.chart-main-resize-handle.dragging::before {
  height: 4px;
  background: #58a6ff;
  box-shadow: 0 0 12px rgba(88, 166, 255, 0.6);
}

.chart-main-resize-handle.dragging::after {
  color: #58a6ff;
  opacity: 1;
  font-weight: bold;
  transform: translate(-50%, -50%) scale(1.1);
}

/* ⭐ 副图拖动条：橙色主题，更低调 */
.chart-sub-resize-handle::before {
  opacity: 0.3;
}

.chart-sub-resize-handle::after {
  content: '⋮⋮⋮';
  font-size: 9px;
  padding: 1px 8px;
}

.chart-sub-resize-handle:hover::before {
  height: 2px;
  background: linear-gradient(to bottom, 
    transparent 0%, 
    #ff9800 50%, 
    transparent 100%);
  opacity: 1;
  box-shadow: 0 0 6px rgba(255, 152, 0, 0.3);
}

.chart-sub-resize-handle:hover::after {
  opacity: 1;
  color: #ff9800;
  font-weight: bold;
  border-color: #ff9800;
}

.chart-sub-resize-handle.dragging::before {
  height: 3px;
  background: #ff9800;
  box-shadow: 0 0 10px rgba(255, 152, 0, 0.5);
}

.chart-sub-resize-handle.dragging::after {
  color: #ff9800;
  opacity: 1;
  font-weight: bold;
  transform: translate(-50%, -50%) scale(1.1);
}

/* ==================== Sub Chart Container ==================== */

/* Sub-chart Container */
.sub-chart-container {
  position: relative;  /* ⭐ 为悬浮调整条提供定位上下文 */
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  height: 150px;  /* Default height */
  background: var(--bg-primary, #0d1117);
}

/* Sub-chart (Lightweight Charts) */
.sub-chart {
  width: 100%;
  flex: 1;  /* Fill the container */
  position: relative;  /* Important for overlay positioning */
  min-height: 0;  /* Allow flex shrink */
}

/* ==================== Indicator Info Overlay ==================== */

/* Overlay Container */
.indicators-info-container {
  position: absolute;
  top: 0;  /* ⭐ 紧贴上缘，无间距 */
  left: 0; /* ⭐ 紧贴左侧，无间距 */
  z-index: 100;
  pointer-events: none;  /* ⭐ 不拦截鼠标事件，让事件透传到图表 */
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Indicator Info Row */
.indicator-info-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: transparent;
  border: none;
  border-radius: 0;
  font-size: 12px;
  transition: all 0.2s;
  pointer-events: auto;
}

/* ⭐ 第一个指标标签：紧贴左上角，无圆角 */
.indicator-info-row:first-child {
  border-radius: 0;  /* 确保第一个无圆角 */
}

.indicator-info-row:hover {
  background: var(--bg-hover, rgba(177, 186, 196, 0.08));
}

/* Indicator Name */
.indicator-name {
  color: var(--text-primary, #d1d4dc);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: color 0.2s;
}

.indicator-name:hover {
  color: #58a6ff;
}

/* Indicator Values */
.indicator-values {
  color: var(--text-secondary, #8b949e);
  font-family: 'Courier New', monospace;
  font-size: 11px;
  flex: 1;
  text-align: left;
}

/* Indicator Buttons */
.indicator-btn-small {
  background: transparent;
  border: none;
  color: var(--text-secondary, #8b949e);
  font-size: 14px;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
}

.indicator-btn-small:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary, #d1d4dc);
}

.indicator-btn-small:active {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(0.95);
}

/* Delete button special style */
.indicator-btn-small[title="删除"]:hover {
  color: #f85149;
  background: rgba(248, 81, 73, 0.1);
}

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

@media (max-width: 768px) {
  .indicator-info-row {
    font-size: 11px;
    padding: 3px 6px;
    gap: 6px;
  }
  
  .indicator-btn-small {
    font-size: 12px;
    padding: 1px 3px;
  }
}

/* OHLC 顯示列 - 使用 CSS 變數，支援主題切換 */
.ohlc-time {
  color: var(--text-secondary, #8b949e);
  font-size: 11px;
}

.ohlc-label {
  color: var(--text-primary, #d1d4dc);
  font-size: 11px;
}
