/* ============================================
   搭乘 DaCheng — 设计系统
   温暖 · 简约 · 陪伴感
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* 品牌色（PRD 规定） */
  --color-primary: #264135;      /* 深松绿 - 主色 */
  --color-secondary: #7FA27F;    /* 鼠尾草绿 - 辅助色 */
  --color-accent: #F4C96A;       /* 黄油黄 - 强调色 */
  --color-bg: #FFF6EF;           /* 奶油背景 */
  --color-surface: #E7EDE4;      /* 卡片浅绿背景 */

  --color-text: #23302A;
  --color-text-secondary: #5B6B62;
  --color-text-tertiary: #8B9A91;
  --color-border: rgba(38, 65, 53, 0.10);
  --color-white: #FFFFFF;

  --color-danger: #C96A5A;
  --color-success: #7FA27F;
  --color-warning: #F4C96A;

  /* 深色主题变量（切换时覆盖） */
  --color-bg-dark: #17211C;
  --color-surface-dark: #202D26;
  --color-text-dark: #EDF2EE;

  /* 圆角 & 间距（PRD 8pt Grid） */
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --gap-card: 16px;
  --gap-form: 16px;
  --pad-card: 20px;
  --pad-page: 24px;
  --gap-module: 32px;
  --gap-section: 48px;

  --shadow-card: 0 2px 12px rgba(38, 65, 53, 0.06);
  --shadow-hover: 0 6px 20px rgba(38, 65, 53, 0.10);
  --shadow-float: 0 8px 28px rgba(38, 65, 53, 0.16);

  --font-cn: "HarmonyOS Sans", "MiSans", "Source Han Sans", "PingFang SC", sans-serif;
  --font-en: "Inter", sans-serif;

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --color-bg: #17211C;
  --color-surface: #202D26;
  --color-text: #EDF2EE;
  --color-text-secondary: #A9B8AF;
  --color-text-tertiary: #6E8077;
  --color-border: rgba(237, 242, 238, 0.08);
  --color-white: #1D2A23;
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-en), var(--font-cn);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 16px;
  line-height: 1.6;
  transition: background 200ms var(--ease), color 200ms var(--ease);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--color-accent); color: var(--color-primary); }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }

/* ============ 排版层级 ============ */
h1, .h1 { font-size: 32px; font-weight: 700; letter-spacing: -0.01em; }
h2, .h2 { font-size: 24px; font-weight: 600; letter-spacing: -0.01em; }
h3, .h3 { font-size: 20px; font-weight: 600; }
.body { font-size: 16px; font-weight: 400; }
.caption { font-size: 13px; font-weight: 400; color: var(--color-text-tertiary); }

/* ============ 布局 ============ */
.app-shell {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--color-white);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 20px 12px;
  transition: width 200ms var(--ease);
  position: relative;
}

.sidebar.collapsed { width: 76px; }
.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .user-mini-text { display: none; }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 24px;
}

.sidebar-brand-mark {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--color-primary);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-accent);
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
  overflow: visible;
}
.sidebar-brand-mark.has-logo { background: transparent; border-radius: 0; width: 44px; height: 44px; }

.sidebar-brand-text { font-weight: 700; font-size: 18px; color: var(--color-primary); white-space: nowrap; }

.sidebar-toggle {
  position: absolute;
  top: 22px;
  right: -12px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-card);
  color: var(--color-text-secondary);
  font-size: 12px;
  z-index: 5;
}

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }

.sidebar-group-label {
  font-size: 12px;
  color: var(--color-text-tertiary);
  padding: 16px 12px 6px;
  white-space: nowrap;
}
.sidebar.collapsed .sidebar-group-label { overflow: hidden; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background 150ms var(--ease), color 150ms var(--ease);
}

.nav-item .icon { width: 20px; height: 20px; flex-shrink: 0; display:flex; align-items:center; justify-content:center; }

.nav-item:hover { background: var(--color-surface); color: var(--color-primary); }
.nav-item.active { background: var(--color-primary); color: var(--color-white); }

.nav-item.nav-sub {
  padding-left: 34px;
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-tertiary);
}
.nav-item.nav-sub .icon { font-size: 14px; }
.sidebar.collapsed .nav-item.nav-sub { padding-left: 12px; }

.sidebar-footer {
  border-top: 1px solid var(--color-border);
  padding-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 12px;
}

.user-mini-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--color-secondary);
  display: flex; align-items: center; justify-content: center;
  color: var(--color-white); font-weight: 600; font-size: 13px;
  flex-shrink: 0;
}

.user-mini-text { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.main-area {
  flex: 1;
  min-width: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  height: 64px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 var(--pad-page);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 4;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  color: var(--color-text-tertiary);
}
.search-box input { flex: 1; background: none; outline: none; color: var(--color-text); }

.content {
  flex: 1;
  overflow-y: auto;
  padding: var(--pad-page);
  animation: fadeIn 220ms var(--ease);
}

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

.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--gap-module); flex-wrap: wrap; gap: 12px; }
.page-header .subtitle { color: var(--color-text-secondary); font-size: 14px; margin-top: 4px; }

/* ============ 网格 ============ */
.grid {
  display: grid;
  gap: var(--gap-card);
}
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-12 { grid-template-columns: repeat(12, 1fr); }

@media (max-width: 1000px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* ============ 卡片 ============ */
.card {
  background: var(--color-white);
  border-radius: var(--radius);
  padding: var(--pad-card);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--color-border);
  transition: box-shadow 180ms var(--ease), transform 180ms var(--ease);
}
.card.hoverable:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }

.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.card-title { font-size: 16px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.card-link { font-size: 13px; color: var(--color-secondary); font-weight: 500; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 600;
  transition: all 150ms var(--ease);
  white-space: nowrap;
}
.btn-primary { background: var(--color-primary); color: var(--color-white); }
.btn-primary:hover { background: #1c3329; }
.btn-secondary { background: var(--color-surface); color: var(--color-primary); }
.btn-secondary:hover { background: #dbe4d7; }
.btn-outline { border: 1px solid var(--color-border); color: var(--color-text); }
.btn-outline:hover { background: var(--color-surface); }
.btn-ghost { color: var(--color-text-secondary); padding: 8px 10px; }
.btn-ghost:hover { color: var(--color-primary); background: var(--color-surface); }
.btn-danger { background: var(--color-danger); color: white; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: 50%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ============ 表单 ============ */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--gap-form); }
.field label { font-size: 13px; font-weight: 600; color: var(--color-text-secondary); }
.field input, .field textarea, .field select {
  width: 100%;
  display: block;
  box-sizing: border-box;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  background: var(--color-bg);
  outline: none;
  transition: border-color 150ms var(--ease);
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--color-secondary); }
.field textarea { resize: vertical; min-height: 80px; }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; min-width: 0; }

/* ============ 徽标/标签 ============ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 600;
  background: var(--color-surface);
  color: var(--color-primary);
}
.badge-accent { background: rgba(244, 201, 106, 0.25); color: #8A6A1F; }
.badge-danger { background: rgba(201, 106, 90, 0.15); color: var(--color-danger); }
.badge-success { background: rgba(127, 162, 127, 0.2); color: #3E6B3E; }

/* ============ 进度条 ============ */
.progress-track {
  width: 100%; height: 8px; border-radius: 100px;
  background: var(--color-surface);
  overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 100px;
  background: linear-gradient(90deg, var(--color-secondary), var(--color-primary));
  transition: width 400ms var(--ease);
}

/* ============ 复选框任务行 ============ */
.task-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 4px;
  border-radius: var(--radius-sm);
  transition: background 150ms var(--ease);
}
.task-row:hover { background: var(--color-bg); }
.task-check {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--color-secondary);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: all 150ms var(--ease);
  color: transparent;
}
.task-check.checked { background: var(--color-secondary); color: white; }
.task-row.done .task-title { text-decoration: line-through; color: var(--color-text-tertiary); }
.task-title { flex: 1; font-size: 14px; font-weight: 500; }
.task-meta { font-size: 12px; color: var(--color-text-tertiary); }

/* ============ Empty State ============ */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--color-text-secondary);
}
.empty-state .icon { font-size: 40px; margin-bottom: 10px; opacity: 0.5; }
.empty-state .action { margin-top: 14px; }

/* ============ Toast ============ */
.toast-wrap {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 999;
}
.toast {
  background: var(--color-primary);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-float);
  font-size: 14px;
  animation: toastIn 220ms var(--ease);
  max-width: 320px;
}
.toast.error { background: var(--color-danger); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ============ Modal ============ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(23, 33, 28, 0.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  animation: fadeIn 180ms var(--ease);
  padding: 20px;
}
.modal {
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-float);
  animation: modalPop 220ms var(--ease);
}
@keyframes modalPop { from { opacity: 0; transform: scale(0.96) translateY(6px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }

/* ============ 浮动新增按钮（Universal Create） ============ */
.fab {
  position: fixed;
  bottom: 32px; right: 32px;
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-accent);
  font-size: 26px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow-float);
  transition: transform 150ms var(--ease), background 150ms var(--ease);
  z-index: 50;
}
.fab:hover { transform: scale(1.06) rotate(90deg); background: #1c3329; }

.fab-menu {
  position: fixed;
  bottom: 100px; right: 32px;
  background: var(--color-white);
  border-radius: var(--radius);
  box-shadow: var(--shadow-float);
  padding: 8px;
  display: flex; flex-direction: column; gap: 2px;
  z-index: 51;
  min-width: 180px;
  animation: modalPop 160ms var(--ease);
}
.fab-menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500;
  color: var(--color-text);
}
.fab-menu-item:hover { background: var(--color-surface); }

/* ============ 计时器 ============ */
.timer-display {
  font-size: 56px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--color-primary);
  text-align: center;
  letter-spacing: 0.02em;
}
.timer-presets { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.timer-preset {
  padding: 8px 16px;
  border-radius: 100px;
  border: 1px solid var(--color-border);
  font-size: 13px; font-weight: 600;
  color: var(--color-text-secondary);
}
.timer-preset.active { background: var(--color-primary); color: white; border-color: var(--color-primary); }
.timer-ring-wrap { position: relative; width: 220px; height: 220px; margin: 0 auto; }

/* ============ 登录页 ============ */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
  padding: 20px;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-white);
  border-radius: var(--radius-lg);
  padding: 36px 32px;
  box-shadow: var(--shadow-card);
}
.auth-brand { text-align: center; margin-bottom: 8px; }
.auth-brand .mark {
  width: 88px; height: 88px; border-radius: 16px;
  background: var(--color-primary);
  color: var(--color-accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 22px;
  margin: 0 auto 14px;
  overflow: visible;
}
.auth-brand .mark.has-logo { background: transparent; border-radius: 0; }
.auth-slogan { text-align: center; color: var(--color-text-secondary); font-size: 13px; margin-bottom: 28px; }
.auth-tabs { display: flex; gap: 4px; background: var(--color-bg); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 24px; }
.auth-tab { flex: 1; text-align: center; padding: 8px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; color: var(--color-text-secondary); }
.auth-tab.active { background: var(--color-white); color: var(--color-primary); box-shadow: var(--shadow-card); }
.auth-error { color: var(--color-danger); font-size: 13px; margin-bottom: 12px; min-height: 16px; }

/* ============ Onboarding ============ */
.onboard-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--color-bg); padding: 20px; }
.onboard-card { width: 100%; max-width: 440px; background: var(--color-white); border-radius: var(--radius-lg); padding: 36px 32px; box-shadow: var(--shadow-card); }
.onboard-progress { display: flex; gap: 6px; margin-bottom: 28px; }
.onboard-progress .dot { flex: 1; height: 4px; border-radius: 100px; background: var(--color-surface); }
.onboard-progress .dot.done { background: var(--color-primary); }
.identity-options { display: flex; flex-direction: column; gap: 10px; }
.identity-option {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; border-radius: var(--radius-sm);
  border: 2px solid var(--color-border);
  transition: all 150ms var(--ease);
}
.identity-option.selected { border-color: var(--color-secondary); background: var(--color-surface); }
.mbti-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.mbti-cell {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  border: 2px solid var(--color-border);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  overflow: hidden;
  position: relative;
}
.mbti-cell img { width: 100%; height: 100%; object-fit: cover; }
.mbti-cell.selected { border-color: var(--color-accent); box-shadow: 0 0 0 3px rgba(244,201,106,0.3); }
.mbti-cell .label { position: absolute; bottom: 0; left: 0; right: 0; background: rgba(38,65,53,0.75); color: white; font-size: 10px; text-align: center; padding: 2px 0; }

/* ============ 工具类 ============ */
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }
.w-full { width: 100%; }
.text-center { text-align: center; }
.hidden { display: none !important; }
.loading-spin {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 40; transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
}
