/* ══════════════════════════════════
   易连通 · 全局样式
   配色：蓟紫 #5B4B8A + 香槛金 #C9A66B
══════════════════════════════════ */

:root {
  --primary:       #5B4B8A;
  --primary-dark:  #433366;
  --primary-light: #8777B3;
  --gold:          #C9A66B;
  --gold-light:    #E3CB97;
  --danger:        #E0566B;
  --success:       #4CAF7D;

  --bg:            #F7F6FA;
  --surface:       #FFFFFF;
  --surface-alt:   #F0EEF6;
  --text-1:        #221F2C;
  --text-2:        #6B6779;
  --text-3:        #A6A2B5;
  --divider:       #EAE8F0;
  --bubble-me:     #5B4B8A;
  --bubble-other:  #FFFFFF;
  --shadow:        rgba(91,75,138,0.10);
}

[data-theme="dark"] {
  --bg:            #14121C;
  --surface:       #1E1B29;
  --surface-alt:   #272335;
  --text-1:        #EFEbF5;
  --text-2:        #A29DB8;
  --text-3:        #6F6A82;
  --divider:       #322D42;
  --bubble-me:     #6F5DA8;
  --bubble-other:  #272335;
  --shadow:        rgba(0,0,0,0.30);
}

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

body {
  font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
  transition: background .2s, color .2s;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; border: none; outline: none; }
input, textarea { font-family: inherit; outline: none; border: none; }

/* ── 滚动条 ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--divider); border-radius: 2px; }

/* ══════════════════════════════════
   布局框架：左侧边栏 + 右侧内容区
══════════════════════════════════ */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── 左侧导航栏 ── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--divider);
  display: flex;
  flex-direction: column;
  transition: background .2s;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--divider);
}

.logo-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; color: var(--primary-dark);
  flex-shrink: 0;
}

.logo-text { font-size: 17px; font-weight: 700; color: var(--text-1); }

.sidebar-nav { flex: 1; padding: 8px 0; overflow-y: auto; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px;
  border-radius: 10px;
  margin: 2px 8px;
  cursor: pointer;
  color: var(--text-2);
  font-size: 14px;
  transition: all .15s;
  position: relative;
}

.nav-item:hover { background: var(--surface-alt); color: var(--text-1); }

.nav-item.active {
  background: rgba(91,75,138,.12);
  color: var(--primary);
  font-weight: 600;
}

.nav-item .nav-icon { font-size: 18px; width: 22px; text-align: center; }

.nav-badge {
  position: absolute; right: 14px;
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
  min-width: 18px; text-align: center;
}

.sidebar-bottom {
  padding: 12px 8px;
  border-top: 1px solid var(--divider);
}

.user-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s;
}

.user-card:hover { background: var(--surface-alt); }

.user-avatar {
  width: 36px; height: 36px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #fff;
  flex-shrink: 0; overflow: hidden;
}

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

.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; color: var(--text-1); truncate: ellipsis; white-space: nowrap; overflow: hidden; }
.user-ylid { font-size: 11px; color: var(--text-3); }

/* ── 主内容区 ── */
.main-content {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ══════════════════════════════════
   通用组件
══════════════════════════════════ */

/* 搜索框 */
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-alt);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px; color: var(--text-3);
}

.search-box input {
  flex: 1; background: transparent; color: var(--text-1); font-size: 13px;
}

.search-box input::placeholder { color: var(--text-3); }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 9px 20px; border-radius: 10px;
  font-size: 14px; font-weight: 600;
  transition: all .15s; cursor: pointer;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff;
  box-shadow: 0 4px 14px rgba(91,75,138,.3);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(91,75,138,.4); }
.btn-primary:active { transform: none; }

.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}

.btn-ghost:hover { background: rgba(91,75,138,.07); }

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

/* 输入框 */
.input-field {
  width: 100%;
  background: var(--surface-alt);
  border: 1.5px solid transparent;
  border-radius: 10px;
  padding: 11px 14px;
  font-size: 14px; color: var(--text-1);
  transition: border-color .15s;
}

.input-field:focus { border-color: var(--primary); }
.input-field::placeholder { color: var(--text-3); }

/* 头像 */
.avatar {
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff;
  flex-shrink: 0; overflow: hidden;
}

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

/* 分割线 */
.divider { height: 1px; background: var(--divider); }

/* 空状态 */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; height: 100%; color: var(--text-3);
}

.empty-state .empty-icon { font-size: 48px; opacity: .4; }
.empty-state p { font-size: 14px; }

/* Toast提示 */
#toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  background: var(--text-1); color: var(--surface);
  padding: 10px 20px; border-radius: 20px;
  font-size: 13px; z-index: 9999;
  opacity: 0; transition: opacity .2s;
  pointer-events: none;
}

#toast.show { opacity: 1; }

/* 弹窗 */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}

.modal-overlay.show { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border-radius: 18px;
  padding: 28px;
  width: 380px; max-width: 90vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  transform: translateY(10px); transition: transform .2s;
}

.modal-overlay.show .modal { transform: none; }
.modal h3 { font-size: 17px; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

/* ══════════════════════════════════
   页面 Panel 通用结构
══════════════════════════════════ */
.panel {
  width: 300px; flex-shrink: 0;
  border-right: 1px solid var(--divider);
  display: flex; flex-direction: column;
  background: var(--surface);
}

.panel-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--divider);
  flex-shrink: 0;
}

.panel-header h2 { font-size: 18px; font-weight: 700; margin-bottom: 10px; }

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

.detail-panel {
  flex: 1;
  display: flex; flex-direction: column;
  background: var(--bg);
  overflow: hidden;
}

/* ══════════════════════════════════
   聊天列表
══════════════════════════════════ */
.chat-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--divider);
  transition: background .12s;
  position: relative;
}

.chat-item:hover { background: var(--surface-alt); }
.chat-item.active { background: rgba(91,75,138,.08); }

.chat-item .avatar { width: 44px; height: 44px; font-size: 17px; }

.chat-info { flex: 1; min-width: 0; }
.chat-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-preview { font-size: 12px; color: var(--text-3); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 5px; flex-shrink: 0; }
.chat-time { font-size: 11px; color: var(--text-3); }
.unread-badge {
  background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700;
  min-width: 18px; height: 18px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
}

/* ══════════════════════════════════
   聊天详情
══════════════════════════════════ */
.chat-detail-header {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--divider);
  flex-shrink: 0;
}

.chat-detail-header .avatar { width: 38px; height: 38px; font-size: 15px; }
.chat-detail-header .name { font-size: 15px; font-weight: 700; }
.chat-detail-header .status { font-size: 11px; color: var(--success); }

.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg-group { display: flex; gap: 10px; align-items: flex-end; }
.msg-group.mine { flex-direction: row-reverse; }

.msg-group .avatar { width: 32px; height: 32px; font-size: 12px; flex-shrink: 0; }

.msg-bubbles { display: flex; flex-direction: column; gap: 4px; max-width: 65%; }
.msg-group.mine .msg-bubbles { align-items: flex-end; }

.bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px; line-height: 1.5;
  background: var(--bubble-other);
  color: var(--text-1);
  box-shadow: 0 1px 4px var(--shadow);
  word-break: break-word;
}

.mine .bubble { background: var(--bubble-me); color: #fff; }

.bubble.emoji-bubble { background: transparent !important; box-shadow: none; font-size: 36px; padding: 4px; }

.bubble.image-bubble { padding: 4px; }
.bubble.image-bubble img { max-width: 220px; border-radius: 12px; display: block; }

.bubble.voice-bubble {
  display: flex; align-items: center; gap: 8px;
  min-width: 100px; cursor: pointer;
}

.msg-time-label {
  text-align: center; font-size: 11px; color: var(--text-3);
  margin: 4px 0;
}

/* 输入区 */
.input-area {
  background: var(--surface);
  border-top: 1px solid var(--divider);
  padding: 12px 16px;
  flex-shrink: 0;
}

.input-toolbar {
  display: flex; gap: 6px; margin-bottom: 10px;
}

.tool-btn {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--surface-alt);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer; transition: background .12s;
  color: var(--text-2);
}

.tool-btn:hover { background: var(--divider); }

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

.msg-input {
  flex: 1;
  background: var(--surface-alt);
  border: 1.5px solid transparent;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px; color: var(--text-1);
  resize: none; line-height: 1.4;
  max-height: 120px; overflow-y: auto;
  transition: border-color .15s;
}

.msg-input:focus { border-color: var(--primary); }
.msg-input::placeholder { color: var(--text-3); }

.send-btn {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: #fff;
  transition: all .15s; flex-shrink: 0;
}

.send-btn:hover { background: var(--primary-dark); transform: scale(1.05); }

/* 表情面板 */
.emoji-panel {
  display: none;
  flex-wrap: wrap;
  gap: 4px;
  padding: 10px 0;
  max-height: 160px;
  overflow-y: auto;
}

.emoji-panel.show { display: flex; }
.emoji-btn-item { font-size: 22px; cursor: pointer; padding: 4px; border-radius: 6px; transition: background .1s; }
.emoji-btn-item:hover { background: var(--surface-alt); }

/* ══════════════════════════════════
   联系人
══════════════════════════════════ */
.section-label {
  padding: 8px 16px 4px;
  font-size: 11px; font-weight: 600;
  color: var(--text-3); letter-spacing: .5px;
  background: var(--bg);
}

.contact-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--divider);
  transition: background .12s;
}

.contact-item:hover { background: var(--surface-alt); }
.contact-item .avatar { width: 40px; height: 40px; font-size: 15px; }
.contact-item .c-name { font-size: 14px; font-weight: 500; }
.contact-item .c-sig { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* 联系人详情 */
.contact-detail {
  flex: 1; background: var(--bg);
  display: flex; flex-direction: column; align-items: center;
  padding: 40px 30px;
  overflow-y: auto;
}

.contact-detail .big-avatar {
  width: 80px; height: 80px; font-size: 30px; border-radius: 20px;
  margin-bottom: 16px;
}

.contact-detail .d-name { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.contact-detail .d-ylid { font-size: 13px; color: var(--text-3); margin-bottom: 6px; }
.contact-detail .d-sig { font-size: 13px; color: var(--text-2); margin-bottom: 30px; text-align: center; }

.detail-actions { display: flex; gap: 12px; margin-bottom: 30px; }

.detail-card {
  width: 100%; background: var(--surface);
  border-radius: 14px; overflow: hidden;
  box-shadow: 0 2px 10px var(--shadow);
}

.detail-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 13px 16px;
  border-bottom: 1px solid var(--divider);
  font-size: 14px;
}

.detail-row:last-child { border-bottom: none; }
.detail-row .dr-label { color: var(--text-2); }
.detail-row .dr-value { color: var(--text-1); font-weight: 500; }

/* toggle */
.toggle {
  width: 40px; height: 22px; border-radius: 11px;
  background: var(--divider); position: relative;
  cursor: pointer; transition: background .2s;
}

.toggle.on { background: var(--primary); }
.toggle::after {
  content: ''; position: absolute;
  width: 16px; height: 16px; border-radius: 50%; background: #fff;
  top: 3px; left: 3px; transition: left .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}

.toggle.on::after { left: 21px; }

/* ══════════════════════════════════
   动态
══════════════════════════════════ */
.moments-feed {
  flex: 1; overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
}

.moment-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 2px 12px var(--shadow);
}

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

.moment-header .avatar { width: 40px; height: 40px; font-size: 15px; }
.moment-header .m-name { font-size: 14px; font-weight: 600; }
.moment-header .m-time { font-size: 11px; color: var(--text-3); }
.moment-header .m-menu { margin-left: auto; cursor: pointer; color: var(--text-3); font-size: 18px; }

.moment-text { font-size: 14px; line-height: 1.6; margin-bottom: 10px; }

.moment-images {
  display: grid; gap: 4px; margin-bottom: 10px; border-radius: 10px; overflow: hidden;
}

.moment-images.grid-1 { grid-template-columns: 1fr; }
.moment-images.grid-2 { grid-template-columns: 1fr 1fr; }
.moment-images.grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.moment-images img { width: 100%; aspect-ratio: 1; object-fit: cover; cursor: pointer; }

.moment-footer {
  display: flex; align-items: center; gap: 16px;
  padding-top: 10px;
  border-top: 1px solid var(--divider);
}

.moment-action {
  display: flex; align-items: center; gap: 5px;
  font-size: 13px; color: var(--text-3);
  cursor: pointer; transition: color .12s;
}

.moment-action:hover { color: var(--primary); }
.moment-action.liked { color: var(--danger); }

/* 发布动态 */
.publish-panel {
  flex: 1; background: var(--bg);
  padding: 24px;
  display: flex; flex-direction: column; gap: 14px;
  overflow-y: auto;
}

.publish-textarea {
  width: 100%; min-height: 120px;
  background: var(--surface);
  border: 1.5px solid var(--divider);
  border-radius: 12px;
  padding: 14px;
  font-size: 15px; color: var(--text-1);
  resize: none; line-height: 1.6;
  transition: border-color .15s;
}

.publish-textarea:focus { border-color: var(--primary); }

.image-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.image-add-btn {
  aspect-ratio: 1;
  background: var(--surface);
  border: 2px dashed var(--divider);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: var(--text-3);
  cursor: pointer; transition: all .12s;
}

.image-add-btn:hover { border-color: var(--primary); color: var(--primary); }

.image-thumb {
  aspect-ratio: 1; border-radius: 10px; overflow: hidden; position: relative;
}

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

.image-thumb .remove-img {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,.5); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; cursor: pointer;
}

/* ══════════════════════════════════
   个人中心
══════════════════════════════════ */
.profile-page {
  flex: 1; overflow-y: auto;
}

.profile-hero {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary), var(--primary-light));
  padding: 40px 30px 50px;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  position: relative;
}

.profile-hero .big-avatar {
  width: 86px; height: 86px; font-size: 34px; border-radius: 22px;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}

.profile-hero .p-name { font-size: 22px; font-weight: 700; color: #fff; }
.profile-hero .p-ylid { font-size: 12px; color: rgba(255,255,255,.7); }
.profile-hero .p-sig { font-size: 13px; color: rgba(255,255,255,.6); text-align: center; }

.profile-edit-btn {
  position: absolute; top: 20px; right: 20px;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  color: #fff; padding: 6px 14px; border-radius: 20px; font-size: 12px;
  cursor: pointer; transition: background .15s;
}

.profile-edit-btn:hover { background: rgba(255,255,255,.25); }

.profile-content {
  padding: 20px;
  display: flex; flex-direction: column; gap: 14px;
  max-width: 600px; margin: 0 auto;
  margin-top: -20px;
}

.menu-card {
  background: var(--surface);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 12px var(--shadow);
}

.menu-row {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--divider);
  transition: background .12s;
}

.menu-row:last-child { border-bottom: none; }
.menu-row:hover { background: var(--surface-alt); }

.menu-icon {
  width: 32px; height: 32px; border-radius: 8px;
  background: rgba(91,75,138,.1);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}

.menu-label { flex: 1; font-size: 14px; }
.menu-arrow { color: var(--text-3); font-size: 14px; }

/* ══════════════════════════════════
   设置页
══════════════════════════════════ */
.settings-page {
  flex: 1; overflow-y: auto;
  padding: 20px;
  max-width: 520px;
}

.settings-page h2 { font-size: 20px; font-weight: 700; margin-bottom: 16px; }
.settings-section-label { font-size: 12px; color: var(--text-3); padding: 0 4px 8px; margin-top: 16px; }

/* ══════════════════════════════════
   登录/注册页
══════════════════════════════════ */
.auth-page {
  min-height: 100vh;
  display: flex;
}

.auth-left {
  flex: 1;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 40px;
  position: relative; overflow: hidden;
}

.auth-left::before {
  content: ''; position: absolute;
  width: 300px; height: 300px; border-radius: 50%;
  background: rgba(255,255,255,.05);
  top: -80px; right: -80px;
}

.auth-left::after {
  content: ''; position: absolute;
  width: 200px; height: 200px; border-radius: 50%;
  background: rgba(201,166,107,.08);
  bottom: -60px; left: -40px;
}

.auth-logo { width: 80px; height: 80px; border-radius: 22px; margin-bottom: 24px; font-size: 38px; }
.auth-title { font-size: 32px; font-weight: 700; color: #fff; letter-spacing: 2px; margin-bottom: 10px; }
.auth-subtitle { font-size: 14px; color: rgba(255,255,255,.6); letter-spacing: 1px; }

.auth-right {
  width: 440px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
  background: var(--surface);
}

.auth-form { width: 100%; }
.auth-form h2 { font-size: 24px; font-weight: 700; margin-bottom: 6px; }
.auth-form p { font-size: 13px; color: var(--text-3); margin-bottom: 28px; }

.form-group { margin-bottom: 14px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; display: block; }

.auth-switch { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-3); }
.auth-switch a { color: var(--primary); font-weight: 600; cursor: pointer; }

.error-msg { color: var(--danger); font-size: 12px; margin-top: 8px; display: none; }
.error-msg.show { display: block; }

/* ══════════════════════════════════
   响应式
══════════════════════════════════ */
@media (max-width: 768px) {
  .sidebar { width: 60px; }
  .sidebar-logo .logo-text { display: none; }
  .nav-item .nav-label { display: none; }
  .nav-item { justify-content: center; padding: 11px; }
  .user-info { display: none; }
  .panel { width: 100%; border-right: none; }
  .auth-left { display: none; }
  .auth-right { width: 100%; }
}
