﻿/* ================================================
   FIBEMATE 主界面样式
   设计语言：深色极简 · Teal色系
   与登录界面 styles.css 一脉相承
   ================================================ */

:root {
  --bg-primary: #0A0A0F;
  --bg-card: #13131A;
  --bg-input: #1E1E26;
  --border-subtle: #2A2A32;
  --border-focus: #00E5C3;
  --accent: #00E5C3;
  --accent-dark: #00B4A0;
  --accent-dim: rgba(0, 229, 195, 0.10);
  --accent-glow: rgba(0, 229, 195, 0.40);
  --text-primary: #FFFFFF;
  --text-secondary: #8A8A96;
  --text-muted: #55555F;
  --danger: #FF4757;
  --success: #00E5C3;
  --sidebar-width: 280px;
  --font-sans: 'Inter', 'PingFang SC', 'Microsoft YaHei', system-ui, -apple-system, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ================================================
   APP 容器：侧边栏 + 主聊天区
   ================================================ */

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

/* ================================================
   侧边栏
   ================================================ */

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: linear-gradient(180deg, #111916 0%, #0D1210 100%);
  border-right: 1px solid rgba(0, 180, 140, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* 侧边栏顶部 */
.sidebar-header {
  display: flex;
  align-items: center;
  padding: 16px 16px 12px;
  gap: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.shield-icon {
  width: 28px;
  height: 28px;
  color: var(--accent);
  flex-shrink: 0;
}

.shield-icon svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

.sidebar-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--text-primary);
  text-transform: uppercase;
  flex: 1;
}

.sidebar-actions {
  display: flex;
  gap: 4px;
}

/* 图标按钮 */
.icon-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 229, 195, 0.08);
  border: 1px solid rgba(0, 229, 195, 0.15);
  border-radius: 10px;
  color: var(--accent);
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn svg {
  width: 18px;
  height: 18px;
}

.icon-btn:hover {
  background: rgba(0, 229, 195, 0.2);
  border-color: rgba(0, 229, 195, 0.4);
}

.icon-btn:active {
  transform: scale(0.92);
}

.btn-burn-active {
  background: rgba(255, 80, 60, 0.25) !important;
  border-color: rgba(255, 80, 60, 0.5) !important;
  color: #ff503c !important;
  box-shadow: 0 0 12px rgba(255, 80, 60, 0.2);
}

.btn-burn-active:hover {
  background: rgba(255, 80, 60, 0.35) !important;
}

/* ================================================
   搜索栏
   ================================================ */

.search-bar {
  position: relative;
  padding: 10px 14px;
}

.search-icon {
  position: absolute;
  left: 24px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-bar input {
  width: 100%;
  padding: 9px 12px 9px 34px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-sans);
  outline: none;
  transition: all 0.2s;
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

.search-bar input:focus {
  border-color: var(--border-focus);
  background: #1e1e28;
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ================================================
   对话列表
   ================================================ */

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 8px;
}

.conversation-list::-webkit-scrollbar {
  width: 4px;
}

.conversation-list::-webkit-scrollbar-track {
  background: transparent;
}

.conversation-list::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 2px;
}

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 300px;
  padding: 24px;
  text-align: center;
  color: var(--text-secondary);
  animation: fadeIn 0.4s ease;
}

.empty-state svg {
  width: 56px;
  height: 56px;
  color: var(--accent);
  opacity: 0.5;
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 13px;
  margin-bottom: 16px;
  color: var(--text-secondary);
}

.btn-primary-sm {
  padding: 9px 20px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  border: none;
  border-radius: 8px;
  color: #0A0A0F;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.25s;
  letter-spacing: 0.5px;
}

.btn-primary-sm:hover {
  box-shadow: 0 4px 20px var(--accent-glow);
  transform: translateY(-1px);
}

/* 对话项 */
.conversation-item {
  display: flex;
  align-items: center;
  padding: 10px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
  gap: 10px;
}

.conversation-item:hover {
  background: rgba(255,255,255,0.04);
}

.conversation-item.active {
  background: var(--accent-dim);
  border: 1px solid rgba(0, 229, 195, 0.15);
}

.conv-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 600;
  color: #0A0A0F;
  flex-shrink: 0;
  position: relative;
}

.conv-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 9px;
  height: 9px;
  background: #00E5C3;
  border-radius: 50%;
  border: 2px solid var(--bg-card);
}

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

.conv-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 3px;
}

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

.conv-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.conv-time {
  font-size: 10px;
  color: var(--text-muted);
}

.conv-badge {
  min-width: 18px;
  height: 18px;
  background: var(--accent);
  border-radius: 9px;
  font-size: 10px;
  font-weight: 700;
  color: #0A0A0F;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* ================================================
   用户信息栏
   ================================================ */

.user-bar {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-top: 1px solid rgba(0, 180, 140, 0.08);
  gap: 10px;
  background: linear-gradient(180deg, #0F1E18 0%, #0A1712 100%);
}

.btn-exit {
  margin-left: auto;
  padding: 6px 12px;
  background: rgba(255, 80, 80, 0.1);
  border: 1px solid rgba(255, 80, 80, 0.3);
  border-radius: 8px;
  color: #ff7070;
  font-size: 11px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-exit:hover {
  background: rgba(255, 80, 80, 0.2);
  border-color: rgba(255, 80, 80, 0.5);
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #0A0A0F;
  flex-shrink: 0;
  cursor: pointer;
  transition: box-shadow 0.2s;
}

.user-avatar:hover {
  box-shadow: 0 0 0 3px var(--accent-dim);
}

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

.user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.online {
  background: var(--accent);
  box-shadow: 0 0 6px var(--accent-glow);
}

.status-dot.offline {
  background: var(--text-muted);
}

/* ================================================
   主聊天区域
   ================================================ */

.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-primary);
  overflow: hidden;
  position: relative;
}

/* 聊天区空状态 */
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  animation: fadeIn 0.4s ease;
}

.hex-glow {
  width: 80px;
  height: 90px;
  color: var(--accent);
  margin-bottom: 24px;
  opacity: 0.4;
  animation: hexPulse 3s ease-in-out infinite;
}

.hex-glow svg {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 20px var(--accent-glow));
}

@keyframes hexPulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.05); }
}

.chat-empty h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.chat-empty p {
  font-size: 13px;
  color: var(--text-secondary);
  max-width: 280px;
  line-height: 1.6;
}

/* ================================================
   聊天窗口
   ================================================ */

.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* 聊天头部 */
.chat-header {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-subtle);
  gap: 10px;
  min-height: 60px;
}

.chat-peer-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.chat-peer-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: #0A0A0F;
  flex-shrink: 0;
}

.chat-peer-details {
  flex: 1;
  min-width: 0;
}

.chat-peer-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-peer-status {
  font-size: 11px;
  color: var(--accent);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-peer-status::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
}

.chat-header-actions {
  display: flex;
  gap: 4px;
}

/* ================================================
   消息列表
   ================================================ */

.messages-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.messages-list::-webkit-scrollbar {
  width: 4px;
}

.messages-list::-webkit-scrollbar-track {
  background: transparent;
}

.messages-list::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 2px;
}

/* 消息气泡 */
.message {
  display: flex;
  flex-direction: column;
  max-width: 70%;
  animation: msgIn 0.2s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.sent {
  align-self: flex-end;
  align-items: flex-end;
}

.message.received {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  position: relative;
}

.message.sent .msg-bubble {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: #0A0A0F;
  border-bottom-right-radius: 4px;
}

.message.received .msg-bubble {
  background: var(--bg-input);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
}

.msg-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.msg-status {
  font-size: 10px;
  color: var(--accent);
  margin-top: 2px;
  padding: 0 4px;
}

/* 日期分隔线 */
.date-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0;
}

.date-divider::before,
.date-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-subtle);
}

.date-divider span {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* 加密提示消息 */
.system-msg {
  text-align: center;
  padding: 8px 16px;
  margin: 4px 0;
}

.system-msg span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--text-muted);
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 4px 10px;
}

/* ================================================
   输入框区域
   ================================================ */

.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-subtle);
}

.chat-input-bar input {
  flex: 1;
  padding: 11px 14px;
  background: var(--bg-input);
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-sans);
  outline: none;
  transition: all 0.2s;
}

.chat-input-bar input::placeholder {
  color: var(--text-muted);
}

.chat-input-bar input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-dim);
  background: #1e1e28;
}

/* ================================================
   Toast 提示
   ================================================ */

.toast {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-primary);
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  z-index: 1000;
  animation: toastIn 0.3s ease-out;
  letter-spacing: 0.3px;
  display: none;
}

.toast.show {
  display: block;
}

.toast.error {
  border-color: var(--danger);
  color: var(--danger);
}

.toast.success {
  border-color: var(--accent);
  color: var(--accent);
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ================================================
   通用动画
   ================================================ */

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ================================================
   Navigation Tabs
   ================================================ */

.sidebar-nav {
  display: flex;
  gap: 2px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.nav-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
  padding: 6px 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 8px;
  font-size: 10px;
  font-family: var(--font-sans);
  transition: all 0.2s;
}

.nav-tab svg {
  width: 18px;
  height: 18px;
}

.nav-tab:hover {
  color: var(--text-secondary);
  background: var(--accent-dim);
}

.nav-tab.active {
  color: var(--accent);
  background: var(--accent-dim);
}

/* ================================================
   Tab Panels
   ================================================ */

.tab-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.tab-panel.active {
  display: flex;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ================================================
   Contacts
   ================================================ */

.contact-list {
  flex: 1;
  overflow-y: auto;
}

.contact-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s;
}

.contact-item:hover {
  background: var(--accent-dim);
}

.contact-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  flex-shrink: 0;
  position: relative;
}

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

.contact-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-username {
  font-size: 11px;
  color: var(--text-muted);
}

.contact-actions {
  display: flex;
  gap: 4px;
}

.contact-actions .icon-btn {
  opacity: 0;
  transition: opacity 0.15s;
}

.contact-item:hover .contact-actions .icon-btn {
  opacity: 1;
}

/* ================================================
   Vault
   ================================================ */

.vault-list {
  flex: 1;
  overflow-y: auto;
}

.vault-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.15s;
}

.vault-item:hover {
  background: var(--accent-dim);
}

.vault-icon {
  font-size: 24px;
  width: 36px;
  text-align: center;
  flex-shrink: 0;
}

.vault-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.vault-meta {
  font-size: 11px;
  color: var(--text-muted);
}

.vault-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}

.vault-item:hover .vault-actions {
  opacity: 1;
}

/* ================================================
   Voice Call
   ================================================ */

.call-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #0a0a12 0%, #0d1117 100%);
  gap: 12px;
}

.call-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--bg-input);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  font-weight: 600;
  color: var(--accent);
  border: 2px solid var(--accent);
  box-shadow: 0 0 30px var(--accent-glow);
  animation: callPulse 2s ease-in-out infinite;
}

@keyframes callPulse {
  0%, 100% { box-shadow: 0 0 20px var(--accent-glow); }
  50% { box-shadow: 0 0 40px var(--accent-glow); }
}

.call-name {
  font-size: 22px;
  font-weight: 600;
  margin-top: 12px;
}

.call-status {
  font-size: 13px;
  color: var(--accent);
}

.call-timer {
  font-size: 16px;
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
  margin-top: 4px;
}

.call-actions {
  display: flex;
  gap: 20px;
  margin-top: 40px;
}

.call-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--bg-input);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.call-btn svg {
  width: 24px;
  height: 24px;
}

.call-btn:hover {
  background: var(--border-subtle);
}

.call-btn.active {
  background: var(--accent);
  color: var(--bg-primary);
}

.call-btn.hangup {
  background: var(--danger);
  color: white;
}

.call-btn.hangup:hover {
  background: #ff5e6c;
}

/* ================================================
   Video Call UI (from video-call-ui.js)
   ================================================ */
.call-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.call-container {
  width: 100%;
  height: 100%;
  position: relative;
}

.call-remote {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.remote-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remote-avatar {
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00e5c3, #00b8d4);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.avatar-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid #00e5c3;
  animation: pulse-ring 2s infinite;
}

.avatar-ring.pulse {
  animation: pulse-ring 1s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.2); opacity: 0; }
}

.avatar-initial {
  font-size: 60px;
  font-weight: bold;
  color: white;
}

.call-peer-name {
  margin-top: 20px;
  font-size: 24px;
  color: white;
}

.call-local {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 150px;
  height: 200px;
  border-radius: 10px;
  overflow: hidden;
  background: #0a0a15;
  border: 2px solid rgba(0,229,195,0.3);
}

.local-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.local-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.3);
}

.call-controls {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 20px;
}

.call-btn.off {
  background: rgba(255,100,100,0.3);
}

.call-btn.end-call {
  background: #ff4757;
  transform: rotate(135deg);
}

.call-btn.end-call:hover {
  background: #ff6b81;
}

.call-btn.accept {
  background: #00e5c3;
}

.call-btn.reject {
  background: #ff4757;
}

/* Incoming call overlay */
.incoming-call-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.incoming-call-container {
  text-align: center;
}

.incoming-avatar {
  position: relative;
  width: 120px;
  height: 120px;
  margin: 0 auto;
}

.incoming-avatar .avatar-initial {
  font-size: 48px;
}

.incoming-info {
  margin: 30px 0;
}

.incoming-title {
  font-size: 16px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 10px;
}

.incoming-name {
  font-size: 28px;
  color: white;
  margin-bottom: 5px;
}

.incoming-type {
  font-size: 14px;
  color: rgba(255,255,255,0.5);
}

.incoming-controls {
  display: flex;
  gap: 60px;
  justify-content: center;
  margin-top: 40px;
}

.incoming-controls .call-btn {
  width: 70px;
  height: 70px;
}

.incoming-controls .call-btn svg {
  width: 28px;
  height: 28px;
}

/* Call type selection modal */
.call-type-options {
  display: flex;
  gap: 20px;
  justify-content: center;
}

.call-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 30px;
  background: rgba(255,255,255,0.05);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: 15px;
  color: white;
  cursor: pointer;
  transition: all 0.3s;
}

.call-type-btn:hover {
  background: rgba(0,229,195,0.1);
  border-color: #00e5c3;
}

.call-type-btn svg {
  width: 48px;
  height: 48px;
}

.call-type-btn span {
  font-size: 16px;
}

/* ================================================
   Key Management
   ================================================ */

.detail-view {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  padding: 24px;
  align-items: flex-start;
}

.detail-header h3 {
  font-size: 20px;
  font-weight: 700;
  text-align: left;
}

.detail-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: left;
}

.key-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 20px;
  align-items: flex-start;
  width: 100%;
}

.key-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 16px;
  text-align: left;
  width: 100%;
}

.key-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.key-icon {
  font-size: 24px;
}

.key-type {
  font-size: 14px;
  font-weight: 600;
}

.key-algo {
  font-size: 12px;
  color: var(--text-muted);
}

.key-status {
  margin-left: auto;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

.key-status.active {
  background: rgba(0, 229, 195, 0.15);
  color: var(--accent);
}

.key-status.inactive {
  background: rgba(255, 71, 87, 0.15);
  color: var(--danger);
}

.key-fingerprint {
  margin-bottom: 8px;
}

.key-fingerprint label {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 2px;
}

.key-fingerprint code {
  font-family: 'SF Mono', 'Cascadia Code', monospace;
  font-size: 11px;
  color: var(--accent);
  background: var(--bg-primary);
  padding: 4px 8px;
  border-radius: 4px;
  display: block;
  word-break: break-all;
}

.key-meta {
  display: flex;
  gap: 16px;
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.key-rotate-btn {
  font-size: 12px;
  padding: 6px 12px;
}

.key-actions-bar {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

/* ================================================
   Settings
   ================================================ */

.settings-sections {
  margin-top: 20px;
}

.settings-section {
  margin-bottom: 24px;
}

.settings-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
  text-align: left;
}

.setting-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(42, 42, 50, 0.5);
  text-align: left;
}

.setting-info {
  flex: 1;
  text-align: left;
}

.setting-name {
  font-size: 14px;
  font-weight: 500;
}

.setting-desc {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
  text-align: left;
}

.setting-item.clickable {
  cursor: pointer;
}

.setting-item.clickable:hover {
  background: var(--accent-dim);
  margin: 0 -24px;
  padding: 12px 24px;
}

.setting-item.clickable svg {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.setting-item.danger .setting-name {
  color: var(--danger);
}

/* Toggle Switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--border-subtle);
  border-radius: 22px;
  transition: 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.3s;
}

.toggle input:checked + .toggle-slider {
  background: var(--accent);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

/* ================================================
   Modals
   ================================================ */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  width: 380px;
  max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
}

.field-label {
  font-size: 12px;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 4px;
  margin-top: 12px;
}

.field-label:first-child {
  margin-top: 0;
}

.field-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.2s;
}

.field-input:focus {
  border-color: var(--accent);
}

/* Vault dropzone */
.vault-dropzone {
  border: 2px dashed var(--border-subtle);
  border-radius: 12px;
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
}

.vault-dropzone:hover {
  border-color: var(--accent);
}

.vault-dropzone svg {
  width: 32px;
  height: 32px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.vault-dropzone p {
  font-size: 13px;
  color: var(--text-muted);
}

/* ================================================
   Buttons
   ================================================ */

.btn-primary {
  padding: 8px 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: var(--bg-primary);
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: opacity 0.2s;
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-secondary {
  padding: 8px 20px;
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font-sans);
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--accent-dim);
}

/* ================================================
   Loading States
   ================================================ */

.loading-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-subtle);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-card) 25%,
    var(--bg-input) 50%,
    var(--bg-card) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: 4px;
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton-text {
  height: 12px;
  margin-bottom: 8px;
}

.skeleton-text.short {
  width: 60%;
}

.skeleton-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 15, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

/* ================================================
   Safety Numbers Dialog
   ================================================ */

.safety-numbers-dialog {
  padding: 24px;
  max-width: 480px;
}

.safety-header {
  text-align: center;
  margin-bottom: 20px;
}

.safety-header h3 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.safety-header p {
  font-size: 14px;
  color: var(--text-secondary);
}

.safety-numbers-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 20px 0;
}

.safety-number {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 12px;
  text-align: center;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 16px;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 2px;
}

.safety-warning {
  background: rgba(255, 71, 87, 0.1);
  border: 1px solid var(--danger);
  border-radius: 8px;
  padding: 12px;
  margin: 16px 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--danger);
  font-size: 13px;
}

.safety-status {
  text-align: center;
  color: var(--success);
  font-size: 13px;
  margin: 12px 0;
}

.safety-source {
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
  margin: 8px 0;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.safety-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}

/* Safety Numbers Error State */
.safety-error {
  text-align: center;
  padding: 32px 24px;
  background: var(--bg-card);
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  margin: 20px 0;
}

.error-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

.error-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.error-message {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.error-hint {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ================================================
   Toast 通知系统 (主界面)
   ================================================ */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 14px 20px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: toastSlideIn 0.3s ease-out;
  max-width: 380px;
  backdrop-filter: blur(10px);
}

@keyframes toastSlideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toastSlideOut {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

.toast.hiding {
  animation: toastSlideOut 0.25s ease-in forwards;
}

/* Toast types */
.toast.success {
  border-left: 3px solid #00e57a;
}

.toast.error {
  border-left: 3px solid var(--danger);
}

.toast.warning {
  border-left: 3px solid #ffb347;
}

.toast.info {
  border-left: 3px solid var(--accent);
}

/* ================================================
   连接状态指示器
   ================================================ */

.connection-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: rgba(19, 19, 26, 0.9);
  border-top: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-secondary);
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: all 0.3s ease;
}

.connection-dot.online {
  background: #00e57a;
  box-shadow: 0 0 8px rgba(0, 229, 122, 0.5);
}

.connection-dot.connecting {
  background: #ffb347;
  animation: pulse 1s infinite;
}

.connection-dot.offline {
  background: var(--danger);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ================================================
   消息气泡增强
   ================================================ */

.message-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 18px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  position: relative;
  animation: messageFadeIn 0.2s ease-out;
}

@keyframes messageFadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-bubble.sent {
  background: linear-gradient(135deg, rgba(0, 229, 195, 0.15), rgba(0, 229, 195, 0.08));
  border: 1px solid rgba(0, 229, 195, 0.2);
  margin-left: auto;
  border-bottom-right-radius: 4px;
}

.message-bubble.received {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  margin-right: auto;
  border-bottom-left-radius: 4px;
}

.message-bubble .message-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  text-align: right;
}

.message-bubble.burn::after {
  content: '🔥';
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 12px;
}

/* ================================================
   空状态优化
   ================================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  color: var(--text-muted);
  gap: 16px;
}

.empty-state svg {
  width: 64px;
  height: 64px;
  opacity: 0.3;
}

.empty-state p {
  font-size: 15px;
  color: var(--text-secondary);
}

.empty-state button {
  margin-top: 8px;
}

/* ================================================
   响应式设计 - 完整移动端适配
   ================================================ */

/* Tablet (768px) */
@media (max-width: 768px) {
  :root {
    --sidebar-width: 240px;
  }
  
  .sidebar-header {
    padding: 12px 12px 8px;
  }
  
  .sidebar-title {
    font-size: 13px;
    letter-spacing: 2px;
  }
  
  .chat-header-actions {
    gap: 4px;
  }
  
  .key-cards {
    grid-template-columns: 1fr !important;
  }
}

/* Mobile Large (640px) */
@media (max-width: 640px) {
  :root {
    --sidebar-width: 100%;
  }
  
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
    transform: translateX(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

  .sidebar.hidden {
    transform: translateX(-100%);
  }

  .chat-area {
    width: 100%;
  }

  /* Hide nav text on mobile */
  .nav-tab span {
    display: none;
  }
  
  .nav-tab {
    padding: 12px 16px;
    justify-content: center;
  }
  
  /* Chat header adjustments */
  .chat-header {
    padding: 12px 16px;
  }
  
  .chat-peer-name {
    font-size: 15px;
  }
  
  /* Input bar */
  .chat-input-bar {
    padding: 12px 16px;
    gap: 8px;
  }
  
  #messageInput {
    font-size: 15px; /* Prevent zoom on iOS */
  }
  
  /* Modal adjustments */
  .modal {
    width: 95%;
    margin: 20px auto;
    max-height: 85vh;
  }
  
  /* User bar */
  .user-bar {
    padding: 10px 14px;
    flex-wrap: wrap;
    gap: 6px;
  }
  
  .btn-exit {
    font-size: 11px;
    padding: 4px 10px;
  }
}

/* Mobile Small (480px) */
@media (max-width: 480px) {
  .sidebar-header {
    padding: 10px 10px 6px;
  }
  
  .shield-icon {
    width: 22px;
    height: 22px;
  }
  
  .search-bar {
    padding: 8px 10px;
  }
  
  .panel-header {
    padding: 10px 12px;
  }
  
  .chat-input-bar input {
    min-width: 0;
    flex: 1;
  }
  
  /* Call view */
  .call-avatar {
    width: 64px;
    height: 64px;
    font-size: 24px;
  }
  
  .call-name {
    font-size: 18px;
  }
}

/* Extra small (380px) */
@media (max-width: 380px) {
  .nav-tab {
    padding: 10px 12px;
  }
  
  .icon-btn {
    width: 36px;
    height: 36px;
  }
  
  .chat-header-actions .icon-btn {
    width: 32px;
    height: 32px;
  }
  
  .user-avatar {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }
}

/* Mobile menu toggle button */
#btnMenuToggle {
  display: none;
}

@media (max-width: 640px) {
  #btnMenuToggle {
    display: flex !important;
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  .nav-tab {
    min-height: 48px;
  }
  
  .btn-primary,
  .btn-secondary {
    min-height: 44px;
  }
  
  .conversation-item,
  .contact-item {
    min-height: 56px;
    padding: 12px;
  }
  
  .icon-btn {
    min-width: 44px;
    min-height: 44px;
  }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
  .sidebar {
    position: fixed;
    bottom: 0;
    top: auto;
    left: 0;
    right: 0;
    width: 100%;
    height: auto;
    max-height: 60vh;
    border-right: none;
    border-top: 1px solid var(--border-subtle);
    transform: translateY(0);
  }
  
  .sidebar.hidden {
    transform: translateY(100%);
  }
  
  .sidebar-nav {
    flex-direction: row;
    overflow-x: auto;
    justify-content: flex-start;
  }
}

/* P2 Fix: chat-area height & message alignment */
.chat-area, #chatArea { height: calc(100vh - 180px); overflow-y: auto; }
.message, .message-row { display: flex; align-items: center; margin: 8px 0; }