/**
 * PisellEntityCard 样式
 * 按 Figma Entity Card 设计：8px 圆角、8px 内边距、Gray/300 边框、标题 14px Semibold、次级 14px Regular #667085、间距 6px/4px、标签 pill
 */
/* Figma 设计稿：卡片圆角 8px、边框 #D0D5DD */
@entity-card-radius: 8px;
@entity-card-padding: 8px;
@entity-card-border: 1px solid #d0d5dd;
@entity-card-bg: #ffffff;
/* 标题：Text sm/Semibold 14px #000，行高 20 */
@entity-card-title-size: 14px;
@entity-card-title-weight: 600;
@entity-card-title-color: #000000;
@entity-card-title-line-height: 20px;
/* 次级：Text sm/Regular 14px #667085，行高 20 */
@entity-card-secondary-size: 14px;
@entity-card-secondary-color: #667085;
@entity-card-secondary-line-height: 20px;
/* 媒体与文案间距 6px，文案列内间距 4px */
@entity-card-gap-media-text: 6px;
@entity-card-gap-text-inner: 0;
/* 标签：xs/Medium 12px，行高 18，pill 圆角 16px，padding 2px 8px */
@entity-card-tag-size: 12px;
@entity-card-tag-line-height: 18px;
@entity-card-tag-padding: 2px 8px;
@entity-card-tag-radius: 16px;

.pisell-entity-card-wrap {
  box-sizing: border-box;
  min-width: 0;

  &.pisell-entity-card-wrap-swipe {
    overflow: hidden;
    border-radius: @entity-card-radius;
  }
}

.pisell-entity-card-swipe-container {
  position: relative;
  overflow: hidden;
  border-radius: @entity-card-radius;
  touch-action: none;
}

.pisell-entity-card-swipe-delete {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ff4d4f;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
  z-index: 0;
  border-radius: 0 @entity-card-radius @entity-card-radius 0;
}

.pisell-entity-card-swipe-content {
  position: relative;
  z-index: 1;
  background: inherit;
  transition: transform 0.2s ease;
  border-radius: @entity-card-radius;
}

/* 根节点：布局；Figma 默认 8px 圆角/内边距/边框由组件传入 style 合并 */
.pisell-entity-card-root {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.pisell-entity-card-summary {
  display: flex;
  min-width: 0;
  flex: 1;

  /* 横向：头像靠上，文案区垂直居中 */
  &[data-layout='horizontal'] {
    flex-direction: row;
    align-items: flex-start;
  }

  &[data-layout='vertical'] {
    flex-direction: column;
    align-items: center;
  }
}

.pisell-entity-card-summary[data-layout='horizontal'] .pisell-entity-card-media-wrap {
  align-self: flex-start;
}

.pisell-entity-card-summary[data-layout='horizontal'] .pisell-entity-card-text-wrap {
  align-self: center;
}

.pisell-entity-card-media-wrap {
  flex-shrink: 0;
}

.pisell-entity-card-media {
  display: block;
}

.pisell-entity-card-media-avatar {
  border-radius: 50%;
}

.pisell-entity-card-text-wrap {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: @entity-card-gap-text-inner;
  overflow: hidden;
}

.pisell-entity-card-summary[data-layout='horizontal'] .pisell-entity-card-text-wrap {
  margin-left: @entity-card-gap-media-text;
}

.pisell-entity-card-summary[data-layout='vertical'] .pisell-entity-card-text-wrap {
  margin-top: @entity-card-gap-media-text;
  align-items: center;
  text-align: center;
}

/* 主文案行：标题与副标题同一行时垂直居中对齐；空间不够时副标题与标签整体换行 */
.pisell-entity-card-primary-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: @entity-card-gap-media-text;
  min-width: 0;
}

/* 竖向布局：主标题单独一行，副标题与标签单独一行并居中 */
.pisell-entity-card-summary[data-layout='vertical'] .pisell-entity-card-primary-row {
  justify-content: center;
}

.pisell-entity-card-summary[data-layout='vertical'] .pisell-entity-card-primary-row .pisell-entity-card-primary {
  flex: 0 0 100%;
  width: 100%;
  text-align: center;
}

.pisell-entity-card-summary[data-layout='vertical'] .pisell-entity-card-primary-row .pisell-entity-card-primary-extra {
  flex: 0 0 100%;
  width: 100%;
  justify-content: center;
}

/* 副标题与 inline 标签的容器：不压缩，空间不够时整块换行；换行后各自可省略 */
.pisell-entity-card-primary-extra {
  flex: 1 0 auto;
  min-width: min-content;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  overflow: hidden;
  max-width: 100%;
}

/* 主标题：先占内容宽度，不主动压缩，让副标题/标签先换行；仅在极窄时单行省略 */
.pisell-entity-card-primary {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

/* Figma Title text: 14px Semibold #000, line-height 20；宽度不足时单行省略号 */
.pisell-entity-card-primary-text {
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  font-size: @entity-card-title-size;
  font-weight: @entity-card-title-weight;
  color: @entity-card-title-color;
  line-height: @entity-card-title-line-height;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;

  /* 有行数限制时：多行截断并省略，覆盖 antd 与默认单行样式；需有宽度约束 line-clamp 才生效 */

  &.pisell-entity-card-primary-text-has-line-clamp {
    display: -webkit-box !important;
    -webkit-line-clamp: 1; /* 默认 1 行，2/3 行等由组件 style 覆盖 */
    -webkit-box-orient: vertical !important;
    overflow: hidden !important;
    white-space: normal !important;
    text-overflow: ellipsis;
    width: 100%;
    max-width: 100%;
    min-width: 0;
  }
}

/* 副标题：与主标题/标签同行或换行，宽度不足时单行省略 */
.pisell-entity-card-subtitle-wrap {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
}

.pisell-entity-card-subtitle {
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  display: block;
  font-size: @entity-card-secondary-size;
  font-weight: 400;
  color: @entity-card-secondary-color;
  line-height: @entity-card-secondary-line-height;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.pisell-entity-card-secondary {
  min-width: 0;
}

/* Figma Text information: 14px Regular #667085, line-height 20 */
.pisell-entity-card-secondary-text {
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  font-size: @entity-card-secondary-size;
  font-weight: 400;
  color: @entity-card-secondary-color;
  line-height: @entity-card-secondary-line-height;
}

.pisell-entity-card-secondary-line {
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 0;
  padding-bottom: 0;
  display: block;
  line-height: @entity-card-secondary-line-height;
}

.pisell-entity-card-secondary-tooltip-icon {
  margin-right: 4px;
  font-size: 12px;
  color: @entity-card-secondary-color;
}

.pisell-entity-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: @entity-card-gap-media-text;
  margin-top: 0;
  min-width: 0;

  /* inline 标签：可换行，宽度不足时整体收缩、单签可省略 */

  &.pisell-entity-card-tags-inline {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    max-width: 100%;
  }
}

/* Figma Badge: 12px Medium, pill 16px radius, padding 2px 8px */
.pisell-entity-card-tag {
  display: inline-block;
  padding: @entity-card-tag-padding;
  font-size: @entity-card-tag-size;
  font-weight: 500;
  line-height: @entity-card-tag-line-height;
  border-radius: @entity-card-tag-radius;
  background: #f5f5f5;
  color: @entity-card-secondary-color;

  /* inline 时单签过长可省略 */

  .pisell-entity-card-tags-inline & {
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* 设计稿：卡片内容一行，左侧 summary、右侧 actions（justify-between） */
.pisell-entity-card-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-width: 0;
}

/* Figma 13355-110786：Action 在右侧，与 summary 同一行；操作项支持文本/按钮/图标 */
.pisell-entity-card-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.pisell-entity-card-action {
  padding: 4px 0;
  border: none;
  background: transparent;
  font-size: 14px;
  color: #475467;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;

  &:focus-visible {
    outline: 1px solid #1677ff;
    outline-offset: 2px;
  }

  &.pisell-entity-card-action-text {
    color: #1677ff;
  }

  &.pisell-entity-card-action-button {
    padding: 4px 12px;
    border: 1px solid #d0d5dd;
    border-radius: 6px;
    color: #344054;
    background: #fff;

    &:hover {
      border-color: #1677ff;
      color: #1677ff;
    }
  }

  &.pisell-entity-card-action-icon {
    padding: 4px;
    color: #475467;

    .anticon {
      font-size: 20px;
    }
  }
}
