<template>
  <div class="app-container">
    <div class="park-container">

      
      <!-- 搜索区域 -->
      <div class="search-area">
        <el-input
          v-model="queryParams.licensePlate"
          placeholder="请输入车牌号查询"
          clearable
          prefix-icon="Search"
          class="search-input"
          @keyup.enter="handleQuery"
        />
        
        <el-select v-model="queryParams.typeCode" placeholder="车辆类型" clearable class="search-select">
          <el-option label="全部" value="" />
          <el-option 
            v-for="item in vehicleTypeOptions" 
            :key="item.typeId" 
            :label="item.displayNameCn" 
            :value="item.typeCode" 
          />
        </el-select>
        
        <div class="search-buttons">
          <el-button type="primary" class="search-btn" @click="handleQuery">搜索</el-button>
          <el-button class="reset-btn" @click="resetQuery">重置</el-button>
        </div>
        
        <div class="action-buttons">
          <el-button class="search-btn" type="primary" @click="handleAdd">新增</el-button>
          <el-button class="reset-btn"  @click="handleImport">导入</el-button>
          <el-button class="reset-btn" @click="handleExport">导出</el-button>
          <el-button class="export-btn" @click="handleDelete" :disabled="multiple">删除</el-button>
        </div>
      </div>

      <!-- 车辆监控表格 -->
      <div class="table-container">
        <el-table
          v-loading="loading"
          :data="vehicleList"
          @selection-change="handleSelectionChange"
          style="width: 100%"
          class="custom-table"
          :header-cell-style="{ backgroundColor: '#343744', color: '#fff' }"
          :bg-color="'#292C38'"
          :max-height="tableMaxHeight"
        >
        <el-table-column type="selection" width="50" align="left" />
        <el-table-column label="序号" width="60" align="left">
          <template #default="scope">
            {{ scope.$index + 1 }}
          </template>
        </el-table-column>

        <el-table-column label="车牌号" prop="licensePlate" align="left" />
        <el-table-column label="车辆类型" align="left">
          <template #default="scope">
            {{ scope.row.typeDisplayName || '未知类型' }}
          </template>
        </el-table-column>
        <el-table-column label="品牌" prop="brand" align="left" />
        <!-- 车辆图片 -->
        <el-table-column label="车辆图片" align="left">
          <template #default="scope">
            <img :src="scope.row.imageUrl" class="vehicle-image" />
          </template>
        </el-table-column>
        <el-table-column label="所属单位" prop="owningUnit" align="left" />
        <el-table-column label="负责人" prop="contactPerson" align="left" />
        <el-table-column label="负责人电话" prop="phoneNumber" align="left" />
        <el-table-column label="创建人" prop="createBy" align="left" />
        <el-table-column label="创建时间" prop="createTime" align="left" width="160">
          <template #default="scope">
            <span>{{ parseTime(scope.row.createTime) }}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="120" align="left">
          <template #default="scope">
            <el-button link text @click="handleEdit(scope.row)">编辑</el-button>
            <el-button link text type="danger" @click="handleDelete(scope.row)">删除</el-button>
          </template>
        </el-table-column>
        </el-table>

        <!-- 分页组件 -->
        <pagination
          v-show="total > 0"
          :total="total"
          v-model:page="queryParams.pageNum"
          v-model:limit="queryParams.pageSize"
          @pagination="getList"
        />
      </div>
    </div>

    <!-- 新增/编辑弹窗 -->
    <el-dialog
      v-model="dialog.visible"
      :title="dialog.title"
      width="600px"
      append-to-body
      class="vehicle-dialog"
    >
      <el-form ref="vehicleFormRef" :model="form" :rules="rules" label-width="100px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="车牌号" prop="licensePlate">
              <el-input v-model="form.licensePlate" placeholder="请输入车牌号" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="车辆类型" prop="typeCode">
              <el-select v-model="form.typeCode" placeholder="请选择车辆类型" style="width: 100%">
                <el-option
                  v-for="item in vehicleTypeOptions"
                  :key="item.typeId"
                  :label="item.displayNameCn"
                  :value="item.typeCode"
                />
              </el-select>
            </el-form-item>
          </el-col>
      
          <el-col :span="24">
            <el-form-item label="车辆品牌" prop="brand">
              <el-input v-model="form.brand" placeholder="请输入车辆品牌" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="所属单位" prop="owningUnit">
              <el-input v-model="form.owningUnit" placeholder="请输入所属单位" />
            </el-form-item>
          </el-col>
      
          <el-col :span="24">
            <el-form-item label="联系人" prop="contactPerson">
              <el-input v-model="form.contactPerson" placeholder="请输入联系人" />
            </el-form-item>
          </el-col>
          <el-col :span="24">
            <el-form-item label="电话" prop="phoneNumber">
              <el-input v-model="form.phoneNumber" placeholder="请输入电话" />
            </el-form-item>
          </el-col>
        </el-row>
        <!-- 创建人 -->
        <el-form-item label="创建人" prop="createBy">
          <el-input v-model="form.createBy" placeholder="请输入创建人" />
        </el-form-item>
       
        <el-form-item label="车辆图片" prop="imageUrl">
          <div class="avatar-uploader-box">
            <div v-if="form.imageUrl" class="avatar-preview">
              <img :src="form.imageUrl" class="avatar" />
              <div class="avatar-replace" @click.stop="handleRemoveImage">
                <el-icon><Close /></el-icon>
              </div>
            </div>
            <el-upload
              v-else
              class="avatar-uploader"
              :action="uploadUrl"
              :headers="headers"
              :show-file-list="false"
              :on-success="handleImageSuccess"
              :before-upload="beforeImageUpload"
            >
              <div class="avatar-upload-placeholder">
                <el-icon class="avatar-uploader-icon"><Plus /></el-icon>
              </div>
            </el-upload>
            <div class="avatar-count">{{ form.imageUrl ? '1/1' : '0/1' }}</div>
          </div>
        </el-form-item>
      </el-form>
      <template #footer>
        <div class="dialog-footer">
          <el-button class="export-btn" @click="dialog.visible = false">取 消</el-button>
          <el-button class="search-btn" type="primary" @click="submitForm">确 定</el-button>
        </div>
      </template>
    </el-dialog>

    <!-- 导入弹窗 -->
    <el-dialog
      v-model="importDialog.visible"
      title="导入车辆信息"
      width="500px"
      append-to-body
      class="import-dialog"
    >
      <div class="import-title">选择需要导入的车辆文件</div>
      <el-upload
        ref="uploadRef"
        :limit="1"
        accept=".xlsx, .xls"
        :headers="upload.headers"
        :action="upload.url + '?updateSupport=' + upload.updateSupport"
        :disabled="upload.isUploading"
        :on-progress="handleFileUploadProgress"
        :on-success="handleFileSuccess"
        :auto-upload="false"
        drag
        class="import-upload"
      >
        <div class="upload-content">
          <el-icon class="upload-icon"><upload-filled /></el-icon>
          <div class="upload-text">拖拽文件到这里，或</div>
          <div class="upload-link">
            <el-icon class="upload-icon-small" style="color: #347AE2"><upload-filled /></el-icon>
            <span class="click-upload">点此添加</span>
          </div>
        </div>
      </el-upload>
      <div class="import-footer">
        <div class="footer-left">
          <el-checkbox v-model="upload.updateSupport">是否更新已经存在的车辆数据</el-checkbox>
        </div>
        <div class="footer-right">
          <span class="file-format">仅允许导入xls、xlsx格式文件。</span>
          <el-link type="primary" :underline="false" class="download-link" @click="importTemplate">下载模板</el-link>
        </div>
      </div>
      <template #footer>
        <div class="dialog-footer">
          <el-button class="reset-btn" @click="importDialog.visible = false">取 消</el-button>
          <el-button class="search-btn" type="primary" @click="submitFileForm">确 定</el-button>
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script setup name="VehiclePark">
import { ref, reactive, onMounted, getCurrentInstance, computed } from 'vue';
import { getToken } from "@/utils/auth";
import { parseTime } from "@/utils/ruoyi";
import { Search, Download, Plus, UploadFilled, Close } from '@element-plus/icons-vue';
import VehicleStats from '@/components/car/VehicleStats.vue';
import Pagination from '@/components/Pagination/index.vue';
import { 
  listVehicle_info, 
  getVehicle_info, 
  addVehicle_info, 
  updateVehicle_info, 
  delVehicle_info 
} from "@/api/system/vehicle_info.js";
import { listVehicle_type } from "@/api/system/vehicle_type.js";

const { proxy } = getCurrentInstance();

const vehicleList = ref([]);
const loading = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);

// 车辆类型选项
const vehicleTypeOptions = ref([]);
const vehicleTypeMap = ref({});

// 车辆状态统计数据
const vehicleStats = ref([
  { title: '在线', count: 45, icon: 'el-icon-success', color: '#67c23a', trend: '+30%', trendUp: true },
  { title: '任务中', count: 28, icon: 'el-icon-loading', color: '#409eff', trend: '+20%', trendUp: true },
  { title: '故障', count: 5, icon: 'el-icon-warning', color: '#f56c6c', trend: '-10%', trendUp: false },
  { title: '离线', count: 12, icon: 'el-icon-error', color: '#e6a23c', trend: '-5%', trendUp: false }
]);

// 统计信息计算
const statistics = computed(() => {
  return {
    online: vehicleList.value.filter(v => v.status === '在线').length,
    inTask: vehicleList.value.filter(v => v.routeStatus === '任务中').length,
    error: vehicleList.value.filter(v => v.status === '故障').length,
    offline: vehicleList.value.filter(v => v.status === '离线').length
  };
});

// 查询参数
const queryParams = ref({
  pageNum: 1,
  pageSize: 7,
  licensePlate: undefined,
  typeCode: undefined
});

const tableMaxHeight = computed(() => {
  const size = queryParams.value.pageSize || 7;
  return vehicleList.value.length > size ? 520 : undefined;
});

// 弹窗控制
const dialog = reactive({
  visible: false,
  title: ''
});

const importDialog = reactive({
  visible: false
});

// 表单数据
const form = ref({
  vehicleId: undefined,
  licensePlate: '',
  typeCode: '',
  brand: '',
  owningUnit: '',
  contactPerson: '',
  phoneNumber: '',
  imageUrl: ''
});

// 表单验证规则
const rules = {
  licensePlate: [
    { required: true, message: "车牌号不能为空", trigger: "blur" }
  ],
  typeCode: [
    { required: true, message: "车辆类型不能为空", trigger: "change" }
  ],
  brand: [
    { required: true, message: "车辆品牌不能为空", trigger: "blur" }
  ],
  owningUnit: [
    { required: true, message: "所属单位不能为空", trigger: "blur" }
  ],
  contactPerson: [
    { required: true, message: "联系人不能为空", trigger: "blur" }
  ],
  phoneNumber: [
    { required: true, message: "电话不能为空", trigger: "blur" }
  ]
};

// 上传相关
const uploadUrl = window.APP_CONFIG?.VITE_BASE_URL + "/common/upload";
const headers = { Authorization: "Bearer " + getToken() };
const upload = reactive({
  isUploading: false,
  updateSupport: 0,
  title: "",
  open: false,
  // 新增导入文件的接口URL
  url: window.APP_CONFIG?.VITE_BASE_URL + "/system/vehicle_info/importData",
  headers: { Authorization: "Bearer " + getToken() }
});

/** 获取作业状态对应的类型 */
function getRouteStatusType(status) {
  switch (status) {
    case '任务中':
      return 'success';
    case '待命中':
      return '';
    case '充电中':
      return 'warning';
    case '等待中':
      return 'info';
    default:
      return '';
  }
}

/** 获取车辆状态对应的类型 */
function getStatusType(status) {
  switch (status) {
    case '在线':
      return 'success';
    case '离线':
      return 'info';
    case '故障':
      return 'danger';
    default:
      return '';
  }
}

/** 查询车辆列表 */
function getList() {
  loading.value = true;
  listVehicle_info(queryParams.value).then(res => {
    loading.value = false;
    vehicleList.value = res.rows || [];
    
    total.value = res.total || 0;
  }).catch(() => {
    loading.value = false;
    vehicleList.value = [];
    total.value = 0;
  });
}

/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}

/** 重置按钮操作 */
function resetQuery() {
  queryParams.value = {
    pageNum: 1,
    pageSize: 10,
    licensePlate: undefined,
    typeCode: undefined
  };
  handleQuery();
}

/** 选择条数 */
function handleSelectionChange(selection) {
  ids.value = selection.map(item => item.vehicleId);
  single.value = selection.length != 1;
  multiple.value = !selection.length;
}

/** 新增按钮操作 */
function handleAdd() {
  reset();
  getVehicleTypeList();
  dialog.visible = true;
  dialog.title = "添加车辆";
}

/** 修改按钮操作 */
function handleEdit(row) {
  reset();
  const vehicleId = row.vehicleId || ids.value[0];
  getVehicle_info(vehicleId).then(response => {
    form.value = response.data || {};
    if (!vehicleTypeOptions.value.length) {
      getVehicleTypeList();
    }
    if (form.value.typeId && !form.value.typeCode) {
      const match = vehicleTypeOptions.value.find(item => item.typeId === form.value.typeId);
      form.value.typeCode = match ? match.typeCode : form.value.typeCode;
    }
    dialog.visible = true;
    dialog.title = "修改车辆";
  });
}

/** 提交按钮 */
function submitForm() {
  proxy.$refs["vehicleFormRef"].validate(valid => {
    if (valid) {
      if (form.value.vehicleId != undefined) {
        // 更新
        updateVehicle_info({
          vehicleId: form.value.vehicleId,
          licensePlate: form.value.licensePlate,
          typeCode: form.value.typeCode,
          brand: form.value.brand,
          owningUnit: form.value.owningUnit,
          contactPerson: form.value.contactPerson,
          phoneNumber: form.value.phoneNumber,
          imageUrl: form.value.imageUrl
        }).then(response => {
          proxy.$modal.msgSuccess("修改成功");
          dialog.visible = false;
          getList();
        });
      } else {
        // 新增
        addVehicle_info({
          licensePlate: form.value.licensePlate,
          typeCode: form.value.typeCode,
          brand: form.value.brand,
          owningUnit: form.value.owningUnit,
          contactPerson: form.value.contactPerson,
          phoneNumber: form.value.phoneNumber,
          imageUrl: form.value.imageUrl
        }).then(response => {
          proxy.$modal.msgSuccess("新增成功");
          dialog.visible = false;
          getList();
        });
      }
    }
  });
}

/** 删除按钮操作 */
function handleDelete(row) {
  const vehicleIds = row.vehicleId || ids.value;
  proxy.$modal.confirm('是否确认删除车辆编号为"' + vehicleIds + '"的数据项？').then(function() {
    return delVehicle_info(vehicleIds);
  }).then(() => {
    getList();
    proxy.$modal.msgSuccess("删除成功");
  }).catch(() => {});
}

/** 导入按钮操作 */
function handleImport() {
  importDialog.visible = true;
  upload.title = "车辆导入";
}

/** 文件上传中处理 */
function handleFileUploadProgress(event, file, fileList) {
  upload.isUploading = true;
}

/** 文件上传成功处理 */
function handleFileSuccess(response, file, fileList) {
  upload.isUploading = false;
  proxy.$refs["uploadRef"].clearFiles();
  proxy.$alert("<div style='overflow: auto;overflow-x: hidden;max-height: 70vh;padding: 10px 20px 0;'>" + response.msg + "</div>", "导入结果", { dangerouslyUseHTMLString: true });
  importDialog.visible = false;
  getList();
}

/** 提交上传文件 */
function submitFileForm() {
  proxy.$refs["uploadRef"].submit();
}

/** 导出按钮操作 */
function handleExport() {
  proxy.download("system/vehicle_info/export", {
    ...queryParams.value,
    pageNum: undefined,
    pageSize: undefined
  }, `车辆数据_${new Date().getTime()}.xlsx`);
}

/** 图片上传成功处理 */
function handleImageSuccess(response, file) {
  form.value.imageUrl = response.url;
}

/** 图片上传前处理 */
function beforeImageUpload(file) {
  const isJPG = file.type === 'image/jpeg' || file.type === 'image/png';
  const isLt2M = file.size / 1024 / 1024 < 2;

  if (!isJPG) {
    proxy.$message.error('上传图片只能是 JPG/PNG 格式!');
  }
  if (!isLt2M) {
    proxy.$message.error('上传图片大小不能超过 2MB!');
  }
  return isJPG && isLt2M;
}

/** 表单重置 */
function reset() {
  form.value = {
    vehicleId: undefined,
    licensePlate: '',
    typeId: '',
    brand: '',
    owningUnit: '',
    contactPerson: '',
    phoneNumber: '',
    imageUrl: ''
  };
  proxy.resetForm("vehicleFormRef");
}

/** 下载模板操作 */
function importTemplate() {
  proxy.download('system/vehicle_info/importTemplate', {}, `车辆数据模板_${new Date().getTime()}.xlsx`);
}

/** 移除图片操作 */
function handleRemoveImage() {
  form.value.imageUrl = '';
}

/** 获取车辆类型名称 */
function getVehicleTypeName(typeId) {
  // 保留此函数以兼容旧代码，但在表格中直接使用typeDisplayName
  return vehicleTypeMap.value[typeId] || '';
}

/** 获取车辆类型列表 */
function getVehicleTypeList() {
  listVehicle_type().then(res => {
    const list = Array.isArray(res.rows)
      ? res.rows
      : Array.isArray(res.data)
        ? res.data
        : Array.isArray(res)
          ? res
          : [];
    let options = list.filter(item => (item.pathLevel === 2 || item.level === 2));
    if (!options.length) options = list;
    vehicleTypeOptions.value = options;
    vehicleTypeMap.value = {};
    options.forEach(item => {
      vehicleTypeMap.value[item.typeId] = item.displayNameCn;
    });
  }).catch(() => {
    vehicleTypeOptions.value = [];
    vehicleTypeMap.value = {};
  });
}

onMounted(() => {
  getList();
  getVehicleTypeList();
});
</script>

<style lang="scss" scoped>
.app-container {
  padding: 20px;
  background-color: #292C38;
  color: #ffffff;
  height: 100%;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
}

.table-container {
  flex: none;
  height: auto;
  max-height: none;
  overflow: hidden;
  margin-bottom: 0;
}

.park-container {
  background-color: #292c38;
  border-radius: 4px;
  height: auto;
  overflow: visible;
}

.search-area {
  display: flex;
  align-items: center;
  margin-bottom: 20px;
  margin-top: 20px;
  
  .search-input {
    width: 250px;
    margin-right: 10px;
  }
  
  .search-select {
    width: 150px;
    margin-right: 10px;
  }
  
  .search-buttons {
    margin-right: 20px;
    display: flex;
    gap: 10px;
  }
  
  .action-buttons {
    margin-left: auto;
    display: flex;
    gap: 10px;
  }
}
.vehicle-image{
  width:48px;
  height:48px;
  border-radius: 4px;
}
// 输入框 下拉框 搜索栏
:deep(.el-input__wrapper:hover) {
  box-shadow: none !important;
}

:deep(.el-select) {
  border:none !important;
  width:160px !important;
  --el-border-color-hover: #343744!important;
  --el-border-color: #343744!important;
}

:deep(.el-select__wrapper.is-focused) {
  box-shadow: none !important;
}

:deep(.el-select__wrapper) {
  background: #343744 !important;
  color: #96A0B5 !important;
  border-radius: 8px !important;
  height: 36px !important;
  width: 160px;
  font-size: 15px;
  border: none !important;
}

:deep(.el-input__wrapper) {
  background: #343744 !important;
  color: #96A0B5 !important; 
  border-radius: 8px !important;
  height: 36px !important;
  border: none !important;
  box-shadow: none !important;
}

:deep(.el-select__placeholder) {
  color: #96A0B5 !important;
}

.custom-table {
  background-color: #292c38 !important;
  color: #ffffff;
  margin-bottom: 20px;
  border-radius: 4px;
  overflow: hidden;
  
  :deep(.el-loading-mask) {
    background-color: rgba(41, 44, 56, 0.7) !important;
  }
  
  :deep(.el-table__empty-block) {
    background-color: #292c38 !important;
  }
  
  :deep(.el-table__empty-text) {
    color: #96A0B5 !important;
  }
  
  :deep(.el-table) {
    background-color: #292c38 !important;
  }
  
  :deep(.el-table__body) {
    background-color: #292c38 !important;
  }
  
  :deep(.el-table__inner-wrapper::before) {
    display: none;
  }
  
  :deep(.el-table__header) {
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    overflow: hidden;
  }
  
  :deep(.el-table__header-wrapper) {
    th {
      background-color: #343744 !important;
      color: #96A0B5!important;
      font-weight: normal;
      border-bottom: none;
    }
    
    tr th.el-table__cell:first-child {
      border-top-left-radius: 6px;
      
      .cell {
        border-top-left-radius: 6px;
      }
    }
    
    tr th.el-table__cell:last-child {
      border-top-right-radius: 4px;
      
      .cell {
        border-top-right-radius: 4px;
      }
    }
    
    .el-table__header th.el-table__cell {
      background-color: #343744 !important;
      color: #96A0B5;
    }
    
    tr {
      background-color: #343744 !important;
    }
  }
  
  :deep(.el-table__body-wrapper) {
    td {
      height: 56px!important;
      background-color: #292c38;
      color: #ffffff;
      border-bottom: 1px solid #4C4F5F;
    }
  }
  
  :deep(.el-table__body tr:hover > td) {
    background: #2B3B5A!important; 
  }
  
  :deep(.el-button--link) {
    border: none;
    background: transparent;
    color: #347AE2;
    padding: 0;
    margin: 0 5px;
  }
  
  :deep(.el-button.is-text) {
    background-color: transparent !important;
    border-color: transparent;
    color: #347AE2;
    
    &:hover, &:focus, &:active {
      background-color: transparent !important;
      color: #347AE2;
    }
  }
  
  :deep(.el-button.el-button--primary.is-text) {
    background-color: transparent !important;
    color: #347AE2;
    
    &:hover {
      background-color: transparent !important;
      color: #347AE2;
    }
  }
  
  :deep(.el-table__body tr:hover .el-button--link.is-text) {
    background-color: transparent !important;
    color: #347AE2;
  }
}

/* 全局表格样式覆盖 */
:deep(.el-table) {
  --el-table-bg-color: #292c38 !important;
  --el-table-tr-bg-color: #292c38 !important;
  --el-table-border-color: #4C4F5F !important;
  --el-table-header-bg-color: #343744 !important;
  --el-table-row-hover-bg-color: #2B3B5A !important;
  
  &::before {
    display: none;
  }
}

// 弹窗样式
.vehicle-dialog, .import-dialog {
  :deep(.el-dialog) {
    background-color: #343744;
    border-radius: 8px;
  }
  
  :deep(.el-dialog__header) {
    background-color: #343744;
    color: #ffffff;
    border-bottom: 1px solid #4C4F5F;
  }
  
  :deep(.el-dialog__body) {
    background-color: #343744;
    color: #ffffff;
  }
  
  :deep(.el-dialog__footer) {
    background-color: #343744;
    border-top: 1px solid #4C4F5F;
  }
  
  :deep(.el-form-item__label) {
    color: #96A0B5;
  }
  
  :deep(.el-input__wrapper) {
    background: #292C38 !important;
    border: 1px solid #4C4F5F !important;
    color: #ffffff !important;
  }
  
  :deep(.el-select__wrapper) {
    background: #292C38 !important;
    border: 1px solid #4C4F5F !important;
    color: #ffffff !important;
  }
  
  :deep(.el-input__inner) {
    color: #ffffff !important;
  }
  
  :deep(.el-select__placeholder) {
    color: #96A0B5 !important;
  }
}

// 图片上传样式
.avatar-uploader {
  :deep(.el-upload) {
    border: 1px dashed #4C4F5F;
    border-radius: 6px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: var(--el-transition-duration-fast);
    
    &:hover {
      border-color: #347AE2;
    }
  }
  
  :deep(.el-upload-dragger) {
    background-color: #292C38;
    border: 1px dashed #4C4F5F;
    border-radius: 6px;
    box-sizing: border-box;
    width: 90px;
    height: 90px;
    text-align: center;
    
    &:hover {
      border-color: #347AE2;
    }
  }
}

.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 90px;
  height: 90px;
  text-align: center;
  line-height: 90px;
}

.avatar {
  width: 90px;
  height: 90px;
  display: block;
}

// 媒体查询
@media (max-width: 1200px) {
  .search-area {
    flex-wrap: wrap;
    gap: 10px;
    
    .search-input {
      width: 100%;
      max-width: 250px;
      margin-right: 0;
    }
    
    .search-select {
      margin-right: 0;
    }
    
    .search-buttons {
      margin-right: 0;
    }
    
    .action-buttons {
      margin-left: 0;
      margin-top: 10px;
    }
  }
}

@media (max-width: 768px) {
  .search-area {
    flex-direction: column;
    align-items: flex-start;
    
    .search-input,
    .search-select {
      width: 100%;
      max-width: none;
    }
    
    .search-buttons,
    .action-buttons {
      width: 100%;
      margin-top: 10px;
    }
  }
}

// 导入上传样式
.import-dialog {
  :deep(.el-dialog__header) {
    margin-right: 0;
    padding: 20px;
    border-bottom: 1px solid #4C4F5F;
  }

  :deep(.el-dialog__body) {
    padding: 20px;
  }

  :deep(.el-dialog__footer) {
    padding: 20px;
    border-top: 1px solid #4C4F5F;
  }

  .import-title {
    font-size: 14px;
    color: #96A0B5;
    margin-bottom: 20px;
  }

  .import-upload {
    :deep(.el-upload-dragger) {
      width: 100%;
      height: 200px;
      background-color: #292C38;
      border: 1px dashed #4C4F5F;
      border-radius: 8px;
      display: flex;
      justify-content: center;
      align-items: center;

      &:hover {
        border-color: #347AE2;
      }
    }

    .upload-content {
      display: flex;
      flex-direction: column;
      align-items: center;
      color: #96A0B5;

      .upload-icon {
        font-size: 40px;
        color: #96A0B5;
        margin-bottom: 10px;
      }

      .upload-text {
        font-size: 14px;
        margin-bottom: 10px;
      }

      .upload-link {
        display: flex;
        align-items: center;
        color: #347AE2;
        cursor: pointer;

        .upload-icon-small {
          font-size: 16px;
          margin-right: 4px;
        }

        .click-upload {
          font-size: 14px;
        }
      }
    }
  }

  .import-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;

    .footer-left {
      :deep(.el-checkbox__label) {
        color: #96A0B5;
      }
    }

    .footer-right {
      display: flex;
      align-items: center;
      gap: 10px;

      .file-format {
        color: #96A0B5;
        font-size: 12px;
      }

      .download-link {
        font-size: 12px;
      }
    }
  }

  .dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
  }
}

/* 头像上传样式 */
.avatar-uploader-box {
  position: relative;
  display: flex;
  justify-content: flex-start;
  margin-top: 8px;
}

.avatar-uploader {
  text-align: center;
}

.avatar-preview {
  position: relative;
  width: 90px;
  height: 90px;
  border-radius: 0;
  overflow: visible;
  
  .avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 0;
    border: 1px solid #343744;
  }
  
  .avatar-replace {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 20px;
    height: 20px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    opacity: 1;
    z-index: 2;
    
    .el-icon {
      font-size: 14px;
      color: #ffffff;
    }
  }
}

.avatar-upload-placeholder {
  width: 90px;
  height: 90px;
  border: 1px dashed #4C4F5F;
  border-radius: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
  background-color: transparent;
  overflow: visible;
  
  &:hover {
    border-color: #409EFF;
  }
  
  .avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
  }
}

.avatar-count {
  position: absolute;
  top: -5px;
  right: -25px;
  font-size: 14px;
  color: #ffffff;
  z-index: 20;
  background: none;
  padding: 0;
}
</style>

