// 交付执行阶段样式 - 纯 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;

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

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

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

// 交付容器
.stage-delivery-container {
  // 通用卡片样式
  .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);
          flex-shrink: 0;
        }
      }
    }

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

  // 进度卡片
  .progress-card {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;

    .card-content {
      padding: 20px;
    }

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

      h3 {
        margin: 0;
        font-size: 17px;
        font-weight: 600;
      }

      .progress-value {
        font-size: 28px;
        font-weight: 700;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
      }
    }

    // 纯 CSS 进度条
    .progress-bar {
      position: relative;
      width: 100%;
      height: 10px;
      background-color: rgba(255, 255, 255, 0.3);
      border-radius: 5px;
      overflow: hidden;
      box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);

      .progress-fill {
        height: 100%;
        background: linear-gradient(90deg, rgba(255, 255, 255, 0.9), white);
        border-radius: 5px;
        transition: width 0.4s ease;
        box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
      }
    }

    .progress-detail {
      margin: 12px 0 0;
      font-size: 14px;
      opacity: 0.95;
      font-weight: 500;
    }
  }

  // 空间交付物卡片
  .space-deliverables-card {
    .deliverable-item {
      padding: 16px;
      background-color: var(--light-color);
      border-radius: 8px;
      margin-bottom: 16px;
      transition: all 0.3s;

      &:last-child {
        margin-bottom: 0;
      }

      &:hover {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
      }

      // 交付物头部
      .deliverable-header {
        display: flex;
        gap: 8px;
        margin-bottom: 12px;
        flex-wrap: wrap;
      }

      // 文件区域
      .files-section {
        margin-bottom: 16px;

        .empty-text {
          color: var(--medium-color);
          font-size: 13px;
          font-style: italic;
          margin: 12px 0;
          text-align: center;
          padding: 20px;
          background: rgba(var(--medium-color), 0.05);
          border-radius: 8px;
        }

        .files-grid {
          display: grid;
          grid-template-columns: repeat(3, 1fr);
          gap: 10px;
          margin-bottom: 12px;

          .file-item {
            position: relative;
            aspect-ratio: 1;
            border-radius: 8px;
            overflow: hidden;
            background-color: white;
            border: 1px solid var(--light-shade);
            transition: all 0.3s;

            &:hover {
              box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
              transform: translateY(-2px);
            }

            // 图片样式
            img {
              width: 100%;
              height: 100%;
              object-fit: cover;
            }

            // 文件图标
            .file-icon {
              width: 100%;
              height: 100%;
              display: flex;
              flex-direction: column;
              align-items: center;
              justify-content: center;
              gap: 6px;
              padding: 8px;

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

              .file-name {
                font-size: 11px;
                color: var(--dark-color);
                text-align: center;
                word-break: break-all;
                line-height: 1.3;
                max-height: 36px;
                overflow: hidden;
                display: -webkit-box;
                -webkit-line-clamp: 2;
                -webkit-box-orient: vertical;
              }
            }

            // 删除按钮
            .delete-button {
              position: absolute;
              top: 4px;
              right: 4px;
              width: 28px;
              height: 28px;
              border: none;
              background-color: rgba(235, 68, 90, 0.9);
              border-radius: 50%;
              display: flex;
              align-items: center;
              justify-content: center;
              cursor: pointer;
              transition: all 0.3s;
              padding: 0;
              box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);

              &:hover {
                background-color: var(--danger-color);
                transform: scale(1.1);
              }

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

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

      // 质量自查区域
      .quality-check-section,
      .review-section {
        padding-top: 16px;
        border-top: 1px solid var(--light-shade);
        margin-top: 16px;

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

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

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

        // 复选框列表
        .checklist {
          background: white;
          border-radius: 8px;
          padding: 12px;
          margin-bottom: 12px;

          .checkbox-item {
            display: flex;
            align-items: center;
            gap: 12px;
            padding: 10px 8px;
            cursor: pointer;
            transition: background-color 0.3s;
            border-radius: 6px;

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

            input[type="checkbox"] {
              width: 20px;
              height: 20px;
              cursor: pointer;
              accent-color: var(--success-color);
              flex-shrink: 0;
            }

            .checkbox-label {
              flex: 1;
              font-size: 14px;
              color: var(--dark-color);
              line-height: 1.5;
            }
          }
        }

        // 审核按钮
        .review-buttons {
          display: grid;
          grid-template-columns: 1fr 1fr;
          gap: 12px;
          margin-top: 12px;
        }
      }

      // 审核结果
      .review-result {
        padding: 14px;
        background-color: white;
        border-radius: 8px;
        margin-top: 16px;
        border: 1px solid var(--light-shade);

        .result-header {
          display: flex;
          align-items: center;
          gap: 10px;
          margin-bottom: 10px;

          .result-icon {
            width: 26px;
            height: 26px;
            flex-shrink: 0;

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

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

          .reviewer-name {
            font-size: 14px;
            font-weight: 600;
            color: var(--dark-color);
          }

          .review-time {
            margin-left: auto;
            font-size: 11px;
            color: var(--medium-color);
            white-space: nowrap;
          }
        }

        .review-comments {
          margin: 0;
          font-size: 13px;
          color: var(--dark-color);
          line-height: 1.6;
          padding: 8px 12px;
          background: var(--light-color);
          border-radius: 6px;
        }
      }
    }
  }
}

// Badge 组件
.badge {
  display: inline-block;
  padding: 5px 11px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;

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

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

  &.badge-tertiary {
    background: var(--tertiary-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-light {
    background: var(--light-color);
    color: var(--dark-color);
  }
}

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

  .icon {
    width: 18px;
    height: 18px;
    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-secondary {
    background: var(--secondary-color);
    color: white;

    &:hover:not(:disabled) {
      background: #0bb8d4;
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(12, 209, 232, 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-danger {
    background: var(--danger-color);
    color: white;

    &:hover:not(:disabled) {
      background: #d33850;
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(235, 68, 90, 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-light {
    background: var(--light-color);
    color: var(--dark-color);

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

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

  &.btn-sm {
    padding: 6px 12px;
    font-size: 12px;

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

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

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

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

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

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

  .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;
    font-family: inherit;

    &: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: 80px;
    resize: vertical;
    line-height: 1.5;
  }

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

  .form-error {
    margin-top: 6px;
    font-size: 12px;
    color: var(--danger-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;
  }
}

// 响应式适配
@media (min-width: 768px) {
  .stage-delivery-container {
    .space-deliverables-card {
      .deliverable-item {
        .files-section {
          .files-grid {
            grid-template-columns: repeat(4, 1fr);
            gap: 12px;
          }
        }
      }
    }
  }
}

@media (min-width: 1024px) {
  .stage-delivery-container {
    .space-deliverables-card {
      .deliverable-item {
        .files-section {
          .files-grid {
            grid-template-columns: repeat(5, 1fr);
          }
        }
      }
    }
  }
}

// 移动端优化
@media (max-width: 480px) {
  .loading-container {
    .spinner {
      width: 40px;
      height: 40px;
    }

    p {
      font-size: 13px;
    }
  }

  .stage-delivery-container {
    .card {
      border-radius: 10px;

      .card-header {
        padding: 12px;

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

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

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

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

      .progress-info {
        margin-bottom: 12px;

        h3 {
          font-size: 15px;
        }

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

      .progress-bar {
        height: 8px;
      }

      .progress-detail {
        margin-top: 10px;
        font-size: 13px;
      }
    }

    .space-deliverables-card {
      .deliverable-item {
        padding: 12px;

        .files-section {
          .files-grid {
            grid-template-columns: repeat(2, 1fr);
            gap: 8px;

            .file-item {
              .file-icon {
                gap: 4px;
                padding: 6px;

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

                .file-name {
                  font-size: 10px;
                }
              }

              .delete-button {
                width: 24px;
                height: 24px;

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

        .quality-check-section,
        .review-section {
          padding-top: 12px;
          margin-top: 12px;

          .section-header h4,
          h4 {
            font-size: 14px;
          }

          .checklist {
            padding: 10px;

            .checkbox-item {
              padding: 8px 6px;

              input[type="checkbox"] {
                width: 18px;
                height: 18px;
              }

              .checkbox-label {
                font-size: 13px;
              }
            }
          }

          .review-buttons {
            gap: 8px;
          }
        }

        .review-result {
          padding: 12px;

          .result-header {
            gap: 8px;
            margin-bottom: 8px;

            .result-icon {
              width: 22px;
              height: 22px;
            }

            .reviewer-name {
              font-size: 13px;
            }

            .review-time {
              font-size: 10px;
            }
          }

          .review-comments {
            font-size: 12px;
            padding: 6px 10px;
          }
        }
      }
    }

    .badge {
      font-size: 10px;
      padding: 4px 9px;
    }

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

      &.btn-sm {
        padding: 5px 10px;
        font-size: 11px;
      }

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

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

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

      .form-textarea {
        min-height: 70px;
      }

      .form-label {
        font-size: 13px;
      }
    }
  }
}

// 超小屏幕优化
@media (max-width: 360px) {
  .stage-delivery-container {
    .space-deliverables-card {
      .deliverable-item {
        .deliverable-header {
          gap: 6px;
        }

        .files-section {
          .files-grid {
            gap: 6px;

            .file-item {
              .file-icon {
                padding: 4px;

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

                .file-name {
                  font-size: 9px;
                }
              }

              .delete-button {
                width: 22px;
                height: 22px;
                top: 2px;
                right: 2px;

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

        .quality-check-section,
        .review-section {
          .review-buttons {
            gap: 6px;
          }
        }
      }
    }
  }
}
