/**
 * 公共样式
 * 定义全局CSS变量、通用样式和组件样式
 */

/* CSS变量 */
:root {
  --primary-color: #1890ff;
  --success-color: #52c41a;
  --warning-color: #faad14;
  --danger-color: #f5222d;
  --text-primary: #262626;
  --text-secondary: #8c8c8c;
  --text-disabled: #bfbfbf;
  --border-color: #d9d9d9;
  --border-light: #f0f0f0;
  --bg-gray: #f5f5f5;
  --bg-white: #ffffff;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.16);
}

/* 全局样式 */
* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text-primary);
  background: var(--bg-gray);
  margin: 0;
  padding: 0;
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
  background: #c1c1c1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #a8a8a8;
}

/* 消息气泡样式 */
.message-bubble {
  max-width: 70%;
  padding: 10px 14px;
  margin-bottom: 12px;
  word-wrap: break-word;
  line-height: 1.5;
}

/* 商户端：用户消息在左边 */
.message-user {
  background: var(--bg-gray);
  color: var(--text-primary);
  border: 1px solid var(--border-light);
  border-radius: 12px 12px 12px 2px;
  margin-right: auto;
}

/* 商户端：客服消息在右边 */
.message-service {
  background: var(--primary-color);
  color: white;
  border-radius: 12px 12px 2px 12px;
  margin-left: auto;
}

.message-system {
  background: var(--bg-gray);
  color: var(--text-secondary);
  border-radius: 8px;
  text-align: center;
  margin: 8px auto;
  font-size: 12px;
  padding: 6px 12px;
  max-width: 80%;
}

/* 消息容器 */
.message-item {
  display: flex;
  margin-bottom: 16px;
  align-items: flex-start;
}

/* 商户端：用户消息在左边，正常排列 */
.message-item.user {
  flex-direction: row;
}

/* 商户端：客服消息在右边，反向排列 */
.message-item.service {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-gray);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin: 0 8px;
  overflow: hidden;
}

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

.message-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* 商户端：用户消息内容左对齐 */
.message-item.user .message-content {
  align-items: flex-start;
}

/* 商户端：客服消息内容右对齐 */
.message-item.service .message-content {
  align-items: flex-end;
}

.message-time {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* 订单卡片样式 */
.order-card {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border: none;
  border-radius: 12px;
  padding: 16px;
  max-width: 320px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  color: white;
}

.order-card:hover {
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
  transform: translateY(-2px) scale(1.02);
}

.order-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 14px;
}

.order-card-number {
  font-weight: 600;
  color: white;
  font-size: 15px;
}

.order-card-status {
  background: rgba(255, 255, 255, 0.25);
  color: white;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  backdrop-filter: blur(10px);
}

.order-card-info {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.95);
  line-height: 1.8;
  margin-bottom: 8px;
}

.order-card-info .order-title {
  font-weight: 500;
  font-size: 14px;
  margin-bottom: 6px;
  color: white;
}

.order-card-info .order-date {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.8);
}

.order-card-info .order-hint {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  font-style: italic;
}

.order-card-amount {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  font-size: 18px;
  color: #ffd700;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* 图片消息样式 */
.message-image {
  max-width: 200px;
  max-height: 200px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s;
}

.message-image:hover {
  transform: scale(1.02);
}

/* 会话列表项 */
.session-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  gap: 12px;
}

.session-item:hover {
  background: var(--bg-gray);
}

.session-item.active {
  background: #e6f7ff;
  border-left: 3px solid var(--primary-color);
}

.session-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--bg-gray);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

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

.session-info {
  flex: 1;
  min-width: 0;
}

.session-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.session-name {
  font-weight: 500;
  color: var(--text-primary);
  font-size: 14px;
}

.session-time {
  font-size: 12px;
  color: var(--text-secondary);
}

.session-preview {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-badge {
  background: var(--danger-color);
  color: white;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 12px;
  min-width: 18px;
  text-align: center;
}

/* 状态标签 */
.status-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.status-badge.pending {
  background: #fff7e6;
  color: #fa8c16;
}

.status-badge.active {
  background: #f6ffed;
  color: #52c41a;
}

.status-badge.closed {
  background: #f5f5f5;
  color: #8c8c8c;
}

.status-badge.online {
  background: #f6ffed;
  color: #52c41a;
}

.status-badge.offline {
  background: #f5f5f5;
  color: #8c8c8c;
}

/* 按钮样式增强 */
.btn {
  border-radius: 6px;
  padding: 8px 16px;
  font-size: 14px;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.btn-primary:hover {
  background: #40a9ff;
  border-color: #40a9ff;
}

.btn-success {
  background: var(--success-color);
  border-color: var(--success-color);
}

.btn-success:hover {
  background: #73d13d;
  border-color: #73d13d;
}

.btn-danger {
  background: var(--danger-color);
  border-color: var(--danger-color);
}

.btn-danger:hover {
  background: #ff4d4f;
  border-color: #ff4d4f;
}

/* 表单样式增强 */
.form-control:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 0.2rem rgba(24, 144, 255, 0.25);
}

.form-label {
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 8px;
}

/* 卡片样式 */
.card {
  border-radius: 8px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.card-header {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border-light);
  padding: 16px 20px;
  font-weight: 500;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 64px;
  color: var(--text-disabled);
  margin-bottom: 16px;
}

.empty-state-text {
  font-size: 14px;
}

/* 加载动画 */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(24, 144, 255, 0.3);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 1s linear infinite;
}

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

/* 响应式优化 */
@media (max-width: 768px) {
  /* 消息气泡优化 */
  .message-bubble {
    max-width: 90%;
    padding: 12px 16px;
    font-size: 15px;
  }
  
  /* 会话列表项优化 */
  .session-item {
    padding: 14px 16px;
    min-height: 72px;
  }
  
  .session-avatar {
    width: 44px;
    height: 44px;
  }
  
  .session-name {
    font-size: 15px;
  }
  
  .session-preview {
    font-size: 14px;
  }
  
  .session-time {
    font-size: 11px;
  }
  
  /* 消息头像优化 */
  .message-avatar {
    width: 40px;
    height: 40px;
  }
  
  /* 订单卡片优化 */
  .order-card {
    max-width: 100%;
    padding: 14px;
  }
  
  .order-card-header {
    font-size: 13px;
  }
  
  .order-card-number {
    font-size: 14px;
  }
  
  .order-card-info {
    font-size: 12px;
  }
  
  .order-card-amount {
    font-size: 16px;
  }
  
  /* 图片消息优化 */
  .message-image {
    max-width: 180px;
    max-height: 180px;
  }
  
  /* 按钮优化 */
  .btn {
    min-height: 44px;
    font-size: 15px;
  }
  
  .btn-sm {
    min-height: 36px;
    font-size: 13px;
  }
  
  /* 卡片优化 */
  .card {
    margin-bottom: 12px;
  }
  
  .card-body {
    padding: 12px;
  }
  
  /* 模态框优化 */
  .modal-dialog {
    margin: 8px;
  }
  
  .modal-body {
    padding: 16px;
  }
  
  .modal-footer {
    padding: 12px 16px;
  }
  
  /* 空状态优化 */
  .empty-state {
    padding: 40px 20px;
  }
  
  .empty-state-icon {
    font-size: 48px;
  }
  
  .empty-state-text {
    font-size: 13px;
  }
}

@media (max-width: 576px) {
  /* 小屏幕手机优化 */
  body {
    font-size: 14px;
  }
  
  /* 消息气泡优化 */
  .message-bubble {
    max-width: 95%;
    padding: 10px 14px;
    font-size: 14px;
  }
  
  .message-item {
    margin-bottom: 12px;
  }
  
  /* 会话列表优化 */
  .session-item {
    padding: 12px 14px;
    min-height: 68px;
  }
  
  .session-avatar {
    width: 40px;
    height: 40px;
  }
  
  .session-name {
    font-size: 14px;
  }
  
  .session-preview {
    font-size: 13px;
  }
  
  /* 订单卡片优化 */
  .order-card {
    padding: 12px;
  }
  
  .order-card-header {
    font-size: 12px;
  }
  
  .order-card-number {
    font-size: 13px;
  }
  
  .order-card-info {
    font-size: 11px;
    line-height: 1.6;
  }
  
  .order-card-amount {
    font-size: 15px;
    margin-top: 10px;
    padding-top: 10px;
  }
  
  /* 图片消息 */
  .message-image {
    max-width: 150px;
    max-height: 150px;
  }
  
  /* 模态框全屏 */
  .modal-dialog {
    margin: 0;
    max-width: 100%;
    min-height: 100vh;
  }
  
  .modal-content {
    min-height: 100vh;
    border-radius: 0;
  }
  
  .modal-header {
    padding: 12px 16px;
  }
  
  .modal-title {
    font-size: 16px;
  }
  
  .modal-body {
    padding: 12px;
  }
  
  /* 表单优化 */
  .form-control,
  .form-select {
    font-size: 16px; /* 防止iOS自动缩放 */
    min-height: 44px;
  }
  
  .form-label {
    font-size: 13px;
    margin-bottom: 6px;
  }
  
  /* 按钮优化 */
  .btn {
    padding: 10px 16px;
    min-height: 44px;
  }
  
  .btn-sm {
    padding: 6px 12px;
    min-height: 36px;
  }
}

/* 工具类 */
.text-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cursor-pointer {
  cursor: pointer;
}

.no-select {
  user-select: none;
}

