@use 'sass:color';

// iOS风格变量定义
$ios-primary: #007AFF;
$ios-primary-dark: #0062CC;
$ios-secondary: #34C759;
$ios-success: #34C759;
$ios-warning: #FF9500;
$ios-danger: #FF3B30;
$ios-text-primary: #000000;
$ios-text-secondary: #3C3C43;
$ios-text-tertiary: #8E8E93;
$ios-border: #D1D1D6;
$ios-background: #FFFFFF;
$ios-background-secondary: #F2F2F7;
$ios-background-tertiary: #E5E5EA;
$ios-shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
$ios-shadow-md: 0 4px 10px rgba(0,0,0,0.1);
$ios-shadow-lg: 0 10px 30px rgba(0,0,0,0.1);
$ios-radius: 10px;
$ios-radius-lg: 16px;
$ios-transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
$ios-font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', sans-serif;
$ios-spacing-xs: 4px;
$ios-spacing-sm: 8px;
$ios-spacing-md: 16px;
$ios-spacing-lg: 24px;
$ios-spacing-xl: 32px;

// 咨询订单面板样式 - 适配固定区域
.consultation-order-panel {
  background: $ios-background;
  border-radius: $ios-radius-lg;
  box-shadow: $ios-shadow-md;
  height: 100%;
  max-height: 600px;
  display: flex;
  flex-direction: column;
  font-family: $ios-font-family;
  overflow: hidden;

  // 订单分配头部
  .order-assignment-header {
    padding: $ios-spacing-md $ios-spacing-lg;
    background: linear-gradient(135deg, $ios-background 0%, $ios-background-secondary 100%);
    border-bottom: 1px solid $ios-border;
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;

    .assignment-title {
      font-size: 18px;
      font-weight: 600;
      color: $ios-text-primary;
      margin: 0;
    }

    .assignment-actions {
      display: flex;
      gap: $ios-spacing-md;
      align-items: center;

      .assign-designer-btn {
        padding: 8px 16px;
        background: $ios-background;
        border: 2px solid $ios-primary;
        border-radius: $ios-radius;
        color: $ios-primary;
        font-size: 14px;
        font-weight: 500;
        cursor: pointer;
        transition: $ios-transition;
        display: flex;
        align-items: center;
        gap: 6px;
        min-width: 120px;
        justify-content: center;

        &:hover {
          background: $ios-primary;
          color: white;
        }

        &.assigned {
          background: $ios-success;
          border-color: $ios-success;
          color: white;

          &:hover {
            background: color.adjust($ios-success, $lightness: -10%);
          }
        }

        .designer-info {
          display: flex;
          align-items: center;
          gap: 4px;

          .icon-user {
            font-size: 12px;
          }
        }
      }

      .create-order-btn {
        padding: 10px 20px;
        background: $ios-primary;
        border: none;
        border-radius: $ios-radius;
        color: white;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        transition: $ios-transition;
        min-width: 100px;

        &:hover:not(.disabled) {
          background: $ios-primary-dark;
          transform: translateY(-1px);
          box-shadow: $ios-shadow-md;
        }

        &.disabled {
          background: $ios-text-tertiary;
          cursor: not-allowed;
          opacity: 0.6;
        }
      }
    }
  }

  // 可滚动内容区域
  .panel-content {
    flex: 1;
    overflow-y: auto;
    padding: $ios-spacing-md $ios-spacing-lg;
    
    // iOS风格滚动条
    &::-webkit-scrollbar {
      width: 6px;
    }
    
    &::-webkit-scrollbar-track {
      background: $ios-background-secondary;
      border-radius: 3px;
    }
    
    &::-webkit-scrollbar-thumb {
      background: $ios-text-tertiary;
      border-radius: 3px;
      
      &:hover {
        background: $ios-text-secondary;
      }
    }
  }

  // 客户信息栏
  .customer-info-section {
    margin-bottom: $ios-spacing-lg;
    padding: $ios-spacing-md;
    background: $ios-background-secondary;
    border-radius: $ios-radius;
    border: 1px solid $ios-border;

    .section-title {
      font-size: 16px;
      font-weight: 600;
      color: $ios-text-primary;
      margin-bottom: $ios-spacing-md;
    }

    .search-container {
      display: flex;
      align-items: center;
      gap: $ios-spacing-sm;
      margin-bottom: $ios-spacing-sm;

      .search-input {
        flex: 1;
        padding: 12px $ios-spacing-md;
        border: 2px solid $ios-border;
        border-radius: $ios-radius;
        font-size: 16px;
        background: $ios-background;
        transition: $ios-transition;

        &:focus {
          outline: none;
          border-color: $ios-primary;
          box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
        }

        &::placeholder {
          color: $ios-text-tertiary;
        }
      }

      .search-btn {
        padding: 12px $ios-spacing-md;
        background: $ios-primary;
        color: $ios-background;
        border: none;
        border-radius: $ios-radius;
        cursor: pointer;
        font-size: 16px;
        font-weight: 500;
        transition: $ios-transition;

        &:hover {
          background: $ios-primary-dark;
          transform: translateY(-1px);
        }

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

    .search-results {
      max-height: 200px;
      overflow-y: auto;
      border: 1px solid $ios-border;
      border-radius: $ios-radius;
      background: $ios-background;
      margin-top: $ios-spacing-sm;

      .result-item {
        padding: $ios-spacing-md;
        cursor: pointer;
        border-bottom: 1px solid $ios-border;
        transition: $ios-transition;

        &:hover {
          background: $ios-background-secondary;
        }

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

        .customer-name {
          font-weight: 500;
          color: $ios-text-primary;
        }

        .customer-info {
          font-size: 14px;
          color: $ios-text-secondary;
          margin-top: 2px;
        }
      }
    }

    .selected-customer {
      padding: $ios-spacing-md;
      background: rgba($ios-primary, 0.1);
      border-radius: $ios-radius;
      border: 1px solid rgba($ios-primary, 0.2);
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-top: $ios-spacing-sm;

      .customer-details {
        .customer-name {
          font-weight: 600;
          color: $ios-text-primary;
        }

        .customer-phone {
          font-size: 14px;
          color: $ios-text-secondary;
          margin-top: 2px;
        }
      }

      .clear-btn {
        background: $ios-danger;
        color: $ios-background;
        border: none;
        border-radius: 6px;
        padding: 6px 12px;
        cursor: pointer;
        font-size: 14px;
        font-weight: 500;
        transition: $ios-transition;

        &:hover {
          background: color.adjust($ios-danger, $lightness: -10%);
          transform: translateY(-1px);
        }
      }
    }
  }

  // 新客户表单
  .new-customer-form {
    margin-bottom: $ios-spacing-lg;
    padding: $ios-spacing-md;
    background: $ios-background-secondary;
    border-radius: $ios-radius;
    border: 1px solid $ios-border;

    .form-title {
      font-size: 16px;
      font-weight: 600;
      margin-bottom: $ios-spacing-md;
      color: $ios-text-primary;
    }

    .form-row {
      display: flex;
      gap: $ios-spacing-md;
      margin-bottom: $ios-spacing-md;

      @media (max-width: 768px) {
        flex-direction: column;
        gap: $ios-spacing-sm;
      }

      .form-group {
        flex: 1;

        label {
          display: block;
          margin-bottom: $ios-spacing-xs;
          font-size: 14px;
          font-weight: 500;
          color: $ios-text-primary;
        }

        input, select, textarea {
          width: 100%;
          padding: 12px $ios-spacing-md;
          border: 2px solid $ios-border;
          border-radius: $ios-radius;
          font-size: 16px;
          background: $ios-background;
          transition: $ios-transition;
          box-sizing: border-box;

          &:focus {
            outline: none;
            border-color: $ios-primary;
            box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
          }

          &::placeholder {
            color: $ios-text-tertiary;
          }
        }

        textarea {
          resize: vertical;
          min-height: 80px;
          font-family: $ios-font-family;
        }

        select {
          cursor: pointer;
        }
      }
    }
  }

  // 项目需求卡片
  .requirements-card {
    background: $ios-background;
    border: 1px solid $ios-border;
    border-radius: $ios-radius;
    margin-bottom: $ios-spacing-md;
    overflow: hidden;

    .card-header {
      padding: $ios-spacing-md;
      background: linear-gradient(135deg, $ios-background-secondary 0%, $ios-background-tertiary 100%);
      border-bottom: 1px solid $ios-border;
      display: flex;
      justify-content: space-between;
      align-items: center;
      cursor: pointer;
      transition: $ios-transition;

      &:hover {
        background: linear-gradient(135deg, $ios-background-tertiary 0%, $ios-border 100%);
      }

      .card-title {
        font-size: 16px;
        font-weight: 600;
        color: $ios-text-primary;
      }

      .toggle-icon {
        color: $ios-text-secondary;
        transition: transform 0.3s ease;
        font-size: 18px;

        &.expanded {
          transform: rotate(180deg);
        }
      }
    }

    .card-content {
      padding: $ios-spacing-md;
      max-height: 500px;
      overflow-y: auto;

      // iOS风格滚动条
      &::-webkit-scrollbar {
        width: 6px;
      }
      
      &::-webkit-scrollbar-track {
        background: $ios-background-secondary;
        border-radius: 3px;
      }
      
      &::-webkit-scrollbar-thumb {
        background: $ios-text-tertiary;
        border-radius: 3px;
        
        &:hover {
          background: $ios-text-secondary;
        }
      }

      .form-row {
        display: flex;
        gap: $ios-spacing-md;
        margin-bottom: $ios-spacing-md;

        // 优化布局：移除字段后调整间距和对齐
        &:last-child {
          margin-bottom: 0;
        }

        @media (max-width: 768px) {
          flex-direction: column;
          gap: $ios-spacing-sm;
        }

        // 针对不同行数的表单组进行优化
        &.two-columns {
          .form-group {
            flex: 1;
            min-width: calc(50% - #{$ios-spacing-md / 2});
          }
        }

        &.three-columns {
          .form-group {
            flex: 1;
            min-width: calc(33.333% - #{$ios-spacing-md * 2 / 3});
          }
        }

        &.single-column {
          .form-group {
            flex: 1;
            width: 100%;
          }
        }

        .form-group {
          flex: 1;

          label {
            display: block;
            margin-bottom: $ios-spacing-xs;
            font-size: 14px;
            font-weight: 500;
            color: $ios-text-primary;
          }

          .required {
            color: #ff4444;
            font-weight: bold;
          }

          input, select, textarea {
            width: 100%;
            padding: 12px $ios-spacing-md;
            border: 2px solid $ios-border;
            border-radius: $ios-radius;
            font-size: 16px;
            background: $ios-background;
            transition: $ios-transition;
            box-sizing: border-box;

            &:focus {
              outline: none;
              border-color: $ios-primary;
              box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
            }

            &::placeholder {
              color: $ios-text-tertiary;
            }
          }

          select {
            cursor: pointer;
          }
        }
      }

      .tags-section {
        margin-top: $ios-spacing-md;

        .tags-title {
          font-size: 14px;
          font-weight: 600;
          margin-bottom: $ios-spacing-sm;
          color: $ios-text-primary;
        }

        .tags-container {
          display: flex;
          flex-wrap: wrap;
          gap: $ios-spacing-sm;
          margin-bottom: $ios-spacing-md;

          .tag {
            padding: 6px 12px;
            background: rgba($ios-primary, 0.1);
            border: 1px solid rgba($ios-primary, 0.2);
            border-radius: 20px;
            font-size: 14px;
            color: $ios-primary;
            display: flex;
            align-items: center;
            gap: $ios-spacing-xs;
            transition: $ios-transition;

            &:hover {
              background: rgba($ios-primary, 0.15);
            }

            .remove-tag {
              background: none;
              border: none;
              color: $ios-primary;
              cursor: pointer;
              font-size: 16px;
              padding: 0;
              width: 18px;
              height: 18px;
              display: flex;
              align-items: center;
              justify-content: center;
              border-radius: 50%;
              transition: $ios-transition;

              &:hover {
                background: rgba($ios-danger, 0.1);
                color: $ios-danger;
              }
            }
          }
        }

        .tag-input-container {
          display: flex;
          gap: $ios-spacing-sm;

          .tag-input {
            flex: 1;
            padding: 10px $ios-spacing-md;
            border: 2px solid $ios-border;
            border-radius: $ios-radius;
            font-size: 14px;
            background: $ios-background;
            transition: $ios-transition;

            &:focus {
              outline: none;
              border-color: $ios-primary;
              box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
            }

            &::placeholder {
              color: $ios-text-tertiary;
            }
          }

          .add-tag-btn {
            padding: 10px $ios-spacing-md;
            background: $ios-secondary;
            color: $ios-background;
            border: none;
            border-radius: $ios-radius;
            cursor: pointer;
            font-size: 14px;
            font-weight: 500;
            transition: $ios-transition;

            &:hover {
              background: color.adjust($ios-secondary, $lightness: -10%);
              transform: translateY(-1px);
            }

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

  // 紧凑型流程进度指示器
  .compact-stage-indicators {
    margin: $ios-spacing-md 0;
    
    .stage-chain {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: $ios-spacing-xs;
    }
    
    .stage-dot {
      width: 32px;
      height: 32px;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
      font-size: 14px;
      font-weight: 600;
      transition: all 0.3s ease;
      position: relative;
      
      .stage-number {
        color: white;
        font-size: 12px;
      }
      
      &.stage-pending {
        background: #D1D1D6;
        border: 2px solid #8E8E93;
        
        .stage-number {
          color: $ios-text-secondary;
        }
      }
      
      &.stage-in-progress {
        background: $ios-primary;
        border: 2px solid $ios-primary-dark;
        box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.2);
        
        .stage-number {
          color: white;
        }
      }
      
      &.stage-completed {
        background: $ios-success;
        border: 2px solid color.adjust($ios-success, $lightness: -10%);
        
        .stage-number {
          color: white;
        }
      }
    }
    
    .stage-connector {
      width: 24px;
      height: 2px;
      transition: all 0.3s ease;
      
      &.pending {
        background: #D1D1D6;
      }
      
      &.completed {
        background: $ios-success;
      }
    }
  }
  
  // 进度指示器
  .progress-indicator {
    display: flex;
    align-items: center;
    gap: $ios-spacing-sm;
    margin-top: $ios-spacing-sm;
    
    .progress-bar {
      flex: 1;
      height: 6px;
      background: $ios-background-secondary;
      border-radius: 3px;
      overflow: hidden;
      
      .progress-fill {
        height: 100%;
        background: linear-gradient(90deg, $ios-primary, color.adjust($ios-primary, $lightness: 10%));
        border-radius: 3px;
        transition: width 0.3s ease;
      }
    }
    
    .progress-text {
      font-size: 14px;
      color: $ios-text-secondary;
      font-weight: 500;
      min-width: 60px;
      text-align: right;
    }
  }

  // 底部提交区域
  .panel-footer {
    padding: $ios-spacing-md $ios-spacing-lg;
    background: $ios-background-secondary;
    border-top: 1px solid $ios-border;
    flex-shrink: 0;

    .submit-btn {
      width: 100%;
      padding: 12px 24px;
      background: #007bff;
      color: white;
      border: none;
      border-radius: 6px;
      font-size: 16px;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.3s ease;

      &:hover:not(:disabled) {
        transform: translateY(-2px);
        box-shadow: $ios-shadow-md;
        background: linear-gradient(135deg, #0056CC 0%, #004499 100%);
      }

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

      &:disabled {
        background: linear-gradient(135deg, $ios-text-tertiary 0%, #B0B0B0 100%);
        color: #FFFFFF;
        cursor: not-allowed;
        transform: none;
        box-shadow: none;
        opacity: 0.6;
      }
      
      // 表单有效时的强调样式
      &:not(:disabled) {
        background: linear-gradient(135deg, $ios-success 0%, #28A745 100%);
        box-shadow: 0 4px 15px rgba(52, 199, 89, 0.3);
        
        &:hover {
          background: linear-gradient(135deg, #28A745 0%, #1E7E34 100%);
          box-shadow: 0 6px 20px rgba(52, 199, 89, 0.4);
        }
      }
    }
  }

  // 表单验证提示
  .validation-hint {
    display: flex;
    align-items: center;
    gap: $ios-spacing-sm;
    margin-top: $ios-spacing-sm;
    padding: $ios-spacing-sm $ios-spacing-md;
    background: rgba($ios-warning, 0.1);
    border: 1px solid rgba($ios-warning, 0.3);
    border-radius: $ios-radius;
    color: $ios-warning;
    font-size: 14px;
    font-weight: 500;
    
    svg {
      flex-shrink: 0;
    }
  }

  // 响应式设计
  @media (max-width: 768px) {
    .panel-header {
      padding: $ios-spacing-md;
    }

    .panel-content {
      padding: $ios-spacing-md;
    }

    .panel-footer {
      padding: $ios-spacing-md;
    }
  }

  // 同步客户信息显示样式
  .synced-customer-info {
    margin-bottom: $ios-spacing-lg;
    padding: $ios-spacing-md;
    background: rgba($ios-success, 0.05);
    border: 1px solid rgba($ios-success, 0.2);
    border-radius: $ios-radius;

    .form-title {
      font-size: 16px;
      font-weight: 600;
      color: $ios-success;
      margin-bottom: $ios-spacing-md;
    }

    .customer-info-display {
      .info-row {
        display: flex;
        gap: $ios-spacing-lg;
        margin-bottom: $ios-spacing-sm;

        .info-item {
          flex: 1;
          display: flex;
          align-items: center;

          label {
            font-weight: 500;
            color: $ios-text-secondary;
            margin-right: $ios-spacing-sm;
            min-width: 80px;
          }

          span {
            color: $ios-text-primary;
            font-weight: 500;
          }
        }
      }
    }
  }

  // 同步需求信息显示样式
  .synced-requirements-display {
    .sync-title {
      font-size: 16px;
      font-weight: 600;
      color: $ios-success;
      margin-bottom: $ios-spacing-md;
    }

    .requirements-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: $ios-spacing-md;
      margin-bottom: $ios-spacing-lg;

      .requirement-item {
        display: flex;
        align-items: flex-start;
        padding: $ios-spacing-sm;
        background: rgba($ios-success, 0.03);
        border-radius: $ios-radius;

        &.full-width {
          grid-column: 1 / -1;
          flex-direction: column;

          label {
            margin-bottom: $ios-spacing-xs;
          }
        }

        label {
          font-weight: 500;
          color: $ios-text-secondary;
          margin-right: $ios-spacing-sm;
          min-width: 80px;
        }

        span {
          color: $ios-text-primary;
          font-weight: 500;
          flex: 1;
        }
      }
    }

    .synced-tags-section {
      .tags-title {
        font-size: 14px;
        font-weight: 600;
        color: $ios-text-secondary;
        margin-bottom: $ios-spacing-sm;
      }

      .tags-container {
        display: flex;
        flex-wrap: wrap;
        gap: $ios-spacing-sm;

        .synced-tag {
          background: rgba($ios-success, 0.1);
          color: $ios-success;
          border: 1px solid rgba($ios-success, 0.3);
        }
      }
    }
  }
}