.quotation-editor {
  width: 100%;

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

    .spinner {
      margin-bottom: 16px;
    }

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

  // 产品管理区域
  .product-management {
    margin-bottom: 20px;

    .product-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 16px 20px;
      background: var(--ion-color-light);
      border-radius: 12px;
      border: 1px solid var(--ion-color-light-shade);

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

      .product-actions {
        display: flex;
        gap: 12px;

        button {
          display: flex;
          align-items: center;
          gap: 8px;
          padding: 8px 16px;
          border-radius: 8px;
          font-size: 14px;
          font-weight: 500;
          transition: all 0.2s ease;

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

  // 空状态
  .empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--ion-color-medium);

    .empty-icon {
      width: 80px;
      height: 80px;
      margin: 0 auto 16px;
      opacity: 0.3;
    }

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

    .empty-hint {
      font-size: 14px;
      margin: 0;
    }
  }

  // 工具栏
  .quotation-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--ion-color-light);
    border-radius: 8px;
    margin-bottom: 16px;

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

    .toolbar-right {
      display: flex;
      gap: 8px;
    }

    .btn-icon {
      padding: 6px;
      background: transparent;
      border: 1px solid var(--ion-color-medium);
      border-radius: 4px;
      cursor: pointer;
      transition: all 0.2s;

      &:hover {
        background: var(--ion-color-light-shade);
        border-color: var(--ion-color-primary);
      }

      .icon {
        width: 18px;
        height: 18px;
        color: var(--ion-color-medium-shade);
      }
    }
  }

  // 卡片视图
  .quotation-spaces {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .space-card {
    border: 1px solid var(--ion-color-light-shade);
    border-radius: 8px;
    background: white;
    overflow: hidden;
    transition: all 0.3s;

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

      .space-header {
        background: var(--ion-color-light);
        border-bottom: 1px solid var(--ion-color-light-shade);
      }

      .space-toggle .icon {
        transform: rotate(180deg);
      }
    }
  }

  .space-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    cursor: pointer;
    transition: background 0.2s;

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

    .space-info {
      flex: 1;
    }

    .space-name {
      font-size: 16px;
      font-weight: 600;
      margin: 0 0 4px;
      color: var(--ion-color-dark);
    }

    .space-subtotal {
      font-size: 14px;
      margin: 0;
      color: var(--ion-color-primary);
      font-weight: 500;
    }

    .space-toggle {
      .icon {
        width: 20px;
        height: 20px;
        color: var(--ion-color-medium);
        transition: transform 0.3s;
      }
    }
  }

  .space-content {
    padding: 16px;
    animation: slideDown 0.3s ease-out;
  }

  @keyframes slideDown {
    from {
      opacity: 0;
      transform: translateY(-10px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  // 工序网格
  .process-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
  }

  .process-item {
    border: 1px solid var(--ion-color-light-shade);
    border-radius: 6px;
    padding: 12px;
    background: var(--ion-color-light-tint);
    transition: all 0.2s;

    &.enabled {
      border-color: var(--ion-color-primary);
      background: white;
      box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    }

    .process-header {
      display: flex;
      align-items: center;
      gap: 8px;
      cursor: pointer;
      margin-bottom: 8px;

      .checkbox-wrapper {
        display: flex;
        align-items: center;

        .checkbox-input {
          display: none;

          &:checked + .checkbox-custom {
            background: var(--ion-color-primary);
            border-color: var(--ion-color-primary);

            &::after {
              opacity: 1;
            }
          }
        }

        .checkbox-custom {
          width: 18px;
          height: 18px;
          border: 2px solid var(--ion-color-medium);
          border-radius: 4px;
          position: relative;
          transition: all 0.2s;

          &::after {
            content: '';
            position: absolute;
            left: 4px;
            top: 1px;
            width: 5px;
            height: 9px;
            border: solid white;
            border-width: 0 2px 2px 0;
            transform: rotate(45deg);
            opacity: 0;
            transition: opacity 0.2s;
          }
        }
      }

      .badge {
        padding: 4px 12px;
        border-radius: 12px;
        font-size: 16px;
        font-weight: 700;
        background: white;

        &[data-color="primary"] {
          color: var(--ion-color-primary-tint);
                    border: solid 1px var(--ion-color-primary-tint);
        }

        &[data-color="secondary"] {
          color: var(--ion-color-secondary-tint);
                    border: solid 1px var(--ion-color-secondary-tint);
        }

        &[data-color="tertiary"] {
          color: var(--ion-color-tertiary-tint);
                    border: solid 1px var(--ion-color-tertiary-tint);
        }

        &[data-color="success"] {
          color: var(--ion-color-success-tint);
                    border: solid 1px var(--ion-color-success-tint);
        }
      }
    }

    .process-inputs {
      display: flex;
      flex-direction: column;
      gap: 8px;

      .input-group {
        display: flex;
        flex-direction: column;
        gap: 4px;

        .input-label {
          font-size: 12px;
          color: var(--ion-color-medium-shade);
          font-weight: 500;
        }

        .input-with-note {
          display: flex;
          align-items: center;
          gap: 4px;

          .input-field {
            flex: 1;
            padding: 6px 8px;
            border: 1px solid var(--ion-color-light-shade);
            border-radius: 4px;
            font-size: 14px;

            &:focus {
              outline: none;
              border-color: var(--ion-color-primary);
            }

            &:disabled {
              background: var(--ion-color-light);
              color: var(--ion-color-medium);
            }
          }

          .input-note {
            font-size: 12px;
            color: var(--ion-color-medium);
            white-space: nowrap;
          }
        }
      }

      .process-subtotal {
        padding: 6px 8px;
        background: var(--ion-color-light);
        border-radius: 4px;
        font-size: 13px;
        font-weight: 600;
        color: var(--ion-color-primary);
        text-align: right;
      }
    }
  }

  // 表格视图
  .quotation-table {
    display: flex;
    flex-direction: column;
    gap: 24px;
  }

  .table-section {
    border: 1px solid var(--ion-color-light-shade);
    border-radius: 8px;
    overflow: hidden;
    background: white;

    .table-header {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 12px 16px;
      background: var(--ion-color-light);
      border-bottom: 1px solid var(--ion-color-light-shade);

      .table-space-name {
        font-size: 16px;
        font-weight: 600;
        margin: 0;
        color: var(--ion-color-dark);
      }

      .table-space-subtotal {
        font-size: 14px;
        font-weight: 600;
        color: var(--ion-color-primary);
      }
    }
  }

  .process-table {
    width: 100%;
    border-collapse: collapse;

    thead {
      background: var(--ion-color-light-tint);

      th {
        padding: 10px 12px;
        text-align: left;
        font-size: 13px;
        font-weight: 600;
        color: var(--ion-color-medium-shade);
        border-bottom: 2px solid var(--ion-color-light-shade);

        &.col-checkbox {
          width: 40px;
        }

        &.col-process {
          width: auto;
        }

        &.col-price,
        &.col-quantity {
          width: 120px;
        }

        &.col-unit {
          width: 80px;
        }

        &.col-subtotal {
          width: 120px;
          text-align: right;
        }
      }
    }

    tbody {
      tr {
        border-bottom: 1px solid var(--ion-color-light-shade);
        transition: background 0.2s;

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

        &.enabled {
          background: rgba(var(--ion-color-primary-rgb), 0.02);

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

        td {
          padding: 12px;
          font-size: 14px;

          &.col-subtotal {
            text-align: right;
          }

          .checkbox-wrapper {
            display: flex;
            align-items: center;
            justify-content: center;

            .checkbox-input {
              display: none;

              &:checked + .checkbox-custom {
                background: var(--ion-color-primary);
                border-color: var(--ion-color-primary);

                &::after {
                  opacity: 1;
                }
              }
            }

            .checkbox-custom {
              width: 18px;
              height: 18px;
              border: 2px solid var(--ion-color-medium);
              border-radius: 4px;
              position: relative;
              transition: all 0.2s;
              cursor: pointer;

              &::after {
                content: '';
                position: absolute;
                left: 4px;
                top: 1px;
                width: 5px;
                height: 9px;
                border: solid white;
                border-width: 0 2px 2px 0;
                transform: rotate(45deg);
                opacity: 0;
                transition: opacity 0.2s;
              }
            }
          }

          .table-input {
            width: 100%;
            padding: 6px 8px;
            border: 1px solid var(--ion-color-light-shade);
            border-radius: 4px;
            font-size: 14px;

            &:focus {
              outline: none;
              border-color: var(--ion-color-primary);
            }

            &:disabled {
              background: var(--ion-color-light);
              color: var(--ion-color-medium);
            }
          }

          .disabled-value {
            color: var(--ion-color-medium);
          }
        }
      }
    }
  }

  // 总价
  .quotation-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--ion-color-primary) 0%, var(--ion-color-primary-shade) 100%);
    border-radius: 8px;
    margin-top: 16px;

    .total-label {
      font-size: 16px;
      font-weight: 500;
      color: white;
    }

    .total-amount {
      font-size: 24px;
      font-weight: 700;
      color: white;
    }
  }

  // ============ 产品相关样式 ============

  // 产品卡片
  .quotation-products {
    .product-card {
      border: 1px solid var(--ion-color-light-shade);
      border-radius: 12px;
      margin-bottom: 16px;
      background: white;
      overflow: hidden;
      transition: all 0.3s ease;

      &.expanded {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
      }

      .product-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        cursor: pointer;
        user-select: none;
        transition: background-color 0.2s;

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

        .product-info {
          display: flex;
          align-items: center;
          gap: 16px;
          flex: 1;

          .product-title {
            display: flex;
            align-items: center;
            gap: 12px;

            .product-icon {
              width: 40px;
              height: 40px;
              display: flex;
              align-items: center;
              justify-content: center;
              background: var(--ion-color-primary-tint);
              border-radius: 10px;
              color: var(--ion-color-primary);
              font-size: 20px;
            }

            .product-details {
              .product-name {
                font-size: 18px;
                font-weight: 600;
                color: var(--ion-color-dark);
                margin: 0 0 4px;
              }

              .product-meta {
                display: flex;
                align-items: center;
                gap: 8px;

                .badge {
                  font-size: 12px;
                  padding: 2px 8px;
                  border-radius: 12px;
                  font-weight: 500;
                }

                .designer-name {
                  font-size: 13px;
                  color: var(--ion-color-medium);
                }
              }
            }
          }

          .product-pricing {
            text-align: right;

            .product-subtotal {
              font-size: 20px;
              font-weight: 700;
              color: var(--ion-color-primary);
              margin: 0 0 2px;
            }

            .percentage {
              font-size: 13px;
              color: var(--ion-color-medium);
            }
          }
        }

        .product-actions {
          display: flex;
          align-items: center;
          gap: 8px;

          .btn-icon {
            width: 32px;
            height: 32px;
            border-radius: 8px;
            border: none;
            background: var(--ion-color-light-tint);
            color: var(--ion-color-medium);
            cursor: pointer;
            transition: all 0.2s;

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

            &.danger:hover {
              background: var(--ion-color-danger-tint);
              color: var(--ion-color-danger);
            }

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

          .product-toggle {
            margin-left: 8px;
            color: var(--ion-color-medium);
            transition: transform 0.3s ease;

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

      .product-card.expanded .product-toggle {
        transform: rotate(180deg);
      }

      .product-content {
        border-top: 1px solid var(--ion-color-light-shade);
        animation: slideDown 0.3s ease-out;
      }

      .product-details-section {
        padding: 16px 20px;
        background: var(--ion-color-light-tint);
        border-bottom: 1px solid var(--ion-color-light-shade);

        .detail-item {
          display: flex;
          justify-content: space-between;
          align-items: center;
          margin-bottom: 8px;

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

          .detail-label {
            font-size: 14px;
            color: var(--ion-color-medium);
          }

          .detail-value {
            font-size: 14px;
            font-weight: 500;
            color: var(--ion-color-dark);
          }
        }
      }
    }
  }

  // 报价汇总
  .quotation-summary {
    background: white;
    border: 1px solid var(--ion-color-light-shade);
    border-radius: 12px;
    padding: 20px;
    margin-top: 20px;

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

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

      .breakdown-toggle {
        .btn-text {
          background: none;
          border: none;
          color: var(--ion-color-primary);
          font-size: 14px;
          cursor: pointer;
          padding: 4px 8px;
          border-radius: 4px;
          transition: background-color 0.2s;

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

    .breakdown-list {
      margin-bottom: 16px;

      .breakdown-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border-bottom: 1px solid var(--ion-color-light-tint);

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

        .breakdown-name {
          flex: 1;
          font-size: 14px;
          color: var(--ion-color-dark);
        }

        .breakdown-amount {
          font-size: 15px;
          font-weight: 600;
          color: var(--ion-color-dark);
          margin: 0 16px;
        }

        .breakdown-percentage {
          font-size: 13px;
          color: var(--ion-color-medium);
          min-width: 50px;
          text-align: right;
        }
      }
    }

    .total-section {
      .total-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 0;
        border-top: 2px solid var(--ion-color-primary);
        background: linear-gradient(135deg, var(--ion-color-primary) 0%, var(--ion-color-primary-shade) 100%);
        margin: 0 -20px -20px;
        padding: 16px 20px;

        .total-label {
          font-size: 16px;
          font-weight: 500;
          color: white;
        }

        .total-amount {
          font-size: 24px;
          font-weight: 700;
          color: white;
        }
      }

      .total-meta {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 8px;
        font-size: 12px;
        color: var(--ion-color-medium);

        .generate-info,
        .valid-info {
          display: flex;
          align-items: center;
          gap: 4px;
        }
      }
    }
  }

  // 兼容性 - 保持原有space类名
  .quotation-spaces {
    @extend .quotation-products;
  }

  .space-card {
    @extend .product-card;
  }

  .space-header {
    @extend .product-header;
  }

  .space-content {
    @extend .product-content;
  }
}
