// 全局变量
$primary-color: #1976d2;
$primary-light: #e3f2fd;
$secondary-color: #6c757d;
$success-color: #4caf50;
$warning-color: #ff9800;
$danger-color: #f44336;
$text-primary: #333;
$text-secondary: #666;
$text-light: #999;
$bg-light: #f5f7fa;
$bg-white: #fff;
$border-color: #e1e5e9;
$box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
$transition: all 0.3s ease;

// 主容器
.project-list-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  background-color: $bg-light;
}

// 顶部导航栏
.top-navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 24px;
  height: 64px;
  background-color: $bg-white;
  border-bottom: 1px solid $border-color;
  box-shadow: $box-shadow;

  .navbar-left {
    display: flex;
    align-items: center;
    gap: 16px;

    .menu-toggle {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 40px;
      height: 40px;
      border: none;
      background: none;
      color: $text-primary;
      cursor: pointer;
      transition: $transition;

      &:hover {
        color: $primary-color;
        background-color: $bg-light;
        border-radius: 4px;
      }
    }

    .app-title {
      font-size: 18px;
      font-weight: 600;
      color: $text-primary;
      margin: 0;
    }
  }

  .navbar-right {
    display: flex;
    align-items: center;
    gap: 16px;

    .notification-btn {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 40px;
      height: 40px;
      border: none;
      background: none;
      color: $text-primary;
      cursor: pointer;
      position: relative;
      transition: $transition;

      &:hover {
        color: $primary-color;
        background-color: $bg-light;
        border-radius: 4px;
      }

      .notification-badge {
        position: absolute;
        top: 8px;
        right: 8px;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 16px;
        height: 16px;
        font-size: 10px;
        font-weight: 600;
        color: white;
        background-color: $danger-color;
        border-radius: 50%;
      }
    }

    .user-profile {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 8px 12px;
      border-radius: 6px;
      transition: $transition;

      &:hover {
        background-color: $bg-light;
      }

      .user-avatar {
        width: 32px;
        height: 32px;
        border-radius: 50%;
        object-fit: cover;
      }

      .user-name {
        font-size: 14px;
        font-weight: 500;
        color: $text-primary;
      }
    }
  }
}

// 主要内容区
.dashboard-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

// 左侧侧边栏
.sidebar {
  width: 240px;
  background-color: $bg-white;
  border-right: 1px solid $border-color;
  overflow-y: auto;
  flex-shrink: 0;

  .sidebar-nav {
    padding: 16px 0;

    .nav-item {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 12px 24px;
      color: $text-secondary;
      text-decoration: none;
      transition: $transition;

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

      &.active {
        color: $primary-color;
        background-color: #e3f2fd;
        border-left: 3px solid $primary-color;
        padding-left: 21px;
      }

      svg {
        flex-shrink: 0;
      }

      span {
        font-size: 14px;
        font-weight: 500;
      }
    }
  }
}

// 右侧主要内容
.project-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;

  // 页面标题和操作
  .page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;

    h2 {
      font-size: 24px;
      font-weight: 600;
      color: $text-primary;
      margin: 0;
    }

    .header-actions {
      .search-container {
        .search-box {
          display: flex;
          align-items: center;
          width: 320px;
          border: 1px solid $border-color;
          border-radius: 6px;
          overflow: hidden;
          transition: $transition;

          &:focus-within {
            border-color: $primary-color;
            box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.1);
          }

          svg:first-child {
            margin-left: 12px;
            color: $text-light;
          }

          input {
            flex: 1;
            padding: 8px 12px;
            border: none;
            outline: none;
            font-size: 14px;
            color: $text-primary;
            background-color: $bg-white;
          }

          .search-btn {
            display: flex;
            align-items: center;
            justify-content: center;
            width: 40px;
            height: 100%;
            border: none;
            color: $primary-color;
            background-color: $primary-light;
            cursor: pointer;
            transition: $transition;

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

  // 筛选和排序工具栏
  .filter-toolbar {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 16px 20px;
    margin-bottom: 24px;
    background-color: $bg-white;
    border-radius: 8px;
    box-shadow: $box-shadow;

    .filter-group {
      display: flex;
      align-items: center;
      gap: 8px;

      label {
        font-size: 14px;
        font-weight: 500;
        color: $text-secondary;
        white-space: nowrap;
      }

      select {
        padding: 6px 12px;
        border: 1px solid $border-color;
        border-radius: 4px;
        font-size: 14px;
        color: $text-primary;
        background-color: $bg-white;
        cursor: pointer;
        transition: $transition;

        &:focus {
          outline: none;
          border-color: $primary-color;
          box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.1);
        }

        &:hover {
          border-color: $primary-color;
        }
      }
    }

    .filter-results {
      margin-left: auto;
      font-size: 14px;
      color: $text-secondary;
    }
  }

  // 项目网格布局
  .project-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 24px;

    // 项目卡片
    .project-card {
      display: flex;
      flex-direction: column;
      padding: 20px;
      background-color: $bg-white;
      border-radius: 8px;
      box-shadow: $box-shadow;
      transition: $transition;
      border: 1px solid transparent;

      &:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
        border-color: $primary-light;
      }

      // 卡片头部
      .card-header {
        margin-bottom: 16px;

        .card-title-section {
          display: flex;
          justify-content: space-between;
          align-items: flex-start;
          margin-bottom: 8px;

          .project-name {
            font-size: 16px;
            font-weight: 600;
            color: $text-primary;
            margin: 0;
            flex: 1;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }

          .project-id {
            font-size: 12px;
            color: $text-light;
            margin-left: 8px;
          }
        }

        .card-tags {
          display: flex;
          gap: 8px;
          flex-wrap: wrap;

          .project-tag {
            padding: 4px 12px;
            font-size: 12px;
            font-weight: 500;
            color: $primary-color;
            background-color: $primary-light;
            border-radius: 16px;
          }

          .urgent-tag {
            padding: 4px 12px;
            font-size: 12px;
            font-weight: 500;
            color: $danger-color;
            background-color: #ffebee;
            border-radius: 16px;
          }
        }
      }

      // 卡片内容
      .card-content {
        flex: 1;

        // 信息项
        .info-item {
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin-bottom: 12px;

          .info-label {
            font-size: 13px;
            color: $text-light;
          }

          .info-value {
            font-size: 14px;
            font-weight: 500;
            color: $text-primary;
          }

          .status-badge {
            padding: 4px 12px;
            border-radius: 16px;
            font-size: 12px;
            font-weight: 500;
          }

          .stage-badge {
            padding: 4px 12px;
            border-radius: 16px;
            font-size: 12px;
            font-weight: 500;
          }

          // 状态样式
          .status-active {
            color: $primary-color;
            background-color: $primary-light;
          }

          .status-completed {
            color: $success-color;
            background-color: #e8f5e9;
          }

          .status-paused {
            color: $secondary-color;
            background-color: #f5f5f5;
          }

          .status-overdue {
            color: $danger-color;
            background-color: #ffebee;
          }

          // 阶段样式
          .stage-communication {
            color: #9c27b0;
            background-color: #f3e5f5;
          }

          .stage-modeling {
            color: #2196f3;
            background-color: #e3f2fd;
          }

          .stage-decoration {
            color: #009688;
            background-color: #e0f2f1;
          }

          .stage-rendering {
            color: #ff5722;
            background-color: #fbe9e7;
          }

          .stage-postproduction {
            color: #ff9800;
            background-color: #fff3e0;
          }

          .stage-completed {
            color: $success-color;
            background-color: #e8f5e9;
          }
        }

        // 进度部分
        .progress-section {
          margin-bottom: 16px;

          .progress-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 8px;

            .progress-label {
              font-size: 13px;
              color: $text-light;
            }

            .progress-percentage {
              font-size: 14px;
              font-weight: 600;
              color: $primary-color;
            }
          }

          .progress-bar {
            height: 6px;
            background-color: $bg-light;
            border-radius: 3px;
            overflow: hidden;

            .progress-fill {
              height: 100%;
              border-radius: 3px;
              transition: width 0.6s ease;
            }
          }
        }

        // 时间信息
        .timeline-info {
          margin-bottom: 16px;

          .time-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 8px;

            .time-label {
              font-size: 13px;
              color: $text-light;
            }

            .time-value {
              font-size: 13px;
              color: $text-secondary;
            }

            .deadline {
              &.overdue {
                color: $danger-color;
                font-weight: 500;
              }

              &.urgent {
                color: $warning-color;
                font-weight: 500;
              }
            }
          }
        }

        // 高优先级需求
        .needs-section {
          padding-top: 12px;
          border-top: 1px solid $border-color;

          .needs-label {
            display: block;
            font-size: 13px;
            color: $text-light;
            margin-bottom: 8px;
          }

          .needs-list {
            margin: 0;
            padding: 0;
            list-style: none;

            li {
              display: flex;
              align-items: center;
              gap: 6px;
              font-size: 13px;
              color: $warning-color;
              margin-bottom: 4px;

              svg {
                flex-shrink: 0;
                color: $warning-color;
              }
            }
          }
        }
      }

      // 卡片底部
      .card-footer {
        display: flex;
        gap: 12px;
        margin-top: 16px;
        padding-top: 16px;
        border-top: 1px solid $border-color;

        .secondary-btn,
        .primary-btn {
          display: flex;
          align-items: center;
          gap: 6px;
          padding: 8px 16px;
          border: none;
          border-radius: 6px;
          font-size: 14px;
          font-weight: 500;
          cursor: pointer;
          transition: $transition;
        }

        .primary-btn {
          flex: 1;
          color: white;
          background-color: $primary-color;

          &:hover {
            background-color: #1565c0;
          }
          
          &:active {
            background-color: #0E42CB;
          }
        }

        .secondary-btn {
          flex: 1;
          color: $text-primary;
          background-color: $bg-light;

          &:hover {
            background-color: $border-color;
          }
          
          &:active {
            background-color: #D1D1D6;
          }
        }

        .card-action {
          justify-content: center;
        }
      }
    }
  }

  // 分页控件
  .pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 20px;
    background-color: $bg-white;
    border-radius: 8px;
    box-shadow: $box-shadow;

    .pagination-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        border: 1px solid $border-color;
        background-color: $bg-white;
        color: $text-secondary;
        border-radius: 4px;
        cursor: pointer;
        transition: $transition;
        font-size: 14px;
        font-weight: 500;

        &:hover:not(:disabled) {
          color: $primary-color;
          border-color: $primary-color;
        }

        &:active:not(:disabled):not(.active) {
          background-color: $primary-light;
        }

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

        &.active:active {
          background-color: #0E42CB;
        }

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

    .pagination-ellipsis {
      font-size: 14px;
      color: $text-light;
      padding: 0 8px;
    }
  }
}

// 响应式设计
@media (max-width: 1200px) {
  .project-grid {
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)) !important;
  }
}

@media (max-width: 1024px) {
  .sidebar {
    width: 200px;
  }

  .project-content {
    padding: 16px;
  }

  .filter-toolbar {
    flex-wrap: wrap;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 16px;
  }

  .header-actions {
    width: 100%;
  }

  .search-box {
    width: 100% !important;
  }
}

@media (max-width: 768px) {
  .top-navbar {
    padding: 0 16px;

    .navbar-right {
      gap: 8px;
    }

    .user-name {
      display: none;
    }
  }

  .sidebar {
    display: none;
  }

  .filter-toolbar {
    gap: 16px;
    padding: 12px 16px;

    .filter-group {
      flex: 1 1 calc(50% - 8px);
    }

    .filter-results {
      width: 100%;
      margin-left: 0;
      text-align: center;
    }
  }

  .project-grid {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }

  .pagination {
    padding: 16px;
  }

  .pagination-btn {
    width: 32px !important;
    height: 32px !important;
    font-size: 13px !important;
  }
}

// 动画效果
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.project-card {
  animation: fadeIn 0.4s ease-out;
}

.project-card:nth-child(2n) {
  animation-delay: 0.1s;
}

.project-card:nth-child(3n) {
  animation-delay: 0.2s;
}

.project-card:nth-child(4n) {
  animation-delay: 0.3s;
}