/* ===== 深色优雅风设计 ===== */
/* 配色：深靛蓝 + 琥珀金 + 精致阴影 */

:root {
  /* 主色调 - 清新蓝 */
  --primary: #3B82F6;
  --primary-light: #60A5FA;
  --primary-dark: #2563EB;
  --primary-gradient: linear-gradient(135deg, #60A5FA 0%, #3B82F6 50%, #2563EB 100%);

  /* 明亮背景系 */
  --bg: linear-gradient(180deg, #F0F9FF 0%, #E0F2FE 100%);
  --bg-secondary: #FFFFFF;
  --bg-tertiary: #F1F5F9;
  --bg-card: #FFFFFF;

  /* 文字色 */
  --text: #1E293B;
  --text-secondary: #475569;
  --text-muted: #94A3B8;

  /* 边框与阴影 */
  --border: rgba(148, 163, 184, 0.2);
  --border-highlight: rgba(59, 130, 246, 0.3);
  --shadow-soft: 0 4px 20px rgba(59, 130, 246, 0.1);
  --shadow-card: 0 8px 32px rgba(59, 130, 246, 0.12), 0 0 0 1px rgba(255, 255, 255, 0.5);
  --shadow-blue: 0 0 30px rgba(59, 130, 246, 0.15);

  /* 圆角 */
  --radius: 16px;
  --radius-lg: 20px;
  --radius-xl: 24px;
}

/* ===== 基础样式 ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  background-attachment: fixed;
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* 微妙的背景纹理 */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(59, 130, 246, 0.1), transparent),
    radial-gradient(ellipse 60% 40% at 80% 100%, rgba(59, 130, 246, 0.05), transparent);
  pointer-events: none;
  z-index: -1;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 80px;
  position: relative;
}

/* ===== 页面容器 ===== */
.pages-container {
  position: relative;
  min-height: calc(100vh - 80px);
}

.page {
  display: none;
  padding: 0 20px 24px;
  animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.page.active {
  display: block !important;
  pointer-events: auto;
}

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

/* ===== 页面头部 ===== */
.page-header {
  text-align: center;
  padding: 32px 0 24px;
}

.page-header h1 {
  font-family: 'Playfair Display', serif;
  font-size: 32px;
  font-weight: 600;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
  letter-spacing: -0.5px;
}

.subtitle {
  font-size: 15px;
  color: var(--text-secondary);
  font-weight: 400;
}

.subtitle .count {
  color: var(--primary);
  font-weight: 600;
  font-size: 20px;
}

/* ===== 添加记录卡片 ===== */
.add-record-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  padding: 24px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-card), var(--shadow-gold);
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border);
}

/* 顶部蓝色装饰线 */
.add-record-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--primary-gradient);
}

/* 角落装饰 */
.add-record-card::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.06) 0%, transparent 70%);
  pointer-events: none;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  font-size: 16px;
  font-weight: 500;
  color: var(--primary);
}

.heart-icon {
  font-size: 20px;
  animation: gentlePulse 2s ease-in-out infinite;
}

@keyframes gentlePulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.8; }
}

/* ===== 表单样式 ===== */
.form-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
}

.form-group {
  margin-bottom: 16px;
}

.form-row .form-group {
  margin-bottom: 0;
  flex: 1;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group label small {
  font-weight: 400;
  color: var(--text-muted);
  text-transform: none;
}

input, select, textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 15px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-tertiary);
  transition: all 0.2s ease;
  outline: none;
}

input::placeholder, textarea::placeholder {
  color: var(--text-muted);
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  background: var(--bg-secondary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%23F59E0B' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

.number-display {
  padding: 14px 16px;
  background: var(--primary-gradient);
  border-radius: var(--radius);
  text-align: center;
  color: white;
  font-weight: 700;
  font-size: 18px;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.mealtime-group {
  flex: 1.2;
}

.date-group {
  flex: 1.2;
}

/* ===== 按钮样式 ===== */
.btn-primary {
  width: 100%;
  padding: 16px;
  background: var(--primary-gradient);
  border: none;
  border-radius: var(--radius);
  color: white;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 20px rgba(59, 130, 246, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(59, 130, 246, 0.45);
}

.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
  padding: 12px 24px;
  background: transparent;
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius);
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: rgba(245, 158, 11, 0.1);
  border-color: var(--primary);
}

.btn-secondary:active {
  background: rgba(245, 158, 11, 0.2);
}

/* ===== 章节标题 ===== */
.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
}

/* ===== 记录时间线 ===== */
.records-timeline {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.record-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
  position: relative;
  transition: all 0.2s ease;
  border: 1px solid var(--border);
  cursor: pointer;
}

.record-card:hover {
  transform: translateX(4px);
  border-color: var(--border-highlight);
  box-shadow: var(--shadow-card), var(--shadow-blue);
}

.record-card:active {
  transform: scale(0.98);
}

/* 提示用户可以点击 */
.record-card::after {
  content: '⋮';
  position: absolute;
  top: 12px;
  right: 12px;
  font-size: 18px;
  color: var(--text-muted);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.record-card:hover::after {
  opacity: 0.5;
}

.record-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.record-number {
  font-weight: 600;
  color: var(--primary);
  font-size: 14px;
  font-family: 'Playfair Display', serif;
}

.record-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
}

.record-mealtime {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 20px;
  font-size: 12px;
  color: var(--primary);
  font-weight: 500;
}

.record-shop {
  font-weight: 600;
  color: var(--text);
  font-size: 16px;
  margin-bottom: 4px;
}

.record-remark {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
}

/* ===== 搜索区域 ===== */
.search-section {
  margin-bottom: 24px;
}

.search-box {
  position: relative;
  margin-bottom: 12px;
}

.search-box input {
  padding-left: 44px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23F59E0B' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 16px center;
}

.filter-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-tag {
  padding: 8px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-tag:hover {
  border-color: var(--border-highlight);
}

.filter-tag.active {
  background: rgba(59, 130, 246, 0.15);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 500;
}

/* ===== 统计卡片 ===== */
.stats-grid {
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  text-align: center;
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-card-bg {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
  filter: blur(2px) brightness(0.9);
  opacity: 0.6;
}

.stat-content {
  position: relative;
  z-index: 1;
  padding: 24px;
}

.stat-card.big {
  margin-bottom: 12px;
}

.stat-card.big .stat-content {
  padding: 32px 24px;
}

/* 装饰性光晕 */
.stat-card.big::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 60%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  z-index: 2;
}

.stat-card.big::after {
  content: '◆';
  position: absolute;
  right: 20px;
  top: 20px;
  font-size: 20px;
  color: var(--primary);
  opacity: 0.5;
  z-index: 2;
}

.stat-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-icon {
  font-size: 32px;
  margin-bottom: 8px;
  opacity: 0.9;
}

.stat-number {
  font-family: 'Playfair Display', serif;
  font-size: 42px;
  font-weight: 600;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.stat-card.small .stat-number {
  font-size: 32px;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== TOP店列表 ===== */
.top-shops-section {
  margin-bottom: 24px;
}

.top-shops-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.top-shop-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.top-shop-item:hover {
  border-color: var(--border-highlight);
  transform: translateX(4px);
}

.top-shop-rank {
  width: 32px;
  height: 32px;
  background: var(--primary-gradient);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.3);
}

.top-shop-info {
  flex: 1;
}

.top-shop-name {
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
}

.top-shop-bar {
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}

.top-shop-progress {
  height: 100%;
  background: var(--primary-gradient);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.top-shop-count {
  font-size: 13px;
  color: var(--primary);
  font-weight: 500;
}

/* ===== 设置页面 ===== */
.settings-section {
  margin-bottom: 24px;
}

.setting-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  margin-bottom: 12px;
  border: 1px solid var(--border);
  transition: all 0.2s ease;
}

.setting-card:hover {
  border-color: var(--border-highlight);
}

.setting-icon {
  width: 48px;
  height: 48px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
}

.setting-content {
  flex: 1;
}

.setting-content h3 {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 2px;
}

.setting-content p {
  font-size: 13px;
  color: var(--text-muted);
}

.format-help-card {
  background: var(--bg-tertiary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}

.format-help-card h4 {
  font-size: 14px;
  font-weight: 500;
  color: var(--primary);
  margin-bottom: 12px;
}

.format-help-card pre {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: 'JetBrains Mono', 'Courier New', monospace;
}

.app-info {
  text-align: center;
  padding: 32px 20px;
  color: var(--text-muted);
  font-size: 13px;
}

.app-info p:first-child {
  font-family: 'Playfair Display', serif;
  font-size: 24px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: 2px;
}

.app-info p:first-child .heart-icon {
  color: var(--primary);
  font-size: 20px;
  margin: 0 2px;
  animation: heartbeat 1.5s ease-in-out infinite;
}

/* ===== 底部导航 ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: flex;
  justify-content: space-around;
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 30px rgba(59, 130, 246, 0.1);
  z-index: 100;
  max-width: 480px;
  margin: 0 auto;
  border-top: 1px solid var(--border);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px;
  border: none;
  background: none;
  cursor: pointer;
  transition: all 0.2s ease;
  color: var(--text-muted);
}

.nav-icon {
  font-size: 22px;
  transition: transform 0.2s ease;
}

.nav-label {
  font-size: 11px;
  font-weight: 500;
}

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

.nav-item.active .nav-icon {
  transform: scale(1.1);
  filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.5));
}

/* ===== Toast 提示 ===== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  padding: 14px 24px;
  background: var(--bg-card);
  color: var(--text);
  border-radius: var(--radius);
  font-size: 14px;
  z-index: 1000;
  animation: slideDown 0.3s ease;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--border);
}

.toast.error {
  background: #FEE2E2;
  border-color: #FECACA;
  color: #DC2626;
}

.toast.success {
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--primary);
  color: var(--primary);
}

@keyframes slideDown {
  from { opacity: 0; transform: translate(-50%, -20px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

.toast.hidden {
  display: none;
}

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

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

/* ===== 滚动条美化 ===== */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(59, 130, 246, 0.2);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(59, 130, 246, 0.4);
}

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

/* ===== 展开按钮 ===== */
.btn-expand {
  width: 100%;
  padding: 14px;
  margin-top: 16px;
  background: transparent;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-expand:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(59, 130, 246, 0.05);
}

.btn-expand:active {
  transform: scale(0.98);
}

/* ===== 统计页面布局 ===== */
#page-stats.active {
  display: flex;
  flex-direction: column;
  height: auto;
  min-height: calc(100vh - 160px);
  overflow: visible;
}

/* 统计区域（固定） */
.stats-section {
  flex-shrink: 0;
  margin-bottom: 16px;
}

/* 搜索区域（固定） */
.search-section {
  flex-shrink: 0;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* 搜索结果容器（可滚动） */
.search-results-container {
  flex: 1;
  overflow-y: auto;
  padding-right: 4px;
}

.search-results-container .records-timeline {
  gap: 8px;
}

/* ===== 模态框 ===== */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
  padding: 20px;
}

.modal-content {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
  max-width: 100%;
}

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