// 项目详情核心组件样式

// CSS Variables
:host {
  --primary-color: #3880ff;
  --primary-rgb: 56, 128, 255;
  --secondary-color: #0cd1e8;
  --tertiary-color: #7044ff;
  --success-color: #2dd36f;
  --warning-color: #ffc409;
  --danger-color: #eb445a;
  --dark-color: #222428;
  --medium-color: #92949c;
  --light-color: #f4f5f8;
  --light-shade: #d7d8da;
  --white: #ffffff;
}

// Header Container
.header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--white);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

// Toolbar
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: 0 16px;
  background: var(--white);
  border-bottom: 1px solid var(--light-shade);

  .buttons-start,
  .buttons-end {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
  }

  .title {
    flex: 1;
    font-size: 20px;
    font-weight: 600;
    color: var(--dark-color);
    text-align: center;
    padding: 0 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .back-button,
  .icon-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s;
    padding: 0;

    &:hover {
      background-color: rgba(var(--primary-color), 0.1);
    }

    &:active {
      background-color: rgba(var(--primary-color), 0.2);
    }

    .icon {
      width: 24px;
      height: 24px;
      color: var(--primary-color);
    }
  }
}

// 阶段导航工具栏
.stage-toolbar {
  background: var(--white);
  border-bottom: 1px solid var(--light-shade);
  padding: 12px 0;

  .stage-navigation {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;

    &::-webkit-scrollbar {
      display: none;
    }

    .stage-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 4px;
      cursor: pointer;
      transition: all 0.3s;
      flex-shrink: 0;
      min-width: 60px;

      .stage-circle {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-weight: 600;
        font-size: 14px;
        transition: all 0.3s;
        border: 2px solid var(--light-shade);
        background-color: var(--white);
        color: var(--medium-color);

        .icon {
          width: 20px;
          height: 20px;
        }
      }

      .stage-label {
        font-size: 11px;
        color: var(--medium-color);
        text-align: center;
        white-space: nowrap;
      }

      // 已完成状态
      &.completed {
        .stage-circle {
          background-color: var(--success-color);
          border-color: var(--success-color);
          color: var(--white);
        }

        .stage-label {
          color: var(--success-color);
        }
      }

      // 进行中状态
      &.active {
        .stage-circle {
          background-color: var(--primary-color);
          border-color: var(--primary-color);
          color: var(--white);
          box-shadow: 0 0 0 4px rgba(56, 128, 255, 0.2);
          transform: scale(1.1);
        }

        .stage-label {
          color: var(--primary-color);
          font-weight: 600;
        }
      }

      // 待开始状态
      &.pending {
        .stage-circle {
          background-color: var(--white);
          border-color: var(--light-shade);
          color: var(--medium-color);
        }
      }
    }

    .stage-connector {
      flex: 1;
      height: 2px;
      background-color: var(--light-shade);
      margin: 0 8px;
      margin-bottom: 20px;
      transition: background-color 0.3s;
      min-width: 20px;

      &.completed {
        background-color: var(--success-color);
      }
    }
  }
}

// Content Container
.content {
  position: relative;
  width: 100%;
  height: calc(100vh - 80px); // 减去阶段导航工具栏的高度，为底部卡片留空间
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background-color: var(--light-color);
}

// 加载和错误容器
.loading-container,
.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 20px;
  text-align: center;

  p {
    color: var(--medium-color);
    margin: 0;
    font-size: 14px;
  }
}

// Spinner
.spinner {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  position: relative;

  .spinner-circle {
    width: 100%;
    height: 100%;
    border: 4px solid var(--light-shade);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
}

@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

// Error Container
.error-container {
  .error-icon {
    width: 64px;
    height: 64px;
    color: var(--danger-color);
    margin-bottom: 16px;
  }

  .button {
    margin-top: 16px;
    padding: 10px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    background-color: var(--primary-color);
    color: var(--white);

    &.outline {
      background-color: transparent;
      border: 2px solid var(--primary-color);
      color: var(--primary-color);

      &:hover {
        background-color: var(--primary-color);
        color: var(--white);
      }
    }

    &:active {
      transform: scale(0.95);
    }
  }
}

// 客户快速查看
.customer-quick-view {
  padding: 12px 12px 0;

  .card {
    margin: 0;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden;

    .card-content {
      padding: 12px;

      .customer-info {
        display: flex;
        align-items: center;
        gap: 12px;

        .avatar {
          width: 48px;
          height: 48px;
          flex-shrink: 0;
          border-radius: 50%;
          overflow: hidden;
          background-color: var(--light-color);
          display: flex;
          align-items: center;
          justify-content: center;

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

          .avatar-icon {
            width: 48px;
            height: 48px;
            color: var(--medium-color);
          }
        }

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

          h3 {
            margin: 0 0 4px;
            font-size: 16px;
            font-weight: 600;
            color: var(--dark-color);
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
          }

          p {
            margin: 0 0 6px;
            font-size: 13px;
            color: var(--medium-color);
          }

          .tags {
            display: flex;
            flex-wrap: wrap;
            gap: 6px;

            .badge {
              display: inline-block;
              font-size: 11px;
              padding: 4px 8px;
              border-radius: 6px;
              font-weight: 600;
              white-space: nowrap;

              &.badge-primary {
                background-color: rgba(56, 128, 255, 0.15);
                color: var(--primary-color);
              }

              &.badge-success {
                background-color: rgba(45, 211, 111, 0.15);
                color: var(--success-color);
              }

              &.badge-warning {
                background-color: rgba(255, 196, 9, 0.15);
                color: var(--warning-color);
              }
            }
          }
        }
      }
    }
  }
}

// 阶段内容区域
.stage-content {
  padding: 12px;
  padding-bottom: 120px; // 为新的固定底部卡片留空间
}

// 通用卡片样式
.card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  margin-bottom: 16px;
  overflow: hidden;

  .card-header {
    padding: 16px;
    border-bottom: 1px solid var(--light-shade);

    .card-title {
      display: flex;
      align-items: center;
      gap: 8px;
      margin: 0;
      font-size: 16px;
      font-weight: 600;
      color: var(--dark-color);

      .icon {
        width: 20px;
        height: 20px;
        color: var(--primary-color);
      }
    }

    .card-subtitle {
      margin: 4px 0 0;
      font-size: 12px;
      color: var(--medium-color);
    }
  }

  .card-content {
    padding: 16px;
  }
}

// Badge 组件增强
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;

  &.badge-secondary {
    background: var(--secondary-color);
    color: white;
  }

  &.badge-tertiary {
    background: var(--tertiary-color);
    color: white;
  }

  &.badge-danger {
    background: var(--danger-color);
    color: white;
  }

  &.badge-medium {
    background: var(--medium-color);
    color: white;
  }

  &.badge-light {
    background: var(--light-color);
    color: var(--dark-color);
  }
}

// 图标样式
.icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;

  &.icon-sm {
    width: 14px;
    height: 14px;
  }

  &.icon-md {
    width: 24px;
    height: 24px;
  }

  &.icon-lg {
    width: 32px;
    height: 32px;
  }
}

// 按钮样式
.btn {
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  border: none;
  outline: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;

  &.btn-primary {
    background: var(--primary-color);
    color: white;

    &:hover {
      background: #2f6ce5;
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(56, 128, 255, 0.3);
    }

    &:active {
      transform: translateY(0);
    }
  }

  &.btn-secondary {
    background: var(--secondary-color);
    color: white;

    &:hover {
      background: #0bb8d4;
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(12, 209, 232, 0.3);
    }

    &:active {
      transform: translateY(0);
    }
  }

  &.btn-success {
    background: var(--success-color);
    color: white;

    &:hover {
      background: #28ba62;
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(45, 211, 111, 0.3);
    }

    &:active {
      transform: translateY(0);
    }
  }

  &.btn-outline {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);

    &:hover {
      background: var(--primary-color);
      color: white;
    }

    &:active {
      transform: scale(0.98);
    }
  }

  &.btn-light {
    background: var(--light-color);
    color: var(--dark-color);

    &:hover {
      background: var(--light-shade);
    }

    &:active {
      transform: scale(0.98);
    }
  }

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

  .icon {
    width: 20px;
    height: 20px;
  }
}

// 底部操作栏
.footer-toolbar {
  background: white;
  border-top: 1px solid var(--light-shade);
  padding: 12px 16px;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 90;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);

  .action-buttons {
    display: flex;
    gap: 12px;
    max-width: 800px;
    margin: 0 auto;

    .btn {
      flex: 1;
    }
  }
}

// 表单样式
.form-group {
  margin-bottom: 20px;

  .form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--dark-color);

    .required {
      color: var(--danger-color);
      margin-left: 4px;
    }
  }

  .form-input,
  .form-textarea,
  .form-select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--light-shade);
    border-radius: 8px;
    font-size: 14px;
    color: var(--dark-color);
    background: white;
    transition: all 0.3s;

    &:focus {
      outline: none;
      border-color: var(--primary-color);
      box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
    }

    &::placeholder {
      color: var(--medium-color);
    }

    &:disabled {
      background: var(--light-color);
      cursor: not-allowed;
    }
  }

  .form-textarea {
    min-height: 100px;
    resize: vertical;
    font-family: inherit;
  }

  .form-help {
    margin-top: 6px;
    font-size: 12px;
    color: var(--medium-color);
  }

  .form-error {
    margin-top: 6px;
    font-size: 12px;
    color: var(--danger-color);
  }
}

// 列表样式
.list {
  background: white;
  border-radius: 12px;
  overflow: hidden;

  .list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--light-shade);
    cursor: pointer;
    transition: background-color 0.3s;

    &:last-child {
      border-bottom: none;
    }

    &:hover {
      background-color: var(--light-color);
    }

    &:active {
      background-color: var(--light-shade);
    }

    .item-icon {
      width: 40px;
      height: 40px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 50%;
      background-color: var(--light-color);
      flex-shrink: 0;

      .icon {
        width: 24px;
        height: 24px;
        color: var(--primary-color);
      }
    }

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

      .item-title {
        margin: 0 0 4px;
        font-size: 15px;
        font-weight: 600;
        color: var(--dark-color);
      }

      .item-subtitle {
        margin: 0;
        font-size: 13px;
        color: var(--medium-color);
      }
    }

    .item-arrow {
      width: 20px;
      height: 20px;
      color: var(--medium-color);
      flex-shrink: 0;
    }
  }
}

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

  .icon-large {
    width: 80px;
    height: 80px;
    color: var(--medium-color);
    margin-bottom: 16px;
    opacity: 0.5;
  }

  .empty-title {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--dark-color);
  }

  .empty-message {
    margin: 0 0 20px;
    font-size: 14px;
    color: var(--medium-color);
  }
}

// Chip 组件
.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.2);
  color: white;

  &.chip-primary {
    background: rgba(56, 128, 255, 0.15);
    color: var(--primary-color);
  }

  &.chip-success {
    background: rgba(45, 211, 111, 0.15);
    color: var(--success-color);
  }

  &.chip-warning {
    background: rgba(255, 196, 9, 0.15);
    color: var(--warning-color);
  }
}

// 项目状态样式
.status-pending {
  background: var(--warning-color) !important;
  color: var(--dark-color) !important;
}

.status-active {
  background: var(--primary-color) !important;
  color: white !important;
}

.status-completed {
  background: var(--success-color) !important;
  color: white !important;
}

.status-paused {
  background: var(--medium-color) !important;
  color: white !important;
}

.status-cancelled {
  background: var(--danger-color) !important;
  color: white !important;
}

.status-default {
  background: var(--light-color) !important;
  color: var(--dark-color) !important;
}

// 响应式适配
@media (min-width: 768px) {
  .stage-navigation {
    max-width: 600px;
    margin: 0 auto;
  }

  .customer-quick-view,
  .stage-content {
    max-width: 800px;
    margin: 0 auto;
  }

  .footer-toolbar {
    .action-buttons {
      max-width: 800px;
    }
  }
}

// 平板和桌面端
@media (min-width: 1024px) {
  .stage-navigation {
    max-width: 800px;
  }

  .customer-quick-view,
  .stage-content {
    max-width: 1000px;
  }

  .footer-toolbar {
    .action-buttons {
      max-width: 1000px;
    }
  }
}

// 移动端优化
@media (max-width: 480px) {
  // 移动端内容高度调整
  .content {
    height: calc(100vh - 60px); // 移动端调整高度
  }

  .stage-toolbar {
    padding: 8px 0;

    .stage-navigation {
      .stage-item {
        min-width: 50px;

        .stage-circle {
          width: 32px;
          height: 32px;
          font-size: 12px;

          .icon {
            width: 16px;
            height: 16px;
          }
        }

        .stage-label {
          font-size: 10px;
        }
      }

      .stage-connector {
        min-width: 15px;
        margin: 0 4px;
        margin-bottom: 16px;
      }
    }
  }

  .customer-quick-view {
    padding: 8px 8px 0;

    .card {
      .card-content {
        padding: 10px;

        .customer-info {
          gap: 10px;

          .avatar {
            width: 40px;
            height: 40px;

            .avatar-icon {
              width: 40px;
              height: 40px;
            }
          }

          .info-text {
            h3 {
              font-size: 14px;
            }

            p {
              font-size: 12px;
            }

            .tags {
              gap: 4px;

              .badge {
                font-size: 10px;
                padding: 3px 6px;
              }
            }
          }
        }
      }
    }
  }

  .stage-content {
    padding: 8px;
    padding-bottom: 100px; // 移动端为底部卡片留空间
  }

  .footer-toolbar {
    padding: 8px 12px;

    .action-buttons {
      gap: 8px;

      .btn {
        padding: 10px 16px;
        font-size: 13px;
      }
    }
  }

  .card {
    .card-header {
      padding: 12px;

      .card-title {
        font-size: 15px;
      }
    }

    .card-content {
      padding: 12px;
    }
  }

  .form-group {
    .form-input,
    .form-textarea,
    .form-select {
      padding: 10px 12px;
      font-size: 13px;
    }
  }

  .btn {
    padding: 10px 20px;
    font-size: 13px;
  }
}
