/* ==============================================================================
   Cult UI 现代微交互组件系统 (Vanilla JS + CSS 移植版)
   为通辽智慧农牧服务平台定制：
   1. Animated Number（数字动态平滑递增与滚轮微交互）
   2. Expandable Dossier（穿透式审计卷宗与证据链平滑手风琴展开）
   3. Feature Voting / Audit Decider（合规快速裁决与乐观微交互）
   4. Spotlight & Border Beam（液态玻璃光标聚光灯与高光流转边框）
   ============================================================================== */

:root {
  /* OpenDesign (open-design.ai) 统一现代白瓷与原野常青绿 Design Tokens */
  --brand-primary: #218c00;
  --brand-dark: #218c00;
  --brand-light: #83ff3b;
  --brand-accent: #a3e635;
  --bg-canvas: #fafafa;
  --bg-surface: #ffffff;
  --bg-surface-warm: #ffffff;
  --bg-subtle: #fcfbf9;
  --text-primary: #262626;
  --text-secondary: #71717a;
  --text-muted: #a1a1aa;
  --border-subtle: rgba(0, 0, 0, 0.07);
  --tag-bg: rgba(34, 197, 94, 0.08);
  --tag-text: #218c00;

  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.03);
  --shadow-lg: 0 10px 24px -4px rgba(0, 0, 0, 0.06), 0 4px 8px -4px rgba(0, 0, 0, 0.02);
  --shadow-xl: 0 20px 32px -8px rgba(0, 0, 0, 0.08), 0 8px 16px -6px rgba(0, 0, 0, 0.03);

  --cult-ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --cult-ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --cult-font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

:root.dark {
  --brand-primary: #10b981;
  --brand-dark: #059669;
  --brand-light: #34d399;
  --bg-canvas: #09090b;
  --bg-surface: #121215;
  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;
  --border-subtle: rgba(255, 255, 255, 0.08);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.45);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.55);
  --shadow-lg: 0 10px 20px -3px rgba(0, 0, 0, 0.55);
  --shadow-xl: 0 20px 30px -5px rgba(0, 0, 0, 0.65);
}

/* ── 1. Animated Number（动态平滑数字滚动） ────────────────────────── */
.cult-animated-number {
  font-variant-numeric: tabular-nums;
  display: inline-block;
  transition: transform 0.2s var(--cult-ease-spring);
  will-change: transform, contents;
}

.cult-animated-number.is-animating {
  color: #0284c7;
}

:root.dark .cult-animated-number.is-animating {
  color: #38bdf8;
}

/* 滚轮式计数槽（Odometer Reel Effect） */
.cult-odometer {
  display: inline-flex;
  overflow: hidden;
  height: 1.15em;
  line-height: 1.15em;
  vertical-align: baseline;
  font-variant-numeric: tabular-nums;
}

.cult-odometer-digit {
  display: inline-block;
  transition: transform 0.8s cubic-bezier(0.12, 0.8, 0.32, 1);
  will-change: transform;
}

/* ── 2. Expandable Dossier（穿透式审计证据卷宗展开组件） ─────────────── */
.cult-expandable-card {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: box-shadow 0.25s var(--cult-ease-spring), border-color 0.25s ease;
  margin-bottom: var(--space-md);
  box-shadow: var(--shadow-sm);
}

:root.dark .cult-expandable-card {
  background: var(--bg-surface);
  border-color: rgba(51, 65, 85, 0.75);
}

.cult-expandable-card:hover {
  border-color: rgba(21, 128, 61, 0.35);
  box-shadow: var(--shadow-md);
}

.cult-expandable-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  background: transparent;
  transition: background 0.15s ease;
}

.cult-expandable-header:hover {
  background: rgba(241, 245, 249, 0.6);
}

:root.dark .cult-expandable-header:hover {
  background: rgba(30, 41, 59, 0.5);
}

.cult-expandable-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

:root.dark .cult-expandable-title {
  color: var(--text-primary);
}

.cult-expandable-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.cult-expandable-chevron {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(226, 232, 240, 0.6);
  color: var(--text-secondary);
  font-size: 11px;
  transition: transform 0.35s var(--cult-ease-spring), background 0.2s ease, color 0.2s ease;
}

.cult-expandable-card.is-expanded .cult-expandable-chevron {
  transform: rotate(180deg);
  background: var(--brand-primary);
  color: #ffffff;
}

/* CSS Grid 零开销平滑高度过渡动画 */
.cult-expandable-wrapper {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.38s var(--cult-ease-spring);
}

.cult-expandable-card.is-expanded .cult-expandable-wrapper {
  grid-template-rows: 1fr;
}

.cult-expandable-inner {
  overflow: hidden;
}

.cult-expandable-content {
  padding: 0 16px 16px 16px;
  border-top: 1px dashed rgba(226, 232, 240, 0.9);
  background: rgba(248, 250, 252, 0.6);
}

:root.dark .cult-expandable-content {
  border-top-color: rgba(51, 65, 85, 0.8);
  background: rgba(15, 23, 42, 0.45);
}

/* ── 3. Feature Voting / Audit Decider（合规审验快速裁决小组件） ────── */
.cult-audit-decider {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(241, 245, 249, 0.8);
  padding: 3px 6px;
  border-radius: 999px;
  border: 1px solid rgba(203, 213, 225, 0.7);
  font-size: 12px;
  user-select: none;
}

:root.dark .cult-audit-decider {
  background: rgba(30, 41, 59, 0.7);
  border-color: rgba(51, 65, 85, 0.8);
}

.cult-decide-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: none;
  background: transparent;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  color: #475569;
  transition: all 0.18s var(--cult-ease-spring);
  position: relative;
}

:root.dark .cult-decide-btn {
  color: #cbd5e1;
}

.cult-decide-btn:hover {
  background: rgba(255, 255, 255, 0.95);
  transform: translateY(-1px);
}

.cult-decide-btn.approve:hover,
.cult-decide-btn.approve.active {
  background: #dcfce7;
  color: #218c00;
  box-shadow: 0 2px 6px rgba(34, 197, 94, 0.2);
}

.cult-decide-btn.doubt:hover,
.cult-decide-btn.doubt.active {
  background: #fef3c7;
  color: #b45309;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.2);
}

.cult-decide-btn.reject:hover,
.cult-decide-btn.reject.active {
  background: #fee2e2;
  color: #b91c1c;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.2);
}

.cult-decide-count {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  opacity: 0.85;
}

/* 浮动 +1 微动画 */
@keyframes cultFloatUp {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-16px) scale(1.15);
  }
}

.cult-float-pill {
  position: absolute;
  top: -8px;
  right: -4px;
  font-size: 10px;
  font-weight: 800;
  color: #16a34a;
  pointer-events: none;
  animation: cultFloatUp 0.65s var(--cult-ease-spring) forwards;
}

/* ── 4. Spotlight & Border Beam（聚光灯高光与光束流转） ─────────────── */
.cult-spotlight {
  position: relative;
  overflow: hidden;
}

.cult-spotlight::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  background: radial-gradient(
    380px circle at var(--mouse-x, -999px) var(--mouse-y, -999px),
    rgba(56, 189, 248, 0.15),
    transparent 80%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 1;
}

.cult-spotlight:hover::before {
  opacity: 1;
}

:root.dark .cult-spotlight::before {
  background: radial-gradient(
    420px circle at var(--mouse-x, -999px) var(--mouse-y, -999px),
    rgba(56, 189, 248, 0.22),
    transparent 80%
  );
}

/* 旋转光束流转边框 (Border Beam) */
@keyframes cultBorderBeam {
  100% {
    offset-distance: 100%;
  }
}

.cult-border-beam-box {
  position: relative;
  overflow: hidden;
  border-radius: 14px;
}

.cult-border-beam-box::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  padding: 2px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    transparent 40%,
    rgba(56, 189, 248, 0.8) 50%,
    rgba(124, 58, 237, 0.8) 60%,
    transparent 70%,
    transparent 100%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  background-size: 200% 200%;
  animation: cultBeamRotate 4s linear infinite;
}

@keyframes cultBeamRotate {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* 状态脉冲呼吸灯 */
.cult-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: #10b981;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: cultPulse 2s infinite;
}

.cult-pulse-dot.warning {
  background: #f59e0b;
  box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.7);
}

.cult-pulse-dot.danger {
  background: #ef4444;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
}

@keyframes cultPulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

/* ── 5. Printable Slips & Official Government Receipts (A4 格式化单据与印章) ─── */
.printable-slip-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
  padding: 30px 16px;
}

.printable-slip-container {
  background: #ffffff;
  width: 100%;
  max-width: 820px;
  border-radius: 16px;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  color: #0f172a;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

.slip-screen-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
}

.slip-sheet {
  padding: 36px 44px 44px;
  background: #fff;
  position: relative;
}

.slip-header {
  text-align: center;
  border-bottom: 2px solid #0f172a;
  padding-bottom: 14px;
  margin-bottom: 16px;
}

.slip-header-sub {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: #475569;
  margin-top: 10px;
  border-top: 1px dashed #cbd5e1;
  padding-top: 8px;
}

.slip-meta-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-bottom: 14px;
}

.slip-meta-table th {
  background: #f1f5f9;
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  color: #334155;
  text-align: left;
  font-weight: 600;
}

.slip-meta-table td {
  padding: 6px 10px;
  border: 1px solid #cbd5e1;
  color: #0f172a;
}

.slip-drone-box {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 12px;
  margin-bottom: 16px;
}

.slip-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid #e2e8f0;
  position: relative;
}

.slip-seal-box {
  position: absolute;
  right: 50px;
  bottom: 10px;
  pointer-events: none;
}

/* 官方电子红色防伪印章 */
.slip-official-seal {
  width: 130px;
  height: 130px;
  border: 3px solid #dc2626;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: rotate(-12deg);
  opacity: 0.88;
}

.seal-inner {
  width: 118px;
  height: 118px;
  border: 1px solid #dc2626;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #dc2626;
  font-family: "SimSun", "Songti SC", serif;
  font-weight: 700;
  line-height: 1.15;
}

.seal-star {
  font-size: 20px;
  color: #dc2626;
  margin-bottom: 2px;
}

.seal-text-top {
  font-size: 10.5px;
  letter-spacing: 0.05em;
}

.seal-text-mid {
  font-size: 12px;
  letter-spacing: 0.1em;
  margin: 2px 0;
}

.seal-text-bot {
  font-size: 8.5px;
  letter-spacing: 0.05em;
}

.slip-sign-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12.5px;
}

/* 打印媒介查询：只打印单据本身，隐藏所有无关界面与阴影 */
@media print {
  body > * {
    display: none !important;
  }
  .printable-slip-overlay,
  .printable-slip-overlay > * {
    display: block !important;
  }
  .printable-slip-overlay {
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    height: auto !important;
  }
  .printable-slip-container {
    max-width: 100% !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    border: none !important;
  }
  .no-print {
    display: none !important;
  }
  .slip-sheet {
    padding: 10mm 15mm !important;
  }
}
