/* ==========================================================================
   《百年孤独》布恩迪亚家族图谱与导读系统 - 核心主样式表 (main.css)
   支持明暗双主题、响应式跨端适配与典雅拉美魔幻现实主义美学
   ========================================================================== */

:root {
  --bg-primary: #0b0f19;
  --bg-card: #131b2e;
  --bg-surface: #1a233b;
  --bg-subtle: #0f172a;
  --border-color: #27354f;
  --border-hover: #f59e0b;
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-gold: #f59e0b;
  --accent-gold-hover: #d97706;
  --accent-gold-bg: rgba(245, 158, 11, 0.12);
  --accent-gold-border: rgba(245, 158, 11, 0.35);
  --accent-red: #ef4444;
  --accent-blue: #3b82f6;
  --accent-green: #10b981;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.5);
  --shadow-gold: 0 0 24px rgba(245, 158, 11, 0.35);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

html.light {
  --bg-primary: #f8fafc;
  --bg-card: #ffffff;
  --bg-surface: #f1f5f9;
  --bg-subtle: #f8fafc;
  --border-color: #e2e8f0;
  --border-hover: #d97706;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent-gold: #d97706;
  --accent-gold-hover: #b45309;
  --accent-gold-bg: rgba(217, 119, 6, 0.1);
  --accent-gold-border: rgba(217, 119, 6, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 12px 28px rgba(0, 0, 0, 0.12);
  --shadow-gold: 0 0 20px rgba(217, 119, 6, 0.25);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* 顶部导航栏 */
.app-header {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-sm);
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #f59e0b, #b45309);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}

.brand-title-wrap h1 {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.3px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-title-wrap p {
  font-size: 11px;
  color: var(--text-muted);
}

.badge-netflix {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  background-color: var(--accent-gold-bg);
  color: var(--accent-gold);
  border: 1px solid var(--accent-gold-border);
}

/* Tab 切换组 */
.nav-tabs-group {
  display: flex;
  align-items: center;
  background-color: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 3px;
  gap: 4px;
}

.nav-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: all 0.2s ease;
}

.nav-tab-btn:hover {
  color: var(--text-primary);
}

.nav-tab-btn.active {
  background-color: var(--accent-gold);
  color: #ffffff;
  box-shadow: var(--shadow-sm);
}

/* 顶部操作区 (同步状态、备份恢复、暗黑模式) */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.status-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.status-cloud {
  background: rgba(16, 185, 129, 0.15);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.status-offline {
  background: rgba(100, 116, 139, 0.15);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.action-icon-btn {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s;
}

.action-icon-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
  transform: translateY(-1px);
}

/* 主内容视图容器 */
.main-content {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.view-panel {
  display: none;
  flex: 1;
  flex-direction: column;
  overflow-y: auto;
}

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

/* 导读面板与名录通用布局 */
.content-container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 16px 60px;
}

/* 导读面板头部书籍卡片 */
.guide-book-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  md-flex-direction: row;
  gap: 24px;
  box-shadow: var(--shadow-md);
  margin-bottom: 32px;
}

@media (min-width: 768px) {
  .guide-book-card {
    flex-direction: row;
    align-items: flex-start;
  }
}

.guide-cover-wrap {
  width: 100%;
  max-width: 240px;
  aspect-ratio: 3/4;
  border-radius: var(--radius-md);
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  flex-shrink: 0;
  margin: 0 auto;
}

.guide-cover-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.guide-cover-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  color: #f59e0b;
  font-size: 10px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.guide-meta-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.guide-title {
  font-size: 26px;
  font-weight: 900;
  color: var(--text-primary);
  line-height: 1.2;
}

.guide-original-title {
  font-size: 13px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 2px;
}

.guide-author-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
}

.guide-author-bio {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.4;
}

.guide-themes-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.theme-tag {
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background: var(--accent-gold-bg);
  color: var(--accent-gold);
  border: 1px solid var(--accent-gold-border);
}

.guide-summary-text {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.7;
}

.guide-bg-box {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background-color: var(--bg-subtle);
  border-left: 3px solid var(--accent-gold);
}

.guide-tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.guide-tag {
  font-size: 11px;
  color: var(--text-muted);
}

/* 七代兴衰时间轴 */
.section-heading-box {
  margin-bottom: 20px;
}

.section-title {
  font-size: 20px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.section-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

.timeline-wrap {
  display: flex;
  flex-direction: column;
  position: relative;
  margin-bottom: 40px;
}

.timeline-item {
  display: flex;
  gap: 16px;
  position: relative;
}

.timeline-dot-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 36px;
  flex-shrink: 0;
}

.timeline-dot {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  border: 2px solid var(--accent-gold);
  color: var(--accent-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.25);
  z-index: 2;
}

.timeline-line {
  flex: 1;
  width: 2px;
  background-color: var(--border-color);
  margin: 4px 0;
}

.timeline-item:last-child .timeline-line {
  display: none;
}

.timeline-card {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.timeline-header {
  margin-bottom: 8px;
}

.timeline-stage-pill {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent-gold);
  text-transform: uppercase;
}

.timeline-stage-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
}

.timeline-summary {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 10px;
}

.timeline-elements {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.timeline-chip {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  color: var(--text-muted);
}

/* 经典语录流 */
.quotes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

.quote-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, border-color 0.2s;
}

.quote-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-hover);
}

.quote-symbol {
  font-size: 36px;
  color: var(--accent-gold);
  line-height: 1;
  font-family: Georgia, serif;
  margin-bottom: 4px;
}

.quote-text {
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--text-primary);
  font-style: italic;
  margin-bottom: 14px;
}

.quote-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-color);
  padding-top: 10px;
}

.quote-tag {
  font-size: 11px;
  color: var(--text-muted);
}

.quote-author-btn {
  background: transparent;
  border: none;
  color: var(--accent-gold);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}

.quote-author-btn:hover {
  text-decoration: underline;
}

/* 人物名录与检索 */
.roster-toolbar {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.search-input-wrap {
  position: relative;
  width: 100%;
}

.search-input-wrap span {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}

.search-input {
  width: 100%;
  padding: 9px 12px 9px 36px;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.search-input:focus {
  border-color: var(--accent-gold);
}

.gen-filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.gen-filter-btn {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s;
}

.gen-filter-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.gen-filter-btn.active {
  background-color: var(--accent-gold);
  color: #ffffff;
  border-color: var(--accent-gold);
}

.roster-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.roster-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.roster-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--accent-gold);
}

.roster-card-photo-wrap {
  width: 95px;
  position: relative;
  flex-shrink: 0;
  background: #000;
}

.roster-card-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.roster-gen-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 9.5px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.75);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.roster-card-content {
  flex: 1;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.roster-name-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.roster-card-name {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--text-primary);
}

.roster-actor-chip {
  font-size: 9.5px;
  padding: 1px 5px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--accent-gold);
}

.roster-card-es {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}

.roster-card-role {
  font-size: 11.5px;
  color: var(--accent-gold);
  font-weight: 600;
  margin: 2px 0 6px;
}

.roster-card-desc {
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.roster-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-color);
}

.roster-locate-btn {
  background: transparent;
  border: none;
  color: var(--accent-gold);
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  padding: 2px 4px;
}

.roster-locate-btn:hover {
  text-decoration: underline;
}

/* Toast 提示 */
.sync-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--accent-gold);
  color: var(--text-primary);
  padding: 10px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  z-index: 99;
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.toast-fadeout {
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.3s ease;
}

/* 通用隐藏类 */
.hidden {
  display: none !important;
}

/* 响应式优化 */
@media (max-width: 768px) {
  .app-header {
    flex-wrap: wrap;
    padding: 8px 12px;
  }
  .nav-tabs-group {
    order: 3;
    width: 100%;
    justify-content: space-between;
    overflow-x: auto;
  }
  .nav-tab-btn {
    padding: 5px 8px;
    font-size: 12px;
    flex: 1;
    justify-content: center;
  }
  .brand-title-wrap h1 {
    font-size: 14.5px;
  }
  .status-pill {
    padding: 3px 6px;
    font-size: 10px;
  }
}
