// 售后归档阶段样式 - 使用纯 div+scss 实现

// CSS 变量定义
: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;
}

// 加载容器
.loading-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  padding: 20px;

  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;
  }
}

.spinner-small {
  width: 20px;
  height: 20px;
  position: relative;

  .spinner-circle {
    width: 100%;
    height: 100%;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
  }
}

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

// 售后归档容器
.stage-aftercare-container {
  padding: 12px;
  max-width: 800px;
  margin: 0 auto;

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

// 通用卡片样式
.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-wrapper {
      display: flex;
      justify-content: space-between;
      align-items: center;
      gap: 12px;
    }

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

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

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

// Badge 组件
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;

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

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

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

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

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

  &.badge-with-icon {
    .icon {
      width: 16px;
      height: 16px;
    }
  }
}

// 尾款管理卡片
.payment-card {
  .payment-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 16px;

    .summary-item {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 8px;

      .label {
        font-size: 12px;
        color: var(--medium-color);
      }

      .value {
        font-size: 18px;
        font-weight: 700;
        color: var(--dark-color);

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

        &.warning {
          color: var(--warning-color);
        }
      }
    }
  }

  // 进度条
  .progress-bar {
    width: 100%;
    height: 6px;
    background-color: var(--light-shade);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 20px;

    .progress-fill {
      height: 100%;
      background-color: var(--success-color);
      transition: width 0.3s ease;
      border-radius: 3px;
    }
  }

  .vouchers-section {
    margin-top: 20px;

    h4 {
      margin: 0 0 12px;
      font-size: 14px;
      font-weight: 600;
      color: var(--dark-color);
    }

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

      .list-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px;
        background-color: var(--light-color);
        border-radius: 8px;

        .thumbnail {
          width: 60px;
          height: 60px;
          flex-shrink: 0;
          border-radius: 6px;
          overflow: hidden;
          background-color: var(--light-shade);

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

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

          h3 {
            margin: 0 0 4px;
            font-size: 16px;
            font-weight: 600;
            color: var(--dark-color);
          }

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

            &.time {
              font-size: 12px;
            }
          }
        }
      }
    }
  }
}

// 客户评价卡片
.feedback-card {
  .feedback-form {
    .rating-section {
      margin-bottom: 20px;

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

      .stars {
        display: flex;
        gap: 4px;

        .star-icon {
          width: 32px;
          height: 32px;
          color: var(--light-shade);
          cursor: pointer;
          transition: all 0.2s;

          &.active {
            color: var(--warning-color);
          }

          &:hover {
            transform: scale(1.1);
          }
        }
      }
    }

    .checkbox-item {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 12px;
      background-color: var(--light-color);
      border-radius: 8px;
      margin-bottom: 16px;

      .checkbox-input {
        width: 20px;
        height: 20px;
        cursor: pointer;
        accent-color: var(--primary-color);
        margin: 0;
      }

      .checkbox-label {
        flex: 1;
        margin: 0;
        font-size: 14px;
        color: var(--dark-color);
        cursor: pointer;
      }
    }
  }

  .feedback-result {
    text-align: center;

    .rating-display {
      margin-bottom: 20px;

      .stars-large {
        display: flex;
        justify-content: center;
        gap: 8px;
        margin-bottom: 12px;

        .star-icon {
          width: 40px;
          height: 40px;
          color: var(--light-shade);

          &.active {
            color: var(--warning-color);
          }
        }
      }

      .rating-text {
        font-size: 24px;
        font-weight: 700;
        color: var(--dark-color);
        margin: 0;
      }
    }

    .comment-box {
      padding: 16px;
      background-color: var(--light-color);
      border-radius: 8px;
      margin-bottom: 16px;
      text-align: left;

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

// 项目复盘卡片
.retrospective-card {
  .empty-state {
    text-align: center;
    padding: 40px 20px;

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

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

  .retrospective-content {
    .summary {
      padding: 16px;
      background-color: var(--light-color);
      border-radius: 8px;
      margin-bottom: 20px;
      font-size: 14px;
      line-height: 1.6;
      color: var(--dark-color);
    }

    .section {
      margin-bottom: 20px;

      h4 {
        display: flex;
        align-items: center;
        gap: 8px;
        margin: 0 0 12px;
        font-size: 15px;
        font-weight: 600;
        color: var(--dark-color);

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

      ul {
        margin: 0;
        padding-left: 20px;

        li {
          margin-bottom: 8px;
          font-size: 13px;
          line-height: 1.5;
          color: var(--medium-color);
        }
      }
    }
  }
}

// 归档卡片
.archive-card {
  .archive-checklist {
    margin-bottom: 20px;

    h3 {
      margin: 0 0 16px;
      font-size: 16px;
      font-weight: 600;
      color: var(--dark-color);
    }

    .checklist {
      background: var(--light-color);
      border-radius: 8px;
      padding: 12px;

      .checklist-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 8px;

        .check-icon {
          width: 24px;
          height: 24px;
          color: var(--medium-color);
          flex-shrink: 0;

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

        span {
          font-size: 14px;
          color: var(--dark-color);
        }
      }
    }
  }
}

// 已归档卡片
.archived-card {
  background: linear-gradient(135deg, var(--success-color) 0%, #28ba62 100%);

  .card-content {
    padding: 24px;
  }

  .archived-status {
    text-align: center;
    color: white;

    .icon-large {
      width: 64px;
      height: 64px;
      color: white;
      margin-bottom: 16px;
    }

    h3 {
      margin: 0 0 16px;
      font-size: 20px;
      font-weight: 700;
      color: white;
    }

    p {
      margin: 4px 0;
      font-size: 14px;
      color: white;
      opacity: 0.9;
    }
  }
}

// 表单组件
.form-group {
  margin-bottom: 16px;

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

  .form-textarea {
    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;
    font-family: inherit;
    resize: vertical;
    min-height: 100px;

    &: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;
    }
  }
}

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

  .icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
  }

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

    &:hover:not(:disabled) {
      background: #2f6ce5;
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
    }

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

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

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

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

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

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

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

  &.btn-block {
    width: 100%;
    display: flex;
  }

  &.btn-large {
    padding: 14px 28px;
    font-size: 16px;
  }

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

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

// 响应式适配
@media (min-width: 768px) {
  .stage-aftercare-container {
    padding: 24px;
  }

  .payment-summary {
    gap: 24px !important;
  }
}

@media (max-width: 480px) {
  .stage-aftercare-container {
    padding: 8px;
  }

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

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

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

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

  .payment-card {
    .payment-summary {
      gap: 8px;

      .summary-item {
        .label {
          font-size: 11px;
        }

        .value {
          font-size: 16px;
        }
      }
    }

    .vouchers-section {
      .list {
        .list-item {
          padding: 10px;

          .thumbnail {
            width: 50px;
            height: 50px;
          }

          .item-content {
            h3 {
              font-size: 14px;
            }

            p {
              font-size: 12px;

              &.time {
                font-size: 11px;
              }
            }
          }
        }
      }
    }
  }

  .feedback-card {
    .feedback-form {
      .rating-section {
        .stars {
          gap: 2px;

          .star-icon {
            width: 28px;
            height: 28px;
          }
        }
      }
    }

    .feedback-result {
      .rating-display {
        .stars-large {
          gap: 6px;

          .star-icon {
            width: 36px;
            height: 36px;
          }
        }

        .rating-text {
          font-size: 20px;
        }
      }
    }
  }

  .retrospective-card {
    .empty-state {
      padding: 30px 16px;

      .icon-large {
        width: 56px;
        height: 56px;
      }
    }

    .retrospective-content {
      .summary {
        padding: 12px;
        font-size: 13px;
      }

      .section {
        h4 {
          font-size: 14px;

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

        ul {
          padding-left: 16px;

          li {
            font-size: 12px;
          }
        }
      }
    }
  }

  .archive-card {
    .archive-checklist {
      h3 {
        font-size: 15px;
      }

      .checklist {
        padding: 10px;

        .checklist-item {
          padding: 6px;

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

          span {
            font-size: 13px;
          }
        }
      }
    }
  }

  .archived-card {
    .card-content {
      padding: 20px;
    }

    .archived-status {
      .icon-large {
        width: 56px;
        height: 56px;
      }

      h3 {
        font-size: 18px;
      }

      p {
        font-size: 13px;
      }
    }
  }

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

    &.btn-large {
      padding: 12px 24px;
      font-size: 14px;
    }

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

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

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