/**
 * iOS 风格设计系统
 * 
 * 配色、材质、圆角、阴影、动效符合 iOS 设计语言
 * 支持明暗模式
 */

/* ========== 设计 Token ========== */
:root {
  /* iOS 系统色 - 浅色模式 */
  --system-blue: #007AFF;
  --system-green: #34C759;
  --system-orange: #FF9500;
  --system-red: #FF3B30;
  --system-indigo: #5856D6;
  --system-purple: #AF52DE;
  --system-teal: #5AC8FA;
  --system-gray: #8E8E93;
  
  /* 背景层级 */
  --system-background: #FFFFFF;
  --secondary-system-background: #F2F2F7;
  --tertiary-system-background: #FFFFFF;
  --grouped-background: #F2F2F7;
  
  /* 文字层级 */
  --label: #000000;
  --secondary-label: #3C3C43;
  --tertiary-label: #3C3C4399;
  --quaternary-label: #3C3C432E;
  --placeholder-text: #3C3C434D;
  
  /* 填充色 */
  --system-fill: #78788033;
  --secondary-system-fill: #78788029;
  --tertiary-system-fill: #7676801F;
  --quaternary-system-fill: #74748014;
  
  /* 分隔线 */
  --separator: #3C3C4336;
  --opaque-separator: #C6C6C8;
  
  /* 卡片样式 */
  --card-background: #FFFFFF;
  --card-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
  --card-radius: 16px;
  
  /* 毛玻璃效果 */
  --glass-background: rgba(255, 255, 255, 0.72);
  --glass-blur: blur(20px);
  
  /* 动效时长 */
  --duration-micro: 150ms;
  --duration-normal: 300ms;
  --duration-page: 400ms;
  --duration-success: 700ms;
  
  /* 缓动函数 */
  --ease-default: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
}

/* 暗色模式 */
@media (prefers-color-scheme: dark) {
  :root {
    --system-blue: #0A84FF;
    --system-green: #30D158;
    --system-orange: #FF9F0A;
    --system-red: #FF453A;
    --system-indigo: #5E5CE6;
    --system-purple: #BF5AF2;
    --system-teal: #64D2FF;
    --system-gray: #8E8E93;
    
    --system-background: #000000;
    --secondary-system-background: #1C1C1E;
    --tertiary-system-background: #2C2C2E;
    --grouped-background: #000000;
    
    --label: #FFFFFF;
    --secondary-label: #EBEBF5;
    --tertiary-label: #EBEBF599;
    --quaternary-label: #EBEBF52E;
    --placeholder-text: #EBEBF54D;
    
    --system-fill: #78788052;
    --secondary-system-fill: #78788047;
    --tertiary-system-fill: #7676803D;
    --quaternary-system-fill: #7474802E;
    
    --separator: #54545899;
    --opaque-separator: #38383A;
    
    --card-background: #1C1C1E;
    --card-shadow: 0 2px 20px rgba(0, 0, 0, 0.4);
    
    --glass-background: rgba(28, 28, 30, 0.72);
  }
}

/* ========== 基础样式 ========== */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 17px;
  line-height: 1.47059;
  color: var(--label);
  background-color: var(--grouped-background);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ========== 排版 ========== */
.title-1 {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.21429;
  letter-spacing: 0.36px;
}

.title-2 {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.27273;
  letter-spacing: 0.35px;
}

.title-3 {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.38px;
}

.headline {
  font-size: 17px;
  font-weight: 600;
  line-height: 1.29412;
  letter-spacing: -0.41px;
}

.body {
  font-size: 17px;
  font-weight: 400;
  line-height: 1.47059;
  letter-spacing: -0.41px;
}

.callout {
  font-size: 16px;
  font-weight: 400;
  line-height: 1.3125;
  letter-spacing: -0.31px;
}

.subheadline {
  font-size: 15px;
  font-weight: 400;
  line-height: 1.33333;
  letter-spacing: -0.23px;
}

.footnote {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.38462;
  letter-spacing: -0.08px;
}

.caption-1 {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.33333;
}

.caption-2 {
  font-size: 11px;
  font-weight: 400;
  line-height: 1.09091;
  letter-spacing: 0.07px;
}

/* ========== 容器 ========== */
.container {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 0 16px;
}

.page {
  min-height: 100vh;
  padding: 44px 0 34px;
}

/* ========== 卡片 ========== */
.card {
  background: var(--card-background);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  padding: 20px;
  margin-bottom: 16px;
}

.card-glass {
  background: var(--glass-background);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.card-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--secondary-label);
  margin-bottom: 8px;
  letter-spacing: 0.6px;
}

/* ========== 按钮 ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 12px 24px;
  border: none;
  border-radius: 12px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--duration-micro) var(--ease-default);
  text-decoration: none;
}

.btn:active {
  transform: scale(0.98);
  opacity: 0.8;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--system-blue);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: #0066d6;
}

.btn-secondary {
  background: var(--system-fill);
  color: var(--system-blue);
}

.btn-danger {
  background: var(--system-red);
  color: white;
}

.btn-success {
  background: var(--system-green);
  color: white;
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-sm {
  min-height: 36px;
  padding: 8px 16px;
  font-size: 15px;
  border-radius: 8px;
}

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

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary-label);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.form-input {
  display: block;
  width: 100%;
  min-height: 50px;
  padding: 12px 16px;
  background: var(--tertiary-system-background);
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 17px;
  color: var(--label);
  transition: all var(--duration-micro) var(--ease-default);
}

.form-input:focus {
  outline: none;
  border-color: var(--system-blue);
  box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.2);
}

.form-input::placeholder {
  color: var(--placeholder-text);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238E8E93' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
}

.form-hint {
  font-size: 13px;
  color: var(--tertiary-label);
  margin-top: 6px;
}

.form-error {
  font-size: 13px;
  color: var(--system-red);
  margin-top: 6px;
}

/* ========== 输入框组 ========== */
.input-group {
  display: flex;
  align-items: stretch;
}

.input-group .form-input {
  border-radius: 12px 0 0 12px;
}

.input-group .btn {
  border-radius: 0 12px 12px 0;
  white-space: nowrap;
}

/* ========== 列表 ========== */
.list {
  background: var(--card-background);
  border-radius: var(--card-radius);
  overflow: hidden;
}

.list-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 0.5px solid var(--separator);
}

.list-item:last-child {
  border-bottom: none;
}

.list-item-content {
  flex: 1;
  min-width: 0;
}

.list-item-title {
  font-size: 17px;
  color: var(--label);
}

.list-item-subtitle {
  font-size: 15px;
  color: var(--secondary-label);
  margin-top: 2px;
}

.list-item-action {
  color: var(--system-blue);
  font-size: 15px;
}

/* ========== 徽章 ========== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.badge-success {
  background: rgba(52, 199, 89, 0.15);
  color: var(--system-green);
}

.badge-warning {
  background: rgba(255, 149, 0, 0.15);
  color: var(--system-orange);
}

.badge-danger {
  background: rgba(255, 59, 48, 0.15);
  color: var(--system-red);
}

.badge-info {
  background: rgba(0, 122, 255, 0.15);
  color: var(--system-blue);
}

.badge-gray {
  background: var(--quaternary-system-fill);
  color: var(--secondary-label);
}

/* ========== 进度步骤 ========== */
.steps {
  display: flex;
  justify-content: space-between;
  margin-bottom: 32px;
  position: relative;
}

.steps::before {
  content: '';
  position: absolute;
  top: 16px;
  left: 24px;
  right: 24px;
  height: 2px;
  background: var(--quaternary-system-fill);
}

.step {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  z-index: 1;
}

.step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--quaternary-system-fill);
  color: var(--tertiary-label);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  transition: all var(--duration-normal) var(--ease-default);
}

.step.active .step-number {
  background: var(--system-blue);
  color: white;
}

.step.completed .step-number {
  background: var(--system-green);
  color: white;
}

.step-label {
  font-size: 11px;
  color: var(--tertiary-label);
  text-align: center;
}

.step.active .step-label,
.step.completed .step-label {
  color: var(--label);
}

/* ========== 动画 ========== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes checkmark {
  0% {
    stroke-dashoffset: 100;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

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

.animate-fade-in {
  animation: fadeIn var(--duration-normal) var(--ease-out) forwards;
}

.animate-slide-in {
  animation: slideIn var(--duration-page) var(--ease-out) forwards;
}

.animate-scale-in {
  animation: scaleIn var(--duration-normal) var(--ease-out) forwards;
}

/* ========== 加载状态 ========== */
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ========== 成功状态 ========== */
.success-icon {
  width: 80px;
  height: 80px;
  margin: 0 auto 24px;
}

.success-icon svg {
  width: 100%;
  height: 100%;
}

.success-icon .circle {
  stroke: var(--system-green);
  stroke-width: 3;
  fill: none;
  stroke-dasharray: 251;
  stroke-dashoffset: 251;
  animation: checkmark var(--duration-success) var(--ease-out) forwards;
}

.success-icon .check {
  stroke: var(--system-green);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  animation: checkmark calc(var(--duration-success) * 0.5) var(--ease-out) 0.3s forwards;
}

/* ========== 消息提示 ========== */
.toast {
  position: fixed;
  top: 50px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--card-background);
  border-radius: 12px;
  padding: 12px 20px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  z-index: 2000;
  opacity: 0;
  transition: all var(--duration-normal) var(--ease-out);
  pointer-events: none;
}

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

.toast-success {
  color: var(--system-green);
}

.toast-error {
  color: var(--system-red);
}

/* ========== 表格 ========== */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
}

.table th,
.table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 0.5px solid var(--separator);
}

.table th {
  font-weight: 600;
  color: var(--secondary-label);
  background: var(--secondary-system-background);
}

.table td {
  color: var(--label);
}

.table tr:last-child td {
  border-bottom: none;
}

/* ========== 分页 ========== */
.pagination {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 20px;
}

.pagination-item {
  min-width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 15px;
  color: var(--label);
  text-decoration: none;
  background: var(--quaternary-system-fill);
  transition: all var(--duration-micro) var(--ease-default);
}

.pagination-item:hover {
  background: var(--tertiary-system-fill);
}

.pagination-item.active {
  background: var(--system-blue);
  color: white;
}

/* ========== 统计卡片 ========== */
.stat-card {
  text-align: center;
  padding: 20px;
}

.stat-value {
  font-size: 34px;
  font-weight: 700;
  color: var(--label);
  line-height: 1.2;
}

.stat-label {
  font-size: 13px;
  color: var(--secondary-label);
  margin-top: 4px;
}

/* ========== 导航 ========== */
.navbar {
  background: var(--glass-background);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-bottom: 0.5px solid var(--separator);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 12px 16px;
}

.navbar-title {
  font-size: 17px;
  font-weight: 600;
  text-align: center;
}

.sidebar {
  width: 280px;
  background: var(--secondary-system-background);
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  padding: 20px 0;
  overflow-y: auto;
}

.sidebar-item {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  color: var(--label);
  text-decoration: none;
  font-size: 15px;
  transition: background var(--duration-micro) var(--ease-default);
}

.sidebar-item:hover {
  background: var(--tertiary-system-fill);
}

.sidebar-item.active {
  background: var(--system-blue);
  color: white;
  border-radius: 0 12px 12px 0;
  margin-right: 12px;
}

.sidebar-icon {
  width: 24px;
  height: 24px;
  margin-right: 12px;
}

.main-content {
  margin-left: 280px;
  padding: 24px;
  min-height: 100vh;
}

/* ========== 移动端适配 ========== */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  
  .main-content {
    margin-left: 0;
    padding: 16px;
  }
  
  .table-container {
    margin: 0 -16px;
  }
  
  .table th,
  .table td {
    padding: 10px 12px;
    font-size: 14px;
  }
  
  .btn {
    min-height: 48px;
  }
  
  .form-input {
    min-height: 48px;
  }
}

/* ========== 抽奖动画 ========== */
.draw-container {
  text-align: center;
  padding: 40px 20px;
}

.draw-number {
  font-size: 72px;
  font-weight: 700;
  color: var(--system-blue);
  line-height: 1;
  margin-bottom: 16px;
  font-variant-numeric: tabular-nums;
}

.draw-number.rolling {
  animation: numberRoll 0.1s linear infinite;
}

@keyframes numberRoll {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ========== 密码切换 ========== */
.password-toggle {
  position: relative;
}

.password-toggle .form-input {
  padding-right: 50px;
}

.password-toggle-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--tertiary-label);
  cursor: pointer;
  padding: 8px;
}

/* ========== 工具类 ========== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--system-blue); }
.text-success { color: var(--system-green); }
.text-warning { color: var(--system-orange); }
.text-danger { color: var(--system-red); }
.text-muted { color: var(--secondary-label); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.p-0 { padding: 0; }
.p-1 { padding: 8px; }
.p-2 { padding: 16px; }
.p-3 { padding: 24px; }

.d-flex { display: flex; }
.flex-column { flex-direction: column; }
.align-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

.w-100 { width: 100%; }
.h-100 { height: 100%; }
