.materials-page {
  padding: 16px;
}

.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  background: white;
  padding: 12px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.search-input-wrapper {
  position: relative;
  flex: 1;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #999;
  z-index: 1;
}

.search-input {
  padding-left: 36px;
  border-radius: 20px;
  border: 1px solid #e0e0e0;

  &:focus {
    border-color: #1677ff;
    box-shadow: 0 0 0 2px rgba(22, 119, 255, 0.1);
  }
}

.create-btn {
  border-radius: 20px;
  padding: 0 16px;
}

.spinning {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.materials-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 0;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.6;
}

.empty-text {
  color: #999;
  margin-bottom: 20px;
  font-size: 14px;
}

.empty-btn {
  border-radius: 20px;
  padding: 0 20px;
}

.material-card {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  border: none;

  &:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
}

.avatar-section {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #e6f7ff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

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

.avatar-icon-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  top: 0;
  left: 0;
}

.avatar-icon {
  font-size: 24px;
  color: #1677ff;
}

.header-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.creator-name {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  line-height: 1.2;
}

.material-id {
  background: #e6f7ff;
  color: #1677ff;
  font-size: 12px;
  font-weight: 600;
  border-radius: 12px;
  padding: 2px 8px;
  display: inline-block;
}

.material-title {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin-bottom: 12px;
  line-height: 1.4;
}

.content-icon {
  font-size: 16px;
  color: #1677ff;
}

.type-tag {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
}

.menu-btn {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  color: #999;
  border-radius: 4px;

  &:hover {
    background: #f5f5f5;
    color: #666;
  }
}

.menu-dropdown {
  position: absolute;
  right: 0;
  top: 100%;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  min-width: 120px;
  padding: 4px;
  margin-top: 4px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
  color: #333;
  transition: background 0.2s;

  &:hover {
    background: #f5f5f5;
  }

  &.danger {
    color: #ff4d4f;

    &:hover {
      background: #fff2f0;
    }
  }
}

.link-preview {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 8px;
  margin-bottom: 16px;
  border: 1px solid #e9ecef;
  cursor: pointer;
  transition: all 0.2s ease;

  &:hover {
    background: #e9ecef;
    border-color: #1677ff;
  }
}

.link-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;

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

.link-content {
  flex: 1;
  min-width: 0;
}

.link-title {
  font-size: 14px;
  font-weight: 500;
  color: #333;
  margin-bottom: 4px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-url {
  font-size: 12px;
  color: #666;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-buttons {
  display: flex;
  margin-top: 16px;
  justify-content: space-between;
}
.action-btn-group {
  display: flex;
  gap: 8px;
}

.action-btn {
  border-radius: 6px;
  font-size: 16px;
  padding: 6px 12px;
  border: 1px solid #d9d9d9;
  background: white;
  color: #333;

  &:hover {
    border-color: #1677ff;
    color: #1677ff;
  }
}

.delete-btn {
  border-radius: 6px;
  font-size: 16px;
  padding: 6px 12px;
  background: #ff4d4f;
  border-color: #ff4d4f;
  color: white;

  &:hover {
    background: #ff7875;
    border-color: #ff7875;
  }
}

.pagination-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  background: white;
  border-top: 1px solid #f0f0f0;
}

// 内容类型标签样式
.content-type-tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid currentColor;
}

// 图片类型预览样式
.material-image-preview {
  margin: 12px 0;

  .image-grid {
    display: grid;
    gap: 8px;
    width: 100%;

    // 1张图片：宽度拉伸，高度自适应
    &.single {
      grid-template-columns: 1fr;

      img {
        width: 100%;
        height: auto;
        object-fit: cover;
        border-radius: 8px;
      }
    }

    // 2张图片：左右并列
    &.double {
      grid-template-columns: 1fr 1fr;

      img {
        width: 100%;
        height: 120px;
        object-fit: cover;
        border-radius: 8px;
      }
    }

    // 3张图片：三张并列
    &.triple {
      grid-template-columns: 1fr 1fr 1fr;

      img {
        width: 100%;
        height: 100px;
        object-fit: cover;
        border-radius: 8px;
      }
    }

    // 4张图片：2x2网格布局
    &.quad {
      grid-template-columns: repeat(2, 1fr);

      img {
        width: 100%;
        height: 140px;
        object-fit: cover;
        border-radius: 8px;
      }
    }

    // 5张及以上：网格布局
    &.grid {
      grid-template-columns: repeat(3, 1fr);

      img {
        width: 100%;
        height: 100px;
        object-fit: cover;
        border-radius: 8px;
      }

      .image-more {
        display: flex;
        align-items: center;
        justify-content: center;
        background: #f5f5f5;
        border-radius: 8px;
        color: #666;
        font-size: 12px;
        font-weight: 500;
        height: 100px;
      }
    }
  }

  .no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 80px;
    background: #f5f5f5;
    border-radius: 8px;
    color: #999;
    font-size: 14px;
  }
}

// 链接类型预览样式
.material-link-preview {
  margin: 12px 0;

  .link-card {
    display: flex;
    background: #e9f8ff;
    border-radius: 8px;
    padding: 12px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid #cde6ff;
    &:hover {
      background: #cde6ff;
    }

    .link-image {
      width: 60px;
      height: 60px;
      margin-right: 12px;
      flex-shrink: 0;

      img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        border-radius: 6px;
      }
    }

    .link-content {
      flex: 1;
      min-width: 0;

      .link-title {
        font-weight: 500;
        margin-bottom: 4px;
        color: #333;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }

      .link-url {
        font-size: 12px;
        color: #666;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
  }
}

// 视频类型预览样式
.material-video-preview {
  margin: 12px 0;

  .video-thumbnail {
    video {
      width: 100%;
      max-height: 200px;
      border-radius: 8px;
    }
  }

  .no-video {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 120px;
    background: #f5f5f5;
    border-radius: 8px;
    color: #999;
    font-size: 14px;
  }
}

// 文本类型预览样式
.material-text-preview {
  margin: 12px 0;

  .text-content {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    line-height: 1.6;
    color: #333;
    font-size: 14px;
  }
}

// 小程序类型预览样式
.material-miniprogram-preview {
  margin: 12px 0;

  .miniprogram-card {
    display: flex;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 12px;
    width: 100%;

    img {
      width: 60px;
      height: 60px;
      border-radius: 8px;
      margin-right: 12px;
      flex-shrink: 0;
      object-fit: cover;
    }

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

      .miniprogram-title {
        font-weight: 500;
        color: #333;
        margin-bottom: 4px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
      }
    }
  }
}

// 图文类型预览样式
.material-article-preview {
  margin: 12px 0;

  .article-image {
    margin-bottom: 12px;

    img {
      width: 100%;
      height: 120px;
      object-fit: cover;
      border-radius: 8px;
    }
  }

  .article-content {
    .article-title {
      font-weight: 500;
      color: #333;
      margin-bottom: 8px;
      font-size: 16px;
    }

    .article-text {
      color: #666;
      line-height: 1.6;
      font-size: 14px;
    }
  }
}

// 默认预览样式
.material-default-preview {
  margin: 12px 0;

  .default-content {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    color: #333;
    line-height: 1.6;
  }
}

// AI改写弹框样式
.ai-popup-content {
  padding: 20px;
  max-height: 100vh;
  overflow-y: auto;
  background: #f9fbfd;

  .ai-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e8f4ff;

    h3 {
      font-size: 18px;
      font-weight: 600;
      color: #1677ff;
      margin: 0;
      display: flex;
      align-items: center;

      &::before {
        content: '';
        display: inline-block;
        width: 4px;
        height: 18px;
        background: #1677ff;
        margin-right: 8px;
        border-radius: 2px;
      }
    }
  }

  .ai-form {
    .ai-form-item {
      margin-bottom: 20px;

      .ai-form-label {
        font-size: 15px;
        font-weight: 500;
        color: #333;
        margin-bottom: 6px;
        display: flex;
        align-items: center;

        &::before {
          content: '';
          display: inline-block;
          width: 3px;
          height: 14px;
          background: #1677ff;
          margin-right: 6px;
          border-radius: 2px;
        }
      }

      .ai-result-description {
        font-size: 12px;
        color: #999;
        margin-bottom: 10px;
      }
    }

    .ai-submit {
      margin: 24px 0;

      button {
        height: 44px;
        font-size: 16px;
        border-radius: 8px;
        box-shadow: 0 2px 6px rgba(22, 119, 255, 0.2);
      }
    }

    .ai-result-box {
      background: #ffffff;
      border: 1px solid #e0f0ff;
      border-radius: 8px;
      padding: 16px;
      min-height: 100px;
      max-height: 200px;
      overflow-y: auto;
      box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);

      .ai-loading {
        display: flex;
        justify-content: center;
        align-items: center;
        height: 120px;
      }

      .ai-result-content {
        font-size: 15px;
        line-height: 1.8;
        color: #333;
        white-space: pre-wrap;
        padding: 4px;
      }

      .ai-result-placeholder {
        color: #999;
        text-align: center;
        padding: 30px 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;

        .placeholder-icon {
          font-size: 28px;
          margin-bottom: 10px;
        }

        .placeholder-text {
          font-size: 14px;
          color: #999;
        }
      }
    }

    .ai-replace-action {
      margin-top: 20px;

      button {
        height: 44px;
        font-size: 16px;
        border-radius: 8px;
        background: #1677ff;
        border-color: #1677ff;
        box-shadow: 0 2px 6px rgba(22, 119, 255, 0.2);
        color: #ffffff;

        &:hover, &:focus {
          background: #4096ff;
          border-color: #4096ff;
          color: #ffffff;
        }
      }
    }
  }
}

// 导入弹窗样式
.import-popup-content {
  padding: 20px;
  max-height: 90vh;
  overflow-y: auto;
  background: #ffffff;

  .import-popup-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e8f4ff;

    h3 {
      font-size: 18px;
      font-weight: 600;
      color: #1677ff;
      margin: 0;
      display: flex;
      align-items: center;

      &::before {
        content: '';
        display: inline-block;
        width: 4px;
        height: 18px;
        background: #1677ff;
        margin-right: 8px;
        border-radius: 2px;
      }
    }
  }

  .import-form {
    .import-form-item {
      margin-bottom: 20px;

      .import-form-label {
        font-size: 15px;
        font-weight: 500;
        color: #333;
        margin-bottom: 8px;
        display: flex;
        align-items: center;

        &::before {
          content: '';
          display: inline-block;
          width: 3px;
          height: 14px;
          background: #1677ff;
          margin-right: 6px;
          border-radius: 2px;
        }
      }

      .import-form-control {
        .import-tip {
          font-size: 12px;
          color: #999;
          margin-top: 8px;
          line-height: 1.5;
        }
      }
    }

    .import-actions {
      margin-top: 24px;

      button {
        height: 44px;
        font-size: 16px;
        border-radius: 8px;

        &:first-child {
          box-shadow: 0 2px 6px rgba(22, 119, 255, 0.2);
        }
      }
    }
  }
}
