/* 紧凑型布局优化 - 减少左侧栏空间占用 */

/* 调整主布局宽度 - 减少左侧栏宽度 */
.content-grid {
  grid-template-columns: minmax(280px, 320px) 1fr !important;
  gap: 0.75rem;
  padding: 0.75rem;
}

/* 面板内边距优化 */
.panel {
  padding: 0.5rem !important;
}

/* Section 优化 */
.panel section {
  margin-bottom: 0.5rem !important;
  border-radius: 0.5rem !important;
}

/* Section 标题按钮优化 */
.section-toggle {
  padding: 0.5rem 0.75rem !important;
  font-size: 0.8rem !important;
  font-weight: 600 !important;
  min-height: 2rem;
}

.section-toggle .chevron {
  font-size: 0.7rem !important;
}

/* Section body 优化 */
.section-body {
  padding: 0.5rem 0.75rem 0.75rem !important;
}

/* Field row 优化 */
.field-row {
  gap: 0.35rem !important;
  margin-bottom: 0.4rem !important;
}

/* 按钮和输入框尺寸优化 */
button,
.file-btn,
input[type="number"],
input[type="text"],
select {
  padding: 0.35rem 0.6rem !important;
  font-size: 0.75rem !important;
  border-radius: 0.4rem !important;
}

/* 主要按钮保持稍大尺寸 */
#placeCameraBtn,
#detectObstaclesBtn,
#recommendSingleBtn,
#recommendMultiBtn {
  padding: 0.4rem 0.7rem !important;
  font-size: 0.8rem !important;
  font-weight: 600 !important;
}

/* 文件按钮优化 */
.file-btn {
  padding: 0.35rem 0.6rem !important;
  font-size: 0.75rem !important;
}

/* 标签优化 */
label {
  font-size: 0.75rem !important;
  color: var(--text-secondary) !important;
}

/* Range 输入优化 */
input[type="range"] {
  width: 120px !important;
  height: 4px !important;
}

/* 微调文本大小 */
.subtle {
  font-size: 0.7rem !important;
}

/* 内联链接优化 */
.inline-link {
  font-size: 0.75rem !important;
}

/* PDF 预览网格优化 */
.pdf-preview-grid {
  gap: 0.35rem !important;
  padding: 0.35rem !important;
  max-height: 180px !important;
  grid-template-columns: repeat(auto-fill, minmax(85px, 1fr)) !important;
}

.pdf-thumb {
  border-radius: 0.4rem !important;
}

.pdf-thumb img {
  aspect-ratio: 0.72 !important;
}

.pdf-thumb span {
  padding: 0.2rem 0.35rem 0.3rem !important;
  font-size: 0.7rem !important;
}

/* 摄像机列表和候选列表优化 */
.camera-list,
.candidate-list,
.metrics-panel {
  max-height: 160px !important;
  padding: 0.4rem !important;
  font-size: 0.75rem !important;
  border-radius: 0.4rem !important;
}

.camera-item,
.candidate-item {
  padding: 0.4rem !important;
  font-size: 0.75rem !important;
}

/* 状态标签优化 */
.tag {
  padding: 0.15rem 0.4rem !important;
  font-size: 0.7rem !important;
  margin-left: 0.35rem !important;
  border-radius: 0.3rem !important;
}

/* 折叠工具按钮优化 */
.panel-collapsed-tools button {
  padding: 0.4rem 0.2rem !important;
  font-size: 0.8rem !important;
  border-radius: 0.4rem !important;
  min-height: 2rem;
}

/* 按钮布局优化 - 让更多按钮能在同一行显示 */
.field-row button,
.field-row .file-btn {
  flex-shrink: 1;
  min-width: fit-content;
}

/* 特别优化：让短按钮能够并排显示 */
#startCalibrateBtn,
#clearCalibrateBtn,
#applyCalibrationBtn,
#detectObstaclesBtn,
#clearObstaclesBtn,
#drawRoiBtn,
#clearRoiBtn {
  min-width: auto;
  flex: 1;
}

/* 三按钮布局优化 */
.field-row button:nth-child(3),
.field-row button:nth-child(4) {
  flex: 1;
  min-width: 0;
}

/* 输入框宽度优化 */
input[type="number"] {
  min-width: 60px !important;
}

select {
  min-width: 80px !important;
}

/* 长文本换行处理 */
.section-toggle span:first-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 响应式优化 */
@media (max-width: 1100px) {
  .content-grid {
    grid-template-columns: 260px 1fr !important;
  }

  .panel {
    max-height: 42vh !important;
  }
}

/* 滚动条宽度优化 */
.panel::-webkit-scrollbar {
  width: 6px !important;
}

.panel::-webkit-scrollbar-thumb {
  border-radius: 3px !important;
}

/* 特别优化：柱体识别区域 */
#sec-detect .field-row {
  flex-wrap: wrap;
}

/* 推荐区域优化 */
#sec-score .field-row {
  flex-wrap: wrap;
}

#recommendSingleBtn,
#recommendMultiBtn,
#clearRecommendationBtn {
  flex: 1;
  min-width: 0;
}

/* 摄像机区域优化 */
#templateSelect {
  flex: 1;
  min-width: 0;
}

#placeCameraBtn {
  flex: 1;
  min-width: 0;
}

/* ROI 区域优化 */
#sec-roi label {
  font-size: 0.75rem !important;
  padding: 0.25rem 0.5rem !important;
}

/* 减少分割线粗细 */
.panel section {
  border-width: 1px !important;
}

/* 优化复选框和单选按钮样式 */
input[type="radio"],
input[type="checkbox"] {
  width: 0.9rem !important;
  height: 0.9rem !important;
  margin-right: 0.25rem !important;
}

/* 颜色输入框优化 */
input[type="color"] {
  width: 28px !important;
  height: 26px !important;
  padding: 0.1rem !important;
  border-radius: 0.4rem !important;
}

/* 确保所有文本保持可读 */
* {
  -webkit-text-size-adjust: none;
  -moz-text-size-adjust: none;
  -ms-text-size-adjust: none;
}

/* 小屏幕时的特殊优化 */
@media (max-width: 900px) {
  .content-grid {
    grid-template-columns: 1fr !important;
  }

  .panel {
    max-height: none !important;
  }
}

/* 保持按钮可点击区域合理 */
button {
  min-height: 2rem;
}

.file-btn {
  min-height: 2rem;
}

/* 工具栏单行优化 - 强化约束 */
.canvas-toolbar {
  flex-wrap: nowrap !important;
  overflow-x: auto !important;
}

.toolbar-group {
  flex-wrap: nowrap !important;
  gap: 0.25rem !important;
}

#statusText {
  max-width: 140px !important;
}

#modeLabel {
  max-width: 100px !important;
}

.canvas-toolbar button {
  padding: 0.25rem 0.4rem !important;
  font-size: 0.68rem !important;
}

/* 隐藏滚动条但保持功能 */
.canvas-toolbar::-webkit-scrollbar {
  height: 4px;
}

.canvas-toolbar::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.4);
  border-radius: 2px;
}
