/* 自定义样式补充 */
/* 全局：隐藏数字输入框上下箭头 */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield;
  appearance: textfield;
}

:root {
  --primary: #4a7c28;
  --primary-hover: #3d6b21;
  --primary-light: #e8f5e9;
  --color-primary-light: #4a7c28;
  --color-primary-lighter: #6ba33e;
  --accent: #e67e22;
  --accent-hover: #d35400;
  --danger: #e74c3c;
  --text: #2d3436;
  --text-light: #636e72;
  --bg: #f8faf5;
  --white: #ffffff;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --shadow-hover: 0 6px 24px rgba(0,0,0,0.12);
  --radius: 12px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1;
}

/* 链接 */
a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-hover);
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(74, 124, 40, 0.3);
}

.btn-accent {
  background: var(--accent);
  color: white;
}

.btn-accent:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--primary);
  color: var(--primary);
}

.btn-outline:hover {
  background: var(--primary);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-sm {
  padding: 6px 14px;
  font-size: 12px;
}

.btn-lg {
  padding: 14px 32px;
  font-size: 16px;
}

/* 卡片 */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: all 0.3s;
}

.card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

/* 输入框 */
.input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid #e0e0e0;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
  outline: none;
  background: white;
}

.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(74, 124, 40, 0.1);
}

/* 隐藏数字输入框的上下箭头，防止滚轮误触 */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

/* 标签 */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.tag-green {
  background: var(--primary-light);
  color: var(--primary);
}

.tag-orange {
  background: #fef3e2;
  color: var(--accent);
}

.tag-red {
  background: #fde8e8;
  color: var(--danger);
}

.tag-gray {
  background: #f0f0f0;
  color: #888;
}

.tag-amber {
  background: #fef3c7;
  color: #d97706;
}

/* 倒计时高亮 */
.countdown-urgent {
  color: var(--danger) !important;
  animation: pulse 1s infinite;
}

/* 大号倒计时 */
.countdown-large {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--danger);
  animation: pulse 1s infinite;
  text-shadow: 0 0 8px rgba(239, 68, 68, 0.3);
}

.countdown-large-expire {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--danger);
}

.countdown-bar {
  height: 4px;
  border-radius: 2px;
  background: #e5e7eb;
  overflow: hidden;
  margin-top: 8px;
}

.countdown-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--danger), #f59e0b);
  transition: width 1s linear;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* 容器 */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}

/* 栅格 */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-light);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* 响应式调整 */
@media (max-width: 640px) {
  .container {
    padding: 0 12px;
  }
  
  .grid-2, .grid-3 {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
}

/* 加载动画 */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #e0e0e0;
  border-top: 2px solid var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== 移动端底部导航 ========== */
.mobile-bottom-nav {
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: #fff;
  border-top: 1px solid #eee;
  box-shadow: 0 -2px 12px rgba(0,0,0,0.08);
  z-index: 999;
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.mobile-bottom-nav .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  height: 100%;
  text-decoration: none;
  color: #999;
  transition: color 0.2s;
  position: relative;
  padding-top: 6px;
}

.mobile-bottom-nav .nav-item .nav-icon {
  font-size: 20px;
  transition: transform 0.2s;
}

.mobile-bottom-nav .nav-item .nav-label {
  font-size: 10px;
  font-weight: 500;
}

.mobile-bottom-nav .nav-item.active {
  color: var(--primary);
}

.mobile-bottom-nav .nav-item.active .nav-icon {
  transform: scale(1.1);
}

/* 中间发布按钮 */
.mobile-bottom-nav .nav-publish {
  margin-top: -10px;
}

.mobile-bottom-nav .publish-btn-wrap {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(74, 124, 40, 0.35);
  transition: transform 0.2s, box-shadow 0.2s;
}

.mobile-bottom-nav .publish-btn-wrap:active {
  transform: scale(0.92);
}

.mobile-bottom-nav .publish-icon {
  font-size: 24px;
  color: #fff;
}

/* 内容区域底部留空 */
main {
  padding-bottom: 72px;
}

/* 未读红点消息导航徽标 */
.unread-badge {
  position: absolute;
  top: 2px;
  right: 50%;
  margin-right: -18px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  background: #e74c3c;
  color: #fff;
  border-radius: 8px;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
  font-weight: 600;
  z-index: 10;
  box-shadow: 0 2px 4px rgba(231,76,60,0.3);
}

/* 消息-会话列表 */
.conversation-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.conversation-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  text-decoration: none;
  border-bottom: 1px solid #f5f5f5;
  transition: background 0.2s;
}

.conversation-item:last-child {
  border-bottom: none;
}

.conversation-item:hover {
  background: #f8faf5;
}

.conversation-item.unread {
  background: #f0f7ec;
}

.conv-avatar {
  position: relative;
  flex-shrink: 0;
}

.avatar-circle {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
}

.unread-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  background: #e74c3c;
  color: #fff;
  border-radius: 10px;
  font-size: 11px;
  line-height: 20px;
  text-align: center;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(231,76,60,0.3);
}

.conv-content {
  flex: 1;
  min-width: 0;
}

.conv-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.conv-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.conv-time {
  font-size: 11px;
  color: #999;
}

.conv-preview {
  font-size: 13px;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item.unread .conv-preview {
  color: var(--text);
  font-weight: 500;
}

/* 聊天详情 */
.message-detail-page {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 64px - 72px);
  padding-bottom: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: #fff;
  border-bottom: 1px solid #eee;
  position: sticky;
  top: 0;
  z-index: 10;
}

.btn-back {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: var(--text);
  text-decoration: none;
  transition: background 0.2s;
}

.btn-back:hover {
  background: #f5f5f5;
}

.chat-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
}

.chat-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.chat-header-spacer {
  width: 36px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8f9fa;
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #ccc;
}

.msg {
  display: flex;
  max-width: 85%;
  gap: 8px;
}

.msg-other {
  align-self: flex-start;
  align-items: flex-start;
}

.msg-self {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.msg-self .msg-bubble {
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-other .msg-bubble {
  background: #fff;
  color: var(--text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.msg-time {
  font-size: 10px;
  color: #aaa;
  margin-top: 3px;
  padding: 0 4px;
}

.chat-input-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid #eee;
  position: sticky;
  bottom: 0;
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid #e0e0e0;
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  background: #f5f5f5;
}

.chat-input:focus {
  border-color: var(--primary);
  background: #fff;
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--primary), var(--primary-hover));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chat-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(74,124,40,0.3);
}

.chat-send-btn:active {
  transform: scale(0.95);
}

.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

@media (min-width: 768px) {
  .message-detail-page {
    height: calc(100vh - 64px);
  }
  
  .chat-messages {
    padding: 24px 20%;
  }
  
  .msg {
    max-width: 60%;
  }
}
@media (min-width: 768px) {
  main {
    padding-bottom: 0;
  }
}
