/* ========== 岁意互娱 - 2主题系统（白天/晚上） ========== */

/* ── 白天（Daylight） ─────────────────────── */
:root, [data-theme="day"] {
  --bg: #f9f9f9;
  --bg2: #f0f0f0;
  --surface: #fcfcfc;
  --surface2: #f5f5f5;
  --surface3: #efefef;
  --border: #d8d8d8;
  --border-light: #e5e5e5;
  --text: #202020;
  --text-muted: #646464;
  --text-dim: #909090;
  --accent: #644a40;
  --accent2: #8b6b5e;
  --accent-glow: rgba(100, 74, 64, 0.15);
  --cyan: #0d9488;
  --cyan-glow: rgba(13, 148, 136, 0.12);
  --pink: #db2777;
  --pink-glow: rgba(219, 39, 119, 0.12);
  --gold: #b45309;
  --gold-glow: rgba(180, 83, 9, 0.1);
  --orange: #ea580c;
  --red: #e54d2e;
  --green: #059669;
  --blue: #4f46e5;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.08);
  --theme-toggle-bg: var(--surface2);
  --theme-toggle-icon: "☀️";
}

/* ── 晚上（Nightfall） ─────────────────────── */
[data-theme="night"] {
  --bg: #111111;
  --bg2: #18181b;
  --surface: #191919;
  --surface2: #222222;
  --surface3: #2a2a2a;
  --border: #201e18;
  --border-light: #2a2822;
  --text: #eeeeee;
  --text-muted: #b4b4b4;
  --text-dim: #787878;
  --accent: #ffe0c2;
  --accent2: #ffd4a8;
  --accent-glow: rgba(255, 224, 194, 0.15);
  --cyan: #2dd4bf;
  --cyan-glow: rgba(45, 212, 191, 0.15);
  --pink: #f472b6;
  --pink-glow: rgba(244, 114, 182, 0.15);
  --gold: #fbbf24;
  --gold-glow: rgba(251, 191, 36, 0.12);
  --orange: #fb923c;
  --red: #e54d2e;
  --green: #34d399;
  --blue: #60a5fa;
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.5);
  --theme-toggle-bg: var(--surface2);
  --theme-toggle-icon: "🌙";
}

/* ── 白天背景装饰 ── */
[data-theme="day"] body::before {
  background: radial-gradient(ellipse 80% 60% at 10% 20%, rgba(100,74,64,0.03) 0%, transparent 60%),
              radial-gradient(ellipse 60% 80% at 90% 80%, rgba(100,74,64,0.02) 0%, transparent 60%);
}
[data-theme="day"] .glass-card:hover { box-shadow: 0 4px 20px rgba(100,74,64,0.08); }
[data-theme="day"] .stat-card:hover { box-shadow: 0 4px 16px rgba(100,74,64,0.06); }
[data-theme="day"] .data-table tr:hover { background: rgba(100,74,64,0.03); }
[data-theme="day"] .toast { background: var(--surface); box-shadow: 0 4px 16px rgba(0,0,0,0.06); }
[data-theme="day"] img:not(.no-adapt) { box-shadow: 0 2px 8px rgba(100,74,64,0.06); }

/* ── 晚上背景装饰 ── */
[data-theme="night"] body::before {
  background: radial-gradient(ellipse 80% 60% at 10% 20%, rgba(255,224,194,0.04) 0%, transparent 60%),
              radial-gradient(ellipse 60% 80% at 90% 80%, rgba(255,224,194,0.03) 0%, transparent 60%);
}
[data-theme="night"] .glass-card:hover { box-shadow: 0 4px 20px rgba(255,224,194,0.06); }
[data-theme="night"] .stat-card:hover { box-shadow: 0 4px 16px rgba(255,224,194,0.05); }
[data-theme="night"] .data-table tr:hover { background: rgba(255,224,194,0.03); }
[data-theme="night"] .toast { background: var(--surface); box-shadow: 0 4px 16px rgba(0,0,0,0.3); }
[data-theme="night"] img:not(.no-adapt) { box-shadow: 0 2px 12px rgba(0,0,0,0.3); }

/* ── 通用部分（保持不变） ── */

/* === GLASS === */
.glass-card { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; transition: all 0.2s; }
.glass-card:hover { box-shadow: 0 4px 20px rgba(124,92,252,0.08); }

/* === STAT === */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 16px; text-align: center; transition: all 0.2s; }
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card .num { font-size: 1.6rem; font-weight: 900; color: var(--accent); line-height: 1.2; }
.stat-card .label { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }
.stat-card .sub { font-size: 0.7rem; color: var(--text-dim); margin-top: 1px; }

/* === TABLE === */
.data-table { width: 100%; border-collapse: separate; border-spacing: 0; }
.data-table th { background: var(--surface2); padding: 10px 12px; font-size: 0.75rem; font-weight: 700; color: var(--text-muted); text-align: left; border-bottom: 2px solid var(--border); }
.data-table td { padding: 10px 12px; font-size: 0.82rem; border-bottom: 1px solid var(--border); }
.data-table tr:hover { background: rgba(124,92,252,0.03); }

/* === BTN === */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 4px; padding: 8px 18px; border-radius: var(--radius-sm); font-size: 0.82rem; font-weight: 600; cursor: pointer; border: none; font-family: inherit; transition: all 0.15s; text-decoration: none; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); }
.btn-success { background: var(--green); color: #fff; }
.btn-danger { background: var(--red); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 0.75rem; }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--border); }

/* === INPUT === */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 0.78rem; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.form-input { width: 100%; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text); font-size: 0.85rem; outline: none; font-family: inherit; transition: border-color 0.15s; }
.form-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
select.form-input { cursor: pointer; }

/* === MODAL === */
.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 5000; justify-content: center; align-items: center; }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px; max-width: 480px; width: 90%; max-height: 85vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* === TOAST === */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 9999; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: var(--radius-sm); background: var(--surface2); border: 1px solid var(--border); color: var(--text); font-size: 0.85rem; box-shadow: var(--shadow); animation: toastIn 0.3s ease; }
.toast.error { border-left: 3px solid var(--red); }
.toast.success { border-left: 3px solid var(--green); }
.toast.info { border-left: 3px solid var(--accent); }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

/* === EMPTY === */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.5; }

/* === FADE === */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes badgePulse { 0%,100%{opacity:1} 50%{opacity:0.6} }
.page-wrap { animation: fadeInUp 0.4s ease-out; }

/* === IMG ADAPT === */
[data-theme="night"] img:not(.no-adapt) { border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,0.3); }

/* === BOTTOM TAB BAR === */
.bottom-tab-bar { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 800; background: var(--surface); border-top: 1px solid var(--border); padding: 6px 0 env(safe-area-inset-bottom, 8px); backdrop-filter: blur(16px); }
.bottom-tab-bar .tab-list { display: flex; justify-content: space-around; align-items: center; max-width: 500px; margin: 0 auto; }
.bottom-tab-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 12px; border-radius: 12px; text-decoration: none; color: var(--text-dim); font-size: 0.65rem; font-weight: 500; transition: all 0.2s; cursor: pointer; border: none; background: none; font-family: inherit; }
.bottom-tab-item .tab-icon { font-size: 1.3rem; line-height: 1; }
.bottom-tab-item.active { color: var(--accent); }

/* === ONBOARD === */
.onboard-overlay { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 2000; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; }
.onboard-overlay.hidden { display: none !important; }
.onboard-bubble { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px 24px; max-width: 340px; width: 90%; text-align: center; box-shadow: 0 20px 60px rgba(0,0,0,0.4); margin: auto; }
.onboard-bubble .bubble-title { font-size: 1.15rem; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.onboard-bubble .bubble-desc { font-size: 0.88rem; color: var(--text-muted); line-height: 1.7; margin-bottom: 20px; }
.onboard-bubble .bubble-actions { display: flex; gap: 10px; justify-content: center; }

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .page-wrap { padding: 16px 16px 80px; }
  .top-nav { flex-direction: column; gap: 12px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .bottom-tab-bar { display: block; }
  .skeleton-grid { grid-template-columns: 1fr; }
}

/* === PWA === */
@media (display-mode: standalone) { body { padding-top: env(safe-area-inset-top); } }

/* ── Force dark backgrounds for night ── */
[data-theme="night"] { --force-dark: true; }
[data-theme="night"] .stat-card,
[data-theme="night"] .glass-card,
[data-theme="night"] .form-input,
[data-theme="night"] select.form-input,
[data-theme="night"] .toast,
[data-theme="night"] .data-table th,
[data-theme="night"] .data-table td,
[data-theme="night"] .modal-box,
[data-theme="night"] .sidebar,
[data-theme="night"] .sidebar-nav a:hover,
[data-theme="night"] .sidebar-nav button:hover,
[data-theme="night"] .sidebar-bottom button:hover,
[data-theme="night"] .sidebar-bottom a:hover,
[data-theme="night"] .header-btn,
[data-theme="night"] .worker-card,
[data-theme="night"] .section-card,
[data-theme="night"] .pending-item { background: var(--surface) !important; }
[data-theme="night"] .theme-menu { background: var(--surface2) !important; }
[data-theme="night"] body { background: #111111 !important; }
[data-theme="night"] .main-area,
[data-theme="night"] .main { background: #111111; }
[data-theme="night"] input,
[data-theme="night"] textarea,
[data-theme="night"] select { background: var(--bg) !important; color: var(--text) !important; }

/* ===== Admin Dark Theme (added by fix) ===== */
[data-theme="night"] {
  --card: #191919;
  --ring: #ffe0c2;
  --input: #484848;
  --muted: #222222;
  --accent: #2a2a2a;
  --border: #201e18;
  --radius: 0.5rem;
  --chart-1: #ffe0c2;
  --chart-2: #393028;
  --chart-3: #2a2a2a;
  --chart-4: #42382e;
  --chart-5: #ffe0c1;
  --popover: #191919;
  --primary: #ffe0c2;
  --sidebar: #18181b;
  --secondary: #393028;
  --background: #111111;
  --foreground: #eeeeee;
  --destructive: #e54d2e;
  --sidebar-ring: #d4d4d8;
  --sidebar-accent: #27272a;
  --sidebar-border: #27272a;
  --card-foreground: #eeeeee;
  --sidebar-primary: #1d4ed8;
  --muted-foreground: #b4b4b4;
  --accent-foreground: #eeeeee;
  --popover-foreground: #eeeeee;
  --primary-foreground: #081a1b;
  --sidebar-foreground: #f4f4f5;
  --secondary-foreground: #ffe0c2;
  --destructive-foreground: #ffffff;
  --sidebar-accent-foreground: #f4f4f5;
  --sidebar-primary-foreground: #ffffff;
}

[data-theme="day"] {
  --card: #fcfcfc;
  --ring: #644a40;
  --input: #d8d8d8;
  --muted: #efefef;
  --accent: #e8e8e8;
  --border: #d8d8d8;
  --radius: 0.5rem;
  --chart-1: #644a40;
  --chart-2: #ffdfb5;
  --chart-3: #e8e8e8;
  --chart-4: #ffe6c4;
  --chart-5: #66493e;
  --popover: #fcfcfc;
  --primary: #644a40;
  --sidebar: #fbfbfb;
  --secondary: #ffdfb5;
  --background: #f9f9f9;
  --foreground: #202020;
  --destructive: #e54d2e;
  --sidebar-ring: #b5b5b5;
  --sidebar-accent: #f7f7f7;
  --sidebar-border: #ebebeb;
  --card-foreground: #202020;
  --sidebar-primary: #343434;
  --muted-foreground: #646464;
  --accent-foreground: #202020;
  --popover-foreground: #202020;
  --primary-foreground: #ffffff;
  --sidebar-foreground: #252525;
  --secondary-foreground: #582d1d;
  --destructive-foreground: #ffffff;
  --sidebar-accent-foreground: #343434;
  --sidebar-primary-foreground: #fbfbfb;
}
