/* 注意：微信小程序 WXSS 不支持 * 通用选择器
   因此使用 page 和常用元素替代 */
page, view, text, input, textarea, button, image, scroll-view {
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box;
}

page {
  font-family: $font-family;
  background-color: $background;
  color: $text-primary;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* 页面容器 */
.app-container {
  max-width: $design-width;
  margin: 0 auto;
  min-height: 100vh;
  background-color: $background;
  position: relative;
}

/* 点击反馈 */
.clickable {
  transition: transform 0.15s ease, opacity 0.15s ease;

  &:active {
    transform: scale(0.98);
    opacity: 0.9;
  }
}

.clickable-sm {
  transition: transform 0.15s ease;

  &:active {
    transform: scale(0.95);
  }
}

/* 禁用状态 */
.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* ==================== 卡片（原型：白底圆角阴影，无边框） ==================== */
.card {
  background-color: $card-bg;
  border-radius: $radius-card;
  padding: $card-padding;
  margin-bottom: 12px;
  box-shadow: $shadow-card;
  overflow: hidden;

  &:active {
    opacity: 0.95;
  }
}

/* ==================== 按钮（原型：渐变） ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border-radius: $radius-button;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  transition: opacity 0.15s ease, transform 0.15s ease;
  border: none;

  &:active {
    transform: scale(0.98);
    opacity: 0.9;
  }
}

.btn-primary {
  background: $gradient-primary;
  color: #fff;
}

.btn-success {
  background: $gradient-success;
  color: #fff;
}

.btn-warning {
  background: $gradient-warning;
  color: #fff;
}

.btn-danger {
  background: $gradient-danger;
  color: #fff;
}

.btn-secondary {
  background-color: $surface;
  color: $text-primary;
}

/* ==================== 状态标签 ==================== */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: $radius-tag;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.3;
}

.tag-primary {
  background-color: $primary-light;
  color: $primary;
}

.tag-success {
  background-color: $success-light;
  color: $success-dark;
}

.tag-warning {
  background-color: $warning-light;
  color: $warning-dark;
}

.tag-danger {
  background-color: $danger-light;
  color: $danger-dark;
}

.tag-gray {
  background-color: $surface;
  color: $text-secondary;
}

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

/* 表单选择器（picker 用） */
.form-select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid $border-color;
  border-radius: $radius-button;
  font-size: 15px;
  color: $text-primary;
  background: $card-bg;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  line-height: 1.4;
  min-height: 44px;
}

/* ==================== 表单 ==================== */
.form-input,
.form-textarea {
  width: 100%;
  font-size: 15px;
  color: $text-primary;
  box-sizing: border-box;
  line-height: 1.4;
}

.form-input,
.form-input :deep(.uni-easyinput__content) {
  min-height: 44px;
  height: 44px;
  padding: 0 14px !important;
  border: 1px solid $border-color !important;
  border-radius: $radius-button !important;
  background-color: $card-bg !important;
}

.form-input :deep(.uni-easyinput__content-input) {
  height: 42px;
  min-height: 42px;
  font-size: 15px;
  color: $text-primary;
}

.form-input :deep(.uni-easyinput__placeholder-class) {
  color: $text-tertiary !important;
  font-size: 15px;
}

/* uni-easyinput 聚焦状态 */
.form-input :deep(.uni-easyinput__content.focus) {
  border-color: $primary !important;
}

/* uni-easyinput 错误状态 */
.form-input :deep(.uni-easyinput__content.uni-easyinput__content-error) {
  border-color: $danger !important;
}

.form-textarea {
  padding: 12px 14px;
  border: 1px solid $border-color;
  border-radius: $radius-button;
  background-color: $card-bg;
  min-height: 100px;
}

.form-input-readonly {
  width: 100%;
  min-height: 44px;
  padding: 12px 14px;
  border: 1px solid $border-color;
  border-radius: $radius-button;
  font-size: 15px;
  color: $text-secondary;
  background-color: $surface;
  box-sizing: border-box;
  line-height: 1.4;
  display: flex;
  align-items: center;
}

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  color: $text-secondary;
  margin-bottom: 8px;
}

/* ==================== 详情页区块标题（原型带图标） ==================== */
.detail-section-title {
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  color: $text-primary;
  border-bottom: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
  margin-bottom: 0;
}

/* ==================== 详情行 ==================== */
.detail-row {
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  border-bottom: 1px solid #f5f5f5;

  &:last-child {
    border-bottom: none;
  }
}

.detail-label {
  color: $text-secondary;
  font-size: 14px;
  flex-shrink: 0;
  font-weight: 400;
}

.detail-value {
  color: $text-primary;
  font-size: 14px;
  text-align: right;
  flex: 1;
  margin-left: 12px;
  font-weight: 500;
  word-break: break-all;
}

/* ==================== 空状态 ==================== */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  min-height: 200px;
}

/* ==================== 进度条 ==================== */
.progress-bar-track {
  height: 6px;
  background: $border-color;
  border-radius: 3px;
  position: relative;
  overflow: hidden;
}

.progress-bar-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background-color: $primary;
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ==================== 筛选标签 ==================== */
.filter-tab {
  flex-shrink: 0;
  padding: 6px 16px;
  border-radius: $radius-pill;
  font-size: 13px;
  font-weight: 500;
  color: $text-secondary;
  background: $surface;
  border: 1px solid $border-color;
  transition: all 0.15s ease;

  &.active {
    background: $primary;
    color: #fff;
    border-color: $primary;
  }

  &:active {
    transform: scale(0.95);
  }
}

/* ==================== 统计卡片（无边框） ==================== */
.stat-card {
  background: $card-bg;
  border-radius: $radius-card;
  padding: 16px;
  box-shadow: $shadow-card;
}

/* ==================== 图标容器 ==================== */
.icon-box {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: $primary-light;
  color: $primary;
}

/* ==================== 文字样式 ==================== */
.text-desc {
  font-size: 13px;
  color: $text-tertiary;
  line-height: 1.5;
}

.stat-number {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: $text-primary;
}

.section-title {
  font-size: 17px;
  font-weight: 700;
  color: $text-primary;
}

/* ==================== 安全区域 & 其他 ==================== */
.safe-bottom {
  padding-bottom: constant(safe-area-inset-bottom);
  padding-bottom: env(safe-area-inset-bottom);
}

.hide-scrollbar::-webkit-scrollbar {
  display: none;
}

.hide-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.list-item {
  background: $card-bg;
  padding: 16px;
  border-bottom: 1px solid $border-color;

  &:last-child {
    border-bottom: none;
  }
}

/* ==================== 顶部渐变区域 ==================== */
.header-gradient {
  background: $gradient-topbar;
}

/* ==================== active 状态（WXSS 兼容） ==================== */
.active-bg-gray-50:active {
  background-color: #f9fafb;
}

/* ==========================================================
   以下为 TailwindCSS 替代类（全面兼容小程序 WXSS）
   ========================================================== */

/* ---------- Flexbox ---------- */
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.flex-1 { flex: 1 1 0%; }
.flex-row { flex-direction: row; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.flex-nowrap { flex-wrap: nowrap; }
.items-start { align-items: flex-start; }
.items-center { align-items: center; }
.items-end { align-items: flex-end; }
.justify-start { justify-content: flex-start; }
.justify-end { justify-content: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-around { justify-content: space-around; }
.justify-evenly { justify-content: space-evenly; }

/* ---------- Grid ---------- */
.grid { display: grid; }
.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ---------- 文字对齐 ---------- */
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* ---------- 文字大小 ---------- */
.text-xs { font-size: 12px; }
.text-sm { font-size: 13px; }
.text-base { font-size: 15px; }
.text-lg { font-size: 17px; }
.text-xl { font-size: 20px; }
.text-2xl { font-size: 24px; }
.text-3xl { font-size: 30px; }

/* ---------- 文字粗细 ---------- */
.font-normal { font-weight: 400; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

/* ---------- 文字颜色 ---------- */
.text-white { color: #ffffff; }
.text-primary { color: $primary; }
.text-success { color: $success; }
.text-warning { color: $warning; }
.text-danger { color: $danger; }
.text-gray-400 { color: #9ca3af; }
.text-gray-500 { color: #6b7280; }
.text-gray-600 { color: #4b5563; }
.text-gray-700 { color: #374151; }
.text-gray-800 { color: #1f2937; }
.text-gray-900 { color: #111827; }
.text-blue-500 { color: #3b82f6; }
.text-blue-600 { color: #2563eb; }
.text-blue-700 { color: #1d4ed8; }
.text-green-500 { color: #10b981; }
.text-green-600 { color: #059669; }
.text-green-700 { color: #047857; }
.text-orange-500 { color: #f97316; }
.text-orange-600 { color: #ea580c; }
.text-red-500 { color: #ef4444; }
.text-red-600 { color: #dc2626; }
.text-purple-500 { color: #a855f7; }
.text-cyan-500 { color: #06b6d4; }
.text-yellow-600 { color: #d97706; }

/* ---------- 背景颜色 ---------- */
.bg-white { background-color: #ffffff; }
.bg-primary { background-color: $primary; }
.bg-primary-light { background-color: $primary-light; }
.bg-success { background-color: $success; }
.bg-success-light { background-color: $success-light; }
.bg-warning { background-color: $warning; }
.bg-warning-light { background-color: $warning-light; }
.bg-danger { background-color: $danger; }
.bg-danger-light { background-color: $danger-light; }
.bg-gray-50 { background-color: #f9fafb; }
.bg-gray-100 { background-color: #f3f4f6; }
.bg-gray-200 { background-color: #e5e7eb; }
.bg-blue-50 { background-color: #eff6ff; }
.bg-blue-100 { background-color: #dbeafe; }
.bg-green-50 { background-color: #f0fdf4; }
.bg-green-100 { background-color: #dcfce7; }
.bg-orange-50 { background-color: #fff7ed; }
.bg-orange-100 { background-color: #ffedd5; }
.bg-red-50 { background-color: #fef2f2; }
.bg-red-100 { background-color: #fee2e2; }
.bg-purple-50 { background-color: #faf5ff; }
.bg-purple-100 { background-color: #f3e8ff; }
.bg-cyan-50 { background-color: #ecfeff; }
.bg-cyan-100 { background-color: #cffafe; }
.bg-blue-500 { background-color: #3b82f6; }
.bg-green-500 { background-color: #22c55e; }
.bg-red-500 { background-color: #ef4444; }
.bg-yellow-600 { background-color: #d97706; }
.bg-surface { background-color: $surface; }

/* ---------- 间距（padding） ---------- */
.p-1 { padding: 4px; }
.p-2 { padding: 8px; }
.p-3 { padding: 12px; }
.p-4 { padding: 16px; }
.p-5 { padding: 20px; }
.p-6 { padding: 24px; }

.px-1 { padding-left: 4px; padding-right: 4px; }
.px-2 { padding-left: 8px; padding-right: 8px; }
.px-3 { padding-left: 12px; padding-right: 12px; }
.px-4 { padding-left: 16px; padding-right: 16px; }
.px-5 { padding-left: 20px; padding-right: 20px; }
.px-6 { padding-left: 24px; padding-right: 24px; }

.py-1 { padding-top: 4px; padding-bottom: 4px; }
.py-2 { padding-top: 8px; padding-bottom: 8px; }
.py-3 { padding-top: 12px; padding-bottom: 12px; }
.py-4 { padding-top: 16px; padding-bottom: 16px; }
.py-5 { padding-top: 20px; padding-bottom: 20px; }
.py-6 { padding-top: 24px; padding-bottom: 24px; }
.py-8 { padding-top: 32px; padding-bottom: 32px; }
.py-10 { padding-top: 40px; padding-bottom: 40px; }
.py-16 { padding-top: 64px; padding-bottom: 64px; }
.py-20 { padding-top: 80px; padding-bottom: 80px; }

.pt-1 { padding-top: 4px; }
.pt-2 { padding-top: 8px; }
.pt-3 { padding-top: 12px; }
.pt-4 { padding-top: 16px; }
.pt-6 { padding-top: 24px; }
.pt-8 { padding-top: 32px; }

.pb-2 { padding-bottom: 8px; }
.pb-4 { padding-bottom: 16px; }
.pb-6 { padding-bottom: 24px; }
.pb-8 { padding-bottom: 32px; }
.pb-16 { padding-bottom: 64px; }
.pb-24 { padding-bottom: 96px; }

.pl-2 { padding-left: 8px; }
.pl-4 { padding-left: 16px; }
.pl-6 { padding-left: 24px; }

.pr-2 { padding-right: 8px; }
.pr-4 { padding-right: 16px; }

/* ---------- 间距（margin） ---------- */
.m-0 { margin: 0; }
.m-1 { margin: 4px; }
.m-2 { margin: 8px; }
.m-3 { margin: 12px; }
.m-4 { margin: 16px; }

.mx-auto { margin-left: auto; margin-right: auto; }
.mx-2 { margin-left: 8px; margin-right: 8px; }
.mx-4 { margin-left: 16px; margin-right: 16px; }

.my-1 { margin-top: 4px; margin-bottom: 4px; }
.my-2 { margin-top: 8px; margin-bottom: 8px; }
.my-3 { margin-top: 12px; margin-bottom: 12px; }
.my-4 { margin-top: 16px; margin-bottom: 16px; }

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

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

.ml-1 { margin-left: 4px; }
.ml-2 { margin-left: 8px; }
.ml-3 { margin-left: 12px; }
.ml-4 { margin-left: 16px; }
.ml-auto { margin-left: auto; }

.mr-1 { margin-right: 4px; }
.mr-2 { margin-right: 8px; }
.mr-3 { margin-right: 12px; }
.mr-4 { margin-right: 16px; }

/* ---------- 尺寸（width/height） ---------- */
.w-full { width: 100%; }
.w-px { width: 1px; }
.w-3 { width: 12px; }
.w-4 { width: 16px; }
.w-5 { width: 20px; }
.w-6 { width: 24px; }
.w-8 { width: 32px; }
.w-10 { width: 40px; }
.w-12 { width: 48px; }
.w-16 { width: 64px; }
.w-24 { width: 96px; }

.min-w-0 { min-width: 0px; }
.min-w-5 { min-width: 20px; }

.h-full { height: 100%; }
.h-3 { height: 12px; }
.h-4 { height: 16px; }
.h-5 { height: 20px; }
.h-6 { height: 24px; }
.h-8 { height: 32px; }
.h-10 { height: 40px; }
.h-12 { height: 48px; }
.h-16 { height: 64px; }
.h-20 { height: 80px; }
.h-24 { height: 96px; }

/* ---------- 圆角 ---------- */
.rounded { border-radius: 4px; }
.rounded-sm { border-radius: 2px; }
.rounded-md { border-radius: 6px; }
.rounded-lg { border-radius: 8px; }
.rounded-xl { border-radius: 12px; }
.rounded-2xl { border-radius: 16px; }
.rounded-full { border-radius: 9999px; }
.rounded-none { border-radius: 0; }

/* ---------- 边框 ---------- */
.border { border: 1px solid $border-color; }
.border-t { border-top: 1px solid $border-color; }
.border-b { border-bottom: 1px solid $border-color; }
.border-l { border-left: 1px solid $border-color; }
.border-r { border-right: 1px solid $border-color; }
.border-none { border: none; }

.border-dashed { border-style: dashed; }
.border-gray-100 { border-color: #f3f4f6; }
.border-gray-200 { border-color: #e5e7eb; }
.border-gray-300 { border-color: #d1d5db; }

/* ---------- 定位 ---------- */
.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

.top-0 { top: 0; }
.top-1 { top: 4px; }
.right-0 { right: 0; }
.right-1 { right: 4px; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }

.z-0 { z-index: 0; }
.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-30 { z-index: 30; }
.z-40 { z-index: 40; }

/* ---------- 显示 ---------- */
.block { display: block; }
.inline-block { display: inline-block; }
.inline { display: inline; }
.hidden { display: none; }

/* ---------- 溢出 ---------- */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }

/* ---------- 文字截断 ---------- */
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.whitespace-nowrap { white-space: nowrap; }
.break-all { word-break: break-all; }
.break-words { overflow-wrap: break-word; }

/* ---------- 行高 ---------- */
.leading-none { line-height: 1; }
.leading-tight { line-height: 1.25; }
.leading-snug { line-height: 1.375; }
.leading-normal { line-height: 1.5; }
.leading-relaxed { line-height: 1.625; }

/* ---------- 透明度和交互 ---------- */
.opacity-50 { opacity: 0.5; }
.opacity-90 { opacity: 0.9; }
.pointer-events-none { pointer-events: none; }

/* ---------- 其他常用 ---------- */
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.gap-y-2 > view + view { margin-top: 8px; }
.gap-y-3 > view + view { margin-top: 12px; }
.gap-y-4 > view + view { margin-top: 16px; }

.space-y-1 > view + view { margin-top: 4px; }
.space-y-2 > view + view { margin-top: 8px; }
.space-y-3 > view + view { margin-top: 12px; }
.space-y-4 > view + view { margin-top: 16px; }

.space-x-1 > view + view { margin-left: 4px; }
.space-x-2 > view + view { margin-left: 8px; }
.space-x-3 > view + view { margin-left: 12px; }
.space-x-4 > view + view { margin-left: 16px; }

.flex-shrink-0 { flex-shrink: 0; }

/* 装饰性下划线删除 */
.line-through { text-decoration: line-through; }

/* 旋转 */
.animate-spin {
  animation: spin 1s linear infinite;
}

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