// 客户画像组件样式 - 使用纯 div+scss 实现

// CSS 变量定义
:host {
  --primary-color: #3880ff;
  --secondary-color: #0cd1e8;
  --tertiary-color: #7044ff;
  --success-color: #10dc60;
  --warning-color: #ffce00;
  --danger-color: #f04141;
  --dark-color: #222428;
  --medium-color: #989aa2;
  --light-color: #f4f5f8;
  --light-shade: #d7d8da;
}

.contact-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background-color: #f5f5f5;
}

// 头部导航
.header {
  background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;

  .header-toolbar {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    max-height: 56px;

    .back-button {
      background: none;
      border: none;
      color: white;
      padding: 8px;
      cursor: pointer;
      display: flex;
      align-items: center;
      justify-content: center;
      border-radius: 50%;
      transition: background-color 0.3s;

      &:hover {
        background-color: rgba(255, 255, 255, 0.1);
      }

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

    .title {
      flex: 1;
      margin: 0 16px;
      font-size: 18px;
      font-weight: 600;
    }
  }
}

// 内容区域
.content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

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

  .spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--light-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
  }

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

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

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

// 通用按钮样式
.btn {
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  border: none;
  outline: none;

  &.btn-outline {
    background: white;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);

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

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

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

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

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

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

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

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

    .customer-avatar {
      width: 80px;
      height: 80px;
      border: 3px solid white;
      border-radius: 50%;
      overflow: hidden;
      box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgba(255, 255, 255, 0.2);

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

      .icon-avatar {
        width: 80px;
        height: 80px;
        color: white;
      }
    }

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

      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;

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

  .tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 16px;
  }
}

// Chip 组件
.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  background: rgba(255, 255, 255, 0.2);
  color: white;

  &.chip-primary {
    background: rgba(255, 255, 255, 0.2);
    color: white;
  }
}

// Badge 组件
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;

  &.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-medium {
    background: var(--medium-color);
    color: white;
  }
}

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

  &.icon-sm {
    width: 14px;
    height: 14px;
  }

  &.icon-wechat {
    width: 24px;
    height: 24px;
    color: #09BB07;
  }

  &.icon-group {
    width: 40px;
    height: 40px;
  }

  &.arrow {
    width: 20px;
    height: 20px;
    color: var(--medium-color);
  }
}

// 基础信息卡片
.basic-info-card {
  .info-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

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

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

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

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

      .info-value {
        margin: 0;
        color: var(--dark-color);
        font-size: 15px;
        font-weight: 500;
      }
    }
  }

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

    .icon {
      width: 18px;
      height: 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(--medium-color);
        font-weight: 500;

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

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

        .empty {
          color: var(--medium-color);
          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(--light-color);
      border-radius: 8px;
      cursor: pointer;
      transition: all 0.3s;

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

      &:active {
        transform: translateX(2px);
      }

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

        .group-text {
          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;
          }

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

            .icon-sm {
              width: 14px;
              height: 14px;
            }
          }

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

// 历史项目卡片
.projects-card {
  .project-list {
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .project-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 8px;
    cursor: pointer;
    transition: background-color 0.3s;
    border-bottom: 1px solid var(--light-shade);

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

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

    &:active {
      background-color: var(--light-shade);
    }

    .project-content {
      flex: 1;
      min-width: 0;

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

      .project-status {
        display: flex;
        align-items: center;
        gap: 8px;
        margin: 4px 0;

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

      .project-time {
        margin: 4px 0 0;
        font-size: 12px;
        color: var(--medium-color);
      }
    }
  }
}

// 项目状态样式
.status-pending {
  background: var(--warning-color) !important;
  color: var(--dark-color) !important;
}

.status-active {
  background: var(--primary-color) !important;
  color: white !important;
}

.status-completed {
  background: var(--success-color) !important;
  color: white !important;
}

.status-paused {
  background: var(--medium-color) !important;
  color: white !important;
}

.status-cancelled {
  background: var(--danger-color) !important;
  color: white !important;
}

.status-default {
  background: var(--light-color) !important;
  color: var(--dark-color) !important;
}

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

    &::before {
      content: '';
      position: absolute;
      left: 15px;
      top: 8px;
      bottom: 8px;
      width: 2px;
      background-color: var(--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(--primary-color);
        border-radius: 50%;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);

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

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

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

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

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

// 响应式适配
@media (min-width: 768px) {
  .contact-container {
    padding: 24px;

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

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

@media (max-width: 480px) {
  .header {
    .header-toolbar {
      .title {
        font-size: 16px;
      }
    }
  }

  .header-card {
    .customer-header {
      .customer-avatar {
        width: 64px;
        height: 64px;

        .icon-avatar {
          width: 64px;
          height: 64px;
        }
      }

      .customer-info {
        h2 {
          font-size: 20px;
        }
      }
    }
  }
}
