<template>
  <div class="app-containers">
    <div class="containerBlock">
      <div class="top-actions">
        <div class="left-actions">
          <el-button size="small" @click="setVerticalLayout">上下结构</el-button>
          <el-button size="small" @click="setHorizontalLayout">左右结构</el-button>
          <el-button size="small" @click="handlePrevTrace">上一道</el-button>
          <el-button size="small" @click="handleNextTrace">下一道</el-button>
          <el-button type="primary" @click="submitSegyAnnotations">保存标注
            <i class="el-icon-check"></i>
          </el-button>
        </div>
        <!-- 右侧按钮组（与左侧同一行，靠右对齐） -->
        <div class="toolbar-right">
          <!--          <div class="color-maps">-->
          <!--            <el-select v-model="currentColorMap" @change="switchColorMap" size="small">-->
          <!--              <el-option v-for="map in colorMaps" :key="map.value" :label="map.label" :value="map.value">-->
          <!--                <span class="color-map-option">-->
          <!--                  <span class="color-map-preview" :class="map.value"></span>-->
          <!--                  {{ map.label }}-->
          <!--                </span>-->
          <!--              </el-option>-->
          <!--            </el-select>-->
          <!--          </div>-->
          <toolbar-controls :plots="plots" :data-loaded="isWidgetReady" :show-line-style-panel="showLineStylePanel"
            @toggleLineStylePanel="toggleLineStylePanel" @exporting="exporting = $event"
            @closePrintDialog="showPrintDialog = false" />

          <el-tooltip content="设置" placement="bottom" effect="light">
            <el-button @click="editProperties" :class="{ 'active': showLineStylePanel }">
              <i class="el-icon-setting"></i>
            </el-button>
          </el-tooltip>

          <el-tooltip content="绘制文本" placement="bottom" effect="light">
            <el-button @click="toggleDrawText" :class="{ 'active': isDrawingText }">
              <i class="el-icon-edit-outline"></i>
            </el-button>
          </el-tooltip>
          <el-tooltip content="绘制线条" placement="bottom" effect="light">
            <el-button @click="toggleLineStylePanel" :class="{ 'active': showLineStylePanel }">
              <i class="el-icon-edit"></i>
            </el-button>
          </el-tooltip>
          <el-tooltip content="保存标注" placement="bottom" effect="light">

          </el-tooltip>
          <!-- <el-tooltip :content="internalScrollbarSyncEnabled ? '内部滚动条同步已启用' : '内部滚动条同步已禁用'" placement="bottom"
            effect="light">
            <el-button @click="toggleInternalScrollbarSync" :class="{ 'active': internalScrollbarSyncEnabled }">
              <i class="el-icon-s-operation"></i>
            </el-button>
          </el-tooltip> -->
        </div>
        <!-- 缩略图   start-->
        <div v-if="shouldShowThumb" ref="thumbContainer" @click="handleThumbClick" @mousedown="startDrag"
          class="right-thumb draggable-thumb" :style="thumbPosition">
          <!-- <div class="thumb-title">缩略图</div> -->
          <div ref="thumbHolder" class="thumb-holder">
            <YsgcIndex v-if="thumbReady" :key="'thumb-' + routeId + '-' + thumbReady" :compact="true" :width="260"
              :height="160" :id-override="routeId" :active-segy-index="currentSegyIndex" />
          </div>
          <!-- 拖动指示器 -->
          <div class="drag-handle">
            <i class="el-icon-rank"></i>
          </div>
        </div>
        <!-- 缩略图   end-->
        <!-- 缩略图弹窗 start -->
        <!-- 缩略图弹窗 start -->
        <el-dialog v-if="shouldShowThumb" title="缩略图预览" :visible.sync="showThumbDialog" width="80%" append-to-body
          :z-index="9999999" :modal="true" :close-on-click-modal="true" :close-on-press-escape="true"
          custom-class="thumbnail-dialog">
          <div style="height: 100%;">
            <YsgcIndex :key="'dialog-thumb-' + routeId" :id-override="routeId" :active-segy-index="currentSegyIndex"
              @segyLinePick="onThumbLinePick" />
          </div>
        </el-dialog>
        <!-- 缩略图弹窗 end -->
        <!-- 缩略图弹窗 end -->
      </div>

      <!-- 添加加载状态和错误提示 -->
      <div v-if="loadingError" class="error-message">
        {{ loadingError }}
      </div>
      <div class="toolbar" v-if="isWidgetReady">
        <div class="toolbar-left">
        </div>
      </div>
      <div class="split-container" :class="layoutMode === 'vertical' ? 'layout-vertical' : 'layout-horizontal'"
        v-loading="isLoading" element-loading-text="加载中...">
        <div class="sync-section" ref="topScroll" @scroll="onScroll('top')">
          <div class="zoom-wrapper" ref="topWrapper"
            :style="{ width: baseCanvasWidth + 'px', height: baseCanvasHeight + 'px' }">
            <canvas ref="plot" id="canvasTop" class="plot-canvas" />
          </div>
        </div>
        <div class="sync-section" ref="bottomScroll" @scroll="onScroll('bottom')">
          <div class="zoom-wrapper" ref="bottomWrapper"
            :style="{ width: baseCanvasWidth + 'px', height: baseCanvasHeight + 'px' }">
            <canvas ref="plot2" id="canvasBottom" class="plot-canvas" />
          </div>
        </div>
      </div>
      <!-- 自定义右键菜单 -->
      <div v-if="contextMenu.visible" class="context-menu" :style="{
        left: `${contextMenu.x}px`,
        top: `${contextMenu.y}px`
      }" @mouseleave="hideContextMenu">
        <div v-for="(item, index) in contextMenuItems" :key="index">
          <div v-if="item.type === 'separator'" class="context-menu-separator">
          </div>
          <div v-else class="context-menu-item" :class="{ disabled: !isMenuItemEnabled(item.action) }"
            @click="handleMenuAction(item.action)">
            <span>
              <i :class="getElementIcon(item.icon)" class="mr-2"></i>
              {{ item.text }}
            </span>
            <span class="shortcut" v-if="item.shortcut">{{ item.shortcut }}</span>
          </div>
        </div>
      </div>
      <!-- 文本样式面板 -->
      <div class="style-panel text-style-panel" :class="{ 'style-panel-visible': showTextStylePanel }">
        <div class="style-panel-header">
          <h3>文本样式</h3>
          <el-button icon="el-icon-close" size="mini" circle @click="showTextStylePanel = false"></el-button>
        </div>
        <div class="style-content">
          <!-- 填充样式部分 -->
          <div class="style-section-title">填充样式</div>
          <div class="style-item">
            <span class="style-label">颜色：</span>
            <el-color-picker v-model="fillStyle.color" show-alpha @change="updateFillStyle">
            </el-color-picker>
          </div>
          <div class="style-item">
            <span class="style-label">样式：</span>
            <el-select v-model="fillStyle.pattern" placeholder="选择填充样式" @change="updateFillStyle">
              <el-option v-for="(pattern, key) in fillPatterns" :key="key" :label="key" :value="key">
                <div class="pattern-preview-fill" :style="getFillPatternStyle(key)"></div>
              </el-option>
            </el-select>
          </div>
          <div class="style-divider"></div>
          <!-- 线条样式部分 -->
          <div class="style-section-title">线条样式</div>
          <div class="style-item">
            <span class="style-label">颜色：</span>
            <el-color-picker v-model="lineStyle.color" show-alpha @change="updateLineStyle">
            </el-color-picker>
          </div>
          <div class="style-item">
            <span class="style-label">宽度：</span>
            <el-slider v-model="lineStyle.width" :min="1" :max="12" show-input @change="updateLineStyle">
            </el-slider>
          </div>
          <div class="style-item">
            <span class="style-label">样式：</span>
            <el-select v-model="lineStyle.pattern" placeholder="选择线条样式" @change="updateLineStyle">
              <el-option v-for="(pattern, key) in linePatterns" :key="key" :label="key" :value="key">
                <div class="pattern-preview-line" :style="getLinePatternStyle(key)"></div>
              </el-option>
            </el-select>
          </div>
          <!-- 分隔线 -->
          <div class="style-divider"></div>
          <div class="style-section-title">文本样式</div>
          <div class="style-item">
            <span class="style-label">颜色：</span>
            <el-color-picker v-model="textStyle.color" show-alpha @change="updateTextStyle">
            </el-color-picker>
          </div>
          <div class="style-item">
            <span class="style-label">大小：</span>
            <el-slider v-model="textStyle.size" :min="8" :max="60" show-input @change="handleFontSizeChange">
            </el-slider>
          </div>
          <div class="style-item">
            <span class="style-label">字体：</span>
            <el-select v-model="textStyle.font" placeholder="选择字体" @change="handleFontChange">
              <el-option v-for="(font, index) in Object.keys(TEXT_PATTERNS)" :key="index" :label="font" :value="font"
                :style="{ fontFamily: font }">
                {{ font }}
              </el-option>
            </el-select>
          </div>
          <div class="style-item">
            <span class="style-label">对齐：</span>
            <div class="text-style-buttons">
              <el-button-group style="width: 100%">
                <el-button style="min-width: 20%; max-width: 20%" :type="textStyle.align === 'left' ? 'primary' : ''"
                  @click="textStyle.align = 'left'; updateTextStyle()" title="左对齐">
                  <i class="el-icon-s-fold"></i>
                </el-button>
                <el-button style="min-width: 20%; max-width: 20%" :type="textStyle.align === 'center' ? 'primary' : ''"
                  @click="textStyle.align = 'center'; updateTextStyle()" title="居中对齐">
                  <i class="el-icon-menu"></i>
                </el-button>
                <el-button style="min-width: 20%; max-width: 20%" :type="textStyle.align === 'right' ? 'primary' : ''"
                  @click="textStyle.align = 'right'; updateTextStyle()" title="右对齐">
                  <i class="el-icon-s-unfold"></i>
                </el-button>
                <!-- 粗体按钮 -->
                <el-button style="min-width: 20%; max-width: 20%" :type="textStyle.bold ? 'primary' : ''"
                  @click="textStyle.bold = !textStyle.bold; updateTextStyle()" title="粗体">
                  <span style="font-weight: bold">B</span>
                </el-button>
                <!-- 斜体按钮 -->
                <el-button style="min-width: 20%; max-width: 20%" :type="textStyle.italic ? 'primary' : ''"
                  @click="textStyle.italic = !textStyle.italic; updateTextStyle()" title="斜体">
                  <span style="font-style: italic">I</span>
                </el-button>
              </el-button-group>
            </div>
          </div>
          <!-- 添加属性部分 -->
          <div class="style-divider"></div>
          <div class="style-section-title">属性</div>
          <div class="style-item">
            <span class="style-label">边框圆角：</span>
            <el-input-number v-model="textStyle.borderRadius" :min="0" :max="30" size="small"
              @change="handleBorderRadiusChange">
            </el-input-number>
          </div>
          <div class="style-item">
            <el-checkbox v-model="textStyle.fixedFont" @change="handleFixedFontChange">
              固定字体
            </el-checkbox>
          </div>
        </div>
      </div>
      <!-- 线条样式面板 -->
      <div class="style-panel line-style-panel" :class="{ 'style-panel-visible': showLineStylePanel }">
        <div class="style-panel-header">
          <h3>线条样式</h3>
          <el-button icon="el-icon-close" size="mini" circle @click="showLineStylePanel = false"></el-button>
        </div>
        <div class="style-content">
          <div class="style-item">
            <span class="style-label">颜色：</span>
            <el-color-picker v-model="lineStyle.color" show-alpha @change="updateLineStyle">
            </el-color-picker>
          </div>
          <div class="style-item">
            <span class="style-label">样式：</span>
            <el-select v-model="lineStyle.pattern" placeholder="选择线条样式" @change="updateLineStyle">
              <el-option v-for="(pattern, key) in linePatterns" :key="key" :label="key" :value="key">
                <div class="pattern-preview-line" :style="getLinePatternStyle(key)"></div>
              </el-option>
            </el-select>
          </div>
          <div class="style-item">
            <span class="style-label">宽度：</span>
            <el-slider v-model="lineStyle.width" :min="1" :max="12" show-input @change="updateLineStyle">
            </el-slider>
          </div>
        </div>
      </div>
    </div>


    <!--    图形设置-->
    <el-dialog title="设置" :visible.sync="showPropertiesDialog" width="100%">
      <el-form ref="form" label-width="130px">
        <el-row>

          <el-col :span="5">
            <el-form-item label="颜色集合">
              <el-select v-model="colorMapSelect" placeholder="请选择颜色集合" @change="changeColor">
                <el-option v-for="item in listNameColorMaps" :label="item" :value="item"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="归一化类型">
              <el-select v-model="NormalizationType" @change="changeNor" placeholder="请选择归一化类型">
                <el-option v-for="item in NormalizationTypeData" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="归一化比例">
              <el-slider @change="changeNor" style="width: 180px;" v-model="NormalizationBl" :min="0.1" :max="5"
                :step="0.1" show-stops>
              </el-slider>
            </el-form-item>
          </el-col>
          <!--          <el-col :span="5">-->
          <!--            <el-form-item label="每英寸道数" >-->
          <!--              <el-input v-model="mycds" @blur="changeMycds"></el-input>-->
          <!--            </el-form-item>-->
          <!--          </el-col>-->

        </el-row>
        <el-row>
          <!--          <el-col :span="5">-->
          <!--            <el-form-item label="每秒英寸数" >-->
          <!--              <el-input v-model="msycs" @blur="changeMycds"></el-input>-->
          <!--            </el-form-item>-->
          <!--          </el-col>-->
          <el-col :span="5">
            <el-form-item label="采样插值类型">
              <el-select v-model="samplesType" @change="changeInt" placeholder="请选择采样插值类型">
                <el-option v-for="item in InterpolationType" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="采样插值边缘">
              <el-select v-model="samplesEdge" @change="changeInt" placeholder="请选择采样插值边缘">
                <el-option v-for="item in InterpolationEdge" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="道插值类型">
              <el-select v-model="tracesEdge" @change="changeInt" placeholder="请选择道插值类型">
                <el-option v-for="item in InterpolationType" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="5">
            <el-form-item label="道插值边缘">
              <el-select v-model="tracesType" @change="changeInt" placeholder="请选择道插值边缘">
                <el-option v-for="item in InterpolationEdge" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="10">
            <el-form-item label="绘图类型">
              <el-checkbox v-model="Wiggle" @change="changePlotType">Wiggle</el-checkbox>
              <el-checkbox v-model="Reversed" @change="changePlotType">Reversed</el-checkbox>
              <el-checkbox v-model="PositiveFill" @change="changePlotType">Positive fill</el-checkbox>
              <el-checkbox v-model="NegativeFill" @change="changePlotType">Negative fill</el-checkbox>
              <el-checkbox v-model="PositiveColorFill" @change="changePlotType">Positive color fill</el-checkbox>
              <el-checkbox v-model="NegativeColorFill" @change="changePlotType">Negative color fill</el-checkbox>
              <el-checkbox v-model="SimpleDensity" @change="changePlotType">Simple density</el-checkbox>
              <el-checkbox v-model="InterpolatedDensity" @change="changePlotType">Interpolated density</el-checkbox>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="Wiggle-裁剪因子">
              <el-input v-model="ClippingFactor" @blur="changePlotType"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="5">
            <el-form-item label="Wiggle-抽取间距">
              <el-input v-model="DecimationSpacing" @blur="changePlotType"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="Wiggle-密度抽取">
              <el-checkbox v-model="densityDecimation" @change="changePlotType">Density decimation（密度抽取）</el-checkbox>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="Clipping mode（裁剪模式）">
              <el-select v-model="ClippingMode" @change="changePlotType" placeholder="请选择裁剪模式">
                <el-option v-for="item in ClippingModeData" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="3">
            <el-form-item label="TaperFilter（滤波）">
              <el-checkbox v-model="TaperFilterEnbled" @change="changePlotType">启用滤波</el-checkbox>
            </el-form-item>
          </el-col>
          <el-col :span="2">
            <el-form-item label="f1">
              <el-input v-model="f1" style="width: 80px" @blur="changePlotType"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="2">
            <el-form-item label="f2">
              <el-input v-model="f2" style="width: 80px" @blur="changePlotType"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="2">
            <el-form-item label="f3">
              <el-input v-model="f3" style="width: 80px" @blur="changePlotType"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="2">
            <el-form-item label="f4">
              <el-input v-model="f4" style="width: 80px" @blur="changePlotType"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label="采样率">
              <el-input v-model="sampleRate" style="width: 80px" @blur="changePlotType"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="带通模式">
              <el-checkbox v-model="passFlag" @change="changePlotType">带通模式</el-checkbox>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="3">
            <el-form-item label="AGC">
              <el-checkbox v-model="AGCEnbled" @change="changePlotType">启用AGC</el-checkbox>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="AGC length">
              <el-input v-model="AGCLength" style="width: 80px" @blur="changePlotType"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="Desired average">
              <el-input v-model="DesiredAverage" style="width: 80px" @blur="changePlotType"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="Noise reduction">
              <el-select v-model="NoiseReduction" @change="changePlotType" placeholder="请选择降噪">
                <el-option v-for="item in NoiseReductionData" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="Noise reduction percentage">
              <el-input v-model="NoiseReductionPercentage" style="width: 80px" @blur="changePlotType"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="Start sample">
              <el-input v-model="StartSample" style="width: 80px" @blur="changePlotType"></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="Step">
              <el-input v-model="Step" style="width: 80px" @blur="changePlotType"></el-input>
            </el-form-item>
          </el-col>

        </el-row>
        <el-row>
          <el-col :span="4">
            <el-form-item label="Units">
              <el-select v-model="Units" @change="changePlotType" placeholder="请选择单位">
                <el-option v-for="item in UnitsData" :label="item.label" :value="item.value"></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="Window length">
              <el-input v-model="WindowLength" style="width: 80px" @blur="changePlotType"></el-input>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="3">
            <el-form-item label="Reverse">
              <el-checkbox v-model="ReverseEnbled" @change="changePlotType">启用Reverse</el-checkbox>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="inverted">
              <el-checkbox v-model="inverted" @change="changePlotType">启用inverted</el-checkbox>
            </el-form-item>
          </el-col>
          <el-col :span="3">
            <el-form-item label="reversed">
              <el-checkbox v-model="reversed" @change="changePlotType">启用reversed</el-checkbox>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="showPropertiesDialog = false">取 消</el-button>
        <el-button type="primary" @click="showPropertiesDialog = false">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
// 从单独的 JS 文件导入组件逻辑
import componentOptions from './index2.js'

export default componentOptions
</script>

<style scoped>
.app-containers {
  padding: 10px;
  height: 90vh !important;
}

/* 顶部操作与缩略图 */
.top-actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  /* 顶部操作与地震图拉开距离 */
  min-width: 100%;
  /* 确保有足够宽度 */
  overflow: visible;
  /* 允许内容溢出显示 */
  position: relative;
  z-index: 20;
  /* border: 1px solid blue; */
  /* 确保不被地震图覆盖 */
}

.left-actions .el-button+.el-button {
  margin-left: 8px;
}

.left-actions {
  padding-right: 280px;
}

.right-thumb {
  position: fixed;
  /* 固定在视口右上角 */
  top: 150px;
  right: 40px;
  width: 280px;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.15);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 9999;
  /* 确保在画布之上 */
  border-radius: 4px;
  transition: box-shadow 0.3s ease;
}

.right-thumb:hover {
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2), 0 4px 12px rgba(0, 0, 0, 0.15);
}

.thumb-title {
  font-size: 12px;
  color: #666;
  padding: 6px 8px;
  border-bottom: 1px solid #eee;
}

.thumb-holder {
  flex: none;
  /* 改为固定尺寸，不使用flex: 1 */
  width: 260px;
  height: 160px;
  /* 固定高度，确保 ECharts 有可用高度 */
  background: #ffffff;
  /* 白色背景更明显 */
  /* border: 1px solid #409eff; */
  /* 与父容器一致的边框 */
  position: relative;
  min-width: 260px;
  min-height: 160px;
  max-width: 260px;
  max-height: 160px;
  overflow: hidden;
  /* 防止内容溢出 */
}

/* 固定定位的缩略图，确保始终可见 */
/* 移除模板内固定块样式（改为全局 body 容器） */

/* 可拖动的缩略图样式 */
.draggable-thumb {
  cursor: grab;
  user-select: none;
  transition: none;
  /* 拖动时禁用过渡动画 */
}

.draggable-thumb:active {
  cursor: grabbing;
}

.drag-handle {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 20px;
  height: 20px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: grab;
  z-index: 10;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.drag-handle:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.8);
}

.drag-handle:active {
  cursor: grabbing;
}

/* 双画布容器与滚动/缩放 */
.split-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  /* 与顶部操作区留出更大空隙 */
}

.split-container.layout-vertical {
  flex-direction: column;
}

.split-container.layout-horizontal {
  flex-direction: row;
}

.split-container.layout-horizontal .sync-section {
  height: calc(84vh - 20px);
}

.sync-section {
  width: 100%;
  height: calc(42vh - 20px);
  overflow-x: auto;
  overflow-y: auto;
  border: 1px solid #eee;
  background: #fff;
}

/* 彻底隐藏 GeoToolkit-js 2.0 内部滚动条 */
.sync-section *[class*="scrollbar"],
.sync-section *[class*="Scrollbar"],
.sync-section *[class*="scroll"],
.sync-section *[class*="Scroll"],
.sync-section *[class*="geotoolkit.controls.tools.scroll"],
.sync-section .gt-scrollbar,
.sync-section .gt-scrollbar-horizontal,
.sync-section .gt-scrollbar-vertical {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  position: absolute !important;
  left: -9999px !important;
  top: -9999px !important;
  pointer-events: none !important;
}

/* 仅作用于本页面地震图区域，避免影响全局布局（如左侧菜单） */
.app-container .sync-section *[class*="scrollbar"],
.app-container .sync-section *[class*="Scrollbar"],
.app-container .sync-section *[class*="scroll"],
.app-container .sync-section *[class*="Scroll"],
.app-container .sync-section *[class*="geotoolkit.controls.tools.scroll"],
.app-container .sync-section .gt-scrollbar,
.app-container .sync-section .gt-scrollbar-horizontal,
.app-container .sync-section .gt-scrollbar-vertical {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  position: absolute !important;
  left: -9999px !important;
  top: -9999px !important;
  pointer-events: none !important;
}

.zoom-wrapper {
  width: 100%;
  display: inline-block;
  transform-origin: top left;
}

.plot-canvas {
  width: 100% !important;
  height: calc(85vh - 100px) !important;
  /* margin-top: 20px; */
  transform-origin: top left;
}

.toolbar {
  padding: 10px;
  border-bottom: 1px solid #ddd;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: nowrap;
}

.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-grow: 1;
}

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-left: auto;
  flex-wrap: nowrap;
  white-space: nowrap;
}

/* 左侧操作按钮样式 - 现代渐变风格 */
.left-actions .el-button {
  height: 32px;
  padding: 0 14px;
  border-radius: 6px;
  border: none;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  background: linear-gradient(135deg, #409EFF 0%, #66b1ff 50%, #85c1ff 100%);
  box-shadow: 0 2px 6px rgba(64, 158, 255, 0.25);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  letter-spacing: 0.3px;
}

.left-actions .el-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.left-actions .el-button:hover {
  background: linear-gradient(135deg, #337ecc 0%, #5a9eff 50%, #73b5ff 100%);
  box-shadow: 0 6px 16px rgba(64, 158, 255, 0.35);
  transform: translateY(-2px);
}

.left-actions .el-button:hover::before {
  left: 100%;
}

.left-actions .el-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(64, 158, 255, 0.25);
}

/* 右侧工具栏按钮样式 - 精致图标按钮 */
.toolbar-right .el-button {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 0;
  border: none;
  background: linear-gradient(145deg, #f8f9fa 0%, #e9ecef 100%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.toolbar-right .el-button [class^="el-icon-"] {
  font-size: 16px;
  margin: 0;
  color: #6c757d;
  transition: all 0.3s ease;
}

/* 绘制文本按钮 - 简化橙色系 */
.toolbar-right .el-button:has(.el-icon-edit-outline) [class^="el-icon-"] {
  color: #ff8c00;
}

.toolbar-right .el-button:has(.el-icon-edit-outline):hover {
  background: linear-gradient(145deg, #ff8c00 0%, #ffa500 100%);
  box-shadow: 0 4px 12px rgba(255, 140, 0, 0.25),
    0 2px 4px rgba(0, 0, 0, 0.1);
}

.toolbar-right .el-button:has(.el-icon-edit-outline):hover [class^="el-icon-"] {
  color: #fff;
}

.toolbar-right .el-button:has(.el-icon-edit-outline).active {
  background: linear-gradient(145deg, #ff8c00 0%, #ffa500 100%);
  box-shadow: 0 6px 16px rgba(255, 140, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.toolbar-right .el-button:has(.el-icon-edit-outline).active [class^="el-icon-"] {
  color: #fff;
}

/* 绘制线条按钮 - 简化绿色系 */
.toolbar-right .el-button:has(.el-icon-edit) [class^="el-icon-"] {
  color: #28a745;
}

.toolbar-right .el-button:has(.el-icon-edit):hover {
  background: linear-gradient(145deg, #28a745 0%, #34ce57 100%);
  box-shadow: 0 4px 12px rgba(40, 167, 69, 0.25),
    0 2px 4px rgba(0, 0, 0, 0.1);
}

.toolbar-right .el-button:has(.el-icon-edit):hover [class^="el-icon-"] {
  color: #fff;
}

.toolbar-right .el-button:has(.el-icon-edit).active {
  background: linear-gradient(145deg, #28a745 0%, #34ce57 100%);
  box-shadow: 0 6px 16px rgba(40, 167, 69, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.toolbar-right .el-button:has(.el-icon-edit).active [class^="el-icon-"] {
  color: #fff;
}

/* 同步按钮 - 紫色系 */
.toolbar-right .el-button:has(.el-icon-s-operation) {
  background: linear-gradient(145deg, #f3e5f5 0%, #e1bee7 100%);
}

.toolbar-right .el-button:has(.el-icon-s-operation) [class^="el-icon-"] {
  color: #9c27b0;
}

.toolbar-right .el-button:has(.el-icon-s-operation):hover {
  background: linear-gradient(145deg, #9c27b0 0%, #ba68c8 100%);
  box-shadow: 0 4px 12px rgba(156, 39, 176, 0.25),
    0 2px 4px rgba(0, 0, 0, 0.1);
}

.toolbar-right .el-button:has(.el-icon-s-operation):hover [class^="el-icon-"] {
  color: #fff;
}

.toolbar-right .el-button:has(.el-icon-s-operation).active {
  background: linear-gradient(145deg, #9c27b0 0%, #ba68c8 100%);
  box-shadow: 0 6px 16px rgba(156, 39, 176, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.toolbar-right .el-button:has(.el-icon-s-operation).active [class^="el-icon-"] {
  color: #fff;
}

.toolbar-right .el-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(145deg, #409EFF 0%, #66b1ff 100%);
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: 10px;
}

.toolbar-right .el-button:hover {
  background: linear-gradient(145deg, #409EFF 0%, #66b1ff 100%);
  box-shadow: 0 4px 12px rgba(64, 158, 255, 0.25),
    0 2px 4px rgba(0, 0, 0, 0.1);
  transform: translateY(-1px);
}

.toolbar-right .el-button:hover::before {
  opacity: 0;
}

.toolbar-right .el-button:hover [class^="el-icon-"] {
  color: #fff;
  transform: scale(1.1);
}

.toolbar-right .el-button.active {
  background: linear-gradient(145deg, #409EFF 0%, #66b1ff 100%);
  box-shadow: 0 6px 16px rgba(64, 158, 255, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.toolbar-right .el-button.active [class^="el-icon-"] {
  color: #fff;
}

.toolbar-right .el-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(64, 158, 255, 0.25);
}

/* 统一按钮样式 - 保持原有结构 */
.toolbar .el-button {
  width: 40px;
  height: 40px;
  padding: 10px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 0;
}

.toolbar .el-button [class^="el-icon-"] {
  font-size: 16px;
  margin: 0;
}

.toolbar .el-button:not(.el-button--text) {
  border: 1px solid #ddd;
  background-color: #fff;
}

.toolbar .el-button-group .el-button {
  margin-right: -1px;
}

.toolbar .el-button-group .el-button:first-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.toolbar .el-button-group .el-button:last-child {
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  margin-right: 0;
}

.toolbar .el-button-group .el-button:not(:first-child):not(:last-child) {
  border-radius: 0;
}

.toolbar .el-button:hover {
  background-color: #e6e6e6;
}

.toolbar .el-button.active {
  background-color: #e6e6e6;
  border-color: #adadad;
  color: #409eff;
}

/* 鼠标悬停信息面板样式 */
.cursor-info-panel {
  display: none;
}

.cs_status_bar {
  display: none;
}

.info-pill {
  display: none;
}

/* 样式面板相关样式 */
.style-panel {
  position: fixed;
  right: -300px;
  top: 0;
  width: 300px;
  height: 100vh;
  background-color: #fff;
  box-shadow: -2px 0 5px rgba(0, 0, 0, 0.1);
  transition: right 0.3s ease;
  z-index: 1000;
  overflow-y: auto;
}

.style-panel-visible {
  right: 0;
}

.style-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 15px;
  border-bottom: 1px solid #ddd;
}

.style-panel-header h3 {
  margin: 0;
  font-size: 16px;
}

.style-content {
  padding: 15px;
}

.style-section-title {
  font-weight: bold;
  margin: 10px 0;
  color: #333;
}

.style-item {
  margin-bottom: 15px;
}

.style-label {
  display: block;
  margin-bottom: 5px;
  color: #666;
}

.style-divider {
  height: 1px;
  background-color: #eee;
  margin: 15px 0;
}

.text-style-buttons {
  display: flex;
  gap: 5px;
}

.pattern-preview-fill {
  width: 100%;
  height: 24px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

/* 调整滑块和输入框的样式 */
.el-slider {
  margin-top: 8px;
}

.el-input-number {
  width: 100%;
}

.el-select {
  width: 100%;
}

.el-color-picker {
  width: 100%;
}

/* 添加错误和加载状态样式 */
.error-message {
  color: red;
  padding: 10px;
  margin: 10px;
  background-color: #fff3f3;
  border: 1px solid #ffa7a7;
  border-radius: 4px;
}

.loading-message {
  text-align: center;
  padding: 20px;
  color: #666;
}

.color-maps {
  margin-right: 10px;
}

.color-maps .el-select {
  width: 140px;
}

.color-maps-label {
  margin-right: 8px;
  font-size: 14px;
  color: #666;
}

.toolbar-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.is-active {
  background-color: #e6e6e6;
  border-color: #adadad;
}

.context-menu {
  position: fixed;
  background-color: #fff;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  z-index: 1001;
  padding: 5px 0;
}

.context-menu-separator {
  height: 1px;
  background-color: #eee;
  margin: 5px 0;
}

.context-menu-item {
  padding: 8px 16px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
  color: #333;
}

.context-menu-item:hover {
  background-color: #f5f5f5;
}

.context-menu-item.disabled {
  color: #999;
  cursor: not-allowed;
}

.context-menu-item.disabled:hover {
  background-color: transparent;
}

.shortcut {
  font-size: 12px;
  color: #999;
  margin-left: 16px;
}

.pattern-preview-line {
  width: 100%;
  height: 20px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

/* 响应式布局调整 */
@media (max-width: 768px) {
  .toolbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .toolbar-left,
  .toolbar-right {
    width: 100%;
    margin: 5px 0;
  }

  .toolbar-right {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
  }

  .color-maps {
    margin-right: 0;
  }
}

.color-map-option {
  display: flex;
  align-items: center;
  gap: 8px;
}

.color-map-preview {
  width: 40px;
  height: 20px;
  border: 1px solid #ddd;
  border-radius: 2px;
}

.WhiteBlack {
  background: linear-gradient(to right, white, black);
}

.CustomGrayScale {
  background: linear-gradient(to right,
      rgb(255, 255, 255) 50%,
      /* -4000到181保持白色 */
      rgb(253, 253, 253) 55%,
      /* 181开始的颜色 */
      rgb(240, 240, 240) 65%,
      /* 到566的颜色 */
      rgb(180, 180, 180) 80%,
      /* 566后的过渡色 */
      rgb(6, 6, 6) 100%
      /* 最终颜色 */
    );
}

.CustomRedScale {
  background: linear-gradient(to right,
      #f62814,
      #dd8b66,
      #d7c692,
      #fbfaff,
      #6e6e8a,
      #323136);
}

.BlueWhiteRed {
  background: linear-gradient(to right, #0000ff, #ffffff, #ff0000);
}

.Rainbow {
  background: linear-gradient(to right,
      #ff0000,
      #ffff00,
      #00ff00,
      #00ffff,
      #0000ff,
      #ff00ff,
      #ff0000);
}

.Jet {
  background: linear-gradient(to right,
      #00008f,
      #0000ff,
      #00ffff,
      #00ff00,
      #ffff00,
      #ff7f00,
      #ff0000,
      #7f0000);
}

.Hot {
  background: linear-gradient(to right, #000000, #ff0000, #ffff00, #ffffff);
}

.Cool {
  background: linear-gradient(to right, #00ffff, #ff00ff);
}

/* 在style标签中添加 */
.cs_status_bar {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cs_status_bar section {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 状态栏样式优化 */
.cs_status_bar {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  font-size: 12px !important;
  font-family: monospace !important;
}

.cs_status_bar section {
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  padding: 0 5px !important;
  max-width: 120px !important;
}

.cs_status_bar section span {
  display: inline-block !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
  max-width: 100% !important;
}

/* 确保状态栏容器不会过度扩展 */
.gt-statusbar {
  max-width: 100% !important;
  overflow: hidden !important;
}

.gt-statusbar-section {
  max-width: 120px !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

/* 状态栏样式 */
.gt-statusbar {
  font-family: monospace !important;
  font-size: 12px !important;
  background-color: #f5f5f5 !important;
  border-top: 1px solid #ddd !important;
  height: 25px !important;
  line-height: 25px !important;
  padding: 0 10px !important;
}

.gt-statusbar-section {
  display: inline-block !important;
  margin-right: 15px !important;
  min-width: 80px !important;
  max-width: 80px !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  white-space: nowrap !important;
}

.gt-statusbar-section:last-child {
  margin-right: 0 !important;
}

/* 隐藏 GeoToolkit 内部滚动条，仅使用外层滚动 */
.gt-scrollbar,
.gt-scrollbar-horizontal,
.gt-scrollbar-vertical,
[class*="scrollbar"],
[class*="Scrollbar"],
.scrollbar,
.scrollbar-horizontal,
.scrollbar-vertical,
[class*="Scroll"],
[class*="scroll"] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
  position: absolute !important;
  left: -9999px !important;
  top: -9999px !important;
}

/* 隐藏滚动条滑块和轨道 */
.scrollbar-thumb,
.scrollbar-track,
.gt-scrollbar-thumb,
.gt-scrollbar-track,
/* 仅在地震图可滚动区域内隐藏内部滚动条相关"thumb/track"，避免误伤缩略图 */
.sync-section [class*="thumb"]:not(.thumb-holder):not(.thumb-title):not(.right-thumb),
.sync-section [class*="track"] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  pointer-events: none !important;
}

/* 隐藏滚动条容器 */
[class*="scroll-container"],
[class*="ScrollContainer"],
.scroll-container {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  pointer-events: none !important;
}

/* 隐藏所有可能的滚动条容器 */
.gt-widget [class*="scrollbar"],
.gt-plot [class*="scrollbar"],
.gt-seismic [class*="scrollbar"],
.gt-widget [class*="Scroll"],
.gt-plot [class*="Scroll"],
.gt-seismic [class*="Scroll"] {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
}

/* 针对GeoToolkit特定滚动条类名的强制隐藏 */
*[class="geotoolkit.controls.tools.scroll.HorizontalScroll"],
*[class="geotoolkit.controls.tools.scroll.VerticalScroll"] {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  pointer-events: none !important;
  position: absolute !important;
  left: -9999px !important;
  top: -9999px !important;
}

/* 外层滚动区域样式*/
.sync-section {
  pointer-events: auto !important;
}

.sync-section::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

.sync-section::-webkit-scrollbar-track {
  background: #f1f1f1;
}

.sync-section::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 3px;
}

.sync-section::-webkit-scrollbar-thumb:hover {
  background: #555;
}
</style>

<style>
.thumb-holder {
  flex: none;
  width: 260px;
  height: 160px;
  background: #ffffff;
  position: relative;
  min-width: 260px;
  min-height: 160px;
  max-width: 260px;
  max-height: 160px;
  overflow: hidden;
}

/* 缩略图弹窗样式 - 确保不被遮挡 */
.thumbnail-dialog {
  z-index: 9999999 !important;
}

.thumbnail-dialog .el-dialog {
  z-index: 9999999 !important;
}

.thumbnail-dialog .el-dialog__wrapper {
  z-index: 9999999 !important;
}

.thumbnail-dialog .el-overlay {
  z-index: 9999998 !important;
}

/* 确保弹窗内容完全可见 */
.thumbnail-dialog .el-dialog__body {
  overflow: visible !important;
  max-height: none !important;
}

/* 修复可能的容器遮挡问题 */
.app-containers {
  overflow: visible !important;
}

.containerBlock {
  overflow: visible !important;
}
</style>