/**
 * 聆悉 Lycence — 智慧化客户体验设计系统
 * Style: 人文温度 (warm terra palette) + 一次一题的对话式作答流程
 * Inspired by Typeform's conversational model + 咨询报告质感
 * Brand: 聆悉 Lycence (Provided by 斐绩咨询)
 */

/* ========== Design Tokens ========== */
:root {
  /* Colors — 人文温度 · 暖陶土色板 */
  --bg-canvas: #FBF7F2;
  --bg-surface: #FFFFFF;
  --bg-surface-elevated: #F4EFE8;
  --bg-overlay: rgba(46, 41, 37, 0.04);
  --bg-hover: rgba(180, 90, 60, 0.06);

  /* Text */
  --text-primary: #2E2925;
  --text-secondary: #6B625A;
  --text-tertiary: #A2988C;
  --text-inverse: #FFFFFF;
  --text-accent: #B45A3C;
  --text-accent-hover: #8C4430;

  /* Accent — 赤陶 Terra (人文 + 咨询权威) */
  --accent: #B45A3C;
  --accent-hover: #8C4430;
  --accent-light: rgba(180, 90, 60, 0.08);
  --accent-border: rgba(180, 90, 60, 0.2);
  --accent-warm: #D9A441;

  /* Status colors */
  --color-success: #2E7D5B;
  --color-success-bg: rgba(46, 125, 91, 0.08);
  --color-warning: #B8860B;
  --color-warning-bg: rgba(184, 134, 11, 0.08);
  --color-error: #C44545;
  --color-error-bg: rgba(196, 69, 69, 0.08);
  --color-info: #B45A3C;
  --color-info-bg: rgba(180, 90, 60, 0.06);

  /* Borders */
  --border-subtle: rgba(46, 41, 37, 0.08);
  --border-default: rgba(46, 41, 37, 0.12);
  --border-strong: rgba(46, 41, 37, 0.2);
  --border-accent: var(--accent);

  /* Spacing — adapted from TraeCode token system */
  --space-0: 0px;
  --space-4: 4px;
  --space-8: 8px;
  --space-10: 10px;
  --space-12: 12px;
  --space-14: 14px;
  --space-16: 16px;
  --space-20: 20px;
  --space-24: 24px;
  --space-32: 32px;
  --space-40: 40px;
  --space-48: 48px;
  --space-64: 64px;
  --space-80: 80px;
  --space-96: 96px;

  /* Radius — from TraeCode */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 9999px;

  /* Typography */
  --font-sans: 'Inter', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
  --font-serif: 'Source Serif 4', 'Noto Serif SC', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Type scale */
  --text-2xs: 11px;
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 28px;
  --text-4xl: 32px;
  --text-5xl: 40px;

  /* Line heights */
  --leading-tight: 1.2;
  --leading-snug: 1.35;
  --leading-normal: 1.5;
  --leading-relaxed: 1.65;
  --leading-loose: 1.8;

  /* Font weights */
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;

  /* Transitions */
  --ease-conversational: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-enter: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-exit: cubic-bezier(0.7, 0, 0.84, 0);
  --duration-fast: 150ms;
  --duration-normal: 200ms;
  --duration-slow: 300ms;

  /* Shadows — soft and warm */
  --shadow-sm: 0 1px 2px rgba(46, 41, 37, 0.04);
  --shadow-md: 0 2px 8px rgba(46, 41, 37, 0.06);
  --shadow-lg: 0 8px 24px rgba(46, 41, 37, 0.08);
  --shadow-xl: 0 16px 48px rgba(46, 41, 37, 0.1);

  /* Layout */
  --content-width: 720px;
  --content-wide: 1080px;
  --nav-height: 64px;
}

/* ========== Reset ========== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  line-height: var(--leading-normal);
  min-height: 100vh;
  font-weight: var(--weight-regular);
}

/* ========== Typography ========== */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: -0.02em;
}

a {
  color: var(--text-accent);
  text-decoration: none;
  transition: color var(--duration-fast) var(--ease-conversational);
}

a:hover { color: var(--text-accent-hover); }

/* ========== Navigation Bar ========== */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: rgba(250, 249, 247, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 1000;
  display: flex;
  align-items: center;
  padding: 0 var(--space-32);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-8);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.navbar-brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-inverse);
  font-size: 14px;
  font-weight: var(--weight-bold);
  flex-shrink: 0;
}

.navbar-brand-mark svg {
  width: 18px;
  height: 18px;
  display: block;
}

.navbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-16);
}

.navbar-link {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: var(--weight-medium);
  transition: color var(--duration-fast);
  padding: var(--space-8) var(--space-4);
}

.navbar-link:hover, .navbar-link.active {
  color: var(--text-accent);
}

/* Language toggle */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-full);
  padding: 3px;
  border: 1px solid var(--border-subtle);
}

.lang-toggle button {
  border: none;
  background: transparent;
  padding: var(--space-4) var(--space-12);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-full);
  transition: all var(--duration-fast);
  font-family: inherit;
}

.lang-toggle button.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* ========== Buttons ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-8);
  padding: var(--space-12) var(--space-24);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  font-family: inherit;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-conversational);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}

.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:disabled {
  background: var(--text-tertiary);
  border-color: var(--text-tertiary);
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  opacity: 0.5;
}

.btn-secondary {
  background: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--text-accent);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
  padding: var(--space-8) var(--space-12);
}

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

.btn-lg {
  padding: var(--space-16) var(--space-32);
  font-size: var(--text-base);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
}

/* ========== Cards ========== */
.card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  transition: all var(--duration-normal) var(--ease-conversational);
}

.card-hover:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.card-body {
  padding: var(--space-24);
}

/* ========== Progress Ring (SVG) ========== */
.progress-ring {
  position: relative;
  width: 160px;
  height: 160px;
}

.progress-ring svg {
  transform: rotate(-90deg);
}

.progress-ring-circle {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  transition: stroke-dashoffset var(--duration-slow) var(--ease-conversational);
}

.progress-ring-bg {
  stroke: var(--border-subtle);
}

.progress-ring-fill {
  stroke: var(--accent);
}

.progress-ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.progress-ring-percent {
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--text-primary);
}

.progress-ring-label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: var(--space-4);
}

/* ========== Linear Progress Bar ========== */
.progress-bar {
  height: 4px;
  background: var(--border-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width var(--duration-slow) var(--ease-conversational);
}

/* ========== Tags / Badges ========== */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-4);
  padding: 3px var(--space-10);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tag-default { background: var(--bg-surface-elevated); color: var(--text-secondary); }
.tag-accent { background: var(--accent-light); color: var(--text-accent); }
.tag-success { background: var(--color-success-bg); color: var(--color-success); }
.tag-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.tag-error { background: var(--color-error-bg); color: var(--color-error); }

/* ========== Status Dot ========== */
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  display: inline-block;
}

.status-dot-not-started { background: var(--text-tertiary); }
.status-dot-in-progress { background: var(--color-warning); }
.status-dot-completed { background: var(--color-success); }

/* ========== Toast ========== */
.toast {
  position: fixed;
  bottom: var(--space-32);
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text-primary);
  color: var(--text-inverse);
  padding: var(--space-12) var(--space-24);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-lg);
  z-index: 9999;
  opacity: 0;
  transition: all var(--duration-normal) var(--ease-enter);
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-success { background: var(--color-success); }
.toast-error { background: var(--color-error); }

/* ========== Form Elements ========== */
.input, .textarea, .select {
  width: 100%;
  padding: var(--space-12) var(--space-16);
  font-size: var(--text-base);
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-md);
  transition: all var(--duration-fast);
  outline: none;
  line-height: var(--leading-normal);
}

.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

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

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

/* Radio & Checkbox as option cards */
.option-card {
  display: flex;
  align-items: center;
  gap: var(--space-12);
  padding: var(--space-16) var(--space-20);
  border: 1.5px solid var(--border-default);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--duration-fast) var(--ease-conversational);
  background: var(--bg-surface);
  font-size: var(--text-base);
  color: var(--text-primary);
  user-select: none;
}

.option-card:hover {
  border-color: var(--accent-border);
  background: var(--bg-hover);
}

.option-card.selected {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--text-accent);
  font-weight: var(--weight-medium);
}

.option-card-indicator {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-strong);
  border-radius: var(--radius-full);
  flex-shrink: 0;
  transition: all var(--duration-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.option-card.checkbox .option-card-indicator {
  border-radius: var(--radius-sm);
}

.option-card.selected .option-card-indicator {
  border-color: var(--accent);
  background: var(--accent);
}

.option-card.selected .option-card-indicator::after {
  content: '';
  width: 8px;
  height: 8px;
  background: var(--text-inverse);
  border-radius: var(--radius-full);
}

.option-card.checkbox.selected .option-card-indicator::after {
  border-radius: 0;
  width: 6px;
  height: 10px;
  border: solid var(--text-inverse);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  background: transparent;
  margin-top: -2px;
}

/* Scale rating */
.scale-group {
  display: flex;
  gap: var(--space-8);
  justify-content: space-between;
}

.scale-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-8);
  cursor: pointer;
  padding: var(--space-12);
  border-radius: var(--radius-md);
  transition: all var(--duration-fast);
}

.scale-option:hover {
  background: var(--bg-hover);
}

.scale-option-num {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--border-default);
  border-radius: var(--radius-full);
  font-size: var(--text-lg);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  transition: all var(--duration-fast);
}

.scale-option.selected .scale-option-num {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--text-inverse);
}

.scale-option-label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  text-align: center;
}

/* ========== Bottom Nav (Mobile) ========== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 56px;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-subtle);
  display: none;
  align-items: center;
  justify-content: space-around;
  z-index: 999;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 10px;
  color: var(--text-tertiary);
  text-decoration: none;
  padding: var(--space-8);
  transition: color var(--duration-fast);
}

.bottom-nav-item.active, .bottom-nav-item:hover {
  color: var(--text-accent);
}

.bottom-nav-icon {
  width: 22px;
  height: 22px;
}

/* ========== Conversational Question Animation ========== */
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInLeft {
  from { opacity: 0; transform: translateX(-30px); }
  to { opacity: 1; transform: translateX(0); }
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.animate-slide-in-right { animation: slideInRight var(--duration-normal) var(--ease-enter) forwards; }
.animate-slide-in-left { animation: slideInLeft var(--duration-normal) var(--ease-enter) forwards; }
.animate-fade-in-up { animation: fadeInUp var(--duration-slow) var(--ease-enter) forwards; }
.animate-fade-in { animation: fadeIn var(--duration-slow) var(--ease-enter) forwards; }

/* Staggered children */
.stagger > * {
  opacity: 0;
  animation: fadeInUp var(--duration-slow) var(--ease-enter) forwards;
}

.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 60ms; }
.stagger > *:nth-child(3) { animation-delay: 120ms; }
.stagger > *:nth-child(4) { animation-delay: 180ms; }
.stagger > *:nth-child(5) { animation-delay: 240ms; }
.stagger > *:nth-child(6) { animation-delay: 300ms; }
.stagger > *:nth-child(7) { animation-delay: 360ms; }
.stagger > *:nth-child(8) { animation-delay: 420ms; }

/* ========== Responsive ========== */
@media (max-width: 768px) {
  :root {
    --space-32: 20px;
    --space-40: 24px;
    --space-48: 28px;
    --space-64: 36px;
  }

  .navbar { padding: 0 var(--space-16); }
  .navbar-brand { font-size: var(--text-base); }

  .bottom-nav { display: flex; }
  body { padding-bottom: 56px; }

  .scale-group { flex-wrap: wrap; }
  .scale-option { min-width: calc(33% - var(--space-8)); }
}

@media (max-width: 1024px) {
  .navbar { padding: 0 var(--space-24); }
}

/* ========== Utility ========== */
.text-center { text-align: center; }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-accent { color: var(--text-accent); }
.font-medium { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.mt-4 { margin-top: var(--space-16); }
.mt-8 { margin-top: var(--space-32); }
.mt-12 { margin-top: var(--space-48); }
.mb-4 { margin-bottom: var(--space-16); }
.mb-8 { margin-bottom: var(--space-32); }
.hidden { display: none; }
.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-4 { gap: var(--space-16); }
.gap-8 { gap: var(--space-32); }
.w-full { width: 100%; }
.max-w-content { max-width: var(--content-width); }
.max-w-wide { max-width: var(--content-wide); }
.mx-auto { margin-left: auto; margin-right: auto; }
