<template>
  <div class="converter-container">
    <div class="converter-header">
      <div class="header-content">
        <div class="header-icon">
          <i class="fas fa-exchange-alt"></i>
        </div>
        <div class="header-text">
          <h2>格式转换</h2>
          <p>将STP文件转换为GLTF格式，用于Web展示</p>
        </div>
      </div>
    </div>

    <div class="converter-content">
      <div class="conversion-flow">
        <div class="flow-step">
          <div class="step-icon">
            <i class="fas fa-file-upload"></i>
          </div>
          <h3>1. 选择STP文件</h3>
          <p>选择要转换的STEP格式文件</p>
        </div>
        <div class="flow-arrow">
          <i class="fas fa-arrow-right"></i>
        </div>
        <div class="flow-step">
          <div class="step-icon">
            <i class="fas fa-cogs"></i>
          </div>
          <h3>2. 转换处理</h3>
          <p>自动处理几何数据和材质</p>
        </div>
        <div class="flow-arrow">
          <i class="fas fa-arrow-right"></i>
        </div>
        <div class="flow-step">
          <div class="step-icon">
            <i class="fas fa-download"></i>
          </div>
          <h3>3. 下载GLTF</h3>
          <p>获取Web优化的3D模型文件</p>
        </div>
      </div>

      <div class="converter-panel">
        <div class="upload-section">
          <div class="upload-area" id="stp-upload-area">
            <i class="fas fa-cloud-upload-alt"></i>
            <h4>拖拽STP文件到此处</h4>
            <p>或点击选择文件</p>
            <input type="file" id="stp-file-input" accept=".stp,.step" class="hidden-input">
            <button class="upload-btn" @click="selectFile">
              <i class="fas fa-folder-open"></i>
              选择文件
            </button>
          </div>
        </div>

        <div class="conversion-options">
          <h4>转换选项</h4>
          <div class="options-grid">
            <div class="option-item">
              <label>输出质量:</label>
              <select id="gltf-quality">
                <option value="high">高质量</option>
                <option value="medium" selected>中等质量</option>
                <option value="low">低质量(适合Web)</option>
              </select>
            </div>
            <div class="option-item">
              <label>
                <input type="checkbox" id="optimize-size" checked>
                优化文件大小
              </label>
            </div>
            <div class="option-item">
              <label>
                <input type="checkbox" id="include-textures">
                包含纹理
              </label>
            </div>
            <div class="option-item">
              <label>
                <input type="checkbox" id="compress-gltf" checked>
                压缩GLTF
              </label>
            </div>
          </div>
        </div>

        <div class="conversion-actions">
          <button class="action-btn primary" id="start-conversion" disabled>
            <i class="fas fa-play"></i>
            开始转换
          </button>
          <button class="action-btn secondary">
            <i class="fas fa-undo"></i>
            重置
          </button>
        </div>
      </div>

      <div class="conversion-progress" id="conversion-progress" v-show="false">
        <div class="progress-content">
          <div class="progress-icon">
            <i class="fas fa-spinner fa-spin"></i>
          </div>
          <h4>正在转换...</h4>
          <div class="progress-bar">
            <div class="progress-fill" id="conversion-progress-fill"></div>
          </div>
          <p id="conversion-status">准备转换...</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
// 格式转换页面 - 只实现UI，不实现功能


const selectFile = () => {
  // 空函数，只为了避免Vue警告
}
</script>

<style scoped>
.converter-container {
  padding: 24px;
  max-width: 900px;
  margin: 0 auto;
}

.converter-header {
  margin-bottom: 32px;
}

.header-content {
  display: flex;
  align-items: center;
  gap: 20px;
}

.header-icon {
  width: 64px;
  height: 64px;
  background: var(--color-primary-gradient);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: white;
  box-shadow: 0 4px 16px var(--color-primary-rgb);
}

.header-text h2 {
  color: var(--color-text-primary);
  margin: 0 0 8px 0;
  font-size: 32px;
  font-weight: 600;
}

.header-text p {
  color: var(--color-text-secondary);
  margin: 0;
  font-size: 16px;
}

.converter-content {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border-primary);
  border-radius: 16px;
  padding: 32px;
}

.conversion-flow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-bottom: 40px;
  flex-wrap: wrap;
}

.flow-step {
  flex: 1;
  min-width: 200px;
  text-align: center;
  padding: 20px;
  background: var(--color-bg-tertiary);
  border-radius: 12px;
  border: 1px solid var(--color-border-primary);
}

.step-icon {
  width: 56px;
  height: 56px;
  background: var(--color-primary-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: white;
  margin: 0 auto 16px;
}

.flow-step h3 {
  color: var(--color-text-primary);
  margin: 0 0 8px 0;
  font-size: 18px;
  font-weight: 600;
}

.flow-step p {
  color: var(--color-text-secondary);
  margin: 0;
  font-size: 14px;
}

.flow-arrow {
  color: var(--color-text-tertiary);
  font-size: 20px;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .flow-arrow {
    transform: rotate(90deg);
  }
}

.converter-panel {
  display: grid;
  gap: 32px;
}

.upload-section {
  margin-bottom: 24px;
}

.upload-area {
  border: 2px dashed var(--color-border-primary);
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  background: var(--color-bg-tertiary);
  transition: all 0.3s ease;
  cursor: pointer;
}

.upload-area:hover {
  border-color: var(--color-primary);
  background: var(--color-bg-hover);
}

.upload-area i {
  font-size: 48px;
  color: var(--color-primary);
  margin-bottom: 16px;
}

.upload-area h4 {
  color: var(--color-text-primary);
  margin: 0 0 8px 0;
  font-size: 20px;
  font-weight: 600;
}

.upload-area p {
  color: var(--color-text-secondary);
  margin: 0 0 24px 0;
  font-size: 14px;
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: var(--color-primary-gradient);
  border: none;
  border-radius: 8px;
  color: white;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.upload-btn:hover {
  background: var(--color-primary-gradient-hover);
  transform: translateY(-2px);
}

.conversion-options {
  background: var(--color-bg-tertiary);
  border-radius: 12px;
  padding: 24px;
  border: 1px solid var(--color-border-primary);
}

.conversion-options h4 {
  color: var(--color-text-primary);
  margin: 0 0 20px 0;
  font-size: 18px;
  font-weight: 600;
}

.options-grid {
  display: grid;
  gap: 16px;
}

.option-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.option-item label {
  color: var(--color-text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.option-item select {
  padding: 8px 12px;
  background: var(--color-bg-input);
  border: 1px solid var(--color-border-primary);
  border-radius: 6px;
  color: var(--color-text-primary);
  font-size: 14px;
  min-width: 160px;
}

.option-item select:focus {
  outline: none;
  border-color: var(--color-primary);
}

.option-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--color-primary);
}

.conversion-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 24px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 140px;
  justify-content: center;
}

.action-btn.primary {
  background: var(--color-success);
  color: white;
  box-shadow: 0 4px 16px var(--color-success-rgb-1);
}

.action-btn.primary:hover:not(:disabled) {
  background: var(--color-success-rgb-5);
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--color-success-rgb-3);
}

.action-btn.primary:disabled {
  background: var(--color-text-tertiary);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.action-btn.secondary {
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border-primary);
  color: var(--color-text-secondary);
}

.action-btn.secondary:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}

.conversion-progress {
  background: var(--color-bg-tertiary);
  border: 1px solid var(--color-border-primary);
  border-radius: 12px;
  padding: 32px;
  text-align: center;
  margin-top: 24px;
}

.progress-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.progress-icon i {
  font-size: 48px;
  color: var(--color-primary);
}

.progress-content h4 {
  color: var(--color-text-primary);
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.progress-content p {
  color: var(--color-text-secondary);
  margin: 0;
  font-size: 14px;
}

.progress-bar {
  width: 100%;
  max-width: 300px;
  height: 8px;
  background: var(--color-bg-primary);
  border-radius: 4px;
  overflow: hidden;
  margin: 16px 0;
}

.progress-fill {
  height: 100%;
  background: var(--color-primary-gradient);
  border-radius: 4px;
  transition: width 0.3s ease;
  width: 0%;
}

/* 隐藏元素 */
.hidden-input {
  display: none;
}

/* 使用全局CSS变量 - 已在theme.css中统一定义 */
</style>