/* ================================================================
 *  DuskSocial — common.css
 *  公共样式、星空主题配色、样式重置
 *  晚霜工作室 (DuskFrost Studio)
 * ================================================================ */

/* ---------- CSS 变量 / 星空主题配色 ---------- */
:root {
  --bg-deep:      #06060e;
  --bg-mid:       #0c0c1a;
  --bg-card:      rgba(14, 14, 30, 0.75);
  --bg-input:     rgba(20, 18, 40, 0.6);
  --bg-hover:     rgba(30, 28, 55, 0.5);
  --text-primary: #e8e4f0;
  --text-secondary:#9a92b0;
  --text-muted:   #5e5773;
  --accent:       #c47a5a;          /* 暮色橙 */
  --accent-light: #d4936f;
  --accent-dark:  #a85d3e;
  --star:         #f0c86e;         /* 星光金 */
  --nebula:       #6b5ce7;         /* 星云紫 */
  --aurora:       #3dd6c8;         /* 极光青 */
  --rose:         #d47a9a;         /* 玫瑰粉 */
  --border:       rgba(200, 180, 220, 0.08);
  --border-light: rgba(200, 180, 220, 0.14);
  --glass:        rgba(20, 18, 40, 0.55);
  --glass-border: rgba(200, 180, 220, 0.12);
  --radius-sm:    8px;
  --radius-md:    12px;
  --radius-lg:    16px;
  --radius-full:  9999px;
  --shadow:       0 4px 20px rgba(0, 0, 0, 0.3);
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body:    'Outfit', -apple-system, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', 'Fira Code', monospace;
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
}

/* ---------- 样式重置 ---------- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

ul, ol { list-style: none; }

img {
  display: block;
  max-width: 100%;
}

button, input, textarea {
  font-family: var(--font-body);
  font-size: inherit;
  color: inherit;
  border: none;
  outline: none;
  background: none;
}

button { cursor: pointer; }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 4px; }

/* ---------- 通用工具类 ---------- */

/* Flex 布局 */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-1 { flex: 1; }
.flex-shrink-0 { flex-shrink: 0; }

/* 文字 */
.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent); }
.text-star { color: var(--star); }
.text-center { text-align: center; }
.text-ellipsis {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 字体 */
.font-display { font-family: var(--font-display); }

/* 间距 */
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.p-1 { padding: 0.5rem; }
.p-2 { padding: 1rem; }
.p-3 { padding: 1.5rem; }

/* ---------- 公共组件 ---------- */

/* 页面容器 */
.page {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg-deep);
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.page.active {
  opacity: 1;
  pointer-events: auto;
  z-index: 10;
}

/* 顶部导航栏 */
.nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 50px;
  padding: 0 16px;
  background: rgba(6, 6, 14, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.nav-bar .title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 500;
}

.nav-bar .back-btn {
  width: 32px; height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  color: var(--text-secondary);
  transition: background 0.2s;
}

.nav-bar .back-btn:active {
  background: var(--bg-hover);
}

/* 内容滚动区 */
.page-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* 底部导航栏 */
.tab-bar {
  display: flex;
  align-items: center;
  height: 54px;
  padding-bottom: var(--safe-bottom);
  background: rgba(6, 6, 14, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 100%;
  color: var(--text-muted);
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  transition: color 0.2s;
  position: relative;
}

.tab-item.active { color: var(--accent); }

.tab-item .tab-icon {
  width: 22px; height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
}

/* SVG 图标在 tab-icon 中自动着色 */
.tab-item .tab-icon svg {
  color: inherit;
}

.tab-item .badge {
  position: absolute;
  top: 4px; right: calc(50% - 18px);
  min-width: 14px; height: 14px;
  border-radius: var(--radius-full);
  background: var(--rose);
  font-size: 0.55rem;
  font-weight: 600;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* 输入框 */
.input-group {
  margin-bottom: 14px;
}

.input-group label {
  display: block;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.06em;
}

.input-field {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--glass-border);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: border-color 0.25s, box-shadow 0.25s;
}

.input-field:focus {
  border-color: rgba(196, 122, 90, 0.4);
  box-shadow: 0 0 0 3px rgba(196, 122, 90, 0.06);
}

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

/* 错误提示 */
.error-tip {
  font-size: 0.72rem;
  color: var(--rose);
  margin-top: 4px;
  display: none;
}

.error-tip.show { display: block; }

/* 主按钮 */
.btn-primary {
  width: 100%;
  height: 46px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  font-size: 0.92rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  box-shadow: 0 4px 16px rgba(196, 122, 90, 0.2);
  transition: opacity 0.2s, transform 0.2s;
}

.btn-primary:active {
  opacity: 0.85;
  transform: scale(0.98);
}

.btn-primary:disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* 次按钮 */
.btn-ghost {
  height: 38px;
  padding: 0 16px;
  border-radius: var(--radius-sm);
  background: var(--glass);
  border: 1px solid var(--glass-border);
  color: var(--text-secondary);
  font-size: 0.82rem;
  transition: background 0.2s;
}

.btn-ghost:active { background: var(--bg-hover); }

/* 头像 */
.avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--nebula));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
  color: #fff;
}

.avatar-lg {
  width: 72px; height: 72px;
  font-size: 1.8rem;
}

/* Toast 提示 */
.toast {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  background: rgba(20, 18, 40, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-light);
  color: var(--text-primary);
  font-size: 0.82rem;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 加载状态 */
.loading-mask {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(6, 6, 14, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.loading-mask.show {
  opacity: 1;
  pointer-events: auto;
}

.spinner {
  width: 32px; height: 32px;
  border: 2px solid var(--border-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.empty-state .empty-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.4;
  display: flex;
  align-items: center;
  justify-content: center;
}

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

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

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

.list-item .item-title {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 2px;
}

.list-item .item-desc {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.list-item .item-right {
  flex-shrink: 0;
  text-align: right;
}

.list-item .item-time {
  font-size: 0.68rem;
  color: var(--text-muted);
}

/* 分隔线 */
.divider {
  height: 1px;
  background: var(--border);
  margin: 0 16px;
}

/* ---------- 开关组件（设置页面用） ---------- */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  transition: background 0.3s, border-color 0.3s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: transform 0.3s, background 0.3s;
}

.toggle-switch input:checked + .toggle-slider {
  background: rgba(196, 122, 90, 0.3);
  border-color: rgba(196, 122, 90, 0.5);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: var(--accent);
}
