/**
 * 每日一卦 PWA 平台 - 全局主题样式
 * 让八卦有文化，让国学有温度
 */

/* ========== CSS变量定义 ========== */
:root {
  /* 主色调 */
  --primary: #C04851;
  --primary-light: #D4646B;
  --primary-dark: #9A3A41;
  
  /* 强调色 */
  --accent: #D4AF37;
  --accent-light: #E5C765;
  --accent-dark: #B8962E;
  
  /* 背景色 */
  --bg-main: #FFFBF0;
  --bg-card: #FFFFFF;
  --bg-dark: #1a1a2e;
  --bg-gradient: linear-gradient(135deg, #C04851 0%, #D4AF37 100%);
  
  /* 文字色 */
  --text-primary: #2C3E50;
  --text-secondary: #666666;
  --text-light: #999999;
  --text-white: #FFFFFF;
  
  /* 分割线 */
  --divider: #E8E0D0;
  --divider-light: #F0EBE0;
  
  /* 状态色 */
  --success: #27AE60;
  --warning: #F39C12;
  --error: #E74C3C;
  --info: #3498DB;
  
  /* 吉凶色 */
  --ji-color: #C04851;
  --xiong-color: #E74C3C;
  --ping-color: #95A5A6;
  
  /* 阴影 */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.15);
  
  /* 圆角 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;
  
  /* 字体 */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-serif: "Songti SC", "STSong", "SimSun", serif;
  --font-numbers: "DIN Alternate", "Roboto", sans-serif;
  
  /* 动画时长 */
  --duration-fast: 150ms;
  --duration-normal: 300ms;
  --duration-slow: 500ms;
  
  /* 安全区域 */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 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-sans);
  background: var(--bg-dark);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========== 容器 ========== */
.container {
  width: 100%;
  max-width: 100%;
  margin: 0 auto;
  padding: 0 16px;
}

.phone-container {
  max-width: 375px;
  margin: 0 auto;
  background: var(--bg-main);
  min-height: 100vh;
  position: relative;
  overflow: hidden;
}

/* ========== 卡片 ========== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin: 16px;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--bg-gradient);
}

.card-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
  font-family: var(--font-serif);
}

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: var(--radius-full);
  font-size: 15px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all var(--duration-fast) ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--bg-gradient);
  color: var(--text-white);
}

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

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--divider);
}

.btn-ghost {
  background: transparent;
  color: var(--primary);
}

.btn-disabled,
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-block {
  width: 100%;
}

/* ========== 头部 ========== */
.header {
  padding: calc(var(--safe-top) + 50px) 20px 20px;
  text-align: center;
  position: relative;
}

.header-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.header-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ========== 底部导航 ========== */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 calc(var(--safe-bottom) + 8px);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  z-index: 100;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color var(--duration-fast);
}

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

.tab-item-icon {
  font-size: 24px;
}

.tab-item-text {
  font-size: 11px;
}

/* ========== 徽章 ========== */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
}

.badge-vip {
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%);
  color: var(--text-white);
}

.badge-free {
  background: var(--divider-light);
  color: var(--text-secondary);
}

/* ========== 星星评分 ========== */
.stars {
  display: inline-flex;
  gap: 2px;
  color: var(--accent);
}

.star {
  font-size: 14px;
}

.star.half {
  position: relative;
}

.star.empty {
  color: var(--divider);
}

/* ========== 滚动区域 ========== */
.scroll-area {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.scroll-area::-webkit-scrollbar {
  display: none;
}

/* ========== 加载状态 ========== */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-secondary);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--divider);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 12px;
}

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

/* ========== 空状态 ========== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-text {
  font-size: 14px;
}

/* ========== 免责声明 ========== */
.disclaimer {
  font-size: 11px;
  color: var(--text-light);
  text-align: center;
  padding: 20px 16px;
  line-height: 1.8;
}

/* ========== 语言切换 ========== */
.lang-switch {
  position: absolute;
  top: calc(var(--safe-top) + 12px);
  right: 16px;
  display: flex;
  gap: 8px;
}

.lang-btn {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  border: 1px solid var(--divider);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--duration-fast);
}

.lang-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--text-white);
}

/* ========== 动画 ========== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-fadeIn {
  animation: fadeIn var(--duration-normal) ease;
}

.animate-slideUp {
  animation: slideUp var(--duration-slow) ease;
}

.animate-bounce {
  animation: bounce 1s ease infinite;
}

/* ========== 响应式 ========== */
@media (max-width: 375px) {
  html {
    font-size: 15px;
  }
}

@media (min-width: 768px) {
  .phone-container {
    max-width: 414px;
    border-radius: var(--radius-xl);
    margin: 20px auto;
    box-shadow: var(--shadow-lg);
    min-height: calc(100vh - 40px);
  }
  
  .tab-bar {
    max-width: 414px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  }
}

@media (min-width: 1024px) {
  .phone-container {
    max-width: 430px;
  }
}

/* ========== 辅助类 ========== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-light { color: var(--text-light); }
.text-accent { color: var(--accent); }
.text-primary-color { color: var(--primary); }

.bg-main { background: var(--bg-main); }
.bg-card { background: var(--bg-card); }

.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }

.p-16 { padding: 16px; }
.px-16 { padding-left: 16px; padding-right: 16px; }
.py-12 { padding-top: 12px; padding-bottom: 12px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }

.w-full { width: 100%; }
.h-full { height: 100%; }

.hidden { display: none; }
.visible { visibility: visible; }
.invisible { visibility: hidden; }

.overflow-hidden { overflow: hidden; }
.relative { position: relative; }
.absolute { position: absolute; }

/* 底部安全距离 */
.pb-safe {
  padding-bottom: calc(80px + var(--safe-bottom));
}
