/* 全局样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #5B9BD5;
  --primary-light: #7FB3E0;
  --primary-dark: #4A8BC4;
  --bg-color: #FFFFFF;
  --bg-secondary: #F8F9FA;
  --text-primary: #333333;
  --text-secondary: #666666;
  --text-light: #999999;
  --border-color: #E8E8E8;
  --success-color: #52C41A;
  --danger-color: #FF4D4F;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
}

/* 登录/注册页面 */
.auth-page {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary-light) 0%, var(--bg-color) 100%);
}

.auth-container {
  background: var(--bg-color);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

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

.auth-header h1 {
  color: var(--primary-color);
  font-size: 28px;
  margin-bottom: 8px;
}

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

.auth-tabs {
  display: flex;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-color);
}

.tab-btn {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  font-size: 16px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.3s;
}

.tab-btn.active {
  color: var(--primary-color);
  border-bottom: 2px solid var(--primary-color);
}

.auth-form {
  display: none;
}

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

.form-group {
  margin-bottom: 16px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.3s;
}

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

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.3s;
}

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

.btn-secondary {
  width: 100%;
  padding: 12px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.3s;
}

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

.btn-small {
  padding: 6px 12px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}

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

.auth-message {
  margin-top: 16px;
  padding: 12px;
  border-radius: 8px;
  text-align: center;
  font-size: 14px;
  display: none;
}

.auth-message.show {
  display: block;
}

.auth-message.success {
  background: #F6FFED;
  color: var(--success-color);
  border: 1px solid #B7EB8F;
}

.auth-message.error {
  background: #FFF2F0;
  color: var(--danger-color);
  border: 1px solid #FFCCC7;
}

/* 主应用容器 */
.app-container {
  max-width: 480px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-color);
}

/* 顶部导航 */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--bg-color);
  border-bottom: 1px solid var(--border-color);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.user-nickname {
  font-size: 16px;
  font-weight: 500;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  font-size: 20px;
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.3s;
}

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

/* 主内容区 */
.app-content {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.content-panel {
  display: none;
  height: 100%;
  flex-direction: column;
}

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

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

.panel-header h2 {
  font-size: 18px;
  font-weight: 500;
}

.panel-section {
  padding: 16px;
  border-top: 1px solid var(--border-color);
}

.panel-section h3 {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  background: var(--danger-color);
  color: white;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 10px;
}

.list-container {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-light);
}

/* 列表项 */
.list-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.3s;
}

.list-item:hover {
  background: var(--bg-secondary);
}

.list-item-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 12px;
}

.list-item-content {
  flex: 1;
  min-width: 0;
}

.list-item-title {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.list-item-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

/* 聊天窗口 */
.message-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg-secondary);
}

.message-item {
  display: flex;
  margin-bottom: 16px;
}

.message-item.sent {
  flex-direction: row-reverse;
}

.message-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
}

.message-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 12px;
  margin: 0 8px;
  word-wrap: break-word;
}

.message-item.received .message-bubble {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
}

.message-item.sent .message-bubble {
  background: var(--primary-light);
  color: white;
}

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

.message-input {
  display: flex;
  padding: 12px;
  background: var(--bg-color);
  border-top: 1px solid var(--border-color);
  gap: 8px;
}

.message-input input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 14px;
}

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

.message-input button {
  padding: 10px 20px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 20px;
  cursor: pointer;
}

.btn-back {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
}

/* 朋友圈 */
.moment-item {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

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

.moment-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 12px;
}

.moment-user {
  flex: 1;
}

.moment-nickname {
  font-size: 15px;
  font-weight: 500;
}

.moment-time {
  font-size: 12px;
  color: var(--text-light);
}

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

.moment-images {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  margin-bottom: 12px;
}

.moment-images img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 4px;
}

.moment-actions {
  display: flex;
  gap: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.moment-action {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
}

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

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

.moment-likes {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 8px;
}

.moment-comments {
  margin-top: 8px;
  padding: 8px;
  background: var(--bg-secondary);
  border-radius: 4px;
}

.moment-comment {
  font-size: 13px;
  margin-bottom: 4px;
}

.moment-comment .nickname {
  color: var(--primary-color);
  font-weight: 500;
}

/* 底部导航 */
.app-nav {
  display: flex;
  background: var(--bg-color);
  border-top: 1px solid var(--border-color);
  padding: 8px 0;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px;
  background: none;
  border: none;
  cursor: pointer;
  transition: color 0.3s;
}

.nav-icon {
  font-size: 24px;
  margin-bottom: 4px;
}

.nav-text {
  font-size: 12px;
}

.nav-btn.active {
  color: var(--primary-color);
}

.nav-btn:not(.active) {
  color: var(--text-secondary);
}

/* 弹窗 */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  justify-content: center;
  align-items: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: var(--bg-color);
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  max-height: 80vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

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

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

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--text-secondary);
}

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

.modal-body input,
.modal-body textarea {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
  resize: vertical;
}

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

/* 搜索结果 */
.search-results {
  margin-top: 16px;
}

.search-result-item {
  display: flex;
  align-items: center;
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-info {
  flex: 1;
  margin: 0 12px;
}

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

.search-result-username {
  font-size: 12px;
  color: var(--text-light);
}

/* 视频通话 */
.video-modal .modal-content {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  border-radius: 0;
}

.video-container {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000;
}

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

#localVideo {
  position: absolute;
  bottom: 100px;
  right: 20px;
  width: 120px;
  height: 160px;
  border-radius: 8px;
  border: 2px solid white;
}

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

.control-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 24px;
  cursor: pointer;
  transition: background 0.3s;
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.3);
}

.control-btn.end-call {
  background: var(--danger-color);
}

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

/* 来电弹窗 */
.call-actions {
  display: flex;
  gap: 12px;
  margin-top: 20px;
}

.call-actions button {
  flex: 1;
}

/* 响应式 */
@media (max-width: 480px) {
  .app-container {
    max-width: 100%;
  }
}
