// 全局变量
$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;
}

/* --- Kanban, toolbar, and modal styles (scoped to customer-service project list) --- */

/* Header actions layout */
.project-content .page-header .header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* View toggle buttons */
.project-content .page-header .header-actions .view-toggle {
  display: inline-flex;
  border: 1px solid $border-color;
  background-color: $bg-white;
  border-radius: 6px;
  overflow: hidden;
}

.project-content .page-header .header-actions .view-toggle button {
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: $text-secondary;
  font-size: 14px;
  cursor: pointer;
  transition: $transition;
}

.project-content .page-header .header-actions .view-toggle button:hover:not(.active) {
  background-color: $bg-light;
  color: $text-primary;
}

.project-content .page-header .header-actions .view-toggle button.active {
  background-color: $primary-light;
  color: $primary-color;
  font-weight: 600;
}

/* Add project button */
.project-content .page-header .header-actions .add-project-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  color: #fff;
  background-color: $primary-color;
  cursor: pointer;
  transition: $transition;
}

.project-content .page-header .header-actions .add-project-btn:hover {
  background-color: #1565c0;
}

.project-content .page-header .header-actions .add-project-btn:active {
  background-color: #0E42CB;
}

/* Kanban layout */
.project-content .kanban-container {
  background-color: transparent;
}

.project-content .kanban-scroll {
  overflow-x: auto;
  padding-bottom: 8px;
}

.project-content .kanban-header,
.project-content .kanban-body {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 320px;
  gap: 16px;
}

/* Column header */
.project-content .kanban-header .kanban-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  background-color: $bg-white;
  border: 1px solid $border-color;
  border-radius: 8px;
  box-shadow: $box-shadow;
}

.project-content .kanban-header .kanban-column-header .column-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: $text-primary;
}

.project-content .kanban-header .kanban-column-header .stage-count {
  font-size: 12px;
  color: $text-light;
  background-color: $bg-light;
  border-radius: 12px;
  padding: 2px 8px;
}

/* Column body */
.project-content .kanban-body .kanban-column {
  min-height: 420px;
  padding: 12px;
  background-color: $bg-white;
  border: 1px dashed $border-color;
  border-radius: 8px;
  box-shadow: $box-shadow;
}

/* Card */
.project-content .kanban-card {
  background-color: $bg-white;
  border: 1px solid $border-color;
  border-radius: 8px;
  box-shadow: $box-shadow;
  padding: 12px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.project-content .kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.project-content .kanban-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.project-content .kanban-card-header .left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-content .kanban-card-header .left .project-name {
  margin: 0;
  font-size: 16px;
  color: $text-primary;
}

.project-content .kanban-card-header .left .project-id {
  font-size: 12px;
  color: $text-light;
}

.project-content .kanban-card-header .right {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Pending badge */
.project-content .pending-badge {
  color: $warning-color;
  background-color: #fff8e1;
  border: 1px solid #ffe0b2;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

.project-content .kanban-card-content {
  font-size: 13px;
  color: $text-secondary;
}

.project-content .kanban-card-content .stage-badge {
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 12px;
}

.project-content .kanban-card-content .progress-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.project-content .kanban-card-content .progress-line .progress-bar {
  flex: 1;
  height: 6px;
  background-color: $bg-light;
  border-radius: 3px;
  overflow: hidden;
}

.project-content .kanban-card-content .progress-line .progress-fill {
  height: 100%;
  background-color: $primary-color;
}

.project-content .kanban-card-content .progress-line .progress-text {
  font-size: 12px;
  color: $text-secondary;
}

.project-content .kanban-card-footer {
  display: flex;
  justify-content: flex-end;
}

.project-content .kanban-card-footer .btn-link {
  border: none;
  background: none;
  color: $primary-color;
  cursor: pointer;
  padding: 6px 8px;
}

.project-content .kanban-card-footer .btn-link:hover {
  text-decoration: underline;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 480px;
  max-width: 90vw;
  background: $bg-white;
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
  z-index: 1001;
  overflow: hidden;
}

.modal .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid $border-color;
}

.modal .modal-header h3 {
  margin: 0;
  font-size: 18px;
  color: $text-primary;
}

.modal .modal-header .close-btn {
  border: none;
  background: none;
  font-size: 16px;
  color: $text-secondary;
  cursor: pointer;
}

.modal .modal-header .close-btn:hover {
  color: $text-primary;
}

.modal .modal-body {
  padding: 16px;
}

.modal .modal-body .form-item {
  margin-bottom: 12px;
}

.modal .modal-body .form-item label {
  display: block;
  font-size: 13px;
  color: $text-secondary;
  margin-bottom: 6px;
}

.modal .modal-body .form-item input,
.modal .modal-body .form-item textarea {
  width: 100%;
  border: 1px solid $border-color;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 14px;
  background: $bg-white;
  outline: none;
}

.modal .modal-body .form-item input:focus,
.modal .modal-body .form-item textarea:focus {
  border-color: $primary-color;
  box-shadow: 0 0 0 2px rgba(25, 118, 210, 0.1);
}

.modal .modal-body .tip {
  font-size: 12px;
  color: $text-light;
  margin-top: 8px;
}

.modal .modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 12px 16px;
  border-top: 1px solid $border-color;
}

.modal .modal-footer .btn-secondary,
.modal .modal-footer .btn-primary {
  border: none;
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
}

.modal .modal-footer .btn-secondary {
  background: $bg-light;
  color: $text-primary;
}

.modal .modal-footer .btn-secondary:hover {
  background: $border-color;
}

.modal .modal-footer .btn-primary {
  background: $primary-color;
  color: #fff;
}

.modal .modal-footer .btn-primary:hover {
  background: #1565c0;
}

.modal .modal-footer .btn-primary:active {
  background: #0E42CB;
}

// 监控大盘视图样式
.dashboard-container {
  width: 100%;
  height: 100%;
  min-height: 800px;
  border: none;
  
  iframe {
    width: 100%;
    height: 100%;
    min-height: 800px;
    border: none;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }
}

// 视图切换按钮样式优化
.view-toggle-buttons {
  .btn-view-toggle {
    &.active {
      background-color: $primary-color;
      color: white;
      
      // 监控大盘按钮特殊样式
      &[data-view="dashboard"] {
        background-color: #9c27b0; // 紫色主题色
        border-color: #9c27b0;
        
        &:hover {
          background-color: #7b1fa2;
          border-color: #7b1fa2;
        }
      }
    }
  }
}
