// 客户画像组件样式

// 加载和错误容器
.loading-container,
.error-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 20px;
  text-align: center;

  ion-spinner {
    --color: var(--ion-color-primary);
    transform: scale(1.5);
    margin-bottom: 16px;
  }

  ion-icon {
    font-size: 64px;
    color: var(--ion-color-danger);
    margin-bottom: 16px;
  }

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

// 客户画像容器
.contact-container {
  max-width: 800px;
  margin: 0 auto;
  padding-bottom: 20px;

  // 通用卡片样式
  ion-card {
    margin-bottom: 16px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);

    ion-card-title {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 16px;
      font-weight: 600;

      ion-icon {
        font-size: 20px;
        color: var(--ion-color-primary);
      }
    }

    ion-card-subtitle {
      color: var(--ion-color-medium);
      font-size: 12px;
      margin-top: 4px;
    }
  }

  // 头部卡片
  .header-card {
    background: linear-gradient(135deg, var(--ion-color-primary) 0%, var(--ion-color-secondary) 100%);
    color: white;

    .customer-header {
      display: flex;
      align-items: center;
      gap: 16px;
      margin-bottom: 16px;

      .customer-avatar {
        width: 80px;
        height: 80px;
        border: 3px solid white;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);

        ion-icon {
          font-size: 80px;
          color: white;
        }
      }

      .customer-info {
        flex: 1;

        h2 {
          margin: 0 0 8px;
          font-size: 24px;
          font-weight: 700;
          color: white;
        }

        .source-badge {
          display: inline-flex;
          align-items: center;
          gap: 6px;
          padding: 4px 12px;
          background-color: rgba(255, 255, 255, 0.2);
          border-radius: 12px;
          font-size: 13px;

          ion-icon {
            font-size: 16px;
          }
        }
      }
    }

    .tags-container {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;

      ion-chip {
        --background: rgba(255, 255, 255, 0.2);
        --color: white;
        margin: 0;
        height: 28px;
        font-size: 12px;
      }
    }
  }

  // 基础信息卡片
  .basic-info-card {
    ion-list {
      ion-item {
        --padding-start: 0;
        margin-bottom: 12px;

        ion-icon {
          font-size: 24px;
          color: var(--ion-color-primary);
          margin-right: 12px;
        }

        ion-label {
          p {
            color: var(--ion-color-medium);
            font-size: 12px;
            margin-bottom: 4px;
          }

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

    .permission-notice {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 12px;
      margin-top: 12px;
      background-color: var(--ion-color-light);
      border-radius: 8px;
      font-size: 13px;
      color: var(--ion-color-medium);

      ion-icon {
        font-size: 18px;
        flex-shrink: 0;
      }
    }
  }

  // 客户画像卡片
  .preferences-card {
    .preference-grid {
      display: grid;
      gap: 16px;

      .preference-item {
        .preference-label {
          display: flex;
          align-items: center;
          gap: 6px;
          margin-bottom: 8px;
          font-size: 13px;
          color: var(--ion-color-medium);
          font-weight: 500;

          ion-icon {
            font-size: 18px;
          }
        }

        .preference-value {
          display: flex;
          flex-wrap: wrap;
          gap: 6px;

          ion-badge {
            font-size: 12px;
            padding: 6px 12px;
          }

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

  // 群聊卡片
  .groups-card {
    .groups-grid {
      display: grid;
      gap: 12px;

      .group-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px;
        background-color: var(--ion-color-light);
        border-radius: 8px;
        cursor: pointer;
        transition: all 0.2s;

        &:hover {
          background-color: var(--ion-color-light-shade);
          transform: translateX(4px);
        }

        .group-info {
          display: flex;
          align-items: center;
          gap: 12px;
          flex: 1;

          > ion-icon {
            font-size: 40px;
            color: var(--ion-color-primary);
            flex-shrink: 0;
          }

          .group-text {
            flex: 1;
            min-width: 0;

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

            .project-name {
              display: flex;
              align-items: center;
              gap: 4px;
              margin: 0;
              font-size: 12px;
              color: var(--ion-color-success);

              ion-icon {
                font-size: 14px;
              }
            }

            .no-project {
              margin: 0;
              font-size: 12px;
              color: var(--ion-color-medium);
              font-style: italic;
            }
          }
        }

        .arrow {
          font-size: 20px;
          color: var(--ion-color-medium);
          flex-shrink: 0;
        }
      }
    }
  }

  // 历史项目卡片
  .projects-card {
    ion-item {
      --padding-start: 8px;
      cursor: pointer;

      h2 {
        font-weight: 600;
        margin-bottom: 4px;
        color: var(--ion-color-dark);
      }

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

      ion-badge {
        font-size: 11px;
        padding: 4px 8px;
        border-radius: 4px;
      }
    }
  }

  // 时间线卡片
  .timeline-card {
    .timeline {
      position: relative;
      padding-left: 40px;

      &::before {
        content: '';
        position: absolute;
        left: 15px;
        top: 8px;
        bottom: 8px;
        width: 2px;
        background-color: var(--ion-color-light-shade);
      }

      .timeline-item {
        position: relative;
        margin-bottom: 24px;

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

        .timeline-dot {
          position: absolute;
          left: -40px;
          top: 2px;
          width: 32px;
          height: 32px;
          display: flex;
          align-items: center;
          justify-content: center;
          background-color: var(--ion-color-primary);
          border-radius: 50%;
          box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);

          ion-icon {
            font-size: 18px;
            color: white;
          }
        }

        .timeline-content {
          .timeline-time {
            font-size: 11px;
            color: var(--ion-color-medium);
            margin-bottom: 4px;
          }

          .timeline-text {
            padding: 12px;
            background-color: var(--ion-color-light);
            border-radius: 8px;

            strong {
              font-size: 13px;
              color: var(--ion-color-dark);
            }

            p {
              margin: 4px 0 0;
              font-size: 13px;
              color: var(--ion-color-medium);
              line-height: 1.5;
            }
          }
        }
      }
    }
  }
}

// 项目状态徽标
ion-badge {
  &.status-pending {
    --background: var(--ion-color-warning);
    --color: white;
  }

  &.status-active {
    --background: var(--ion-color-primary);
    --color: white;
  }

  &.status-completed {
    --background: var(--ion-color-success);
    --color: white;
  }

  &.status-paused {
    --background: var(--ion-color-medium);
    --color: white;
  }

  &.status-cancelled {
    --background: var(--ion-color-danger);
    --color: white;
  }

  &.status-default {
    --background: var(--ion-color-light);
    --color: var(--ion-color-dark);
  }
}

// 响应式适配
@media (min-width: 768px) {
  .contact-container {
    .preference-grid {
      grid-template-columns: repeat(2, 1fr);
    }

    .groups-grid {
      grid-template-columns: repeat(2, 1fr);
    }
  }
}
