/* ============================================
   要素详情面板（属性表 + 图表）
   主题兼容：边框/分割线使用 --c-border，深浅主题自适应
   ============================================ */

/* 面板遮罩 */
.feature-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 9998;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.25s ease,
    visibility 0.25s ease;
}
.feature-panel-backdrop.open {
  opacity: 1;
  visibility: visible;
}

/* 面板主体：右侧滑出 */
.feature-panel {
  --fp-border: var(--c-border, #d0d0d0);
  --fp-border-subtle: color-mix(in srgb, var(--fp-border) 50%, transparent);
  --fp-bg-subtle: rgba(128, 128, 128, 0.06);
  --fp-bg-hover: rgba(128, 128, 128, 0.1);

  position: fixed;
  top: 0;
  right: 0;
  width: 480px;
  max-width: calc(100vw - 60px);
  min-width: 320px;
  height: 100vh;
  background: var(--panel-bg, #fff);
  color: var(--text-primary, #333);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}
.feature-panel.open {
  transform: translateX(0);
}

/* ========== 面板左侧拖拽 resize 手柄 ========== */
.feature-panel-resize-handle {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 10;
  background: transparent;
  transition: background 0.15s;
}
.feature-panel-resize-handle:hover,
.feature-panel-resize-handle.active {
  background: rgba(153, 204, 153, 0.4);
}
.feature-panel-resize-handle::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 32px;
  border-radius: 1px;
  background: var(--fp-border);
  opacity: 0;
  transition: opacity 0.15s;
}
.feature-panel-resize-handle:hover::after,
.feature-panel-resize-handle.active::after {
  opacity: 1;
}

/* ========== 面板头部 ========== */
.feature-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 12px 14px;
  border-bottom: 1px solid var(--fp-border);
  flex-shrink: 0;
  gap: 10px;
}
.feature-panel-title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}
.feature-panel-subtitle {
  font-size: 11px;
  color: var(--text-dim, #888);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.feature-panel-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--fp-bg-subtle);
  color: var(--text-primary, #333);
  border-radius: 6px;
  cursor: pointer;
  font-size: 18px;
  flex-shrink: 0;
  transition: background 0.15s;
}
.feature-panel-close:hover {
  background: var(--fp-bg-hover);
}

/* ========== Tab 导航 ========== */
.feature-panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--fp-border);
  flex-shrink: 0;
  padding: 0 16px;
  gap: 0;
}
.feature-panel-tab {
  padding: 10px 20px;
  background: none;
  border: none;
  color: var(--text-dim, #888);
  font-size: 13px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition:
    color 0.15s,
    border-color 0.15s;
  margin-bottom: -1px;
  white-space: nowrap;
}
.feature-panel-tab:hover {
  color: var(--text-primary, #333);
}
.feature-panel-tab.active {
  color: #9c9;
  border-bottom-color: #9c9;
  font-weight: 600;
}

/* ========== 面板内容区 ========== */
.feature-panel-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ========== 属性表模式切换（单要素 / 全部要素） ========== */
.feature-panel-mode-switch {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--fp-border-subtle);
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-dim, #888);
}
.feature-panel-mode-switch .mode-label {
  margin-right: 8px;
}
.feature-panel-mode-switch .mode-btn {
  padding: 3px 10px;
  border-radius: 12px;
  border: 1px solid var(--fp-border);
  background: transparent;
  color: var(--text-dim, #888);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}
.feature-panel-mode-switch .mode-btn.active {
  background: #9c9;
  color: #1a1a2e;
  border-color: #9c9;
  font-weight: 600;
}
.feature-panel-mode-switch .mode-btn:hover:not(.active) {
  border-color: #777;
  color: var(--text-primary, #333);
}

/* ========== 搜索过滤栏 ========== */
.feature-panel-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--fp-border-subtle);
  flex-shrink: 0;
}
.feature-panel-search input {
  flex: 1;
  padding: 6px 10px;
  background: var(--fp-bg-subtle);
  border: 1px solid var(--fp-border);
  border-radius: 6px;
  color: var(--text-primary, #333);
  font-size: 12px;
  outline: none;
  transition: border-color 0.15s;
  min-width: 0;
}
.feature-panel-search input:focus {
  border-color: #9c9;
}
.feature-panel-search input::placeholder {
  color: var(--text-dim, #999);
}
.feature-panel-result-count {
  font-size: 11px;
  color: var(--text-dim, #888);
  white-space: nowrap;
  flex-shrink: 0;
}

/* ========== 属性表格容器（可滚动） ========== */
.feature-panel-table-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.feature-panel-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: auto;
}
.feature-panel-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
}
.feature-panel-table th {
  background: var(--panel-bg, #fff);
  padding: 6px 8px;
  line-height: 1.3;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  color: var(--text-dim, #888);
  border-bottom: 2px solid var(--fp-border);
  white-space: nowrap;
  position: sticky;
  top: 0;
}
/* 单要素模式：属性名列 35%，属性值列 65% */
.feature-panel-table.cols-2 th.col-key {
  width: 35%;
  min-width: 80px;
  padding: 4px 10px;
}
.feature-panel-table.cols-2 th.col-val {
  width: 65%;
  padding: 4px 10px;
}
.feature-panel-table.cols-2 td {
  padding: 4px 10px;
}
.feature-panel-table td {
  padding: 3px 8px;
  line-height: 1.35;
  max-height: 4.05em; /* 3行 × 1.35 ≈ 3行上限 */
  overflow: hidden;
  border-bottom: 1px solid var(--fp-border-subtle);
  vertical-align: top;
  overflow-wrap: break-word;
  word-break: break-word;
  max-width: 600px;
}
.feature-panel-table td.col-key {
  color: var(--text-dim, #888);
  font-weight: 500;
}
.feature-panel-table td.col-val {
  color: var(--text-primary, #333);
  position: relative;
}
.feature-panel-table tr:hover td {
  background: var(--fp-bg-subtle);
}

/* 图层表格缩放按钮列 */
.feature-panel-table th.col-zoom {
  width: 32px;
  min-width: 32px;
  max-width: 32px;
  padding: 4px 2px;
  text-align: center;
}
.feature-panel-table td.col-zoom {
  width: 32px;
  min-width: 32px;
  max-width: 32px;
  padding: 4px 2px;
  text-align: center;
}
.zoom-to-feat-btn {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--fp-bg-subtle);
  color: var(--text-dim, #888);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}
.zoom-to-feat-btn:hover {
  background: #9c9;
  color: #1a1a2e;
}

/* 图层表格（多列）：虚线列分隔，紧致行高 */
.feature-panel-table.cols-multi th {
  min-width: 100px;
  max-width: 280px;
  padding: 5px 8px;
  border-right: 1px dotted var(--fp-border-subtle);
}
.feature-panel-table.cols-multi th:last-child {
  border-right: none;
}
.feature-panel-table.cols-multi td {
  min-width: 100px;
  max-width: 280px;
  padding: 3px 8px;
  border-right: 1px dotted var(--fp-border-subtle);
}
.feature-panel-table.cols-multi td:last-child {
  border-right: none;
}

/* 数值右对齐 */
.feature-panel-table td.col-val.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: "SF Mono", "Cascadia Code", "Consolas", monospace;
}

/* 复制按钮 */
.feature-panel-table .copy-val-btn {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--fp-bg-subtle);
  color: var(--text-dim, #888);
  border-radius: 4px;
  cursor: pointer;
  font-size: 11px;
  opacity: 0;
  transition:
    opacity 0.15s,
    background 0.15s;
}
.feature-panel-table tr:hover .copy-val-btn {
  opacity: 1;
}
.copy-val-btn:hover {
  background: var(--fp-bg-hover);
}
.copy-val-btn.copied {
  background: #9c9;
  color: #1a1a2e;
}

/* URL 链接样式 */
.feature-panel-table a {
  color: #9c9;
  text-decoration: none;
}
.feature-panel-table a:hover {
  text-decoration: underline;
}

/* ========== 空状态 ========== */
.feature-panel-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-dim, #888);
  font-size: 13px;
  gap: 8px;
}

/* ========== 翻页器（仅图层模式显示） ========== */
.feature-panel-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-top: 1px solid var(--fp-border);
  flex-shrink: 0;
  font-size: 12px;
  color: var(--text-dim, #888);
  gap: 6px;
}
.feature-panel-pager button {
  padding: 4px 12px;
  border: 1px solid var(--fp-border);
  border-radius: 6px;
  background: var(--fp-bg-subtle);
  color: var(--text-primary, #333);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.feature-panel-pager button:hover:not(:disabled) {
  background: var(--fp-bg-hover);
  border-color: #777;
}
.feature-panel-pager button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.feature-panel-pager .page-info {
  font-size: 12px;
  white-space: nowrap;
}
.feature-panel-pager .page-jump {
  display: flex;
  align-items: center;
  gap: 4px;
}
.feature-panel-pager .page-jump input {
  width: 42px;
  padding: 4px 6px;
  background: var(--fp-bg-subtle);
  border: 1px solid var(--fp-border);
  border-radius: 4px;
  color: var(--text-primary, #333);
  font-size: 12px;
  text-align: center;
  outline: none;
}
.feature-panel-pager .page-jump input:focus {
  border-color: #9c9;
}

/* ========== 图表容器 ========== */
.feature-panel-chart-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--fp-border-subtle);
  flex-shrink: 0;
  font-size: 12px;
}
.feature-panel-chart-toolbar label {
  color: var(--text-dim, #888);
  font-size: 11px;
  white-space: nowrap;
}
.feature-panel-chart-toolbar select {
  padding: 4px 8px;
  background: var(--fp-bg-subtle);
  border: 1px solid var(--fp-border);
  border-radius: 4px;
  color: var(--text-primary, #333);
  font-size: 11px;
  outline: none;
  cursor: pointer;
  color-scheme: light dark;
}
.feature-panel-chart-toolbar select option {
  background: var(--panel-bg, #fff);
  color: var(--text-primary, #333);
}
.feature-panel-chart-toolbar select:focus {
  border-color: #9c9;
}
.feature-panel-chart-container {
  flex: 1;
  min-height: 250px;
}
.feature-panel-chart-legend {
  padding: 6px 16px;
  font-size: 11px;
  color: var(--text-dim, #888);
  border-top: 1px solid var(--fp-border-subtle);
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.feature-panel-chart-legend span {
  display: flex;
  align-items: center;
  gap: 4px;
}
.feature-panel-chart-legend .legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ========== 响应式：窄屏时面板全宽 ========== */
@media (max-width: 520px) {
  .feature-panel {
    width: 100vw !important;
    max-width: 100vw;
    min-width: 100vw;
  }
  .feature-panel-resize-handle {
    display: none;
  }
}

/* Popup 中的「查看详情」按钮样式（覆盖 zoom-btn 的 accent 色） */
.popup-detail-btn {
  background: #6b8ec4 !important;
  font-size: 13px !important;
  line-height: 22px !important;
}
.popup-detail-btn:hover {
  background: #7da0d8 !important;
}

/* 图层面板的属性表按钮 */
.layer-attr-btn {
  font-size: 11px !important;
  opacity: 0.7;
}
.layer-attr-btn:hover {
  opacity: 1;
}
