// 文件上传组件 - 精简版样式
.file-upload {
  display: inline-block;
  width: 100%;

  // 封面模式
  &.cover {
    width: 300px;
    height: 200px;

    .image-wrapper {
      position: relative;
      width: 300px;
      height: 200px;
      border-radius: 6px;
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
      background: #f5f7fa;

      &:hover .actions {
        opacity: 1;
      }

      .image {
        display: block;
        object-fit: contain;
        max-width: 100%;
        max-height: 100%;

        &.horizontal {
          width: 100%;
          height: auto;
        }

        &.vertical {
          height: 100%;
          width: auto;
        }
      }

      .actions {
        position: absolute;
        top: 8px;
        right: 8px;
        opacity: 0;
        transition: opacity 0.3s;
      }
    }
  }

  // 弹窗模式
  &.dialog {
    .dialog-content {
      padding: 0;
    }

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

  // 内容模式
  &.content {
    display: block;
  }

  // 通用容器
  .container {
    padding: 20px 0;
  }

  // 上传区域
  .area {
    border: 2px dashed #dcdfe6;
    border-radius: 8px;
    padding: 60px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: #fafafa;
    min-height: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;

    // 封面模式特殊样式
    &.cover {
      border: 1px dashed #d9d9d9;
      border-radius: 6px;
      background: #ffffff;
      padding: 30px 20px;

      &:hover {
        box-shadow: 0 4px 12px rgba(64, 158, 255, 0.1);
        transform: translateY(-2px);

        .icon {
          transform: scale(1.1);
        }
      }
    }

    &:hover {
      border-color: #409eff;
      background: #f0f9ff;

      .icon .plus {

        &::before,
        &::after {
          background-color: #409eff;
        }
      }

      .text {
        color: #409eff;
      }
    }

    &.dragover {
      border-color: #409eff;
      background: #e6f7ff;
      border-style: solid;
    }

    &.disabled {
      cursor: not-allowed;
      opacity: 0.6;
    }
  }

  // 内容区域
  .content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
  }

  // 图标
  .icon {
    margin-bottom: 16px;
    transition: all 0.3s;

    .plus {
      width: 80px;
      height: 80px;
      position: relative;
      margin: 0 auto;

      &::before,
      &::after {
        content: '';
        position: absolute;
        background-color: #c0c4cc;
        transition: all 0.3s;
      }

      // 竖线
      &::before {
        width: 2px;
        height: 80px;
        left: 50%;
        top: 0;
        transform: translateX(-50%);
      }

      // 横线
      &::after {
        width: 80px;
        height: 2px;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
      }
    }
  }

  // 封面模式的小图标
  &.cover .icon .plus {
    width: 48px;
    height: 48px;

    &::before {
      width: 1px;
      height: 48px;
    }

    &::after {
      width: 48px;
      height: 1px;
    }
  }

  // 文字
  .text {
    color: #606266;
    font-size: 16px;
    margin-bottom: 8px;
    font-weight: 500;
    transition: color 0.3s;

    .link {
      color: #409eff;
      cursor: pointer;
      text-decoration: underline;
    }
  }

  // 提示
  .tip {
    color: #909399;
    font-size: 13px;
    line-height: 1.5;
    max-width: 240px;
  }

  // 加载状态
  .loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    .spinner {
      font-size: 32px;
      color: #409eff;
      margin-bottom: 8px;
      animation: rotate 1s linear infinite;
    }

    div {
      font-size: 14px;
      color: #606266;
    }
  }

  // 文件列表
  .files {
    margin-top: 20px;

    h4 {
      margin: 0 0 12px 0;
      font-size: 14px;
      font-weight: 600;
      color: #374151;
    }
  }

  // 单个文件
  .file {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    background-color: #f8fafc;
    border-radius: 6px;
    margin-bottom: 8px;
    transition: background-color 0.2s ease;

    &:hover {
      background-color: #e2e8f0;
    }

    .preview {
      width: 60px;
      height: 60px;
      border-radius: 4px;
      overflow: hidden;
      display: flex;
      align-items: center;
      justify-content: center;
      background: #f5f7fa;
      flex-shrink: 0;

      .thumb {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }

      .type-icon {
        font-size: 24px;
      }
    }

    .info {
      flex: 1;
      min-width: 0;

      .name {
        font-size: 14px;
        font-weight: 500;
        color: #1e293b;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-bottom: 4px;
      }

      .size {
        font-size: 12px;
        color: #64748b;
      }
    }

    .actions {
      display: flex;
      gap: 8px;
    }
  }

  // 操作按钮区域
  .actions {
    margin-top: 16px;
    text-align: center;

    &:not(.file .actions) {
      display: flex;
      gap: 12px;
      justify-content: center;
    }
  }
}

// 动画
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

// 响应式设计
@media (max-width: 768px) {
  .file-upload {
    &.dialog .modal {
      margin: 16px;
      padding: 20px;
      width: calc(100% - 32px);
    }

    .area.cover {
      width: 250px;
      height: 160px;
    }
  }
}