// 确认需求阶段样式 - 纯 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: 16px 0 0;
    font-size: 14px;
  }
}

// Spinner 动画
.spinner {
  width: 48px;
  height: 48px;
  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;
  display: inline-block;

  .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-requirements-container {
  padding: 0 12px 80px;

  // 通用卡片样式
  .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 0 4px;
        font-size: 16px;
        font-weight: 600;
        color: var(--dark-color);

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

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

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

  // 必填标记
  .required {
    color: var(--danger-color);
    margin-left: 4px;
  }

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

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

    p {
      color: var(--medium-color);
      margin: 0 0 16px;
    }

    .btn {
      margin-top: 8px;
    }
  }

  // 参考图片卡片
  .reference-images-card {
    .images-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 12px;

      .image-item {
        position: relative;
        aspect-ratio: 1;
        border-radius: 8px;
        overflow: hidden;
        cursor: pointer;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);

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

        .image-overlay {
          position: absolute;
          top: 0;
          left: 0;
          right: 0;
          bottom: 0;
          background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3), transparent);
          display: flex;
          justify-content: space-between;
          padding: 8px;
          opacity: 1;
          transition: opacity 0.3s;

          .badge {
            height: fit-content;
            font-size: 10px;
            padding: 4px 8px;
          }

          .btn-icon {
            width: 32px;
            height: 32px;
            padding: 4px;
          }
        }

        &:hover .image-overlay {
          opacity: 1;
        }
      }

      .upload-placeholder {
        aspect-ratio: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        border: 2px dashed var(--light-shade);
        border-radius: 8px;
        background-color: var(--light-color);
        transition: all 0.3s;

        &:hover {
          border-color: var(--primary-color);
          background-color: rgba(var(--primary-rgb), 0.05);
        }
      }
    }
  }

  // CAD文件卡片
  .cad-files-card {
    .file-list {
      display: flex;
      flex-direction: column;
      gap: 0;
      margin-bottom: 16px;
    }

    .file-item {
      display: flex;
      align-items: center;
      gap: 12px;
      padding: 12px 0;
      border-bottom: 1px solid var(--light-shade);

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

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

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

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

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

      .btn-icon {
        flex-shrink: 0;
      }
    }
  }

  // 需求清单卡片
  .requirements-card {
    .section {
      margin-bottom: 24px;
      padding-bottom: 24px;
      border-bottom: 1px solid var(--light-shade);

      &:last-child {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
      }

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

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

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

      .empty-text {
        color: var(--medium-color);
        font-size: 13px;
        font-style: italic;
        margin: 0;
      }

      .space-item {
        padding: 16px;
        background-color: var(--light-color);
        border-radius: 8px;
        margin-bottom: 12px;

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

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

      .budget-range {
        display: grid;
        grid-template-columns: 1fr auto 1fr;
        align-items: flex-start;
        gap: 12px;

        .separator {
          font-size: 20px;
          font-weight: 600;
          color: var(--medium-color);
          padding-top: 32px;
        }
      }
    }
  }

  // AI方案卡片
  .ai-solution-card {
    .ai-solution-content {
      .solution-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
        padding-bottom: 16px;
        border-bottom: 1px solid var(--light-shade);

        .badge {
          display: flex;
          align-items: center;
          gap: 4px;
          padding: 6px 12px;

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

      .spaces-solution {
        .space-solution-item {
          padding: 16px;
          background-color: var(--light-color);
          border-radius: 8px;
          margin-bottom: 16px;

          &:last-child {
            margin-bottom: 20px;
          }

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

          .style-desc {
            margin: 0 0 16px;
            font-size: 13px;
            line-height: 1.6;
            color: var(--medium-color);
          }

          .color-palette,
          .materials,
          .furniture {
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 12px;

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

            .label {
              font-size: 12px;
              font-weight: 500;
              color: var(--medium-color);
              white-space: nowrap;
            }

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

              .color-swatch {
                width: 32px;
                height: 32px;
                border-radius: 4px;
                border: 1px solid rgba(0, 0, 0, 0.1);
                box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
              }
            }

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

      .summary {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;

        .summary-item {
          display: flex;
          align-items: center;
          gap: 12px;
          padding: 16px;
          background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.1), rgba(12, 209, 232, 0.1));
          border-radius: 8px;

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

          .label {
            font-size: 11px;
            color: var(--medium-color);
            margin: 0 0 4px;
          }

          h3 {
            margin: 0;
            font-size: 18px;
            font-weight: 700;
            color: var(--primary-color);
          }

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

  // 操作按钮
  .action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 16px 0;
    margin-top: 20px;
  }
}

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

// Badge 组件
.badge {
  display: inline-block;
  padding: 4px 10px;
  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;
  }
}

// 按钮样式
.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;
  white-space: nowrap;

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

  &.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-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-sm {
    padding: 8px 16px;
    font-size: 12px;

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

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

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

// 图标按钮
.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.2s;
  padding: 8px;

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

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

    &:hover:not(:disabled) {
      background: #d33939;
      transform: scale(1.1);
    }

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

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

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

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

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

  .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;
      opacity: 0.7;
    }
  }

  .form-textarea {
    min-height: 80px;
    resize: vertical;
  }

  .form-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23999' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;

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

// 响应式适配
@media (min-width: 768px) {
  .stage-requirements-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 24px 80px;

    .reference-images-card {
      .images-grid {
        grid-template-columns: repeat(3, 1fr);
      }
    }

    .ai-solution-card {
      .ai-solution-content {
        .summary {
          grid-template-columns: repeat(2, 1fr);
        }
      }
    }
  }
}

@media (min-width: 1024px) {
  .stage-requirements-container {
    max-width: 1000px;

    .reference-images-card {
      .images-grid {
        grid-template-columns: repeat(4, 1fr);
      }
    }
  }
}

// 移动端优化
@media (max-width: 480px) {
  .stage-requirements-container {
    padding: 0 8px 70px;

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

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

        .card-subtitle {
          font-size: 11px;
        }
      }

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

    .reference-images-card {
      .images-grid {
        gap: 8px;

        .image-item {
          .image-overlay {
            padding: 6px;

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

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

    .requirements-card {
      .section {
        margin-bottom: 20px;
        padding-bottom: 20px;

        .space-item {
          padding: 12px;
        }

        .budget-range {
          gap: 8px;

          .separator {
            font-size: 18px;
            padding-top: 28px;
          }
        }
      }
    }

    .ai-solution-card {
      .ai-solution-content {
        .spaces-solution {
          .space-solution-item {
            padding: 12px;

            h4 {
              font-size: 15px;
            }

            .color-palette,
            .materials,
            .furniture {
              flex-direction: column;
              align-items: flex-start;
              gap: 8px;

              .label {
                width: 100%;
              }
            }
          }
        }

        .summary {
          grid-template-columns: 1fr;

          .summary-item {
            padding: 12px;

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

            h3 {
              font-size: 16px;
            }
          }
        }
      }
    }

    .action-buttons {
      gap: 8px;

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

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

    .form-group {
      margin-bottom: 14px;

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

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

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

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

    .btn-icon {
      width: 36px;
      height: 36px;

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