.stage-delivery-container {
  padding: 16px;
  background-color: #f8f9fa;
  min-height: 100vh;

  // 加载状态
  .loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;

    .spinner {
      width: 40px;
      height: 40px;
      border: 4px solid #e9ecef;
      border-top-color: var(--ion-color-primary, #3880ff);
      border-radius: 50%;
      animation: spin 0.8s linear infinite;
    }

    p {
      margin-top: 16px;
      color: #6c757d;
      font-size: 14px;
    }
  }

  @keyframes spin {
    to { transform: rotate(360deg); }
  }

  // 通用标签标题
  .section-label {
    font-size: 13px;
    font-weight: 600;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
    padding-left: 4px;
  }

  // 场景Product选择标签 (第一层)
  .product-tabs-section {
    margin-bottom: 20px;

    .product-tabs {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
      gap: 10px;

      .product-tab {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 6px;
        padding: 14px 12px;
        background: white;
        border-radius: 12px;
        border: 2px solid #e9ecef;
        cursor: pointer;
        transition: all 0.3s ease;
        position: relative;

        .product-icon {
          width: 36px;
          height: 36px;
          display: flex;
          align-items: center;
          justify-content: center;
          border-radius: 10px;
          background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
          color: white;
          transition: transform 0.3s ease;

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

        .product-name {
          font-size: 13px;
          font-weight: 600;
          color: #495057;
          text-align: center;
          line-height: 1.3;
        }

        .file-count-badge {
          position: absolute;
          top: 8px;
          right: 8px;
          background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
          color: white;
          font-size: 11px;
          font-weight: 700;
          padding: 2px 6px;
          border-radius: 10px;
          min-width: 18px;
          text-align: center;
        }

        &:hover {
          border-color: var(--ion-color-primary, #3880ff);
          transform: translateY(-2px);
          box-shadow: 0 4px 12px rgba(56, 128, 255, 0.15);

          .product-icon {
            transform: scale(1.1);
          }
        }

        &.active {
          background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
          border-color: transparent;
          color: white;
          box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);

          .product-icon {
            background: rgba(255, 255, 255, 0.25);
            transform: scale(1.15);
          }

          .product-name {
            color: white;
          }

          .file-count-badge {
            background: white;
            color: #667eea;
          }
        }
      }
    }
  }

  // 交付类型选择标签 (第二层)
  .delivery-types-section {
    margin-bottom: 20px;

    .delivery-types-tabs {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 10px;

      .delivery-type-tab {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 8px;
        padding: 16px 10px;
        background: white;
        border-radius: 14px;
        border: 2px solid #e9ecef;
        cursor: pointer;
        transition: all 0.3s ease;
        position: relative;

        .type-icon {
          width: 44px;
          height: 44px;
          display: flex;
          align-items: center;
          justify-content: center;
          border-radius: 12px;
          background: #f8f9fa;
          transition: all 0.3s ease;

          .icon {
            width: 24px;
            height: 24px;
            color: #6c757d;
            transition: color 0.3s ease;
          }
        }

        .type-content {
          display: flex;
          flex-direction: column;
          align-items: center;
          gap: 2px;

          .type-name {
            font-size: 14px;
            font-weight: 700;
            color: #212529;
            text-align: center;
          }

          .type-description {
            font-size: 11px;
            color: #868e96;
            text-align: center;
            line-height: 1.3;
            display: -webkit-box;
            -webkit-line-clamp: 2;
            -webkit-box-orient: vertical;
            overflow: hidden;
          }
        }

        .file-count-badge {
          position: absolute;
          top: 10px;
          right: 10px;
          background: #6c757d;
          color: white;
          font-size: 11px;
          font-weight: 700;
          padding: 3px 7px;
          border-radius: 12px;
          min-width: 20px;
          text-align: center;
        }

        &:hover {
          border-color: #adb5bd;
          transform: translateY(-2px);
          box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);

          .type-icon {
            transform: scale(1.08);
          }
        }

        // 不同类型的配色
        &[data-color="primary"].active {
          background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
          border-color: transparent;
          box-shadow: 0 6px 20px rgba(79, 172, 254, 0.4);

          .type-icon {
            background: rgba(255, 255, 255, 0.25);
            .icon { color: white; }
          }

          .type-content {
            .type-name, .type-description { color: white; }
          }

          .file-count-badge {
            background: white;
            color: #4facfe;
          }
        }

        &[data-color="secondary"].active {
          background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
          border-color: transparent;
          box-shadow: 0 6px 20px rgba(250, 112, 154, 0.4);

          .type-icon {
            background: rgba(255, 255, 255, 0.25);
            .icon { color: white; }
          }

          .type-content {
            .type-name, .type-description { color: white; }
          }

          .file-count-badge {
            background: white;
            color: #fa709a;
          }
        }

        &[data-color="tertiary"].active {
          background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
          border-color: transparent;
          box-shadow: 0 6px 20px rgba(168, 237, 234, 0.4);

          .type-icon {
            background: rgba(255, 255, 255, 0.25);
            .icon { color: white; }
          }

          .type-content {
            .type-name, .type-description { color: white; }
          }

          .file-count-badge {
            background: white;
            color: #a8edea;
          }
        }

        &[data-color="success"].active {
          background: linear-gradient(135deg, #81fbb8 0%, #28c76f 100%);
          border-color: transparent;
          box-shadow: 0 6px 20px rgba(129, 251, 184, 0.4);

          .type-icon {
            background: rgba(255, 255, 255, 0.25);
            .icon { color: white; }
          }

          .type-content {
            .type-name, .type-description { color: white; }
          }

          .file-count-badge {
            background: white;
            color: #28c76f;
          }
        }
      }
    }
  }

  // 文件上传和展示区域
  .delivery-content-section {
    display: flex;
    flex-direction: column;
    gap: 20px;

    // 上传区域
    .upload-section {
      .upload-area {
        background: white;
        border-radius: 16px;
        padding: 24px;
        border: 2px dashed #dee2e6;
        transition: all 0.3s ease;

        .upload-content {
          display: flex;
          flex-direction: column;
          align-items: center;
          gap: 16px;
          text-align: center;

          .upload-icon {
            width: 56px;
            height: 56px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;

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

          .upload-text {
            h4 {
              font-size: 16px;
              font-weight: 700;
              color: #212529;
              margin: 0 0 6px;
            }

            p {
              font-size: 13px;
              color: #6c757d;
              margin: 0;
              line-height: 1.4;
            }
          }

          .upload-button {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 12px 24px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 10px;
            font-size: 14px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.3s ease;
            box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);

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

            &:hover:not(:disabled) {
              transform: translateY(-2px);
              box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
            }

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

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

        .upload-progress {
          margin-top: 16px;
          display: flex;
          flex-direction: column;
          gap: 8px;

          .progress-bar {
            height: 8px;
            background: #e9ecef;
            border-radius: 10px;
            overflow: hidden;

            .progress-fill {
              height: 100%;
              background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
              border-radius: 10px;
              transition: width 0.3s ease;
            }
          }

          .progress-text {
            font-size: 12px;
            color: #667eea;
            font-weight: 600;
            text-align: center;
          }
        }

        &.uploading {
          border-color: #667eea;
          background: #f8f9ff;
        }
      }
    }

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

        h4 {
          font-size: 16px;
          font-weight: 700;
          color: #212529;
          margin: 0;
        }
      }

      .files-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 14px;

        .file-card {
          background: white;
          border-radius: 14px;
          overflow: hidden;
          box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
          transition: all 0.3s ease;

          &:hover {
            transform: translateY(-4px);
            box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
          }

          .file-preview {
            position: relative;
            width: 100%;
            aspect-ratio: 1;
            overflow: hidden;
            background: #f8f9fa;
            cursor: pointer;

            .preview-image {
              width: 100%;
              height: 100%;
              object-fit: cover;
            }

            .file-type-icon {
              width: 100%;
              height: 100%;
              display: flex;
              align-items: center;
              justify-content: center;

              .icon {
                width: 48px;
                height: 48px;
                color: #adb5bd;
              }
            }

            .file-overlay {
              position: absolute;
              top: 0;
              left: 0;
              right: 0;
              bottom: 0;
              background: rgba(0, 0, 0, 0.6);
              display: flex;
              align-items: center;
              justify-content: center;
              opacity: 0;
              transition: opacity 0.3s ease;

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

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

          .file-info {
            padding: 12px;

            .file-name {
              font-size: 13px;
              font-weight: 600;
              color: #212529;
              margin-bottom: 6px;
              overflow: hidden;
              text-overflow: ellipsis;
              white-space: nowrap;
            }

            .file-meta {
              display: flex;
              align-items: center;
              gap: 8px;
              font-size: 11px;
              color: #868e96;
              margin-bottom: 4px;

              .file-size {
                &::after {
                  content: "•";
                  margin-left: 8px;
                }
              }
            }

            .file-uploader {
              font-size: 11px;
              color: #adb5bd;
            }
          }

          .file-actions {
            display: flex;
            gap: 6px;
            padding: 0 12px 12px;

            .action-button {
              flex: 1;
              display: flex;
              align-items: center;
              justify-content: center;
              padding: 8px;
              background: #f8f9fa;
              border: none;
              border-radius: 8px;
              cursor: pointer;
              transition: all 0.2s ease;

              .icon {
                width: 18px;
                height: 18px;
                color: #6c757d;
              }

              &:hover {
                background: #e9ecef;

                .icon {
                  color: #495057;
                }
              }

              &.preview:hover {
                background: #e3f2fd;
                .icon { color: #2196f3; }
              }

              &.download:hover {
                background: #e8f5e9;
                .icon { color: #4caf50; }
              }

              &.delete:hover {
                background: #ffebee;
                .icon { color: #f44336; }
              }
            }
          }
        }
      }

      // 空状态
      .empty-state {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 60px 20px;
        text-align: center;
        background: white;
        border-radius: 16px;

        .empty-icon {
          width: 80px;
          height: 80px;
          display: flex;
          align-items: center;
          justify-content: center;
          border-radius: 50%;
          background: #f8f9fa;
          margin-bottom: 20px;

          .icon {
            width: 48px;
            height: 48px;
            color: #adb5bd;
          }
        }

        h4 {
          font-size: 18px;
          font-weight: 700;
          color: #495057;
          margin: 0 0 8px;
        }

        p {
          font-size: 14px;
          color: #868e96;
          margin: 0 0 24px;
          line-height: 1.5;
        }

        .upload-button-primary {
          display: flex;
          align-items: center;
          gap: 8px;
          padding: 14px 28px;
          background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
          color: white;
          border: none;
          border-radius: 12px;
          font-size: 15px;
          font-weight: 600;
          cursor: pointer;
          transition: all 0.3s ease;
          box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);

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

          &:hover {
            transform: translateY(-2px);
            box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
          }

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

  // 未选择场景状态
  .no-selection-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
    background: white;
    border-radius: 16px;
    margin-top: 20px;

    .state-icon {
      width: 100px;
      height: 100px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 50%;
      background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
      margin-bottom: 24px;

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

    h3 {
      font-size: 20px;
      font-weight: 700;
      color: #212529;
      margin: 0 0 10px;
    }

    p {
      font-size: 15px;
      color: #6c757d;
      margin: 0;
      line-height: 1.5;
    }
  }

  // 没有场景状态
  .no-products-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
    background: white;
    border-radius: 16px;

    .state-icon {
      width: 100px;
      height: 100px;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 50%;
      background: #f8f9fa;
      margin-bottom: 24px;

      .icon {
        width: 56px;
        height: 56px;
        color: #adb5bd;
      }
    }

    h3 {
      font-size: 20px;
      font-weight: 700;
      color: #495057;
      margin: 0 0 10px;
    }

    p {
      font-size: 15px;
      color: #868e96;
      margin: 0;
      line-height: 1.5;
    }
  }
}

// 移动端响应式
@media (max-width: 768px) {
  .stage-delivery-container {
    padding: 12px;

    .product-tabs-section {
      .product-tabs {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 8px;

        .product-tab {
          padding: 12px 10px;

          .product-icon {
            width: 32px;
            height: 32px;

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

          .product-name {
            font-size: 12px;
          }
        }
      }
    }

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

        .delivery-type-tab {
          padding: 14px 8px;

          .type-icon {
            width: 40px;
            height: 40px;

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

          .type-content {
            .type-name {
              font-size: 13px;
            }

            .type-description {
              font-size: 10px;
            }
          }
        }
      }
    }

    .delivery-content-section {
      gap: 16px;

      .upload-section {
        .upload-area {
          padding: 20px;

          .upload-content {
            gap: 12px;

            .upload-icon {
              width: 48px;
              height: 48px;

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

            .upload-text {
              h4 {
                font-size: 15px;
              }

              p {
                font-size: 12px;
              }
            }

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

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

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

    .no-selection-state,
    .no-products-state {
      padding: 60px 16px;

      .state-icon {
        width: 80px;
        height: 80px;

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

      h3 {
        font-size: 18px;
      }

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

@media (max-width: 480px) {
  .stage-delivery-container {
    .product-tabs-section {
      .product-tabs {
        grid-template-columns: repeat(2, 1fr);
      }
    }

    .delivery-content-section {
      .files-display-section {
        .files-grid {
          grid-template-columns: repeat(2, 1fr);
        }
      }
    }
  }
}
