/* ============================================================
   私密日记 - 主样式文件
   支持浅色 / 深色双主题，响应式布局
   ============================================================ */

/* ---------- CSS 变量 / 主题 ---------- */
:root {
  --primary:        #8B5CF6;
  --primary-dark:   #7C3AED;
  --primary-light:  #EDE9FE;
  --secondary:      #EC4899;
  --secondary-light:#FCE7F3;
  --success:        #10B981;
  --danger:         #EF4444;
  --warning:        #F59E0B;
  --info:           #3B82F6;

  --bg:             #F5F3FF;
  --bg-card:        #FFFFFF;
  --bg-input:       #FFFFFF;
  --text:           #1F1B2E;
  --text-muted:     #6B7280;
  --text-inverse:   #FFFFFF;
  --border:         #E9E4F5;
  --shadow:         rgba(139,92,246,0.08);
  --shadow-md:      rgba(139,92,246,0.15);

  --nav-bg:         #FFFFFF;
  --nav-border:     #E9E4F5;

  --radius:         12px;
  --radius-sm:      8px;
  --radius-lg:      16px;
  --radius-full:    9999px;
  --transition:     0.2s ease;
  --font:           -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

[data-theme="dark"] {
  --bg:             #0D0A1A;
  --bg-card:        #1A1530;
  --bg-input:       #221C3A;
  --text:           #F1EEF9;
  --text-muted:     #9D93B8;
  --border:         #2D2650;
  --shadow:         rgba(0,0,0,0.3);
  --shadow-md:      rgba(0,0,0,0.5);
  --nav-bg:         #1A1530;
  --nav-border:     #2D2650;
  --primary-light:  #1E1533;
}

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

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

body {
  font-family:      var(--font);
  background:       var(--bg);
  color:            var(--text);
  line-height:      1.6;
  min-height:       100vh;
  transition:       background var(--transition), color var(--transition);
  -webkit-user-select: none;
  user-select:      none;
}

/* 允许输入框选中文字 */
input, textarea, [contenteditable] {
  -webkit-user-select: text;
  user-select: text;
}

/* 禁止右键菜单（隐私保护） */
body { -webkit-touch-callout: none; }

img { max-width: 100%; display: block; }
a   { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ---------- 导航栏 ---------- */
.navbar {
  position:         sticky;
  top:              0;
  z-index:          100;
  background:       var(--nav-bg);
  border-bottom:    1px solid var(--nav-border);
  backdrop-filter:  blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow:       0 1px 10px var(--shadow);
}

.navbar-inner {
  max-width:        1000px;
  margin:           0 auto;
  padding:          0 20px;
  height:           60px;
  display:          flex;
  align-items:      center;
  justify-content:  space-between;
}

.navbar-brand {
  display:    flex;
  align-items:center;
  gap:         8px;
  font-size:   1.15rem;
  font-weight: 700;
  color:       var(--primary);
}

.navbar-brand .icon { font-size: 1.4rem; }

.navbar-nav {
  display:     flex;
  align-items: center;
  gap:         4px;
  list-style:  none;
}

.navbar-nav a {
  padding:       6px 12px;
  border-radius: var(--radius-sm);
  font-size:     0.9rem;
  font-weight:   500;
  color:         var(--text-muted);
  transition:    all var(--transition);
  display:       flex;
  align-items:   center;
  gap:           5px;
}

.navbar-nav a:hover,
.navbar-nav a.active {
  color:      var(--primary);
  background: var(--primary-light);
}

.navbar-user {
  display:     flex;
  align-items: center;
  gap:         8px;
}

.btn-icon {
  width:          36px;
  height:         36px;
  border-radius:  var(--radius-full);
  border:         none;
  background:     var(--primary-light);
  color:          var(--primary);
  cursor:         pointer;
  display:        flex;
  align-items:    center;
  justify-content:center;
  font-size:      1.1rem;
  transition:     all var(--transition);
}

.btn-icon:hover { background: var(--primary); color: #fff; }

/* ---------- 主容器 ---------- */
.container {
  max-width:  1000px;
  margin:     0 auto;
  padding:    24px 20px;
}

.container-sm {
  max-width:  480px;
  margin:     0 auto;
  padding:    24px 20px;
}

/* ---------- 卡片 ---------- */
.card {
  background:    var(--bg-card);
  border-radius: var(--radius-lg);
  border:        1px solid var(--border);
  box-shadow:    0 2px 12px var(--shadow);
  overflow:      hidden;
  transition:    box-shadow var(--transition);
}

.card:hover { box-shadow: 0 4px 24px var(--shadow-md); }

.card-header {
  padding:       20px 24px 0;
  border-bottom: none;
}

.card-body { padding: 24px; }

.card-footer {
  padding:    16px 24px;
  border-top: 1px solid var(--border);
}

/* ---------- 按钮 ---------- */
.btn {
  display:        inline-flex;
  align-items:    center;
  justify-content:center;
  gap:            6px;
  padding:        10px 20px;
  border:         2px solid transparent;
  border-radius:  var(--radius-sm);
  font-size:      0.9rem;
  font-weight:    600;
  cursor:         pointer;
  transition:     all var(--transition);
  white-space:    nowrap;
  text-decoration:none;
  font-family:    var(--font);
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color:      #fff;
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-dark), #be185d);
  transform:  translateY(-1px);
  box-shadow: 0 4px 15px rgba(139,92,246,0.4);
  color:      #fff;
}

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

.btn-outline:hover:not(:disabled) {
  background: var(--primary-light);
}

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

.btn-ghost:hover { background: var(--border); color: var(--text); }

.btn-danger {
  background: var(--danger);
  color:      #fff;
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
  transform:  translateY(-1px);
}

.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn-full { width: 100%; }

/* ---------- 表单 ---------- */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display:       block;
  font-size:     0.88rem;
  font-weight:   600;
  color:         var(--text-muted);
  margin-bottom: 8px;
  text-transform:uppercase;
  letter-spacing:0.5px;
}

.form-control {
  width:         100%;
  padding:       11px 14px;
  background:    var(--bg-input);
  border:        1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color:         var(--text);
  font-size:     0.95rem;
  font-family:   var(--font);
  transition:    border-color var(--transition), box-shadow var(--transition);
  outline:       none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow:   0 0 0 3px rgba(139,92,246,0.15);
}

.form-control::placeholder { color: var(--text-muted); opacity: 0.7; }

textarea.form-control {
  resize:     vertical;
  min-height: 100px;
}

select.form-control { cursor: pointer; }

.form-hint {
  font-size:  0.8rem;
  color:      var(--text-muted);
  margin-top: 5px;
}

.form-error {
  font-size:  0.82rem;
  color:      var(--danger);
  margin-top: 5px;
}

/* ---------- 标签选择器 ---------- */
.tag-group {
  display:    flex;
  flex-wrap:  wrap;
  gap:        8px;
  margin-top: 8px;
}

.tag-btn {
  padding:       5px 13px;
  border:        1.5px solid var(--border);
  border-radius: var(--radius-full);
  font-size:     0.85rem;
  cursor:        pointer;
  transition:    all var(--transition);
  background:    var(--bg-card);
  color:         var(--text-muted);
  font-family:   var(--font);
  white-space:   nowrap;
}

.tag-btn:hover      { border-color: var(--primary); color: var(--primary); }
.tag-btn.selected   {
  border-color: var(--primary);
  background:   var(--primary);
  color:        #fff;
}

/* ---------- 评分滑块 ---------- */
.rating-row {
  display:     flex;
  align-items: center;
  gap:         12px;
}

.rating-row input[type="range"] {
  flex:       1;
  accent-color: var(--primary);
}

.rating-val {
  min-width:  32px;
  text-align: center;
  font-weight:700;
  color:      var(--primary);
  font-size:  1.1rem;
}

/* ---------- 状态提示 ---------- */
.alert {
  padding:       12px 16px;
  border-radius: var(--radius-sm);
  font-size:     0.9rem;
  margin-bottom: 16px;
  display:       flex;
  align-items:   flex-start;
  gap:           8px;
}

.alert-danger  { background: #FEF2F2; color: #991B1B; border: 1px solid #FCA5A5; }
.alert-success { background: #F0FDF4; color: #166534; border: 1px solid #86EFAC; }
.alert-warning { background: #FFFBEB; color: #92400E; border: 1px solid #FDE68A; }
.alert-info    { background: #EFF6FF; color: #1E40AF; border: 1px solid #BFDBFE; }

[data-theme="dark"] .alert-danger  { background: #2d1515; color: #fca5a5; border-color: #7f1d1d; }
[data-theme="dark"] .alert-success { background: #052e16; color: #86efac; border-color: #14532d; }
[data-theme="dark"] .alert-warning { background: #2d1d00; color: #fde68a; border-color: #78350f; }
[data-theme="dark"] .alert-info    { background: #0d1f3d; color: #bfdbfe; border-color: #1e3a5f; }

/* ---------- 日记列表卡片 ---------- */
.diary-card {
  background:    var(--bg-card);
  border:        1px solid var(--border);
  border-radius: var(--radius);
  padding:       16px 20px;
  cursor:        pointer;
  transition:    all var(--transition);
  display:       flex;
  flex-direction:column;
  gap:           10px;
}

.diary-card:hover {
  border-color: var(--primary);
  box-shadow:   0 4px 20px var(--shadow-md);
  transform:    translateY(-2px);
}

.diary-card-header {
  display:         flex;
  justify-content: space-between;
  align-items:     flex-start;
}

.diary-date {
  font-weight: 700;
  font-size:   1rem;
  color:       var(--text);
}

.diary-meta {
  display:  flex;
  gap:      8px;
  flex-wrap:wrap;
  align-items:center;
}

.badge {
  padding:       3px 10px;
  border-radius: var(--radius-full);
  font-size:     0.78rem;
  font-weight:   600;
  white-space:   nowrap;
}

.badge-primary  { background: var(--primary-light); color: var(--primary); }
.badge-secondary{ background: var(--secondary-light); color: var(--secondary); }
.badge-muted    { background: var(--border); color: var(--text-muted); }
.badge-success  { background: #d1fae5; color: #065f46; }
.badge-danger   { background: #fee2e2; color: #991b1b; }

[data-theme="dark"] .badge-success { background: #052e16; color: #6ee7b7; }
[data-theme="dark"] .badge-danger  { background: #2d1515; color: #fca5a5; }

.diary-rating {
  display:    flex;
  gap:        4px;
  align-items:center;
  font-size:  0.85rem;
  color:      var(--text-muted);
}

.diary-rating .stars { color: #F59E0B; }

.diary-preview {
  font-size:    0.88rem;
  color:        var(--text-muted);
  line-height:  1.5;
  overflow:     hidden;
  display:      -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp:         2;
  -webkit-box-orient: vertical;
}

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

.tag-chip {
  padding:       2px 8px;
  border-radius: var(--radius-full);
  font-size:     0.75rem;
  background:    var(--primary-light);
  color:         var(--primary);
}

/* ---------- 页面标题 ---------- */
.page-title {
  font-size:   1.5rem;
  font-weight: 800;
  color:       var(--text);
  margin-bottom:4px;
}

.page-subtitle {
  font-size:  0.9rem;
  color:      var(--text-muted);
  margin-bottom:24px;
}

/* ---------- 统计卡片 ---------- */
.stat-grid {
  display:               grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap:                   16px;
  margin-bottom:         24px;
}

.stat-card {
  background:    var(--bg-card);
  border:        1px solid var(--border);
  border-radius: var(--radius);
  padding:       20px;
  text-align:    center;
}

.stat-value {
  font-size:   2rem;
  font-weight: 800;
  background:  linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.stat-label {
  font-size:  0.82rem;
  color:      var(--text-muted);
  margin-top: 4px;
}

/* ---------- 搜索栏 ---------- */
.search-bar {
  position:  relative;
  flex:      1;
}

.search-bar input {
  padding-left: 38px;
}

.search-bar .search-icon {
  position:   absolute;
  left:       12px;
  top:        50%;
  transform:  translateY(-50%);
  color:      var(--text-muted);
  font-size:  1rem;
  pointer-events: none;
}

/* ---------- 筛选栏 ---------- */
.filter-bar {
  display:       flex;
  gap:           10px;
  flex-wrap:     wrap;
  align-items:   center;
  margin-bottom: 20px;
  padding:       16px;
  background:    var(--bg-card);
  border:        1px solid var(--border);
  border-radius: var(--radius);
}

.filter-btn {
  padding:       6px 14px;
  border:        1.5px solid var(--border);
  border-radius: var(--radius-full);
  background:    transparent;
  color:         var(--text-muted);
  font-size:     0.85rem;
  cursor:        pointer;
  transition:    all var(--transition);
  font-family:   var(--font);
}

.filter-btn:hover,
.filter-btn.active {
  border-color: var(--primary);
  color:        var(--primary);
  background:   var(--primary-light);
}

/* ---------- 加载状态 ---------- */
.loading {
  text-align:  center;
  padding:     60px 20px;
  color:       var(--text-muted);
}

.spinner {
  width:        40px;
  height:       40px;
  border:       3px solid var(--border);
  border-top:   3px solid var(--primary);
  border-radius:50%;
  animation:    spin 0.8s linear infinite;
  margin:       0 auto 16px;
}

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

.empty-state {
  text-align:   center;
  padding:      60px 20px;
  color:        var(--text-muted);
}

.empty-state .empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state p { font-size: 0.95rem; }

/* ---------- 模态框 ---------- */
.modal-overlay {
  position:    fixed;
  inset:       0;
  background:  rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index:     1000;
  display:     flex;
  align-items: center;
  justify-content:center;
  opacity:     0;
  pointer-events:none;
  transition:  opacity var(--transition);
}

.modal-overlay.show { opacity: 1; pointer-events: all; }

.modal {
  background:    var(--bg-card);
  border-radius: var(--radius-lg);
  border:        1px solid var(--border);
  padding:       32px;
  max-width:     440px;
  width:         90%;
  transform:     scale(0.95);
  transition:    transform var(--transition);
}

.modal-overlay.show .modal { transform: scale(1); }

.modal-title {
  font-size:     1.1rem;
  font-weight:   700;
  margin-bottom: 12px;
}

.modal-actions {
  display:        flex;
  gap:            10px;
  justify-content:flex-end;
  margin-top:     24px;
}

/* ---------- 分页 ---------- */
.pagination {
  display:         flex;
  gap:             6px;
  justify-content: center;
  margin-top:      28px;
  flex-wrap:       wrap;
}

.page-btn {
  padding:       7px 13px;
  border:        1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background:    var(--bg-card);
  color:         var(--text-muted);
  cursor:        pointer;
  font-size:     0.9rem;
  transition:    all var(--transition);
  font-family:   var(--font);
}

.page-btn:hover,
.page-btn.active {
  border-color: var(--primary);
  background:   var(--primary);
  color:        #fff;
}

.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- 详情页 ---------- */
.detail-section {
  margin-bottom: 24px;
}

.detail-section-title {
  font-size:     0.8rem;
  font-weight:   700;
  color:         var(--text-muted);
  text-transform:uppercase;
  letter-spacing:0.8px;
  margin-bottom: 12px;
  padding-bottom:8px;
  border-bottom: 1px solid var(--border);
}

.detail-grid {
  display:               grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap:                   16px;
}

.detail-item label {
  font-size:  0.78rem;
  color:      var(--text-muted);
  display:    block;
  margin-bottom:4px;
}

.detail-item .value {
  font-weight: 600;
  font-size:   0.95rem;
  color:       var(--text);
}

/* ---------- 首页 / Landing ---------- */
.hero {
  text-align:  center;
  padding:     80px 20px 60px;
}

.hero-icon { font-size: 4rem; margin-bottom: 20px; }

.hero h1 {
  font-size:   2.2rem;
  font-weight: 800;
  background:  linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom:16px;
  line-height: 1.2;
}

.hero p {
  font-size:   1rem;
  color:       var(--text-muted);
  max-width:   480px;
  margin:      0 auto 32px;
  line-height: 1.7;
}

.feature-grid {
  display:               grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap:                   20px;
  margin-top:            40px;
}

.feature-card {
  background:    var(--bg-card);
  border:        1px solid var(--border);
  border-radius: var(--radius-lg);
  padding:       24px;
  text-align:    center;
}

.feature-card .f-icon { font-size: 2rem; margin-bottom: 12px; }
.feature-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.feature-card p  { font-size: 0.88rem; color: var(--text-muted); line-height: 1.6; }

/* ---------- 图表容器 ---------- */
.chart-container {
  position:    relative;
  padding:     16px;
  background:  var(--bg-card);
  border:      1px solid var(--border);
  border-radius:var(--radius-lg);
}

.chart-title {
  font-size:     0.9rem;
  font-weight:   700;
  color:         var(--text-muted);
  margin-bottom: 16px;
}

/* ---------- 登录 / 注册页 ---------- */
.auth-page {
  min-height:      100vh;
  display:         flex;
  align-items:     center;
  justify-content: center;
  padding:         24px;
  background:      var(--bg);
}

.auth-card {
  width:         100%;
  max-width:     420px;
  background:    var(--bg-card);
  border-radius: var(--radius-lg);
  border:        1px solid var(--border);
  box-shadow:    0 8px 40px var(--shadow-md);
  padding:       40px;
}

.auth-logo {
  text-align:    center;
  margin-bottom: 32px;
}

.auth-logo .icon { font-size: 2.5rem; }
.auth-logo h1    { font-size: 1.4rem; font-weight: 800; color: var(--primary); margin-top: 8px; }
.auth-logo p     { font-size: 0.85rem; color: var(--text-muted); margin-top: 4px; }

/* ---------- Toast 通知 ---------- */
#toast-container {
  position:   fixed;
  bottom:     24px;
  right:      24px;
  z-index:    9999;
  display:    flex;
  flex-direction:column;
  gap:        8px;
  pointer-events:none;
}

.toast {
  padding:       12px 18px;
  border-radius: var(--radius-sm);
  font-size:     0.9rem;
  font-weight:   500;
  color:         #fff;
  box-shadow:    0 4px 20px rgba(0,0,0,0.25);
  transform:     translateX(120%);
  transition:    transform 0.3s ease;
  max-width:     300px;
  pointer-events:all;
}

.toast.show { transform: translateX(0); }

.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info    { background: var(--primary); }

/* ---------- 响应式 ---------- */
@media (max-width: 640px) {
  .navbar-nav { display: none; }
  .hero h1    { font-size: 1.6rem; }
  .container  { padding: 16px; }
  .card-body  { padding: 16px; }
  .auth-card  { padding: 28px 20px; }
  .stat-grid  { grid-template-columns: repeat(2, 1fr); }
  .detail-grid{ grid-template-columns: 1fr 1fr; }
  .modal      { padding: 24px 18px; }
}

/* ---------- 滚动条美化 ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* ---------- 选中文字颜色 ---------- */
::selection { background: var(--primary); color: #fff; }

/* ---------- 分割线 ---------- */
.divider {
  border:        none;
  border-top:    1px solid var(--border);
  margin:        20px 0;
}

/* ---------- 行内操作按钮组 ---------- */
.action-bar {
  display:         flex;
  gap:             10px;
  justify-content: space-between;
  align-items:     center;
  flex-wrap:       wrap;
  margin-bottom:   20px;
}

/* ---------- 批量操作栏 ---------- */
.bulk-bar {
  position:      fixed;
  bottom:        80px;
  left:          50%;
  transform:     translateX(-50%) translateY(20px);
  opacity:       0;
  pointer-events:none;
  background:    var(--text);
  color:         var(--bg);
  border-radius: var(--radius-full);
  padding:       10px 20px;
  display:       flex;
  align-items:   center;
  gap:           12px;
  box-shadow:    0 6px 30px rgba(0,0,0,0.3);
  transition:    all var(--transition);
  z-index:       50;
  font-size:     0.9rem;
  font-weight:   600;
  white-space:   nowrap;
}

.bulk-bar.show {
  opacity:       1;
  pointer-events:all;
  transform:     translateX(-50%) translateY(0);
}

/* ---------- 底部移动导航 ---------- */
.bottom-nav {
  display:         none;
  position:        fixed;
  bottom:          0;
  left:            0; right: 0;
  background:      var(--nav-bg);
  border-top:      1px solid var(--nav-border);
  padding:         8px 0;
  z-index:         100;
}

.bottom-nav-inner {
  display:         flex;
  justify-content: space-around;
}

.bottom-nav a {
  display:         flex;
  flex-direction:  column;
  align-items:     center;
  gap:             3px;
  font-size:       0.7rem;
  color:           var(--text-muted);
  padding:         6px 16px;
  border-radius:   var(--radius-sm);
  transition:      color var(--transition);
}

.bottom-nav a .nav-icon { font-size: 1.3rem; }
.bottom-nav a.active, .bottom-nav a:hover { color: var(--primary); }

@media (max-width: 640px) {
  .bottom-nav { display: block; }
  .container  { padding-bottom: 80px; }
}

/* ---------- 健康提醒横幅 ---------- */
.health-alert {
  background:    linear-gradient(135deg, #FEF3C7, #FDE68A);
  border:        1px solid #F59E0B;
  border-radius: var(--radius);
  padding:       14px 18px;
  margin-bottom: 20px;
  display:       flex;
  align-items:   flex-start;
  gap:           10px;
  font-size:     0.9rem;
  color:         #78350F;
}

[data-theme="dark"] .health-alert {
  background:  #2d1d00;
  border-color:#78350f;
  color:       #fde68a;
}
