/* ===========================
   铃铛按钮 — 顶部导航
=========================== */
.btn-bell {
  position: relative;
  background: rgba(255,255,255,0.08);
  border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: 50%;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-main);
  font-size: var(--icon-lg);
  cursor: pointer;
  transition: all 0.25s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 3px 12px rgba(0,0,0,0.3);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.btn-bell:active { transform: scale(0.88); }
.btn-bell i { transition: transform 0.3s cubic-bezier(.4,0,.2,1); }
.btn-bell:active i { transform: rotate(-20deg) scale(0.9); }

/* 未读角标 */
.bell-badge {
  position: absolute;
  top: -3px; right: -3px;
  min-width: 16px; height: 16px;
  background: var(--accent-red);
  color: #fff;
  font-size: 9px; font-weight: 800;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  border: 1.5px solid #0B1426;
  line-height: 1;
  animation: badgePop 0.4s cubic-bezier(.34,1.56,.64,1);
  box-shadow: 0 2px 6px rgba(255,107,107,0.5);
}
@keyframes badgePop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* 铃铛摇动动画（有新消息时触发） */
.btn-bell.has-new i {
  animation: bellShake 0.7s cubic-bezier(.36,.07,.19,.97) both;
}
@keyframes bellShake {
  10%, 90% { transform: rotate(-4deg); }
  20%, 80% { transform: rotate(6deg); }
  30%, 70% { transform: rotate(-5deg); }
  40%, 60% { transform: rotate(4deg); }
  50%       { transform: rotate(-3deg); }
}

/* ===========================
   消息中心全屏页面
=========================== */
#pageMessages {
  position: fixed;
  top: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  height: 100%;
  z-index: var(--z-detail-page);
  background: var(--bg-page);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  /* 滑入动画：从右侧移入视口 */
  animation: msgPageIn 0.35s cubic-bezier(.22,.68,0,1) forwards;
}
@keyframes msgPageIn {
  from { transform: translateX(50vw); }
  to   { transform: translateX(-50%); }
}
#pageMessages.closing {
  animation: msgPageOut 0.3s cubic-bezier(.4,0,1,1) forwards;
}
@keyframes msgPageOut {
  from { transform: translateX(-50%); }
  to   { transform: translateX(50vw); }
}

/* 消息页头部 — 固定顶部 */
.msg-header {
  position: sticky;
  top: 0;
  width: 100%;
  z-index: 10;
  background: rgba(11,20,38,0.95);
  backdrop-filter: saturate(180%) blur(24px);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  box-sizing: border-box;
  flex-shrink: 0;
}
.msg-back-btn {
  background: rgba(255,255,255,0.07);
  border: 1.5px solid rgba(255,255,255,0.10);
  border-radius: 50%;
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-main);
  font-size: var(--icon-lg);
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.msg-back-btn:active { transform: scale(0.88); background: rgba(255,255,255,0.12); }

.msg-header-center {
  display: flex; align-items: center; gap: 7px;
  flex: 1; justify-content: center;
}
.msg-header-icon {
  font-size: var(--icon-lg);
  color: var(--primary);
  filter: drop-shadow(0 0 6px rgba(0,230,138,0.4));
}
.msg-header-title {
  font-size: var(--fs-lg);
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.2px;
}

.msg-mark-all-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  padding: 6px 4px 6px 10px;
  opacity: 0.85;
  transition: opacity 0.2s;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.msg-mark-all-btn:active { opacity: 0.5; }

/* ===========================
   消息 Tab 切换
=========================== */
.msg-tabs {
  display: flex;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 0 16px;
  gap: 0;
  flex-shrink: 0;
}
.msg-tab {
  flex: 1;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 13px 0 11px;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  position: relative;
  transition: color 0.25s;
  -webkit-tap-highlight-color: transparent;
}
.msg-tab i { font-size: var(--icon-sm); }
.msg-tab.active {
  color: var(--primary);
  font-weight: 700;
}
.msg-tab.active::after {
  content: '';
  position: absolute; bottom: 0; left: 20%; right: 20%;
  height: 2.5px;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
  box-shadow: 0 0 6px rgba(0,230,138,0.4);
  animation: tabLineIn 0.25s cubic-bezier(.22,.68,0,1);
}
@keyframes tabLineIn {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

/* Tab 未读角标 */
.msg-tab-badge {
  min-width: 16px; height: 16px;
  background: var(--accent-red);
  color: #fff;
  font-size: 9px; font-weight: 800;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
  line-height: 1;
}

/* ===========================
   消息卡片
=========================== */
.msg-list-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 16px 24px;
  min-height: 0;
}

/* 消息卡片 */
.msg-card {
  display: flex; gap: 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: var(--radius-lg);
  padding: 14px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: background 0.2s, transform 0.18s;
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  animation: msgCardIn 0.3s cubic-bezier(.22,.68,0,1) both;
}
.msg-card:active { transform: scale(0.985); background: rgba(255,255,255,0.08); }

/* 未读状态卡片左侧绿色边线 */
.msg-card.unread {
  border-left: 3px solid var(--primary);
  background: rgba(0,230,138,0.04);
}
.msg-card.unread::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, rgba(0,230,138,0.3), transparent);
}

/* 卡片进场动画 */
@keyframes msgCardIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 消息图标区 */
.msg-card-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--icon-lg);
  flex-shrink: 0;
  position: relative;
}
.msg-card-icon.notice-icon {
  background: linear-gradient(135deg, rgba(255,209,102,0.15), rgba(255,165,0,0.08));
  color: var(--gold);
  border: 1px solid rgba(255,209,102,0.2);
}
.msg-card-icon.system-icon {
  background: linear-gradient(135deg, rgba(124,58,237,0.15), rgba(167,139,250,0.08));
  color: #A78BFA;
  border: 1px solid rgba(124,58,237,0.2);
}
.msg-card-icon.reward-icon {
  background: linear-gradient(135deg, rgba(0,230,138,0.15), rgba(0,180,110,0.08));
  color: var(--primary);
  border: 1px solid rgba(0,230,138,0.2);
}
.msg-card-icon.alert-icon {
  background: linear-gradient(135deg, rgba(255,107,107,0.15), rgba(239,68,68,0.08));
  color: var(--accent-red);
  border: 1px solid rgba(255,107,107,0.2);
}

/* 未读红点 — 图标右上角 */
.msg-card-icon .unread-dot {
  position: absolute; top: -3px; right: -3px;
  width: 9px; height: 9px;
  background: var(--accent-red);
  border-radius: 50%;
  border: 1.5px solid var(--bg-page);
  box-shadow: 0 0 6px rgba(255,107,107,0.6);
  animation: dotPulse 2s ease-in-out infinite;
}
@keyframes dotPulse {
  0%,100% { box-shadow: 0 0 6px rgba(255,107,107,0.6); }
  50%      { box-shadow: 0 0 10px rgba(255,107,107,0.9); }
}

/* 消息内容区 */
.msg-card-body {
  flex: 1; min-width: 0;
}
.msg-card-top {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
  margin-bottom: 5px;
}
.msg-card-title {
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.3;
  flex: 1; min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-card.unread .msg-card-title {
  color: #fff;
}

/* 消息时间 */
.msg-card-time {
  font-size: var(--fs-xs);
  color: var(--text-light);
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 1px;
}

/* 消息摘要 */
.msg-card-summary {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.msg-card.unread .msg-card-summary {
  color: var(--text-sub);
}

/* 未读标签 */
.msg-unread-tag {
  display: inline-flex; align-items: center;
  background: rgba(0,230,138,0.12);
  color: var(--primary);
  font-size: 9px; font-weight: 800;
  border-radius: 4px;
  padding: 1px 6px;
  margin-top: 6px;
  border: 1px solid rgba(0,230,138,0.2);
  letter-spacing: 0.5px;
}

/* ===========================
   空消息状态
=========================== */
.msg-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px;
  gap: 14px;
  color: var(--text-light);
}
.msg-empty-icon {
  font-size: 48px;
  opacity: 0.25;
  animation: emptyFloat 3s ease-in-out infinite;
}
@keyframes emptyFloat {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-8px); }
}
.msg-empty-text {
  font-size: var(--fs-md);
  color: var(--text-light);
  font-weight: 600;
}
.msg-empty-sub {
  font-size: var(--fs-sm);
  color: var(--text-light);
  opacity: 0.6;
  text-align: center;
}

/* ===========================
   消息详情弹窗
=========================== */
.msg-detail-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: calc(var(--z-detail-page) + 10);
  display: flex; align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.msg-detail-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.msg-detail-panel {
  background: #131d30;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%; max-width: 480px;
  margin: 0 auto;
  padding: 0 0 env(safe-area-inset-bottom, 16px);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(.22,.68,0,1);
  border-top: 1px solid rgba(255,255,255,0.08);
  max-height: 80vh;
  overflow-y: auto;
}
.msg-detail-overlay.open .msg-detail-panel {
  transform: translateY(0);
}
.msg-detail-handle {
  width: 36px; height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  margin: 14px auto 0;
}
.msg-detail-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.msg-detail-icon {
  width: 38px; height: 38px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--icon-lg);
  flex-shrink: 0;
}
.msg-detail-title {
  font-size: var(--fs-lg);
  font-weight: 800;
  color: var(--text-main);
  flex: 1; min-width: 0;
}
.msg-detail-close {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 50%;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: var(--icon-sm);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}
.msg-detail-close:active { transform: scale(0.88); }
.msg-detail-meta {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.msg-detail-time {
  font-size: var(--fs-xs);
  color: var(--text-light);
  display: flex; align-items: center; gap: 4px;
}
.msg-detail-time i { font-size: var(--icon-xs); }
.msg-detail-body {
  padding: 16px 18px 24px;
  font-size: var(--fs-md);
  color: var(--text-sub);
  line-height: 1.7;
}

/* ===========================
   我的页面 — 消息未读数角标
=========================== */
.profile-menu-unread {
  background: var(--accent-red);
  color: #fff;
  font-size: var(--fs-xs);
  font-weight: 800;
  min-width: 18px; height: 18px;
  border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 5px;
  margin-right: 4px;
  box-shadow: 0 2px 6px rgba(255,107,107,0.4);
}

/* ===========================
   消息分页 — 固定底部
=========================== */
.msg-pagination {
  flex-shrink: 0;
  width: 100%;
  background: rgba(11,20,38,0.96);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid rgba(255,255,255,0.06);
  padding: 8px 12px calc(env(safe-area-inset-bottom, 0px) + 8px);
  display: none; /* 默认隐藏，超过10条才显示 */
  box-sizing: border-box;
}
.msg-pagination.visible {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.msg-pg-btn {
  min-width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  padding: 0 6px;
}
.msg-pg-btn:active { transform: scale(0.93); background: rgba(255,255,255,0.10); }
.msg-pg-btn.disabled { opacity: 0.3; pointer-events: none; }
.msg-pg-btn.active {
  background: var(--primary);
  color: #0B1426;
  border-color: var(--primary);
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0,230,138,0.3);
}
.msg-pg-info {
  font-size: var(--fs-xs);
  color: var(--text-light);
  margin: 0 4px;
}
