/* ============================================
   光宗耀祖族谱系统 - 全局样式
   主题色：深红 #8B0000 / 金色 #FFD700
   ============================================ */

:root {
  --primary: #8B0000;
  --primary-dark: #6b0000;
  --primary-light: #a52a2a;
  --gold: #FFD700;
  --gold-dark: #c9a800;
  --bg: #f5f1e8;
  --bg-card: #ffffff;
  --text: #2c2419;
  --text-muted: #8a7f6d;
  --border: #e0d8c8;
  --shadow: 0 2px 12px rgba(139, 0, 0, 0.08);
  --shadow-lg: 0 8px 30px rgba(139, 0, 0, 0.15);
  --radius: 10px;
  --radius-sm: 6px;
  --header-h: 60px;
  --success: #2e7d32;
  --danger: #c62828;
  --info: #1565c0;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.hidden { display: none !important; }

/* ===== 启动屏 ===== */
.splash {
  position: fixed; inset: 0; z-index: 9999;
  background: linear-gradient(135deg, #8B0000 0%, #5c0000 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--gold);
  animation: splashIn 0.4s ease;
}
.splash.fade-out { opacity: 0; transition: opacity 0.5s; pointer-events: none; }
.splash-logo { animation: pulse 2s infinite; }
.splash-title { font-size: 1.4rem; margin-top: 1rem; font-family: STKaiti, KaiTi, serif; letter-spacing: 2px; }
.splash-loading { margin-top: 0.8rem; font-size: 0.9rem; opacity: 0.85; }
.dots span { animation: blink 1.4s infinite; }
.dots span:nth-child(2) { animation-delay: 0.2s; }
.dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; } 40% { opacity: 1; } }
@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes splashIn { from { opacity: 0; } to { opacity: 1; } }

/* ===== 顶部导航 ===== */
.app-header {
  position: sticky; top: 0; z-index: 100;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  box-shadow: var(--shadow-lg);
  height: var(--header-h);
}
.header-inner {
  max-width: 1280px; margin: 0 auto; height: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 1rem; gap: 1rem;
}
.brand { display: flex; align-items: center; gap: 0.6rem; min-width: 0; }
.brand-logo { flex-shrink: 0; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3)); }
.brand-text { display: flex; align-items: baseline; gap: 0.4rem; min-width: 0; }
.brand-text h1 {
  font-size: 1.15rem; font-weight: 600; white-space: nowrap;
  font-family: STKaiti, KaiTi, serif;
  color: var(--gold);
  text-shadow: 0 1px 3px rgba(0,0,0,0.4);
}
.brand-text .divider { color: rgba(255,255,255,0.5); margin: 0 0.2rem; }
.brand-sub { font-size: 0.8rem; color: rgba(255,255,255,0.75); white-space: nowrap; }

.main-nav { display: flex; align-items: center; gap: 0.2rem; }
.nav-link {
  display: flex; align-items: center; gap: 0.35rem;
  padding: 0.45rem 0.85rem; border-radius: var(--radius-sm);
  color: rgba(255,255,255,0.85); text-decoration: none;
  font-size: 0.95rem; transition: all 0.2s;
  white-space: nowrap;
}
.nav-link:hover { background: rgba(255,255,255,0.12); color: #fff; }
.nav-link.active { background: rgba(255,215,0,0.2); color: var(--gold); }
.nav-link .ico { font-style: normal; font-size: 1.05rem; }

.nav-user { display: flex; align-items: center; gap: 0.6rem; margin-left: 0.8rem; padding-left: 0.8rem; border-left: 1px solid rgba(255,255,255,0.2); }
.user-name { font-size: 0.9rem; color: var(--gold); max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.nav-toggle {
  display: none; background: none; border: none; color: #fff;
  font-size: 1.5rem; cursor: pointer; padding: 0.3rem 0.6rem;
}

/* ===== 主内容 ===== */
.app-main {
  flex: 1; max-width: 1280px; width: 100%; margin: 0 auto;
  padding: 1.2rem 1rem 2rem;
}
.page { display: none; animation: fadeIn 0.3s ease; }
.page.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ===== 卡片 ===== */
.card {
  background: var(--bg-card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.2rem; margin-bottom: 1rem;
  border: 1px solid var(--border);
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 0.8rem; padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 1.05rem; color: var(--primary); }
.link-more { color: var(--primary); text-decoration: none; font-size: 0.85rem; }
.link-more:hover { text-decoration: underline; }

/* ===== 表单 ===== */
.input, .form-control {
  width: 100%; padding: 0.6rem 0.85rem;
  border: 1.5px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.95rem; font-family: inherit;
  background: #fff; color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.input:focus, .form-control:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 0, 0, 0.1);
}
.input-sm { width: auto; padding: 0.45rem 0.7rem; }
textarea.input, textarea.form-control { resize: vertical; min-height: 100px; }
select.input { cursor: pointer; }

.form-group { margin-bottom: 0.9rem; }
.form-group label { display: block; font-size: 0.88rem; margin-bottom: 0.35rem; color: var(--text-muted); font-weight: 500; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.35rem;
  padding: 0.55rem 1.1rem; border: none; border-radius: var(--radius-sm);
  font-size: 0.92rem; font-family: inherit; cursor: pointer;
  transition: all 0.2s; text-decoration: none; white-space: nowrap;
  font-weight: 500;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; box-shadow: 0 2px 8px rgba(139,0,0,0.3); }
.btn-primary:hover { box-shadow: 0 4px 14px rgba(139,0,0,0.4); filter: brightness(1.1); }
.btn-ghost { background: transparent; border: 1px solid currentColor; }
.btn-ghost:hover { background: rgba(255,255,255,0.15); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 0.35rem 0.7rem; font-size: 0.83rem; }
.btn-block { width: 100%; padding: 0.75rem; font-size: 1rem; }
.btn[disabled] { opacity: 0.6; cursor: not-allowed; }

/* ===== 工具栏 ===== */
.toolbar { padding: 0.8rem 1.2rem; }
.toolbar-row { display: flex; gap: 0.7rem; align-items: center; flex-wrap: wrap; }
.toolbar-row .input[type="search"] { flex: 1; min-width: 200px; max-width: none; }
@keyframes loc-pulse { 0% { transform: scale(1); opacity: 0.4; } 100% { transform: scale(3.2); opacity: 0; } }
.search-result-item:hover { background: var(--bg-hover, #f5f5f5); }

/* ===== 选项卡 ===== */
.tabs { display: flex; gap: 0.3rem; flex-wrap: wrap; padding: 0.5rem; }
.tab {
  padding: 0.5rem 1rem; border: none; background: transparent;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 0.92rem;
  font-family: inherit; color: var(--text-muted);
  transition: all 0.2s; font-weight: 500;
}
.tab:hover { background: rgba(139,0,0,0.06); color: var(--primary); }
.tab.active { background: var(--primary); color: #fff; }

/* ===== 首页 ===== */
.dashboard-hero { text-align: center; padding: 2.2rem 1.5rem; background: linear-gradient(135deg, #fff 0%, #faf6ee 100%); }
.dashboard-hero h2 { font-family: STKaiti, KaiTi, serif; color: var(--primary); font-size: 1.7rem; margin-bottom: 0.4rem; }
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 0.9rem; margin-top: 1.5rem;
}
.stat-item { text-align: center; padding: 1rem 0.5rem; background: var(--bg); border-radius: var(--radius-sm); }
.stat-num { font-size: 1.7rem; font-weight: 700; color: var(--primary); font-family: Georgia, serif; }
.stat-label { font-size: 0.83rem; color: var(--text-muted); margin-top: 0.2rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.list-simple { display: flex; flex-direction: column; }
.list-simple .list-item {
  padding: 0.7rem 0.3rem; border-bottom: 1px dashed var(--border);
  cursor: pointer; transition: background 0.2s;
}
.list-simple .list-item:last-child { border-bottom: none; }
.list-simple .list-item:hover { background: rgba(139,0,0,0.04); }
.list-item .item-title { font-weight: 500; font-size: 0.95rem; display: flex; align-items: center; gap: 0.4rem; }
.list-item .item-meta { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.2rem; }
.empty-hint { text-align: center; color: var(--text-muted); padding: 1.5rem 0; font-size: 0.9rem; }

.badge {
  display: inline-block; padding: 0.1rem 0.5rem; border-radius: 20px;
  font-size: 0.72rem; font-weight: 600;
}
.badge-notice { background: #fff3e0; color: #e65100; }
.badge-news { background: #e3f2fd; color: #1565c0; }
.badge-history { background: #f3e5f5; color: #6a1b9a; }
.badge-pinned { background: #ffebee; color: var(--primary); }

/* ===== 族谱 ===== */
.tree-card { padding: 0; overflow: hidden; min-height: 500px; position: relative; }
.tree-chart { width: 100%; height: 600px; }
.tree-list { max-height: 600px; overflow-y: auto; padding: 1rem; }
.tree-list table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tree-list th, .tree-list td { padding: 0.6rem 0.5rem; text-align: left; border-bottom: 1px solid var(--border); }
.tree-list th { background: var(--bg); color: var(--primary); font-weight: 600; position: sticky; top: 0; }
.tree-list tr:hover td { background: rgba(139,0,0,0.03); }
.empty-state { text-align: center; padding: 4rem 1rem; color: var(--text-muted); }
.empty-icon { font-size: 3.5rem; margin-bottom: 1rem; }

/* 头像 */
.avatar-picker { display: flex; align-items: center; gap: 1rem; }
.avatar-preview {
  width: 72px; height: 72px; border-radius: 50%;
  background: var(--bg); border: 2px dashed var(--border);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0; font-size: 2rem;
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 0.35rem; }
.row-avatar {
  width: 30px; height: 30px; border-radius: 50%; object-fit: cover;
  vertical-align: middle; margin-right: 0.45rem;
  border: 1.5px solid var(--border); display: inline-flex;
  align-items: center; justify-content: center; font-size: 1rem; background: var(--bg);
}

/* ===== 地图 ===== */
.map-card { padding: 0; overflow: hidden; }
#map-container { width: 100%; height: 560px; border-radius: var(--radius); }

/* 地图下方标注详细列表 */
.marker-list-item {
  display: flex; gap: 0.7rem; align-items: flex-start;
  padding: 0.8rem 0.2rem; cursor: pointer;
}
.marker-type-tag {
  flex-shrink: 0; margin-top: 0.12rem;
  font-size: 0.75rem; line-height: 1.6; padding: 0 0.55rem;
  border-radius: 10px; color: #fff; white-space: nowrap;
}
.mk-tomb { background: #8B0000; }
.mk-home { background: #1565c0; }
.mk-place { background: #2e7d32; }
.mk-other { background: #6a1b9a; }
.marker-item-body { flex: 1; min-width: 0; }
.marker-item-title { font-weight: 600; font-size: 0.95rem; color: var(--text); }
.marker-item-note {
  font-size: 0.82rem; color: var(--text-muted);
  margin-top: 0.2rem; white-space: pre-wrap; word-break: break-word;
}
.marker-item-coord { font-size: 0.76rem; color: #999; margin-top: 0.25rem; }
.marker-item-actions { flex-shrink: 0; display: flex; gap: 0.4rem; }

/* ===== 动态列表 ===== */
.posts-list { display: flex; flex-direction: column; gap: 0.8rem; }
.post-item {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 1.1rem 1.3rem; box-shadow: var(--shadow);
  border: 1px solid var(--border); border-left: 4px solid var(--primary);
  cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
}
.post-item:hover { transform: translateX(4px); box-shadow: var(--shadow-lg); }
.post-item .post-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.8rem; }
.post-item h3 { font-size: 1.05rem; color: var(--text); }
.post-item .post-excerpt { color: var(--text-muted); font-size: 0.88rem; margin-top: 0.4rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.post-item .post-meta { display: flex; gap: 1rem; font-size: 0.78rem; color: var(--text-muted); margin-top: 0.5rem; }

/* ===== 密方卡片 ===== */
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.recipe-card {
  background: var(--bg-card); border-radius: var(--radius);
  padding: 1.1rem 1.2rem; box-shadow: var(--shadow);
  border: 1px solid var(--border); border-top: 3px solid var(--gold);
  cursor: pointer; transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}
.recipe-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.recipe-card h3 { font-size: 1rem; color: var(--primary); font-family: STKaiti, KaiTi, serif; }
.recipe-card .recipe-cat { font-size: 0.75rem; color: var(--gold-dark); margin-top: 0.15rem; }
.recipe-card .recipe-desc { font-size: 0.85rem; color: var(--text-muted); margin-top: 0.5rem; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.recipe-card .recipe-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.6rem; display: flex; justify-content: space-between; }

/* ===== 弹窗 ===== */
.modal-mask {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; animation: fadeIn 0.2s;
}
.modal {
  background: #fff; border-radius: var(--radius);
  width: 100%; max-width: 560px; max-height: 88vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: modalIn 0.25s ease;
}
@keyframes modalIn { from { transform: scale(0.92) translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1rem 1.3rem; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.05rem; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 1.15rem; cursor: pointer; color: var(--text-muted); padding: 0.2rem 0.4rem; border-radius: 4px; }
.modal-close:hover { background: rgba(0,0,0,0.06); color: var(--danger); }
.modal-body { padding: 1.3rem; overflow-y: auto; flex: 1; }
.modal-footer { padding: 0.9rem 1.3rem; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 0.8rem; }

.popup-modal { max-width: 460px; border-top: 5px solid var(--gold); }
.popup-banner {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--gold); text-align: center; padding: 0.9rem;
  font-size: 1.1rem; font-weight: 600; letter-spacing: 2px;
  font-family: STKaiti, KaiTi, serif;
  border-radius: var(--radius) var(--radius) 0 0;
}
.popup-modal h3 { color: var(--primary); margin-bottom: 0.6rem; font-size: 1.15rem; }
.popup-modal .popup-content { line-height: 1.8; white-space: pre-wrap; }
.checkbox { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--text-muted); cursor: pointer; }

/* ===== 认证页 ===== */
.auth-view {
  position: fixed; inset: 0; z-index: 500;
  background: linear-gradient(135deg, #5c0000 0%, #8B0000 50%, #3d0000 100%);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  overflow-y: auto;
}
.auth-card { max-width: 400px; width: 100%; text-align: center; padding: 2rem 1.8rem; margin: auto; }
.auth-logo { margin-bottom: 0.6rem; }
.auth-card h2 { font-family: STKaiti, KaiTi, serif; color: var(--primary); font-size: 1.35rem; }
.auth-card > .muted { font-size: 0.85rem; margin: 0.4rem 0 1.2rem; }
.auth-tabs { display: flex; background: var(--bg); border-radius: var(--radius-sm); padding: 4px; margin-bottom: 1.2rem; }
.auth-tab {
  flex: 1; padding: 0.55rem; border: none; background: transparent;
  border-radius: 4px; cursor: pointer; font-size: 0.95rem; font-family: inherit;
  color: var(--text-muted); transition: all 0.2s; font-weight: 500;
}
.auth-tab.active { background: var(--primary); color: #fff; }
.auth-form { display: flex; flex-direction: column; gap: 0.8rem; text-align: left; }
.auth-msg { margin-top: 0.8rem; font-size: 0.85rem; min-height: 1.2em; }
.auth-msg.error { color: var(--danger); }
.auth-msg.success { color: var(--success); }

/* ===== Toast ===== */
#toast-root { position: fixed; top: 70px; right: 1rem; z-index: 2000; display: flex; flex-direction: column; gap: 0.5rem; }
.toast {
  padding: 0.75rem 1.1rem; border-radius: var(--radius-sm);
  color: #fff; font-size: 0.9rem; box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  animation: toastIn 0.3s ease; max-width: 320px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.info { background: var(--info); }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: none; opacity: 1; } }
.toast.fade-out { opacity: 0; transform: translateX(30%); transition: all 0.3s; }

/* ===== 页脚 ===== */
.app-footer {
  background: #2c2419; color: rgba(255,255,255,0.7);
  text-align: center; padding: 1rem; font-size: 0.85rem;
  margin-top: auto;
}
.app-footer a { color: var(--gold); text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }

/* ===== 表格（管理后台） ===== */
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.admin-table th, .admin-table td { padding: 0.6rem 0.5rem; text-align: left; border-bottom: 1px solid var(--border); }
.admin-table th { background: var(--bg); color: var(--primary); font-weight: 600; }
.admin-table tr:hover td { background: rgba(139,0,0,0.03); }
.admin-table .ops { display: flex; gap: 0.4rem; }

.muted { color: var(--text-muted); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.mt-1 { margin-top: 0.5rem; } .mt-2 { margin-top: 1rem; } .mb-1 { margin-bottom: 0.5rem; }

/* ===== 响应式：手机 ===== */
@media (max-width: 768px) {
  html { font-size: 15px; }
  .header-inner { padding: 0 0.7rem; }
  .brand-text h1 { font-size: 1rem; }
  .brand-sub { display: none; }
  .nav-toggle { display: block; }
  .main-nav {
    display: none; position: absolute; top: var(--header-h); left: 0; right: 0;
    background: var(--primary-dark); flex-direction: column;
    align-items: stretch; padding: 0.5rem; gap: 0.2rem;
    box-shadow: var(--shadow-lg);
  }
  .main-nav.open { display: flex; }
  .nav-link { padding: 0.8rem 1rem; }
  .nav-user { margin: 0.3rem 0 0; padding: 0.8rem 1rem 0.3rem; border-left: none; border-top: 1px solid rgba(255,255,255,0.2); }
  .app-main { padding: 0.8rem 0.6rem 1.5rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .tree-chart { height: 450px; }
  #map-container { height: 420px; }
  .modal { max-width: 100%; max-height: 92vh; }
  .toolbar-row .input[type="search"] { max-width: none; }
  .cards-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
  .stat-num { font-size: 1.3rem; }
  .admin-table { font-size: 0.8rem; }
  .admin-table th, .admin-table td { padding: 0.45rem 0.3rem; }
}

@media (max-width: 400px) {
  .brand-text h1 { font-size: 0.9rem; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
