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

:root {
  --primary-color: #07c160;
  --primary-light: #95ec69;
  --bg-color: #f5f5f5;
  --chat-bg: #ededed;
  --white: #ffffff;
  --gray: #999;
  --dark: #333;
  --message-self: #95ec69;
  --message-other: #ffffff;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-color);
  height: 100vh;
  overflow: hidden;
}

/* 登录/注册界面 */
.auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.auth-container {
  background: var(--white);
  padding: 2rem;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  width: 90%;
  max-width: 400px;
}

.logo {
  text-align: center;
  font-size: 2.5rem;
  color: var(--primary-color);
  margin-bottom: 1.5rem;
  font-weight: 300;
}

.auth-tabs {
  display: flex;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid #eee;
}

.tab-btn {
  flex: 1;
  padding: 0.75rem;
  border: none;
  background: transparent;
  font-size: 1rem;
  color: var(--gray);
  cursor: pointer;
  transition: all 0.3s;
  position: relative;
}

.tab-btn.active {
  color: var(--primary-color);
  font-weight: 500;
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary-color);
}

.auth-form {
  display: none;
}

.auth-form.active {
  display: block;
}

.auth-form input[type="text"],
.auth-form input[type="password"] {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.3s;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.checkbox-label {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
  color: var(--gray);
  font-size: 0.9rem;
}

.checkbox-label input {
  margin-right: 0.5rem;
}

.auth-form button {
  width: 100%;
  padding: 0.75rem;
  background: var(--primary-color);
  color: var(--white);
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.3s;
}

.auth-form button:hover {
  background: var(--primary-light);
}

.error-msg {
  color: #e74c3c;
  font-size: 0.85rem;
  margin-top: 1rem;
  text-align: center;
}

/* 聊天界面 */
.chat-screen {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.chat-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--chat-bg);
}

/* 消息列表 */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  -webkit-overflow-scrolling: touch;
}

.message {
  display: flex;
  margin-bottom: 1rem;
  animation: fadeIn 0.3s ease;
}

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

.message.self {
  justify-content: flex-end;
}

.message.other {
  justify-content: flex-start;
}

.message-bubble {
  max-width: 70%;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  word-wrap: break-word;
  position: relative;
}

.message.self .message-bubble {
  background: var(--message-self);
}

.message.other .message-bubble {
  background: var(--message-other);
}

.message-sender {
  font-size: 0.75rem;
  color: var(--gray);
  margin-bottom: 0.25rem;
}

.message-content {
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--dark);
}

.message-time {
  font-size: 0.7rem;
  color: var(--gray);
  margin-top: 0.25rem;
  text-align: right;
}

/* 图片消息 */
.message-image {
  max-width: 200px;
  max-height: 200px;
  border-radius: 4px;
  cursor: pointer;
}

/* 语音消息 */
.voice-message {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 100px;
}

.voice-icon {
  font-size: 1.5rem;
}

.voice-duration {
  font-size: 0.85rem;
  color: var(--gray);
}

/* 输入区域 */
.input-container {
  background: var(--white);
  padding: 0.5rem;
  border-top: 1px solid #eee;
}

.input-toolbar {
  display: flex;
  gap: 0.5rem;
  padding-bottom: 0.5rem;
}

.tool-btn {
  padding: 0.5rem 0.75rem;
  border: 1px solid #eee;
  background: var(--white);
  border-radius: 4px;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.2s;
}

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

#messageInput {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  background: #fafafa;
  resize: none;
  font-size: 1rem;
  font-family: inherit;
  max-height: 100px;
  outline: none;
  transition: all 0.2s;
}

#messageInput:focus {
  border-color: var(--primary-color);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.1);
}

.send-btn {
  float: right;
  margin-top: 0.5rem;
  padding: 0.5rem 1.5rem;
  background: var(--primary-color);
  color: var(--white);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.9rem;
}

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

/* 表情选择器 */
.emoji-picker {
  position: fixed;
  bottom: 150px;
  left: 10px;
  background: var(--white);
  border-radius: 8px;
  padding: 0.5rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  z-index: 1000;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 0.25rem;
  max-height: 200px;
  overflow-y: auto;
}

.emoji-item {
  font-size: 1.5rem;
  padding: 0.25rem;
  cursor: pointer;
  text-align: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.emoji-item:hover {
  background: var(--bg-color);
}

/* 语音录制 */
.voice-record {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--white);
  padding: 2rem;
  border-radius: 16px;
  box-shadow: 0 5px 30px rgba(0, 0, 0, 0.3);
  text-align: center;
  z-index: 1000;
}

.record-animation {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.wave {
  width: 10px;
  height: 30px;
  background: var(--primary-color);
  border-radius: 5px;
  animation: wave 1s infinite ease-in-out;
}

.wave:nth-child(2) {
  animation-delay: 0.1s;
}

.wave:nth-child(3) {
  animation-delay: 0.2s;
}

@keyframes wave {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(2); }
}

#recordTime {
  font-size: 1.5rem;
  margin-bottom: 1rem;
  color: var(--dark);
}

#stopRecordBtn {
  padding: 0.75rem 2rem;
  background: #e74c3c;
  color: var(--white);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
}

/* 按住说话录音界面 */
.recording-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: 2000;
  transition: background 0.3s;
}

.recording-overlay.recording {
  background: rgba(0, 0, 0, 0.7);
}

.recording-overlay.cancel {
  background: rgba(231, 76, 60, 0.9);
}

.recording-content {
  text-align: center;
  color: white;
}

.recording-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.recording-text {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  opacity: 0.9;
}

.recording-time {
  font-size: 2rem;
  font-weight: 300;
}

/* 加载指示器 */
.loading {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2000;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* 响应式 */
@media (max-width: 768px) {
  .auth-container {
    padding: 1.5rem;
  }

  .message-bubble {
    max-width: 80%;
  }

  .emoji-picker {
    bottom: 120px;
    left: 5px;
    right: 5px;
  }

  .emoji-grid {
    grid-template-columns: repeat(8, 1fr);
  }
}

/* 对话列表界面 */
.conversation-list-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--bg-color);
}

.list-header {
  background: var(--white);
  padding: 1rem;
  border-bottom: 1px solid #eee;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.list-header h2 {
  font-size: 1.2rem;
  color: var(--dark);
}

.user-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-small {
  padding: 0.4rem 0.8rem;
  background: var(--primary-color);
  color: var(--white);
  border: none;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
}

.section-title {
  padding: 0.75rem 1rem 0.5rem;
  font-size: 0.85rem;
  color: var(--gray);
}

/* 对话列表项 */
.conversation-item {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--white);
  border-bottom: 1px solid #f5f5f5;
  cursor: pointer;
  transition: background 0.2s;
}

.conversation-item:active {
  background: var(--bg-color);
}

.conversation-item.unread {
  background: #f0f9ff;
}

.conversation-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 1.2rem;
  margin-right: 0.75rem;
  position: relative;
  flex-shrink: 0;
}

.online-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  background: #4ade80;
  border: 2px solid var(--white);
  border-radius: 50%;
}

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

.conversation-header {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.25rem;
}

.conversation-name {
  font-weight: 500;
  color: var(--dark);
}

.conversation-time {
  font-size: 0.75rem;
  color: var(--gray);
}

.conversation-preview {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.last-message {
  font-size: 0.85rem;
  color: var(--gray);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.unread-badge {
  background: var(--primary-color);
  color: var(--white);
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

/* 成员列表 */
.members-list {
  background: var(--white);
  margin-bottom: 0.5rem;
}

.members-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.5rem;
  padding: 0.5rem;
}

.member-card {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  background: var(--white);
  border: 1px solid #eee;
  border-radius: 8px;
  gap: 0.75rem;
}

.member-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white);
  font-size: 1.1rem;
  position: relative;
  flex-shrink: 0;
}

.online-dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 10px;
  height: 10px;
  background: #4ade80;
  border: 2px solid var(--white);
  border-radius: 50%;
}

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

.member-name {
  font-weight: 500;
  color: var(--dark);
  font-size: 0.95rem;
}

.member-note {
  font-size: 0.8rem;
  color: var(--gray);
  margin-top: 0.15rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: pointer;
}

.member-note:hover {
  color: var(--primary-color);
}

.action-btn {
  padding: 0.4rem 0.8rem;
  background: var(--primary-color);
  color: var(--white);
  border: none;
  border-radius: 4px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
}

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

/* 聊天头部 */
.chat-header {
  display: flex;
  align-items: center;
  padding: 0.75rem 1rem;
  background: var(--white);
  border-bottom: 1px solid #eee;
}

.back-btn {
  background: none;
  border: none;
  padding: 0.5rem;
  margin-right: 0.5rem;
  cursor: pointer;
  color: var(--dark);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

.chat-user-info .username {
  font-weight: 500;
  color: var(--dark);
  font-size: 1rem;
}

.user-status {
  font-size: 0.75rem;
  color: var(--gray);
}

.user-status.online {
  color: #4ade80;
}

.icon-btn {
  background: none;
  border: none;
  padding: 0.5rem;
  cursor: pointer;
  color: var(--gray);
  display: flex;
  align-items: center;
  justify-content: center;
}

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

/* 弹窗 */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.modal-content {
  background: var(--white);
  padding: 1.5rem;
  border-radius: 12px;
  width: 90%;
  max-width: 320px;
}

.modal-content h3 {
  margin-bottom: 1rem;
  color: var(--dark);
  font-size: 1.1rem;
}

.modal-content input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 1rem;
}

.modal-content input:focus {
  outline: none;
  border-color: var(--primary-color);
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
}

.modal-actions button {
  flex: 1;
  padding: 0.75rem;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
}

.btn-primary {
  background: var(--primary-color);
  color: var(--white);
}

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

.btn-secondary {
  background: #f5f5f5;
  color: var(--dark);
}

.btn-secondary:hover {
  background: #eee;
}

/* 消息设置弹窗样式 */
.modal-content-lg {
  max-width: 450px;
  max-height: 80vh;
  overflow-y: auto;
  /* 移动端适配 */
  width: 90vw;
  margin: auto;
}

@media (max-width: 768px) {
  .modal-content-lg {
    max-width: 90vw;
    max-height: 75vh;
    width: 90vw;
  }
}

.setting-group {
  margin-bottom: 1.5rem;
}

.setting-label {
  display: flex;
  align-items: center;
  font-size: 1rem;
  color: var(--dark);
  margin-bottom: 0.5rem;
}

.setting-label input[type="checkbox"] {
  margin-right: 0.5rem;
  width: 18px;
  height: 18px;
}

.delete-options {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.radio-option {
  display: flex;
  align-items: center;
  padding: 0.75rem;
  border: 1px solid #eee;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

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

.radio-option input {
  margin-right: 0.5rem;
}

.time-range-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid #eee;
  border-radius: 8px;
  flex-wrap: wrap;
}

.time-range-group input[type="radio"] {
  flex-shrink: 0;
}

.time-range-group input[type="number"] {
  width: 70px;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-align: center;
  flex-shrink: 0;
}

.time-range-group span {
  flex: 1;
  min-width: 80px;
}

@media (max-width: 480px) {
  .time-range-group {
    font-size: 0.9rem;
    padding: 0.6rem;
  }

  .time-range-group input[type="number"] {
    width: 60px;
    font-size: 0.9rem;
  }
}

.setting-info {
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 1rem;
}

.setting-info p {
  margin: 0;
  font-size: 0.85rem;
  color: #856404;
}

/* 响应式 - 移动端 */
@media (max-width: 767px) {
  .conversation-list-screen {
    display: flex;
  }

  .chat-screen {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 100;
    transform: translateX(100%);
    transition: transform 0.3s ease;
  }

  .chat-screen.active {
    display: flex;
    transform: translateX(0);
  }

  .back-btn {
    display: flex !important;
  }

  .members-grid {
    grid-template-columns: 1fr;
  }
}

/* 响应式 - 桌面端 */
@media (min-width: 768px) {
  .conversation-list-screen {
    width: 320px;
    border-right: 1px solid #eee;
    flex-shrink: 0;
  }

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

  .back-btn {
    display: none !important;
  }
}
