/* Connect Page Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans CJK SC", "PingFang SC", "Microsoft YaHei", Helvetica, Arial, sans-serif;
    background: #f7f7f8;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* === 左侧边栏 === */
.sidebar {
    width: 0;
    background: #f9f9f9;
    border-right: none;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
    transition: width 150ms ease-out;
}

.sidebar-header {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e5e5;
}

/* 商机卡片 */
.opportunity-card {
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.opportunity-card:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.opportunity-card.active {
    border-color: #667eea;
    background: linear-gradient(135deg, #f0f4ff, #fff);
}

.card-index {
    font-size: 12px;
    font-weight: 600;
    color: #8b95a5;
    margin-right: 8px;
    min-width: 24px;
    text-align: right;
}

.card-icon {
    font-size: 16px;
    margin-right: 8px;
}

.card-title {
    font-size: 14px;
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 4px;
}

.card-meta {
    font-size: 12px;
    color: #8b95a5;
}

.card-unread {
    display: inline-block;
    background: #dc3545;
    color: #fff;
    border-radius: 8px;
    padding: 1px 6px;
    font-size: 11px;
    margin-left: 4px;
}

.empty-sidebar {
    text-align: center;
    padding: 40px 16px;
    color: #8b95a5;
}

/* === 右侧主区域 === */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
    position: relative;
    min-height: 0;
    overflow: hidden;
}

/* === 聊天区域（连接页） === */
.chat-main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    position: relative;
}

.chat-screen {
    flex: 1;
    display: none;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

.chat-screen.active {
    display: flex;
}

.chat-area {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
}

.message {
    max-width: 80%;
    margin-bottom: 16px;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
}

.message.user {
    background: #667eea;
    color: #fff;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.message.assistant {
    background: #fff;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.6;
    overflow: hidden;
}

.message.user .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message.assistant .message-content {
    background: #f7f7f8;
    color: #2d333a;
    max-width: calc(70% + 40px);
}

.message-meta {
    font-size: 11px;
    color: #8b95a5;
    margin-top: 4px;
}

/* === 聊天头部（两行布局：标题 + tag+操作） === */
.chat-header {
    display: flex;
    flex-direction: column;
    padding: 0;
    background: #ffffff;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

.chat-header-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    min-width: 0;
}

.chat-header-title-row { padding: 12px 16px 6px; }
.chat-header-action-row { padding: 4px 12px 10px; flex-wrap: wrap; }

.chat-title-block { flex: 1; min-width: 0; }

.chat-title {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-subtitle {
    font-size: 13px;
    color: #6c757d;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.back-link {
    color: #007bff;
    text-decoration: none;
    font-size: 14px;
}

.back-link:hover {
    text-decoration: underline;
}

/* === Header 通用按钮（copy/quit/overflow/…） === */
.header-action-btn {
    background: #f0f4ff;
    color: #667eea;
    border: 1px solid #667eea;
    border-radius: 6px;
    padding: 6px 12px;
    font-size: 13px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: all 0.2s;
    white-space: nowrap;
    text-decoration: none;
}

.header-action-btn:hover {
    background: #667eea;
    color: #fff;
}

.header-action-btn.copied {
    background: #28a745;
    border-color: #28a745;
    color: #fff;
}

.header-action-danger {
    color: #dc3545;
    border-color: #dc3545;
    background: #fff5f5;
}

.header-action-danger:hover {
    background: #dc3545;
    color: #fff;
}

/* === 聊天头部 ⋯ 溢出菜单 === */
.header-overflow-wrap { position: relative; }

.header-overflow-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
}

.header-overflow-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: #fff;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.12);
    min-width: 180px;
    padding: 4px;
    z-index: 100;
}

.header-overflow-menu[hidden] { display: none; }

.header-overflow-menu button,
.header-overflow-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: transparent;
    color: #2c3e50;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
    border-radius: 4px;
    text-decoration: none;
}

.header-overflow-menu button:hover,
.header-overflow-menu a:hover {
    background: #f0f4ff;
    color: #667eea;
}

/* === 窄屏：按钮文字隐藏，只剩 emoji === */
@media (max-width: 640px) {
    .header-action-btn .btn-label { display: none; }
    .header-action-btn { padding: 6px 8px; }
}

/* === 对话消息区域 === */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: linear-gradient(180deg, #f8f9fa 0%, #fff 100%);
}

/* === 输入区域 === */
.chat-input-area {
    padding: 16px 24px;
    border-top: 1px solid #e9ecef;
    background: #fff;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    border: 1px solid #e9ecef;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 14px;
    resize: none;
    min-height: 44px;
    max-height: 120px;
}

.chat-input:focus {
    border-color: #667eea;
    outline: none;
}

.send-btn {
    background: #667eea;
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.send-btn:hover {
    background: #5a6fd6;
}

.send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* === 欢迎状态（无对话时） === */
.welcome-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 64px;
    text-align: center;
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 24px;
}

.welcome-title {
    font-size: 24px;
    color: #2c3e50;
    margin-bottom: 12px;
}

.welcome-desc {
    font-size: 15px;
    color: #6c757d;
    max-width: 400px;
}

/* === 加载状态 === */
.loading-state {
    text-align: center;
    padding: 40px;
    color: #8b95a5;
}

.hidden {
    display: none !important;
}

/* Visually hidden but accessible to screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* === Message with Avatar and Sender Info === */
.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    margin-bottom: 16px;
}

.message.user {
    align-items: flex-end;
    margin-left: auto;
}

.message.assistant {
    align-items: flex-start;
}

.message.system {
    align-items: center;
    max-width: 100%;
}

.message-sender {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.message.user .message-sender {
    flex-direction: row-reverse;
}

.sender-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e9ecef;
}

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

.avatar-text {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
}

.avatar-text.ai-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.avatar-text.self-avatar {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.avatar-text.other-avatar {
    background: linear-gradient(135deg, #6c757d 0%, #adb5bd 100%);
}

.sender-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.message.user .sender-info {
    align-items: flex-end;
}

.sender-name {
    font-size: 13px;
    font-weight: 600;
    color: #2c3e50;
}

.message.user .sender-name {
    color: #667eea;
}

.sender-business {
    font-size: 11px;
    color: #8b95a5;
}

.ai-badge {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 8px;
    margin-top: 2px;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.5;
    max-width: 100%;
    word-wrap: break-word;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message.assistant .message-bubble {
    background: #fff;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
    color: #2d333a;
}

.system-bubble {
    background: #f8f9fa !important;
    border: 1px solid #e9ecef !important;
    color: #6c757d !important;
    font-size: 13px;
    text-align: center;
    padding: 8px 16px;
    border-radius: 8px !important;
}

.system-content {
    font-style: italic;
}

.message-meta {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 4px;
    text-align: right;
}

.message.assistant .message-meta {
    color: #8b95a5;
    text-align: left;
}

.message.system .message-meta {
    color: #adb5bd;
    text-align: center;
}


/* === Account Center Sidebar Footer (2026-06-22) === */
.sidebar-footer {
  border-top: 1px solid #e5e5e5;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-footer .user-info-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
}

.sidebar-footer .user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-footer .user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-footer .user-name {
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-footer .user-status {
  font-size: 11px;
  color: #888;
}

.sidebar-footer .footer-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px 0;
}

.sidebar-footer .footer-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 6px;
  color: #333;
  text-decoration: none;
  font-size: 13px;
  transition: background 0.15s;
}

.sidebar-footer .footer-link:hover {
  background: #f5f5f5;
  color: #667eea;
}

.sidebar-footer .footer-link-highlight {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.08) 0%, rgba(118, 75, 162, 0.08) 100%);
  color: #667eea;
  font-weight: 500;
}

.sidebar-footer .quit-btn {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: white;
  color: #d33;
  font-size: 13px;
  cursor: pointer;
  width: 100%;
}

.sidebar-footer .quit-btn:hover {
  background: #fff5f5;
  border-color: #d33;
}

/* Account Center Sidebar Footer (2026-06-22 简化版) — icon-only 按钮 */
.sidebar-footer {
  border-top: 1px solid #e9ecef;
  padding: 12px 8px;
  background: #fff;
}

.sidebar-footer .footer-links {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  padding: 0;
}

.sidebar-footer .footer-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 8px;
  color: #6c757d;
  text-decoration: none;
  font-size: 18px;
  background: #f8f9fa;
  transition: all 0.15s;
}

.sidebar-footer .footer-link:hover {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
  color: #667eea;
  transform: translateY(-1px);
}

.sidebar-footer .quit-btn {
  margin-top: 8px;
  width: 100%;
  padding: 8px;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  background: white;
  color: #6c757d;
  font-size: 16px;
  cursor: pointer;
  text-align: center;
}

.sidebar-footer .quit-btn:hover {
  background: #fff5f5;
  color: #d33;
  border-color: #d33;
}
