/* ===== CSS Variables & Reset ===== */
:root {
  --primary: #5cb85c;
  --primary-dark: #449d44;
  --primary-light: #e8f5e9;
  --accent: #f5a623;
  --accent-light: #fff8e1;
  --bg: #faf8f5;
  --bg-card: #ffffff;
  --sidebar-bg: #fff;
  --text: #3d3a36;
  --text-secondary: #9e9a94;
  --text-light: #c4c0b8;
  --border: #f0ece6;
  --shadow: rgba(60, 50, 40, 0.08);
  --shadow-md: rgba(60, 50, 40, 0.12);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-full: 9999px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "LXGW WenKai", "Microsoft YaHei", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  width: 100%; height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

#app { width: 100%; height: 100%; display: flex; flex-direction: column; }

/* ===== Auth Page ===== */
.page { display: none; width: 100%; height: 100%; }
.page.active { display: flex; }

#auth-page {
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, #f9f7f4 0%, #f0ece6 50%, #e8f5e9 100%);
  position: relative;
  overflow: hidden;
}

#auth-page::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(92,184,92,0.1) 0%, transparent 70%);
  top: -150px; right: -150px;
  pointer-events: none;
}

#auth-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245,166,35,0.08) 0%, transparent 70%);
  bottom: -100px; left: -100px;
  pointer-events: none;
}

.auth-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  padding: 24px;
  animation: fadeInUp 0.6s ease;
}

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

.auth-header { text-align: center; margin-bottom: 32px; }

.auth-logo {
  width: 72px; height: 72px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 8px 24px rgba(92,184,92,0.3);
  animation: floatIn 0.8s ease 0.2s both;
}

.auth-logo i { font-size: 32px; color: white; }

@keyframes floatIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

.auth-header h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary-dark);
  letter-spacing: 2px;
  margin-bottom: 6px;
}

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

.auth-tabs {
  display: flex;
  background: var(--bg);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 20px;
  border: 1px solid var(--border);
}

.auth-tab {
  flex: 1;
  padding: 10px;
  border: none;
  background: transparent;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: calc(var(--radius) - 4px);
  cursor: pointer;
  transition: all 0.25s;
}

.auth-tab.active {
  background: var(--bg-card);
  color: var(--primary-dark);
  box-shadow: 0 2px 8px var(--shadow);
}

.auth-form { animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.form-group {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  padding: 0 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(92,184,92,0.12);
}

.form-group i { color: var(--text-light); font-size: 15px; flex-shrink: 0; }

.form-group input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 13px 10px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  font-family: var(--font);
}

.form-group input::placeholder { color: var(--text-light); }

/* 记住密码 */
.remember-me {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  margin-bottom: 16px;
  user-select: none;
}

.remember-me input[type="checkbox"] { display: none; }

.checkmark {
  width: 18px; height: 18px;
  background: #fff;
  border: 1.5px solid #2d8a4e;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.remember-me input:checked ~ .checkmark {
  background: var(--primary);
  border-color: var(--primary);
}

.remember-me input:checked ~ .checkmark::after {
  content: '';
  width: 5px; height: 9px;
  border: 2px solid white;
  border-top: none; border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
  display: block;
}

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s;
  font-family: var(--font);
  box-shadow: 0 4px 14px rgba(92,184,92,0.35);
}

.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(92,184,92,0.4); }
.btn-primary:active { transform: translateY(0); }

.btn-accent {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #f5a623, #e89520);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
  font-family: var(--font);
}

.btn-accent:hover { transform: translateY(-1px); box-shadow: 0 4px 14px rgba(245,166,35,0.35); }

.btn-secondary {
  padding: 10px 20px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font);
}
.btn-secondary:hover { border-color: var(--primary); color: var(--primary); }

/* ===== Chat Layout ===== */
#chat-page { display: none; flex-direction: row; }
#chat-page.active { display: flex; }

#sidebar {
  width: 280px;
  min-width: 280px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  flex-shrink: 0;
}

/* 响应式布局：当屏幕宽度小于500px时，只显示侧边栏 */
@media (max-width: 500px) {
  #chat-area {
    display: none !important;
  }
  
  #sidebar {
    width: 100% !important;
    min-width: 100% !important;
  }
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  /* 添加安全区域内边距，防止被刘海屏遮挡 */
  /* 为iOS 11.0-11.2 使用 constant() */
  padding-top: calc(16px + constant(safe-area-inset-top));
  padding-left: calc(14px + constant(safe-area-inset-left));
  padding-right: calc(14px + constant(safe-area-inset-right));
  /* 为 iOS 11.2+ 使用 env() */
  padding-top: calc(16px + env(safe-area-inset-top));
  padding-left: calc(14px + env(safe-area-inset-left));
  padding-right: calc(14px + env(safe-area-inset-right));
  padding-bottom: 12px;
}

.sidebar-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--primary-dark);
  letter-spacing: 1px;
}

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

.icon-btn {
  width: 36px; height: 36px;
  border: none;
  background: transparent;
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.icon-btn:hover { background: var(--primary-light); color: var(--primary); }

.search-box {
  display: flex;
  align-items: center;
  padding: 8px 14px;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}

.search-box i { color: var(--text-light); font-size: 13px; flex-shrink: 0; }

.search-box input {
  flex: 1;
  border: none;
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 4px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  font-family: var(--font);
}

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

/* Conversation List */
.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

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

.conv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 2px;
  position: relative;
}

.conv-item:hover { background: var(--bg); }
.conv-item.active { background: var(--primary-light); }

.conv-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 60%;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

.conv-avatar {
  width: 46px; height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  position: relative;
}

.conv-avatar.group { background: linear-gradient(135deg, #fff8e1, #ffe082); }

.online-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: #4caf50;
  border: 2px solid white;
  position: absolute;
  bottom: 1px; right: 1px;
}

.online-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #4caf50;
  border: 2px solid white;
  position: absolute;
  bottom: -2px;
  right: -2px;
  z-index: 1;
}

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

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

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

.conv-time {
  font-size: 11px;
  color: var(--text-light);
  flex-shrink: 0;
}

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

.conv-unread {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: #e74c3c;
  color: white;
  font-size: 11px;
  font-weight: 600;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(231, 76, 60, 0.3);
}

.admin-actions {
  padding: 12px;
  border-top: 1px solid var(--border);
}

/* ===== Chat Area ===== */
#chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  min-height: 0;
}

.no-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-light);
}

.no-chat i { font-size: 56px; opacity: 0.4; }
.no-chat p { font-size: 14px; }

.chat-view { display: none; flex-direction: column; min-height: 0; }
.chat-view.active { display: flex; }

.chat-header {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 4px var(--shadow);
  z-index: 10;
  position: sticky;
  top: 0;
  /* 添加安全区域内边距，防止被刘海屏遮挡 */
  /* 为iOS 11.0-11.2 使用 constant() */
  padding-top: calc(12px + constant(safe-area-inset-top));
  padding-left: calc(16px + constant(safe-area-inset-left));
  padding-right: calc(16px + constant(safe-area-inset-right));
  /* 为 iOS 11.2+ 使用 env() */
  padding-top: calc(12px + env(safe-area-inset-top));
  padding-left: calc(16px + env(safe-area-inset-left));
  padding-right: calc(16px + env(safe-area-inset-right));
  padding-bottom: 12px;
}

.back-btn { display: none; }

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

#chat-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-subtitle { font-size: 11px; color: var(--text-secondary); }

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

/* Message List */
.message-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.message-list::-webkit-scrollbar { width: 5px; }
.message-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 78%;
  animation: msgIn 0.25s ease;
}

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

.msg-row.me { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  font-weight: 600;
  color: var(--primary-dark);
}

.msg-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.msg-row.me .msg-body { align-items: flex-end; }
.msg-row.other .msg-body { align-items: flex-start; }

.msg-sender { font-size: 10px; color: var(--text-secondary); font-weight: 500; }

.msg-row.other .msg-sender { color: rgba(255,255,255,0.9); }

.msg-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg-header .msg-time {
  position: static;
}

.msg-row.other .msg-bubble {
  padding-top: 6px;
}

.msg-bubble {
  padding: 10px 14px 10px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  box-shadow: 0 1px 4px var(--shadow);
  position: relative;
  width: fit-content;
  max-width: 360px;
}

.msg-row.me .msg-bubble {
  padding-right: 50px;
  padding-bottom: 16px;
}

.msg-text {
  display: inline;
}

.msg-row.other .msg-bubble {
  background: linear-gradient(135deg, #07c160, #06ad56);
  border-bottom-left-radius: 6px;
  color: white;
}

.msg-row.me .msg-bubble {
  background: var(--bg-card);
  border-bottom-right-radius: 6px;
  color: var(--text);
}

.msg-time {
  position: absolute;
  right: 8px;
  bottom: 4px;
  font-size: 10px;
  color: var(--text-light);
  white-space: nowrap;
  line-height: 1;
}

.msg-row.me .msg-time {
  color: var(--text-light);
}

.msg-row.other .msg-time {
  color: rgba(255,255,255,0.7);
}

.msg-image {
  max-width: 240px;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px var(--shadow);
}

.msg-image img {
  width: 100%;
  display: block;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.2s;
}

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

.msg-audio {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  width: 120px;
  padding: 10px 16px;
  border-radius: 16px;
  height: 40px;
  box-sizing: border-box;
}

.msg-audio audio { display: none; }

.msg-audio .audio-icon {
  font-size: 18px;
  flex-shrink: 0;
  transition: transform 0.2s;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.msg-audio-me .audio-icon {
  color: var(--primary);
}

.msg-audio-other .audio-icon {
  color: rgba(255,255,255,0.95);
}

.msg-audio.playing .audio-icon {
  animation: audioPulse 0.8s ease-in-out infinite;
}

@keyframes audioPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.7; }
}

/* 已播放状态 - 长度变短 */
.msg-audio.msg-audio-played {
  width: 80px;
  opacity: 0.85;
}

.msg-audio-me {
  background: var(--bg-card);
  color: var(--text);
  border-bottom-right-radius: 4px;
  flex-direction: row-reverse;
  padding: 10px 16px !important;
}

.msg-audio-other {
  background: linear-gradient(135deg, #07c160, #06ad56);
  color: #fff;
  border-bottom-left-radius: 4px;
  flex-direction: row;
  padding: 10px 16px !important;
}

.msg-audio-other .msg-header {
  display: none;
}

.system-msg {
  text-align: center;
  font-size: 12px;
  color: var(--text-light);
  padding: 6px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.system-msg::before, .system-msg::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
  max-width: 60px;
}

/* Input Area */
.input-area {
  padding: 8px 10px 12px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  position: relative;
  z-index: 10;
  /* 添加安全区域内边距，防止被底部手势区域遮挡 */
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  padding-left: calc(10px + env(safe-area-inset-left));
  padding-right: calc(10px + env(safe-area-inset-right));
}

/* 移动端适配 */
@media (max-width: 768px) {
  #chat-page {
    flex-direction: column;
  }
  
  #sidebar {
    width: 100% !important;
    min-width: 100% !important;
    height: 100% !important;
    position: relative;
    z-index: 100;
  }
  
  #chat-area {
    display: none !important;
  }
  
  #sidebar.hidden {
    display: none !important;
  }
  
  #sidebar.hidden + #chat-area {
    display: flex !important;
    width: 100% !important;
    height: 100vh;
  }
  
  .back-btn {
    display: flex !important;
  }
  
  .chat-view {
    min-height: 100vh;
  }
  
  .input-area {
    position: sticky;
    bottom: 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
  }
  
  /* 防止移动端键盘弹出时输入框被遮挡 */
  html {
    height: 100%;
    overflow: hidden;
  }
  
  body {
    height: 100%;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  #app {
    height: 100%;
  }
  
  #chat-page {
    height: 100%;
  }
}

.input-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.input-row .icon-btn {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  font-size: 18px;
}

.btn-send {
  width: 42px;
  height: 42px;
  font-size: 16px;
}

.input-text-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
}

#msg-input {
  flex: 1;
  border: none;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  color: var(--text);
  background: #f5f5f5;
  outline: none;
  font-family: var(--font);
}

#msg-input:focus {
  box-shadow: 0 0 0 2px rgba(92,184,92,0.3);
}

#msg-input::placeholder { color: var(--text-light); }

.btn-send {
  width: 38px; height: 38px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: white;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-send:hover { transform: scale(1.05); box-shadow: 0 3px 10px rgba(92,184,92,0.35); }
.btn-send:active { transform: scale(0.95); }

.btn-voice-record {
  flex: 1;
  height: 40px;
  border: none;
  border-radius: 20px;
  background: #f5f5f5;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  text-align: center;
  user-select: none;
  transition: all 0.15s;
}

.btn-voice-record.recording {
  background: #e8f5e9;
  color: var(--primary);
}

.btn-voice-record .voice-hint {
  pointer-events: none;
}

/* 语音录制提示浮层 */
.voice-record-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.75);
  border-radius: 12px;
  padding: 20px 30px;
  color: white;
  text-align: center;
  z-index: 1001;
  display: none;
}

.voice-record-overlay.show {
  display: block;
}

.voice-record-overlay .mic-icon {
  font-size: 48px;
  margin-bottom: 10px;
}

.voice-record-overlay .voice-tip {
  font-size: 14px;
}

.voice-record-overlay .voice-tip.cancel {
  color: #ff6b6b;
}

/* ===== Modal ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  z-index: 1;
  width: 90%;
  max-width: 400px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  animation: modalIn 0.3s ease;
  overflow: hidden;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.9) translateY(20px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--text); }

.modal-close {
  width: 30px; height: 30px;
  border: none;
  background: var(--bg);
  border-radius: 8px;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.modal-close:hover { background: #ffebee; color: #e53935; }

.modal-body { padding: 16px 18px; max-height: 60vh; overflow-y: auto; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 18px;
  border-top: 1px solid var(--border);
}

/* Member select */
.label { font-size: 13px; color: var(--text-secondary); margin-bottom: 10px; }

.member-select-list { display: flex; flex-direction: column; gap: 6px; max-height: 280px; overflow-y: auto; }

.member-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s;
}

.member-option:hover { background: var(--bg); }

.member-option.selected { background: var(--primary-light); }

.member-option .avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #e8f5e9, #c8e6c9);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-dark);
}

.member-option .name { font-size: 14px; font-weight: 500; flex: 1; }

.member-option .check {
  width: 20px; height: 20px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: white;
  transition: all 0.2s;
}

.member-option.selected .check {
  background: var(--primary);
  border-color: var(--primary);
}

/* Admin buttons */
.btn-danger-admin, .btn-info-admin {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s;
  font-family: var(--font);
  margin-bottom: 8px;
  text-align: left;
}

.btn-danger-admin {
  background: #fff5f5;
  color: #e53935;
  border: 1.5px solid #ffcdd2;
}

.btn-danger-admin:hover { background: #ffebee; transform: translateX(2px); }

.btn-info-admin {
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1.5px solid #c8e6c9;
}

.btn-info-admin:hover { background: #d7ffd9; transform: translateX(2px); }

/* ===== Toast ===== */
#toast-container {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
  white-space: nowrap;
}

.toast.success { background: var(--primary); color: white; }
.toast.error { background: #e53935; color: white; }
.toast.info { background: #1976d2; color: white; }

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

@keyframes toastOut {
  to { opacity: 0; transform: translateY(-10px); }
}

/* Voice Call Overlay */
#voice-call-overlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #2d8a4e, #1a5c30);
  z-index: 2000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  color: white;
}

#voice-call-overlay.active { display: flex; animation: fadeIn 0.4s ease; }

.voice-avatar {
  width: 100px; height: 100px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
}

.voice-info { text-align: center; }
.voice-info h3 { font-size: 22px; font-weight: 700; margin-bottom: 6px; }
.voice-info p { font-size: 13px; opacity: 0.7; }

.voice-actions { display: flex; gap: 30px; margin-top: 20px; }

.voice-btn {
  width: 56px; height: 56px;
  border-radius: 50%;
  border: none;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.voice-btn.accept { background: #4caf50; color: white; }
.voice-btn.hangup { background: #e53935; color: white; }

/* Image Preview Modal */
#image-preview {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 3000;
  display: none;
  align-items: center;
  justify-content: center;
}

#image-preview.active { display: flex; }
#image-preview img { max-width: 90%; max-height: 90%; border-radius: 12px; object-fit: contain; }

/* Empty state */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--text-light);
  padding: 40px;
  text-align: center;
}

.empty-state i { font-size: 48px; opacity: 0.3; }
.empty-state p { font-size: 14px; }

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.typing-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-light);
  animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(1); opacity: 0.4; }
  40% { transform: scale(1.3); opacity: 1; }
}

/* Responsive */
@media (max-width: 600px) {
  #sidebar { width: 100%; position: absolute; left: 0; top: 0; height: 100%; z-index: 50; }
  #sidebar.hidden { display: none; }
  #chat-area { width: 100%; }
  .back-btn { display: flex !important; }
  .msg-row { max-width: 88%; }
}

/* TURN Switch Toggle */
.turn-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
}

.turn-switch input { opacity: 0; width: 0; height: 0; }

.turn-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #ccc;
  transition: 0.3s;
  border-radius: 26px;
}

.turn-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.turn-switch input:checked + .turn-slider { background-color: var(--primary); }

.turn-switch input:checked + .turn-slider:before { transform: translateX(24px); }

.turn-switch input:disabled + .turn-slider { opacity: 0.5; cursor: not-allowed; }
