// 全局变量定义
$primary-color: #165DFF;
$secondary-color: #6B7280;
$success-color: #00B42A;
$warning-color: #FFAA00;
$error-color: #F53F3F;
$text-primary: #333333;
$text-secondary: #666666;
$text-tertiary: #999999;
$border-color: #E5E7EB;
$bg-light: #F9FAFB;
$bg-white: #FFFFFF;
$shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
$shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
$shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

// 主容器
.project-management {
  padding: 24px;
  min-height: 100vh;
  background-color: $bg-light;
}

// 页面标题区域
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid $border-color;

  .header-left {
    .page-title {
      font-size: 24px;
      font-weight: 600;
      color: $text-primary;
      margin: 0 0 4px 0;
    }

    .page-description {
      font-size: 14px;
      color: $text-tertiary;
      margin: 0;
    }
  }

  .header-right {
    .create-btn {
      display: flex;
      align-items: center;
      gap: 8px;
      background-color: $primary-color;
      color: $bg-white;
      border-radius: 8px;
      padding: 8px 16px;
      font-size: 14px;
      font-weight: 500;
      transition: all 0.2s ease;
      box-shadow: $shadow-sm;

      &:hover {
        background-color: #0E4BD8;
        box-shadow: $shadow-md;
        transform: translateY(-1px);
      }
    }
  }
}

// 搜索和筛选区域
.search-filter-section {
  display: flex;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;

  .search-input-wrapper {
    flex: 1;
    min-width: 300px;
    position: relative;
    display: flex;
    align-items: center;

    .search-icon {
      position: absolute;
      left: 12px;
      color: $text-tertiary;
      z-index: 1;
    }

    .search-input {
      width: 100%;
      padding: 10px 12px 10px 40px;
      border: 1px solid $border-color;
      border-radius: 8px;
      font-size: 14px;
      color: $text-primary;
      background-color: $bg-white;
      transition: all 0.2s ease;
      box-shadow: $shadow-sm;

      &:focus {
        outline: none;
        border-color: $primary-color;
        box-shadow: 0 0 0 3px rgba(22, 93, 255, 0.1);
      }

      &::placeholder {
        color: $text-tertiary;
      }
    }

    .clear-search-btn {
      position: absolute;
      right: 8px;
      color: $text-tertiary;
      padding: 4px;
    }
  }

  .filter-controls {
    display: flex;
    gap: 12px;
    align-items: center;

    .status-filter-wrapper {
      .status-filter {
        min-width: 160px;
        border: 1px solid $border-color;
        border-radius: 8px;
        background-color: $bg-white;
        box-shadow: $shadow-sm;

        .mat-select-trigger {
          height: 40px;
          font-size: 14px;
          color: $text-primary;
        }
      }
    }

    .filter-btn {
      display: flex;
      align-items: center;
      gap: 6px;
      color: $primary-color;
      border: 1px solid $primary-color;
      border-radius: 8px;
      padding: 8px 16px;
      font-size: 14px;
      font-weight: 500;
      background-color: $bg-white;
      transition: all 0.2s ease;

      &:hover {
        background-color: $primary-color;
        color: $bg-white;
      }
    }
  }
}

// 统计卡片区域
.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;

  .stat-card {
    background-color: $bg-white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: $shadow-sm;
    text-align: center;
    transition: all 0.2s ease;

    &:hover {
      box-shadow: $shadow-md;
      transform: translateY(-2px);
    }

    .stat-value {
      font-size: 28px;
      font-weight: 700;
      color: $text-primary;
      margin-bottom: 4px;
    }

    .stat-label {
      font-size: 14px;
      color: $text-tertiary;
    }
  }
}

// 项目表格容器
.project-table-container {
  background-color: $bg-white;
  border-radius: 12px;
  box-shadow: $shadow-sm;
  overflow: hidden;
  margin-bottom: 24px;

  .project-table {
    width: 100%;
    border-collapse: collapse;

    .table-header {
      background-color: $bg-light;
      font-weight: 600;
      color: $text-secondary;
      font-size: 13px;
      text-align: left;
      padding: 16px 20px;
      border-bottom: 1px solid $border-color;
      cursor: pointer;
      transition: background-color 0.2s ease;

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

      .header-content {
        display: flex;
        align-items: center;
        justify-content: space-between;
      }

      .sort-icon {
        opacity: 0.5;
      }
    }

    .table-cell {
      padding: 16px 20px;
      border-bottom: 1px solid $border-color;
      font-size: 14px;
      color: $text-primary;
      vertical-align: middle;

      &:last-child {
        text-align: right;
      }

      .project-name {
        a {
          color: $primary-color;
          text-decoration: none;
          font-weight: 500;
          transition: color 0.2s ease;

          &:hover {
            color: #0E4BD8;
            text-decoration: underline;
          }
        }
      }

      .status-badge {
        display: inline-block;
        padding: 4px 12px;
        border-radius: 16px;
        font-size: 12px;
        font-weight: 500;
        color: $bg-white;
        text-align: center;
      }

      .progress-container {
        display: flex;
        align-items: center;
        gap: 12px;

        .progress-bar {
          flex: 1;
          height: 8px;
          border-radius: 4px;
          background-color: $border-color;
          overflow: hidden;
          position: relative;

          &::before {
            content: '';
            position: absolute;
            top: 0;
            left: 0;
            height: 100%;
            border-radius: 4px;
            transition: width 0.3s ease;
          }
        }

        .progress-text {
          min-width: 40px;
          font-size: 13px;
          color: $text-secondary;
          font-weight: 500;
        }
      }

      .action-buttons {
        display: flex;
        gap: 8px;
        justify-content: flex-end;

        .action-btn {
          width: 36px;
          height: 36px;
          border-radius: 6px;
          display: flex;
          align-items: center;
          justify-content: center;
          transition: all 0.2s ease;
          background-color: transparent;
          border: 1px solid $border-color;
          color: $text-secondary;

          &:hover {
            border-color: currentColor;
            transform: translateY(-1px);
          }

          &.mat-primary {
            color: $primary-color;
          }

          &.mat-accent {
            color: $warning-color;
          }

          &.mat-warn {
            color: $error-color;
          }
        }
      }
    }

    tr:last-child .table-cell {
      border-bottom: none;
    }

    tr:hover .table-cell {
      background-color: $bg-light;
    }
  }

  // 空状态
  .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;

    svg {
      margin-bottom: 16px;
      opacity: 0.5;
    }

    p {
      font-size: 16px;
      color: $text-tertiary;
      margin-bottom: 24px;
    }

    button {
      border-radius: 8px;
      padding: 8px 24px;
      font-size: 14px;
      font-weight: 500;
    }
  }
}

// 分页控件
.pagination-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background-color: $bg-white;
  border-radius: 12px;
  box-shadow: $shadow-sm;

  .pagination-info {
    font-size: 14px;
    color: $text-tertiary;
  }

  .pagination-buttons {
    display: flex;
    align-items: center;
    gap: 8px;

    button {
      padding: 6px 12px;
      border-radius: 6px;
      font-size: 13px;
      font-weight: 500;
      transition: all 0.2s ease;
      min-width: auto;

      &:disabled {
        opacity: 0.5;
        cursor: not-allowed;
      }

      &.active {
        background-color: $primary-color;
        color: $bg-white;
      }
    }

    .page-numbers {
      display: flex;
      gap: 4px;
    }
  }
}

// 响应式设计
@media (max-width: 1200px) {
  .project-table {
    .table-header,
    .table-cell {
      padding: 12px 16px;
    }
  }
}

@media (max-width: 992px) {
  .project-management {
    padding: 16px;
  }

  .stats-cards {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }

  .search-filter-section {
    flex-direction: column;
    gap: 12px;
  }

  .search-input-wrapper {
    min-width: 100% !important;
  }

  .pagination-controls {
    flex-direction: column;
    gap: 16px;

    .pagination-buttons {
      flex-wrap: wrap;
      justify-content: center;
    }
  }
}

@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    gap: 16px;
    align-items: flex-start;
  }

  .stats-cards {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
  }

  .stat-card {
    padding: 16px;

    .stat-value {
      font-size: 24px;
    }
  }

  .project-table-container {
    overflow-x: auto;
  }
}

@media (max-width: 480px) {
  .project-management {
    padding: 12px;
  }

  .stats-cards {
    grid-template-columns: 1fr 1fr;
  }
}