/* 客服页 · 会话列表样式 */
:root {
  --kefu-red: #E60012;
  --kefu-bg: #f3f4f6;
  --bottom-nav-height: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

.kefu-page {
  margin: 0;
  min-height: 100vh;
  background: var(--kefu-bg);
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + 8px);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

.kefu-page.is-chatting {
  padding-bottom: 0;
}

.kefu-page.is-chatting .v9-tabbar {
  display: none;
}

/* 顶部横幅 */
.kefu-hero {
  position: relative;
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  overflow: hidden;
  background: linear-gradient(135deg, #1a1f2e 0%, #2d3548 55%, #1e2734 100%);
}

.kefu-hero__img {
  display: block;
  width: 100%;
  height: auto;
  min-height: 120px;
  max-height: 168px;
  object-fit: cover;
}

.kefu-hero__fallback {
  min-height: 132px;
  padding: 20px 18px 24px;
  color: #fff;
  background: linear-gradient(135deg, #2b2110 0%, #5c4a1e 40%, #8b6914 100%);
}

.kefu-hero__fallback-title {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.kefu-hero__fallback-sub {
  margin-top: 6px;
  font-size: 12px;
  opacity: 0.88;
}

/* 列表区 */
.kefu-main {
  max-width: 430px;
  margin: 0 auto;
  padding: 10px 12px 16px;
}

.kefu-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 12px;
  margin-bottom: 10px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border: 1px solid rgba(0, 0, 0, 0.03);
}

.kefu-card:active {
  transform: scale(0.99);
}

.kefu-card__avatar {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: #fff;
  font-size: 18px;
  font-weight: 700;
}

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

.kefu-card__avatar--issue { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.kefu-card__avatar--withdraw { background: linear-gradient(135deg, #ef4444, #dc2626); }
.kefu-card__avatar--activity { background: linear-gradient(135deg, #f59e0b, #ea580c); }
.kefu-card__avatar--agent { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }

.kefu-card__body {
  flex: 1;
  min-width: 0;
}

.kefu-card__title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.kefu-card__title {
  font-size: 15px;
  font-weight: 700;
  color: #111;
}

.kefu-card__badge-v {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
}

.kefu-card__desc {
  margin-top: 4px;
  font-size: 12px;
  color: #888;
  line-height: 1.45;
  white-space: pre-line;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kefu-card__meta {
  margin-top: 4px;
  font-size: 11px;
  color: #bbb;
}

.kefu-card__right {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.kefu-card__unread {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--kefu-red);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 20px;
  text-align: center;
}

.kefu-card__arrow {
  color: #d1d5db;
  font-size: 14px;
}

.kefu-card__status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: #22c55e;
}

.kefu-card__status.is-offline {
  color: #9ca3af;
}

.kefu-card__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.kefu-empty {
  text-align: center;
  padding: 40px 20px;
  color: #999;
  font-size: 14px;
}

/* 聊天顶栏 */
.kefu-chat-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: #fff;
  border-bottom: 1px solid #eee;
  max-width: 430px;
  margin: 0 auto;
}

.kefu-chat-header__back {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: #666;
  font-size: 18px;
  cursor: pointer;
}

.kefu-chat-header__title {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: #111;
}

.kefu-chat-header__sub {
  font-size: 11px;
  color: #22c55e;
  font-weight: 400;
}

.kefu-chat-header__action {
  border: none;
  background: transparent;
  color: #666;
  font-size: 13px;
  cursor: pointer;
  min-width: 56px;
  text-align: right;
}

.kefu-chat-wrap {
  max-width: 430px;
  margin: 0 auto;
  background: #f5f5f5;
}

.kefu-chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 57px);
  height: calc(100dvh - 57px);
}

.kefu-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.kefu-message-item {
  display: flex;
  margin-bottom: 14px;
}

.kefu-message-item.user {
  justify-content: flex-end;
}

.kefu-message-item.agent {
  justify-content: flex-start;
}

.kefu-message-bubble {
  max-width: 76%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.kefu-message-item.user .kefu-message-bubble {
  background: var(--kefu-red);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.kefu-message-item.agent .kefu-message-bubble {
  background: #fff;
  color: #333;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.kefu-message-time {
  margin-top: 4px;
  font-size: 10px;
  opacity: 0.7;
}

.kefu-input-area {
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: #fff;
  border-top: 1px solid #eee;
}

.kefu-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.kefu-input-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: #f0f0f0;
  color: #666;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
}

.kefu-input-btn.send {
  background: var(--kefu-red);
  color: #fff;
}

.kefu-input-field {
  flex: 1;
  min-height: 40px;
  max-height: 100px;
  padding: 10px 14px;
  border: none;
  border-radius: 20px;
  background: #f3f4f6;
  font-size: 14px;
  outline: none;
  resize: none;
}

.hidden {
  display: none !important;
}
