/**
 * 设计系统 - Design Tokens
 * 统一的设计规范，降低决策成本
 */

:root {
  /* ==================== 颜色系统 ==================== */

  /* 主色 */
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-active: #1d4ed8;
  --primary-light: #dbeafe;

  /* 成功 */
  --success: #10b981;
  --success-light: #d1fae5;

  /* 警告 */
  --warning: #f59e0b;
  --warning-light: #fef3c7;

  /* 错误/危险 */
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --error: var(--danger);

  /* 信息 */
  --info: #06b6d4;
  --info-light: #cffafe;

  /* 中性色 */
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* 语义化颜色 - 浅色模式 */
  --bg-white: #ffffff;
  --bg-light: var(--gray-50);
  --bg-gray: var(--gray-100);

  --text-primary: var(--gray-900);
  --text-secondary: var(--gray-600);
  --text-tertiary: var(--gray-400);
  --text-disabled: var(--gray-300);

  --border: var(--gray-200);
  --border-light: var(--gray-100);
  --border-dark: var(--gray-300);

  /* ==================== 间距系统（8px基准） ==================== */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* ==================== 字体系统 ==================== */
  --font-xs: 12px;
  --font-sm: 14px;
  --font-base: 16px;
  --font-lg: 18px;
  --font-xl: 20px;
  --font-2xl: 24px;
  --font-3xl: 32px;

  --font-normal: 400;
  --font-medium: 500;
  --font-semibold: 600;
  --font-bold: 700;

  --line-height-tight: 1.25;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.75;

  /* ==================== 圆角系统 ==================== */
  --radius-none: 0;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-2xl: 24px;
  --radius-full: 9999px;

  /* ==================== 阴影系统 ==================== */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.12);
  --shadow-2xl: 0 25px 50px rgba(0, 0, 0, 0.15);

  /* ==================== 动画系统 ==================== */
  --duration-fast: 150ms;
  --duration-base: 250ms;
  --duration-slow: 350ms;
  --duration-slower: 500ms;

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

  /* ==================== Z-index系统 ==================== */
  --z-base: 0;
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
}

/* ==================== 暗色模式 ==================== */
[data-theme="dark"] {
  --bg-white: var(--gray-900);
  --bg-light: var(--gray-800);
  --bg-gray: var(--gray-700);

  --text-primary: var(--gray-50);
  --text-secondary: var(--gray-300);
  --text-tertiary: var(--gray-500);
  --text-disabled: var(--gray-600);

  --border: var(--gray-700);
  --border-light: var(--gray-800);
  --border-dark: var(--gray-600);

  /* 暗色模式下调整阴影 */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.6);
}

/* ==================== 表单必填字段标识 ==================== */
/* 自动为 required 字段的 label 添加红色星号 */
.form-label:has(+ input[required])::after,
.form-label:has(+ select[required])::after,
.form-label:has(+ textarea[required])::after,
label:has(+ input[required])::after,
label:has(+ select[required])::after,
label:has(+ textarea[required])::after {
  content: " *";
  color: var(--danger);
  font-weight: var(--font-semibold);
  margin-left: 2px;
}

/* 针对某些布局，input/select在label内部的情况 */
label:has(input[required])::before,
label:has(select[required])::before,
label:has(textarea[required])::before {
  content: "* ";
  color: var(--danger);
  font-weight: var(--font-semibold);
  margin-right: 2px;
}
