/* ===== 简约二次元风格 ===== */
@import url('https://fonts.googleapis.com/css2?family=M+PLUS+Rounded+1c:wght@300;400;500;700&display=swap');

:root {
  /* 黑白简约配色 */
  --bg-primary: #ffffff;
  --bg-secondary: #fafafa;
  --bg-tertiary: #f5f5f5;
  --bg-hover: #eeeeee;
  --bg-card: #ffffff;
  
  --text-primary: #1a1a1a;
  --text-secondary: #666666;
  --text-muted: #999999;
  
  --accent: #1a1a1a;
  --accent-light: #333333;
  --accent-soft: rgba(26, 26, 26, 0.1);
  
  --border: #e5e5e5;
  --border-dark: #d0d0d0;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.08);
  
  --online: #22c55e;
  --offline: #9ca3af;
  --danger: #ef4444;
  --warning: #f59e0b;
  
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-full: 9999px;
  
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'M PLUS Rounded 1c', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
}

.hidden {
  display: none !important;
}

/* ===== 登录/注册页面 ===== */
.auth-container {
  min-height: 100vh;
  min-height: 100dvh; /* 动态视口高度，适配移动端键盘 */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  background: linear-gradient(135deg, #fafafa 0%, #ffffff 100%);
  overflow-y: auto;
}

.auth-background {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

/* 二次元风格装饰圆点 */
.gradient-orb {
  position: absolute;
  border-radius: 50%;
  background: var(--bg-tertiary);
  opacity: 0.5;
}

.orb-1 {
  width: 300px;
  height: 300px;
  top: -80px;
  right: -80px;
  border: 2px dashed var(--border);
}

.orb-2 {
  width: 200px;
  height: 200px;
  bottom: -50px;
  left: -50px;
  border: 2px dashed var(--border);
}

.orb-3 {
  width: 100px;
  height: 100px;
  top: 30%;
  left: 20%;
  border: 2px dashed var(--border);
}

.auth-card {
  background: var(--bg-card);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: clamp(24px, 5vw, 48px) clamp(20px, 4vw, 40px);
  width: 100%;
  max-width: min(400px, calc(100vw - 40px));
  position: relative;
  z-index: 1;
  box-shadow: var(--shadow-lg);
  margin: auto;
}

.auth-header {
  text-align: center;
  margin-bottom: clamp(24px, 5vw, 36px);
}

.auth-header .logo {
  width: clamp(56px, 12vw, 72px);
  height: clamp(56px, 12vw, 72px);
  background: var(--accent);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto clamp(14px, 3vw, 20px);
  position: relative;
}

/* 二次元风格小装饰 */
.auth-header .logo::before {
  content: '✧';
  position: absolute;
  top: -8px;
  right: -8px;
  font-size: clamp(12px, 2.5vw, 16px);
  color: var(--text-muted);
}

.auth-header .logo svg {
  width: clamp(28px, 6vw, 36px);
  height: clamp(28px, 6vw, 36px);
  color: white;
}

.auth-header h1 {
  font-size: clamp(20px, 5vw, 26px);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: -0.5px;
}

.auth-header .tagline {
  color: var(--text-muted);
  font-size: clamp(12px, 2.5vw, 14px);
  font-weight: 400;
}

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

.tab-btn {
  flex: 1;
  padding: clamp(10px, 2vw, 12px);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: clamp(13px, 2vw, 14px);
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-full);
  transition: var(--transition);
  font-family: inherit;
}

.tab-btn.active {
  background: var(--accent);
  color: white;
  box-shadow: var(--shadow-sm);
}

.tab-btn:hover:not(.active) {
  color: var(--text-primary);
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
  animation: fadeSlideUp 0.3s ease;
}

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

.input-group {
  margin-bottom: clamp(14px, 3vw, 20px);
}

.input-group label {
  display: block;
  font-size: clamp(12px, 2vw, 13px);
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-group input {
  width: 100%;
  padding: clamp(12px, 2.5vw, 14px) clamp(14px, 2.5vw, 16px);
  background: var(--bg-secondary);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: clamp(14px, 2.5vw, 15px);
  font-family: inherit;
  transition: var(--transition);
}

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

.input-group input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-primary);
}

.auth-submit {
  width: 100%;
  padding: clamp(14px, 3vw, 16px);
  background: var(--accent);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-size: clamp(14px, 2.5vw, 15px);
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
  margin-top: clamp(6px, 1.5vw, 8px);
}

.auth-submit svg {
  width: 18px;
  height: 18px;
  transition: transform 0.2s ease;
}

.auth-submit:hover {
  background: var(--accent-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.auth-submit:hover svg {
  transform: translateX(4px);
}

.auth-submit:active {
  transform: translateY(0);
}

.auth-error {
  margin-top: 16px;
  padding: 14px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-md);
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  display: none;
}

.auth-error.show {
  display: block;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

/* ===== 聊天主界面 ===== */
.chat-container {
  display: flex;
  height: 100vh;
  height: 100dvh; /* 动态视口高度，适配移动端 */
  background: var(--bg-secondary);
  overflow: hidden;
}

/* 侧边栏 */
.sidebar {
  width: 340px;
  background: var(--bg-primary);
  border-right: 2px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-header {
  padding: 20px 24px;
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 18px;
  color: white;
  flex-shrink: 0;
  position: relative;
}

/* 二次元风格头像装饰 */
.avatar::after {
  content: '';
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background: var(--online);
  border: 3px solid var(--bg-primary);
  border-radius: 50%;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-weight: 600;
  font-size: 16px;
  color: var(--text-primary);
}

.user-status {
  font-size: 12px;
  color: var(--online);
  font-weight: 500;
}

.logout-btn {
  width: 40px;
  height: 40px;
  border: 2px solid var(--border);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

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

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

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

.nav-btn {
  flex: 1;
  padding: 12px 8px;
  border: 2px solid transparent;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  position: relative;
}

.nav-btn svg {
  width: 22px;
  height: 22px;
}

.nav-btn.active {
  background: var(--bg-tertiary);
  border-color: var(--border);
  color: var(--text-primary);
}

.nav-btn:hover:not(.active) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-btn .badge {
  position: absolute;
  top: 6px;
  right: 6px;
  min-width: 18px;
  height: 18px;
  background: var(--danger);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

.sidebar-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

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

.view.active {
  display: flex;
}

.view-header {
  padding: 20px 24px 12px;
}

.view-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.friend-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 16px;
}

.friend-item {
  display: flex;
  align-items: center;
  padding: 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 6px;
  border: 2px solid transparent;
}

.friend-item:hover {
  background: var(--bg-tertiary);
  border-color: var(--border);
}

.friend-item.active {
  background: var(--bg-tertiary);
  border-color: var(--accent);
}

.friend-item .avatar {
  width: 44px;
  height: 44px;
  font-size: 16px;
}

.friend-item .avatar::after {
  display: none;
}

.friend-item .friend-info {
  flex: 1;
  margin-left: 14px;
  min-width: 0;
}

.friend-item .friend-name {
  font-weight: 500;
  font-size: 15px;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.friend-item .friend-status {
  font-size: 12px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}

.friend-item .friend-status.online {
  color: var(--online);
}

.friend-item .friend-status.online::before {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--online);
  border-radius: 50%;
}

.friend-item .unread-badge {
  min-width: 22px;
  height: 22px;
  background: var(--accent);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}

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

.empty-state svg {
  width: 56px;
  height: 56px;
  margin-bottom: 16px;
  opacity: 0.4;
  stroke-width: 1.5;
}

.empty-state p {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.empty-state span {
  font-size: 13px;
}

/* 搜索框 */
.search-box {
  display: flex;
  align-items: center;
  padding: 0 24px;
  margin-bottom: 16px;
}

.search-box svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  margin-right: -34px;
  z-index: 1;
}

.search-box input {
  width: 100%;
  padding: 14px 14px 14px 42px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
}

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

.search-box input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-primary);
}

.search-results {
  padding: 0 16px;
  overflow-y: auto;
  flex: 1;
}

.search-result-item {
  display: flex;
  align-items: center;
  padding: 14px;
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
}

.search-result-item .avatar {
  width: 42px;
  height: 42px;
  font-size: 15px;
}

.search-result-item .avatar::after {
  display: none;
}

.search-result-item .user-info {
  flex: 1;
  margin-left: 12px;
}

.search-result-item .username {
  font-weight: 500;
  font-size: 14px;
  display: block;
  color: var(--text-primary);
}

.search-result-item .display-name {
  font-size: 12px;
  color: var(--text-muted);
}

.add-friend-btn {
  padding: 10px 18px;
  background: var(--accent);
  border: none;
  border-radius: var(--radius-md);
  color: white;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}

.add-friend-btn:hover {
  background: var(--accent-light);
  transform: translateY(-1px);
}

.add-friend-btn:disabled {
  background: var(--bg-hover);
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
}

/* 好友请求 */
.friend-requests-section {
  padding: 0 16px;
  margin-bottom: 16px;
}

.friend-requests-section h4 {
  font-size: 12px;
  font-weight: 600;
  color: var(--warning);
  margin-bottom: 12px;
  padding: 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.friend-requests-section h4::before {
  content: '✦';
}

.friend-request-item {
  display: flex;
  align-items: center;
  padding: 14px;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  border: 2px solid var(--warning);
}

.friend-request-item .avatar {
  width: 42px;
  height: 42px;
  font-size: 15px;
}

.friend-request-item .avatar::after {
  display: none;
}

.friend-request-item .request-info {
  flex: 1;
  margin-left: 12px;
}

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

.friend-request-item .request-username {
  font-size: 12px;
  color: var(--text-muted);
}

.friend-request-item .request-actions {
  display: flex;
  gap: 8px;
}

.accept-btn, .reject-btn {
  width: 36px;
  height: 36px;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.accept-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.accept-btn:hover {
  background: var(--accent-light);
  transform: scale(1.05);
}

.reject-btn {
  background: var(--bg-primary);
  color: var(--text-muted);
}

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

.accept-btn svg, .reject-btn svg {
  width: 16px;
  height: 16px;
}

/* ===== 聊天区域 ===== */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  min-width: 0;
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.empty-illustration svg {
  width: 120px;
  height: 120px;
  margin-bottom: 24px;
  color: var(--border-dark);
  stroke-width: 1;
}

.chat-empty h2 {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.chat-empty p {
  font-size: 14px;
  color: var(--text-muted);
}

.chat-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  margin: 16px;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.chat-header {
  padding: 18px 24px;
  background: var(--bg-primary);
  border-bottom: 2px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
}

.back-btn {
  display: none;
  width: 40px;
  height: 40px;
  border: 2px solid var(--border);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

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

.back-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.chat-user-info {
  display: flex;
  align-items: center;
  gap: 14px;
}

.chat-user-info .avatar {
  width: 44px;
  height: 44px;
  font-size: 16px;
}

.chat-user-info .info {
  display: flex;
  flex-direction: column;
}

.chat-user-info .name {
  font-weight: 600;
  font-size: 16px;
  color: var(--text-primary);
}

.chat-user-info .status {
  font-size: 12px;
  color: var(--text-muted);
}

.chat-user-info .status.online {
  color: var(--online);
}

/* 消息区域 */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
}

.messages-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.message {
  display: flex;
  max-width: 70%;
  animation: messageIn 0.3s ease;
}

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

.message.sent {
  align-self: flex-end;
  flex-direction: row-reverse;
}

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

.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.message.sent .message-avatar {
  margin-left: 8px;
}

.message.received .message-avatar {
  margin-right: 8px;
}

.message-content {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  max-width: 100%;
  word-wrap: break-word;
  border: 1px solid transparent;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.message.sent .message-content {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border-radius: var(--radius-md) var(--radius-md) 4px var(--radius-md);
}

.message.sent .reply-quote {
  background: rgba(255, 255, 255, 0.2);
  border-left-color: rgba(255, 255, 255, 0.6);
}

.message.sent .reply-author {
  color: rgba(255, 255, 255, 0.9);
}

.message.sent .reply-text {
  color: rgba(255, 255, 255, 0.8);
}

.message.sent .message-time {
  color: rgba(255, 255, 255, 0.7);
}

.message.received .message-content {
  background: var(--bg-primary);
  color: var(--text-primary);
  border-color: var(--border);
  border-radius: var(--radius-md) var(--radius-md) var(--radius-md) 4px;
}

.message-text {
  font-size: 14px;
  line-height: 1.5;
}

.message-time {
  font-size: 10px;
  margin-top: 6px;
  opacity: 0.7;
  text-align: right;
}

.message.received .message-time {
  color: var(--text-muted);
  opacity: 1;
}

/* 正在输入指示器 */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 18px;
  background: var(--bg-primary);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  width: fit-content;
  margin-top: 16px;
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
  animation-delay: 0s;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.4s;
}

.typing-indicator .typing-text {
  width: auto;
  height: auto;
  background: none;
  font-size: 12px;
  color: var(--text-muted);
  animation: none;
  margin-left: 8px;
}

@keyframes typing {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-6px);
  }
}

/* 消息输入框 */
.message-input-container {
  padding: 18px 24px;
  background: var(--bg-primary);
  border-top: 2px solid var(--border);
  flex-shrink: 0;
}

.message-form {
  display: flex;
  gap: 14px;
  align-items: center;
  width: 100%;
}

.message-form input {
  flex: 1;
  min-width: 0; /* 防止 flex 子元素溢出 */
  padding: 16px 20px;
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: var(--transition);
}

.message-form input::placeholder {
  color: var(--text-muted);
}

.message-form input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--bg-primary);
}

.send-btn {
  width: 52px;
  height: 52px;
  background: var(--accent);
  border: none;
  border-radius: 50%;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.send-btn svg {
  width: 22px;
  height: 22px;
}

.send-btn:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-md);
}

.send-btn:active {
  transform: scale(0.95);
}

/* ===== Toast 通知 ===== */
.toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.toast {
  padding: 16px 20px;
  background: var(--bg-primary);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 320px;
}

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

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

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

.toast-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.toast.success .toast-icon {
  color: var(--online);
}

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

.toast.info .toast-icon {
  color: var(--accent);
}

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

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

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

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-dark);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ===== 新功能样式 =====  */

/* 头像图片 */
.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
}

.avatar.large {
  width: 80px;
  height: 80px;
  font-size: 28px;
}

.avatar.small {
  width: 32px;
  height: 32px;
  font-size: 12px;
}

/* 头部操作按钮 */
.header-actions {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border: 2px solid var(--border);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

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

.icon-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

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

/* 加密徽章 */
.encryption-badge {
  font-size: 16px;
  opacity: 0.6;
}

.encryption-note {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 12px;
}

.chat-actions {
  margin-left: auto;
}

/* 引用消息预览 */
.reply-preview {
  padding: 12px 24px;
  background: var(--bg-tertiary);
  border-top: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.reply-preview .reply-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.reply-preview .reply-to-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
}

.reply-preview .reply-to-text {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reply-cancel {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.reply-cancel:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.reply-cancel svg {
  width: 16px;
  height: 16px;
}

/* 消息引用块 */
.reply-quote {
  background: var(--accent-soft);
  padding: 6px 10px;
  border-radius: 8px;
  margin-bottom: 6px;
  border-left: 2px solid var(--accent);
}

.reply-quote .reply-author {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  display: block;
  margin-bottom: 2px;
}

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

/* 消息图片 */
.message-image {
  max-width: 280px;
  max-height: 280px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}

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

/* 消息元数据和操作 */
.message-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
  gap: 8px;
}

.message-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: var(--transition);
}

.message:hover .message-actions {
  opacity: 1;
}

.msg-action {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  color: inherit;
  opacity: 0.5;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.msg-action:hover {
  opacity: 1;
  background: rgba(0,0,0,0.1);
}

.msg-action svg {
  width: 14px;
  height: 14px;
}

.message.deleted .message-text {
  color: var(--text-muted);
  font-style: italic;
}

/* 附件按钮 */
.attach-btn {
  width: 44px;
  height: 44px;
  border: 2px solid var(--border);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  flex-shrink: 0;
}

.attach-btn svg {
  width: 20px;
  height: 20px;
}

.attach-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* 聊天背景 */
.messages-container.bg-gradient1 {
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
}

.messages-container.bg-gradient2 {
  background: linear-gradient(135deg, #fdfbfb 0%, #ebedee 100%);
}

.messages-container.bg-custom {
  background-size: cover;
  background-position: center;
}

/* ===== 模态框 ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

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

.modal-content {
  position: relative;
  background: var(--bg-primary);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.modal-content.large {
  max-width: 800px;
}

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

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close svg {
  width: 18px;
  height: 18px;
}

.modal-close:hover {
  background: var(--danger);
  color: white;
}

.modal-close.light {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255,255,255,0.9);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

/* 设置区块 */
.settings-section {
  margin-bottom: 28px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

.settings-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.avatar-upload {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.background-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.bg-option {
  padding: 10px 16px;
  border: 2px solid var(--border);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.bg-option:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.bg-option.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.info-text {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 12px;
}

/* 按钮 */
.btn {
  padding: 12px 20px;
  border: 2px solid var(--accent);
  background: var(--accent);
  border-radius: var(--radius-md);
  color: white;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
}

.btn:hover {
  background: var(--accent-light);
  border-color: var(--accent-light);
}

.btn.secondary {
  background: transparent;
  color: var(--text-primary);
}

.btn.secondary:hover {
  background: var(--bg-tertiary);
}

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

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

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

/* ===== 管理面板 ===== */
.admin-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-tertiary);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: center;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  display: block;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.admin-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 2px solid var(--border);
  padding-bottom: 12px;
}

.admin-tab {
  padding: 10px 20px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.admin-tab:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.admin-tab.active {
  background: var(--accent);
  color: white;
}

.admin-tab-content {
  display: none;
}

.admin-tab-content.active {
  display: block;
}

.invite-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.invite-actions select {
  padding: 10px 16px;
  border: 2px solid var(--border);
  background: var(--bg-primary);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
}

.admin-table-container {
  overflow-x: auto;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--bg-tertiary);
}

.admin-table td {
  font-size: 14px;
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-badge {
  font-size: 10px;
  padding: 2px 6px;
  background: var(--accent);
  color: white;
  border-radius: var(--radius-full);
  font-weight: 600;
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  margin-right: 6px;
}

.status-dot.online {
  background: var(--online);
}

.status-badge {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  font-weight: 500;
}

.status-badge.available {
  background: rgba(34, 197, 94, 0.1);
  color: var(--online);
}

.status-badge.used {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

.invite-code {
  font-family: monospace;
  font-size: 13px;
  background: var(--bg-tertiary);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  letter-spacing: 1px;
}

/* 图片预览 */
.image-preview-content {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-preview-content img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
}

/* 必填标记 */
.required {
  color: var(--danger);
}

/* ===== 响应式设计 ===== */

/* 平板 */
@media (max-width: 1024px) {
  .sidebar {
    width: 280px;
  }
}

/* 手机 */
@media (max-width: 768px) {
  /* 登录页 */
  .auth-container {
    padding: 16px;
    align-items: flex-start;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  
  .auth-card {
    padding: 24px 20px;
    max-width: 100%;
    border-radius: var(--radius-md);
    margin-top: 20px;
    margin-bottom: 20px;
  }
  
  .auth-header .logo {
    width: 56px;
    height: 56px;
  }
  
  .auth-header h1 {
    font-size: 20px;
  }
  
  .auth-header p {
    font-size: 13px;
  }
  
  .gradient-orb {
    display: none;
  }
  
  /* 主聊天容器 */
  .chat-container {
    flex-direction: column;
  }
  
  .sidebar {
    width: 100%;
    height: 100%;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-right: none;
  }
  
  .sidebar.hidden-mobile {
    transform: translateX(-100%);
    pointer-events: none;
  }
  
  /* 侧边栏头部 - 移动端紧凑布局 */
  .sidebar-header {
    padding: 12px 16px;
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 10;
  }
  
  .user-profile {
    gap: 10px;
  }
  
  .avatar {
    width: 42px;
    height: 42px;
    font-size: 16px;
  }
  
  .user-name {
    font-size: 15px;
  }
  
  .header-actions {
    gap: 6px;
  }
  
  .icon-btn {
    width: 36px;
    height: 36px;
  }
  
  .icon-btn svg {
    width: 16px;
    height: 16px;
  }
  
  /* 导航栏 - 移动端底部固定样式 */
  .sidebar-nav {
    padding: 10px 12px;
    gap: 6px;
    position: sticky;
    top: 66px;
    background: var(--bg-primary);
    z-index: 9;
  }
  
  .nav-btn {
    padding: 10px 6px;
    font-size: 11px;
  }
  
  .nav-btn svg {
    width: 20px;
    height: 20px;
  }
  
  /* 侧边栏内容 */
  .sidebar-content {
    padding-bottom: 80px; /* 防止内容被遮挡 */
  }
  
  .view-header {
    padding: 16px 16px 8px;
  }
  
  .friend-list {
    padding: 0 12px 12px;
  }
  
  .friend-item {
    padding: 12px;
  }
  
  .friend-item .avatar {
    width: 40px;
    height: 40px;
    font-size: 14px;
  }
  
  .friend-item .friend-info {
    margin-left: 12px;
  }
  
  .friend-item .friend-name {
    font-size: 14px;
  }
  
  /* 搜索框 */
  .search-box {
    padding: 0 16px;
  }
  
  .search-box input {
    padding: 12px 12px 12px 38px;
    font-size: 14px;
  }
  
  /* 聊天主区域 */
  .chat-main {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
  }
  
  .chat-empty {
    padding: 20px;
  }
  
  .chat-empty h2 {
    font-size: 18px;
  }
  
  .empty-illustration svg {
    width: 80px;
    height: 80px;
  }
  
  /* 聊天窗口 */
  .chat-window {
    margin: 0;
    border-radius: 0;
    border: none;
    height: 100%;
  }
  
  .chat-header {
    padding: 12px 16px;
    position: sticky;
    top: 0;
    z-index: 10;
  }
  
  .back-btn {
    display: flex;
    width: 36px;
    height: 36px;
  }
  
  .chat-user-info .avatar {
    width: 38px;
    height: 38px;
  }
  
  .chat-user-info .name {
    font-size: 15px;
  }
  
  /* 消息区域 */
  .messages-container {
    padding: 16px;
  }
  
  .message {
    max-width: 85%;
  }
  
  .message-avatar {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }
  
  .message.sent .message-avatar {
    margin-left: 6px;
  }
  
  .message.received .message-avatar {
    margin-right: 6px;
  }
  
  .message-content {
    padding: 8px 12px;
    border-radius: 12px;
  }
  
  .message-text {
    font-size: 14px;
  }
  
  .message-image {
    max-width: 220px;
    max-height: 220px;
  }
  
  /* 消息输入区域 */
  .message-input-container {
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  
  .message-form {
    gap: 8px;
  }
  
  .message-form input {
    padding: 12px 14px;
    font-size: 14px;
    min-width: 0;
  }
  
  .attach-btn {
    width: 38px;
    height: 38px;
    flex-shrink: 0;
  }
  
  .send-btn {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
  }
  
  .send-btn svg {
    width: 18px;
    height: 18px;
  }
  
  .attach-btn svg {
    width: 18px;
    height: 18px;
  }
  
  /* 引用预览 */
  .reply-preview {
    padding: 10px 16px;
  }
  
  /* 模态框 - 移动端全屏 */
  .modal {
    padding: 0;
  }
  
  .modal-content {
    max-width: 100%;
    max-height: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
  }
  
  .modal-content.large {
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
  }
  
  .modal-header {
    padding: 16px;
    position: sticky;
    top: 0;
    background: var(--bg-primary);
    z-index: 10;
  }
  
  .modal-body {
    padding: 16px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  
  /* 设置页面 */
  .settings-section h3 {
    font-size: 13px;
  }
  
  .avatar-upload {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  
  .avatar.large {
    width: 70px;
    height: 70px;
  }
  
  .background-options {
    gap: 6px;
  }
  
  .bg-option {
    padding: 8px 12px;
    font-size: 12px;
  }
  
  /* 管理面板 */
  .admin-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  
  .stat-card {
    padding: 14px;
  }
  
  .stat-value {
    font-size: 22px;
  }
  
  .stat-label {
    font-size: 10px;
  }
  
  .admin-tabs {
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  
  .admin-tab {
    padding: 8px 14px;
    font-size: 13px;
    white-space: nowrap;
  }
  
  .invite-actions {
    flex-wrap: wrap;
    gap: 8px;
  }
  
  .admin-table-container {
    margin: 0 -16px;
    padding: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
  }
  
  .admin-table {
    min-width: 100%;
    width: max-content;
  }
  
  .admin-table th,
  .admin-table td {
    padding: 10px 12px;
    font-size: 12px;
    white-space: nowrap;
  }
  
  /* 操作列固定在右侧 */
  .admin-table th:last-child,
  .admin-table td:last-child {
    position: sticky;
    right: 0;
    background: var(--bg-card);
    box-shadow: -4px 0 8px rgba(0,0,0,0.05);
  }
  
  .admin-table th:last-child {
    background: var(--bg-tertiary);
  }
  
  .btn {
    padding: 10px 16px;
    font-size: 13px;
  }
  
  .btn.small {
    padding: 6px 10px;
    font-size: 11px;
  }
  
  /* 好友请求 */
  .friend-request-item {
    padding: 12px;
  }
  
  .friend-request-item .request-actions {
    gap: 6px;
  }
  
  .accept-btn, .reject-btn {
    width: 32px;
    height: 32px;
  }
  
  /* Toast */
  .toast-container {
    top: auto;
    bottom: max(20px, env(safe-area-inset-bottom));
    left: 16px;
    right: 16px;
  }
  
  .toast {
    max-width: 100%;
  }
  
  /* 图片预览 */
  .image-preview-content img {
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
  }
}

/* 小屏手机 */
@media (max-width: 375px) {
  .auth-card {
    padding: 24px 16px;
  }
  
  .auth-header h1 {
    font-size: 20px;
  }
  
  .input-group input {
    padding: 12px 14px;
    font-size: 14px;
  }
  
  .auth-submit {
    padding: 14px;
    font-size: 14px;
  }
  
  .sidebar-header {
    padding: 10px 12px;
  }
  
  .user-name {
    font-size: 14px;
  }
  
  .nav-btn {
    padding: 8px 4px;
    font-size: 10px;
  }
  
  .nav-btn svg {
    width: 18px;
    height: 18px;
  }
  
  .friend-item .avatar {
    width: 36px;
    height: 36px;
  }
  
  .admin-stats {
    gap: 8px;
  }
  
  .stat-card {
    padding: 12px;
  }
  
  .stat-value {
    font-size: 18px;
  }
}

/* iOS安全区域适配 */
@supports (padding: max(0px)) {
  .message-input-container {
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  
  .modal-body {
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  
  .sidebar-content {
    padding-bottom: max(80px, calc(80px + env(safe-area-inset-bottom)));
  }
}

/* 横屏模式 */
@media (max-width: 768px) and (orientation: landscape) {
  .sidebar-header {
    padding: 8px 16px;
  }
  
  .sidebar-nav {
    padding: 8px 12px;
  }
  
  .nav-btn {
    flex-direction: row;
    gap: 6px;
  }
  
  .chat-header {
    padding: 8px 16px;
  }
  
  .messages-container {
    padding: 12px;
  }
  
  .message-input-container {
    padding: 8px 16px;
  }
}
