<template>
  <div class="side-panel">
    <!-- CAD软件选择器 -->
    <div class="software-selector">
      <h3 class="selector-title">
        <i class="fas fa-desktop"></i>
        选择CAD软件
      </h3>
      <CadSoftwareGrid
        :current-software="currentSoftware"
        :connection-status="connectionStatus"
        @software-selected="selectSoftware"
        @test-connection="testConnection"
      />
      <div class="selected-software">
        <span class="selected-label">当前选择:</span>
        <span class="selected-name">{{ currentSoftware || '请先选择软件' }}</span>
      </div>
    </div>

    <!-- 模型管理面板 -->
    <div class="panel-section">
      <h3 class="section-title">
        <i class="fas fa-folder-open"></i>
        模型管理
      </h3>
      <div class="section-content">
        <!-- PDMS 专用：数据库/项目选择 -->
        <div v-if="isPdmsConnected" class="project-selection pdms-selection">
          <div class="selection-title">
            <i class="fas fa-database"></i>
            <span>PDMS 数据库/项目选择</span>
          </div>

          <!-- 打开类型选择 -->
          <div class="pdms-type-selector">
            <label class="type-label">打开类型</label>
            <div class="type-options">
              <label class="type-option" :class="{ 'active': pdmsOpenType === 'project' }">
                <input type="radio" v-model="pdmsOpenType" value="project" name="pdms-open-type">
                <i class="fas fa-project-diagram"></i>
                <span>项目 (Project)</span>
              </label>
              <label class="type-option" :class="{ 'active': pdmsOpenType === 'database' }">
                <input type="radio" v-model="pdmsOpenType" value="database" name="pdms-open-type">
                <i class="fas fa-database"></i>
                <span>数据库 (Database)</span>
              </label>
            </div>
          </div>

          <!-- 项目名称输入（选择项目时显示） -->
          <div v-if="pdmsOpenType === 'project'" class="pdms-project-input">
            <label class="input-label">
              <i class="fas fa-folder"></i>
              项目名称
            </label>
            <input
              v-model="pdmsProjectName"
              type="text"
              class="pdms-input"
              placeholder="例如：SAMPLE"
            />
            <small class="input-hint">输入 PDMS 项目名称（MDB），用于切换到指定项目</small>
          </div>

          <!-- 数据库路径输入（选择数据库时显示） -->
          <div v-if="pdmsOpenType === 'database'" class="pdms-project-input">
            <label class="input-label">
              <i class="fas fa-hdd"></i>
              数据库路径
            </label>
            <input
              v-model="pdmsDatabasePath"
              type="text"
              class="pdms-input"
              placeholder="例如：C:\\AVEVA\\Plant\\PDMS12.1\\SAMPLE\\Design"
            />
            <small class="input-hint">输入 PDMS 数据库名称或路径</small>
          </div>

          <div class="selection-options pdms-options">
            <label class="option-item" :class="{ 'active': pdmsAction === 'open' }">
              <input type="radio" v-model="pdmsAction" value="open" name="pdms-action">
              <div class="option-content">
                <i class="fas fa-folder-open"></i>
                <span>打开</span>
                <small>打开指定的 {{ pdmsOpenType === 'project' ? '项目' : '数据库' }}</small>
              </div>
            </label>
            <label class="option-item" :class="{ 'active': pdmsAction === 'current' }">
              <input type="radio" v-model="pdmsAction" value="current" name="pdms-action">
              <div class="option-content">
                <i class="fas fa-eye"></i>
                <span>查看当前</span>
                <small>获取当前打开的 PDMS 信息</small>
              </div>
            </label>
          </div>
          <div class="project-actions">
            <button class="confirm-btn" @click="handlePdmsAction">
              <i class="fas" :class="pdmsAction === 'open' ? 'fa-folder-open' : 'fa-eye'"></i>
              {{ pdmsAction === 'open' ? (pdmsOpenType === 'project' ? '打开项目' : '打开数据库') : '查看当前' }}
            </button>
          </div>
        </div>

        <!-- 其他 CAD：模型选择选项 -->
        <div v-else class="project-selection">
          <div class="selection-title">
            <i class="fas fa-project-diagram"></i>
            <span>选择模型来源</span>
          </div>
          <div class="selection-options">
            <label
              class="option-item"
              :class="{ 'drop-active': isDragOver }"
              @dragover.prevent="handleDragOver"
              @dragleave="handleDragLeave"
              @drop.prevent="handleDrop"
            >
              <input type="radio" name="project-source" value="open-file" checked>
              <div class="option-content">
                <i class="fas fa-file-upload"></i>
                <span>打开模型文件</span>
                <small>从本地文件系统选择模型文件 (或将文件拖动到此处)</small>
              </div>
            </label>
            <label class="option-item">
              <input type="radio" name="project-source" value="current-project">
              <div class="option-content">
                <i class="fas fa-eye"></i>
                <span>查看当前模型</span>
                <small>获取已打开的模型</small>
              </div>
            </label>
          </div>
          <div class="project-actions">
            <button class="confirm-btn" @click="handleOpenModel">
              <i class="fas fa-folder-open"></i>
              打开模型
            </button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue'
import { useCADStore } from '@/stores/cad'
import CadSoftwareGrid from '@/components/ui/CadSoftwareGrid.vue'
import creoApi from '@/services/creoApi'
import revitApi from '@/services/revitApi'
import pdmsApi from '@/services/pdmsApi'
import { ElNotification, ElMessageBox } from 'element-plus'
import { getNotificationConfig } from '@/config/cad'

// 获取通知配置

const notificationConfig = getNotificationConfig()



// 定义事件

const emit = defineEmits(['show-model-viewer'])





const cadStore = useCADStore()



// 当前选择的软件

const currentSoftware = ref('')



// PDMS 专用状态



const pdmsOpenType = ref('project') // 'project' 或 'database'



const pdmsProjectName = ref('')



const pdmsDatabasePath = ref('')



const pdmsAction = ref('open')



// 获取连接状态从CAD store

const connectionStatus = computed(() => {

  const statusMap = {}

  cadStore.cadConnections.forEach(cad => {

    const key = cad.name.toLowerCase().replace(/\s+/g, '')

    statusMap[key] = cad.connected ? 'connected' : 'disconnected'

  })

  return statusMap

})



// 是否当前连接的是 PDMS

const isPdmsConnected = computed(() => {

  return cadStore.currentCAD?.id === 'pdms'

})

// 选择软件
const selectSoftware = (software) => {
  currentSoftware.value = software
}

// 预留的获取连接状态方法
// const getConnectionStatus = (software) => {
//   return connectionStatus.value[software] || 'disconnected'
// }

// 测试连接
const testConnection = async (software) => {
  // 设置连接中状态
  cadStore.setCADConnecting(software, true)

  // 目前只支持Creo
  if (software === 'creo' || software === 'Creo') {
    const result = await creoApi.testConnection()
    cadStore.setCADConnection(software, result.success)
  } else if (software === 'revit') {
    const result = await revitApi.testConnection()
    cadStore.setCADConnection(software, result.success)
  } else if (software === 'pdms') {
    const result = await pdmsApi.testConnection()
    cadStore.setCADConnection(software, result.success)
  } else {
    // 其他软件暂不支持
    cadStore.setCADConnection(software, false)
  }

  cadStore.setCADConnecting(software, false)
}

// 处理 PDMS 操作（打开项目/数据库/查看当前）
const handlePdmsAction = async () => {
  const connectedCAD = cadStore.currentCAD
  if (!connectedCAD) {
    ElNotification({
      title: '操作提示',
      message: '请先连接 PDMS 软件',
      type: 'warning',
      position: 'top-right',
      duration: notificationConfig.ERROR_DURATION
    })
    return
  }

  if (pdmsAction.value === 'open') {
    // 打开操作
    if (pdmsOpenType.value === 'project') {
      // 打开项目
      if (!pdmsProjectName.value.trim()) {
        ElNotification({
          title: '操作提示',
          message: '请输入项目名称',
          type: 'warning',
          position: 'top-right',
          duration: notificationConfig.ERROR_DURATION
        })
        return
      }

      try {
        ElNotification({
          title: '正在打开项目',
          message: `正在请求 PDMS 打开项目: ${pdmsProjectName.value}`,
          type: 'info',
          position: 'top-right',
          duration: 2000
        })

        const openResult = await pdmsApi.openProject({
          ProjectName: pdmsProjectName.value.trim()
        })

        if (openResult.success) {
          ElNotification({
            title: '打开成功',
            message: `成功打开 PDMS 项目: ${pdmsProjectName.value}`,
            type: 'success',
            position: 'top-right',
            duration: notificationConfig.SUCCESS_DURATION
          })
          
          const modelResult = await pdmsApi.getCurrentModel()
          if (modelResult.success) {
            cadStore.setCurrentProjectName(modelResult.data.data.ProjectInfo?.ProjectName || pdmsProjectName.value.trim())
            emit('show-model-viewer', modelResult.data.data)
          }
        } else {
          throw new Error(openResult.error || 'API返回失败')
        }
      } catch (error) {
        ElNotification({
          title: '打开项目失败',
          message: error.message || '未知错误',
          type: 'error',
          position: 'top-right',
          duration: notificationConfig.ERROR_DURATION
        })
      }
    } else {
      // 打开数据库
      if (!pdmsDatabasePath.value.trim()) {
        ElNotification({
          title: '操作提示',
          message: '请输入数据库名称或路径',
          type: 'warning',
          position: 'top-right',
          duration: notificationConfig.ERROR_DURATION
        })
        return
      }

      try {
        ElNotification({
          title: '正在打开数据库',
          message: `正在请求 PDMS 打开数据库: ${pdmsDatabasePath.value}`,
          type: 'info',
          position: 'top-right',
          duration: 2000
        })

        const openResult = await pdmsApi.openMdb({
          MdbName: pdmsDatabasePath.value.trim()
        })

        if (openResult.success) {
          ElNotification({
            title: '打开成功',
            message: `成功打开 PDMS 数据库: ${pdmsDatabasePath.value}`,
            type: 'success',
            position: 'top-right',
            duration: notificationConfig.SUCCESS_DURATION
          })
          
          const modelResult = await pdmsApi.getCurrentModel()
          if (modelResult.success) {
            cadStore.setCurrentProjectName(modelResult.data.data.ProjectInfo?.ProjectName || pdmsDatabasePath.value.trim())
            emit('show-model-viewer', modelResult.data.data)
          }
        } else {
          throw new Error(openResult.error || 'API返回失败')
        }
      } catch (error) {
        ElNotification({
          title: '打开数据库失败',
          message: error.message || '未知错误',
          type: 'error',
          position: 'top-right',
          duration: notificationConfig.ERROR_DURATION
        })
      }
    }
  } else {
    // 查看当前
    const result = await pdmsApi.getCurrentModel()
    if (result.success) {
      cadStore.setCurrentProjectName(result.data.data.ProjectInfo.ProjectName)
      emit('show-model-viewer', result.data.data)
    }
  }
}

// 处理打开模型
const handleOpenModel = async () => {
  const connectedCAD = cadStore.currentCAD
  if (!connectedCAD) {
    ElNotification({
      title: '操作提示',
      message: '请先连接CAD软件',
      type: 'warning',
      position: 'top-right',
      duration: notificationConfig.ERROR_DURATION
    })
    return
  }

  // 获取选中的模型来源选项
  const selectedOption = document.querySelector('input[name="project-source"]:checked')?.value

  if (selectedOption === 'current-project') {
    // 查看当前模型
    if (connectedCAD.id === 'creo') {
      const result = await creoApi.getCurrentModel()
      if (result.success) {
        cadStore.setCurrentProjectName(result.data.data.fileName)
        emit('show-model-viewer', result.data)
      }
    } else if (connectedCAD.id === 'revit') {
      const result = await revitApi.getCurrentModel()
      if (result.success) {
        cadStore.setCurrentProjectName(result.data.data.project.name)
        emit('show-model-viewer', result.data.data)
      }
    } else if (connectedCAD.id === 'pdms') {
      const result = await pdmsApi.getCurrentModel()
      if (result.success) {
        cadStore.setCurrentProjectName(result.data.data.ProjectInfo.ProjectName)
        emit('show-model-viewer', result.data.data)
      }
    }
  } else {
    // 打开文件 - 使用ElementPlus输入框
    try {
      const { value: filePath } = await ElMessageBox.prompt('请输入模型文件路径', '打开模型文件', {
        confirmButtonText: '打开',
        cancelButtonText: '取消',
        inputPlaceholder: '例如: Z:\\工具\\Revit2017(64bit)\\model.asm'
      })

      if (filePath) {
        // 处理文件路径格式，支持中文字符和特殊字符
        const processedFilePath = filePath.trim()

        if (connectedCAD.id === 'creo') {
          // 第一步：打开模型文件
          const openResult = await creoApi.openModelFile(processedFilePath)
          if (openResult.success) {
            // 第二步：获取当前模型详细信息
            const modelResult = await creoApi.getCurrentModel()
            if (modelResult.success) {
              cadStore.setCurrentProjectName(modelResult.data.data.fileName)
              emit('show-model-viewer', modelResult.data)
            }
          }
        } else if (connectedCAD.id === 'revit') {
          // Revit：打开模型文件
          const openResult = await revitApi.openModelFile(processedFilePath, false)
          if (openResult.success) {
            // 第二步：获取当前模型详细信息
            const modelResult = await revitApi.getCurrentModel()
            if (modelResult.success) {
              cadStore.setCurrentProjectName(modelResult.data.data.project.name)
              emit('show-model-viewer', modelResult.data.data)
            }
          }
        } else if (connectedCAD.id === 'pdms') {
          ElNotification({
            title: '暂不支持',
            message: 'PDMS 打开模型文件功能尚未实现',
            type: 'warning',
            position: 'top-right',
            duration: notificationConfig.ERROR_DURATION
          })
        }
      }
    } catch (error) {
      if (error === 'cancel') {
        // 用户取消操作，正常流程
        return
      }
      throw new Error(`打开文件失败: ${error.message}`)
    }
  }
}

// 拖拽相关逻辑
const isDragOver = ref(false)

const handleDragOver = (event) => {
  event.dataTransfer.dropEffect = 'copy'
  isDragOver.value = true
}

const handleDragLeave = (event) => {
  isDragOver.value = false
}

const handleDrop = async (event) => {
  console.log('触发Drop事件')
  isDragOver.value = false
  
  let filePath = null
  let fileName = null
  
  // 1. 优先检查是否是外部文件拖拽 (OS -> Browser)
  const files = event.dataTransfer.files
  if (files && files.length > 0) {
      console.log('检测到外部文件拖拽', files[0])
      const file = files[0]
      // 尝试获取全路径 (Electron环境或特定浏览器配置下 file.path 可用)
      // 注意: 普通网页通常拿不到完整路径，但既然用户要求这样实现，且对比ModelGallery，我们尝试读取
      if (file.path) {
          filePath = file.path
          fileName = file.name
      } else {
          // 如果拿不到路径，可能是普通浏览器限制
          // 浏览器安全机制允许读取文件内容(如Model Gallery)，但禁止获取文件完整路径(如D:\file.prt)
          // 而Creo打开文件需要完整路径，因此不支持外部拖拽打开
          ElNotification({
            title: '不支持外部拖拽',
            message: '浏览器安全限制：无法获取文件完整路径供Creo读取。请使用"文件管理"列表进行拖拽，或手动选择文件。',
            type: 'warning',
            duration: 6000
          })
          return
      }
  } else {
      // 2. 检查内部拖拽数据 (App Internal List -> Sidebar)
      let data = event.dataTransfer.getData('application/json')
      if (!data) {
         data = event.dataTransfer.getData('text/plain')
      }
      
      if (data) {
          try {
             const fileInfo = JSON.parse(data)
             if (fileInfo && fileInfo.filePath) {
                 filePath = fileInfo.filePath
                 fileName = fileInfo.filename
             }
          } catch (e) {
             // 忽略解析错误
          }
      }
  }

  if (!filePath) {
      ElNotification({
        title: '操作失败',
        message: '无法识别有效的文件路径',
        type: 'warning'
      })
      return
  }

  console.log('准备打开模型:', fileName, filePath)

  // 3. 检查连接状态
  const connectedCAD = cadStore.currentCAD
  if (!connectedCAD) {
    ElNotification({
      title: '操作提示',
      message: '请先连接CAD软件',
      type: 'warning',
      position: 'top-right',
      duration: notificationConfig.ERROR_DURATION
    })
    return
  }
 
  // 4. 自动选中"打开模型文件"的Radio (UI反馈)
  const radio = document.querySelector('input[name="project-source"][value="open-file"]')
  if (radio) radio.checked = true

  // 5. 执行打开逻辑
  if (connectedCAD.id === 'creo') {
      try {
        ElNotification({
           title: '正在打开',
           message: `正在请求Creo打开: ${fileName}`,
           type: 'info',
           position: 'top-right',
           duration: 2000
        })

        const openResult = await creoApi.openModelFile(filePath)

        if (openResult.success) {
          const modelResult = await creoApi.getCurrentModel()
          if (modelResult.success) {
            cadStore.setCurrentProjectName(modelResult.data.data.fileName)
            emit('show-model-viewer', modelResult.data)

            ElNotification({
              title: '打开成功',
              message: `已成功打开模型: ${fileName}`,
              type: 'success',
              position: 'top-right',
              duration: notificationConfig.SUCCESS_DURATION
            })
          }
        } else {
             throw new Error(openResult.error || 'API返回失败')
        }
      } catch (error) {
        ElNotification({
          title: '打开失败',
          message: error.message || '未知错误',
          type: 'error',
          position: 'top-right',
          duration: notificationConfig.ERROR_DURATION
        })
      }
  } else if (connectedCAD.id === 'revit') {
      // Revit 拖拽打开
      try {
        ElNotification({
           title: '正在打开',
           message: `正在请求Revit打开: ${fileName}`,
           type: 'info',
           position: 'top-right',
           duration: 2000
        })

        const openResult = await revitApi.openModelFile(filePath, false)

        if (openResult.success) {
          const modelResult = await revitApi.getCurrentModel()
          if (modelResult.success) {
            cadStore.setCurrentProjectName(modelResult.data.data.project.name)
            emit('show-model-viewer', modelResult.data.data)

            ElNotification({
              title: '打开成功',
              message: `已成功打开模型: ${fileName}`,
              type: 'success',
              position: 'top-right',
              duration: notificationConfig.SUCCESS_DURATION
            })
          }
        } else {
             throw new Error(openResult.error || 'API返回失败')
        }
      } catch (error) {
        ElNotification({
          title: '打开失败',
          message: error.message || '未知错误',
          type: 'error',
          position: 'top-right',
          duration: notificationConfig.ERROR_DURATION
        })
      }
  } else {
     ElNotification({
        title: '暂不支持',
        message: `当前连接的软件 (${connectedCAD.name}) 暂不支持拖拽打开`,
        type: 'warning',
        position: 'top-right',
        duration: notificationConfig.ERROR_DURATION
     })
  }
}
// 辅助调试日志
const logDrag = (msg) => console.log('[CadSidebar]', msg)
</script>

<style scoped>
.side-panel {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  overflow-y: auto;
  padding: var(--spacing-xl);
  gap: var(--spacing-2xl);
}

/* CAD软件选择器 */
.software-selector {
  background: var(--color-bg-card);
  border-radius: var(--size-border-radius);
  padding: var(--spacing-xl);
  border: var(--border-width-thin) solid var(--color-border-primary);
}

.selector-title {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin: 0 0 var(--spacing-lg) 0;
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text-primary);
}

.selector-title i {
  color: var(--color-primary);
}


.selected-software {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md);
  background: var(--color-white-rgb-05);
  border-radius: var(--size-border-radius-button);
  font-size: var(--font-size-base);
}

.selected-label {
  color: var(--color-text-secondary);
  font-weight: 500;
}

.selected-name {
  color: var(--color-text-primary);
  font-weight: 600;
}

/* 模型管理面板 */
.panel-section {
  background: var(--color-bg-card);
  border-radius: var(--size-border-radius);
  padding: var(--spacing-xl);
  border: var(--border-width-thin) solid var(--color-border-primary);
}

.section-title {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin: 0 0 var(--spacing-lg) 0;
  font-size: var(--font-size-lg);
  font-weight: 600;
  color: var(--color-text-primary);
}

.section-title i {
  color: var(--color-primary);
}

.selection-title {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
  font-size: var(--font-size-base);
  font-weight: 500;
  color: var(--color-text-primary);
}

.selection-title i {
  color: var(--color-primary);
}

.selection-options {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-lg);
}

.option-item {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-md);
  padding: var(--spacing-md);
  background: var(--color-white-rgb-05);
  border-radius: var(--size-border-radius-button);
  cursor: pointer;
  transition: var(--transition-all);
}

.option-item:hover {
  background: var(--color-white-rgb-05);
}

.option-item.drop-active {
  background: rgba(var(--color-primary-rgb), 0.1);
  border: 2px dashed var(--color-primary);
  transform: scale(1.02);
}

.option-item input[type="radio"] {
  margin-top: var(--size-2);
}

.option-content {
  flex: 1;
}

.option-content i {
  color: var(--color-primary);
  margin-right: var(--spacing-sm);
}

.option-content span {
  display: block;
  color: var(--color-text-primary);
  font-weight: 500;
  margin-bottom: var(--spacing-xs);
}

.option-content small {
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
}

.project-actions {
  display: flex;
  gap: var(--spacing-sm);
}

.confirm-btn {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-grid-gap) var(--spacing-lg);
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--size-border-radius-button);
  font-size: var(--font-size-base);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-all);
}

.confirm-btn:hover {
  background: var(--color-primary-dark);
  transform: translateY(-1px);
}

.confirm-btn i {
  font-size: var(--font-size-base);
}

/* PDMS 专用样式 */
.pdms-selection {
  background: rgba(230, 126, 34, 0.05);
  border-radius: var(--size-border-radius);
  padding: var(--spacing-lg);
  border: 1px solid rgba(230, 126, 34, 0.2);
}

.pdms-selection .selection-title {
  color: #e67e22;
  margin-bottom: var(--spacing-lg);
}

.pdms-selection .selection-title i {
  color: #e67e22;
}

/* PDMS 类型选择器 */
.pdms-type-selector {
  margin-bottom: var(--spacing-lg);
}

.type-label {
  display: block;
  color: var(--color-text-primary);
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
  font-size: var(--font-size-base);
}

.type-options {
  display: flex;
  gap: var(--spacing-md);
}

.type-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-md);
  background: var(--color-white-rgb-05);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--size-border-radius);
  cursor: pointer;
  transition: var(--transition-all);
}

.type-option:hover {
  background: rgba(230, 126, 34, 0.05);
  border-color: rgba(230, 126, 34, 0.5);
}

.type-option.active {
  border-color: #e67e22;
  background: rgba(230, 126, 34, 0.1);
}

.type-option input[type="radio"] {
  display: none;
}

.type-option i {
  color: var(--color-text-secondary);
  font-size: 24px;
  transition: var(--transition-all);
}

.type-option.active i {
  color: #e67e22;
}

.type-option span {
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
  font-weight: 500;
  text-align: center;
}

.type-option.active span {
  color: #e67e22;
}

.pdms-project-input {
  margin-bottom: var(--spacing-lg);
}

.input-label {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  color: var(--color-text-primary);
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
  font-size: var(--font-size-base);
}

.input-label i {
  color: #e67e22;
}

.pdms-input {
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--color-bg-input);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--size-border-radius);
  color: var(--color-text-primary);
  font-size: var(--font-size-base);
  transition: var(--transition-all);
  box-sizing: border-box;
}

.pdms-input:focus {
  outline: none;
  border-color: #e67e22;
  box-shadow: 0 0 0 2px rgba(230, 126, 34, 0.2);
}

.pdms-input::placeholder {
  color: var(--color-text-tertiary);
}

.input-hint {
  display: block;
  margin-top: var(--spacing-xs);
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
}

/* PDMS 选项样式修复 */
.pdms-options {
  margin-bottom: var(--spacing-lg);
}

.pdms-options .option-item {
  background: var(--color-white-rgb-05);
  border: 1px solid transparent;
  margin-bottom: var(--spacing-sm);
}

.pdms-options .option-item:hover {
  background: rgba(230, 126, 34, 0.05);
}

.pdms-options .option-item.active {
  border-color: #e67e22;
  background: rgba(230, 126, 34, 0.1);
}

.pdms-options .option-content i {
  color: #e67e22;
}

.pdms-options .option-item input[type="radio"] {
  accent-color: #e67e22;
}

.pdms-selection .confirm-btn {
  background: linear-gradient(135deg, #f5a623 0%, #e67e22 100%);
  width: 100%;
  justify-content: center;
  border: none;
  box-shadow: 0 4px 10px rgba(230, 126, 34, 0.2);
}

.pdms-selection .confirm-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 15px rgba(230, 126, 34, 0.4);
  background: linear-gradient(135deg, #f39c12 0%, #d35400 100%);
}

/* 滚动条样式 */
.side-panel::-webkit-scrollbar {
  width: var(--size-6);
}

.side-panel::-webkit-scrollbar-track {
  background: transparent;
}

.side-panel::-webkit-scrollbar-thumb {
  background: var(--color-white-rgb-2);
  border-radius: var(--size-3);
}

.side-panel::-webkit-scrollbar-thumb:hover {
  background: var(--color-white-rgb-3);
}
</style>