/* ============================================================
   COMPONENTS 2026 — 共享 UI 组件（金 / 绿 / 红）
   StatGrid · DataCard · SegmentTabs · StatusStrip · LotteryBall
   Skeleton · Toast · Modal · Drawer
   ============================================================ */

/* ── StatusStrip ── */
.cz-status-strip,
.status-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: var(--fluid-sm);
}

.cz-status-strip__item,
.status-strip-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-weight: 600;
}

.cz-status-strip__dot,
.status-strip-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--gold-500);
  flex-shrink: 0;
}

.cz-status-strip__dot--ok,
.status-strip-dot.ok { background: var(--green); }
.cz-status-strip__dot--warn,
.status-strip-dot.warn { background: var(--gold-400); }
.cz-status-strip__dot--err,
.status-strip-dot.err { background: var(--red); }

/* ── StatGrid ── */
.cz-stat-grid,
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.cz-stat-card,
.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--shell-radius);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: border-color 0.3s ease, transform 0.2s ease;
}

.cz-stat-card:hover,
.stat-card:hover {
  border-color: var(--border-soft);
  transform: translateY(-2px);
}

.cz-stat-card::after,
.stat-card::after {
  content: '';
  position: absolute;
  right: -20px;
  top: -20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 158, 11, 0.12), transparent 70%);
}

.cz-stat-card__label,
.stat-card .stat-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.cz-stat-card__value,
.stat-card .stat-value {
  font-size: 26px;
  font-weight: 800;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
}

.cz-stat-card__sub,
.stat-card .stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.cz-stat-card--green,
.stat-card.green .stat-value { color: var(--green2); }
.cz-stat-card--green::after,
.stat-card.green::after {
  background: radial-gradient(circle, rgba(16, 185, 129, 0.14), transparent 70%);
}

.cz-stat-card--red,
.stat-card.red .stat-value { color: var(--red2); }
.cz-stat-card--red::after,
.stat-card.red::after {
  background: radial-gradient(circle, rgba(239, 68, 68, 0.14), transparent 70%);
}

.cz-stat-card--gold,
.stat-card.gold .stat-value { color: var(--gold-400); }

/* Legacy .stat-card.cyan → gold (no cyan hue) */
.stat-card.cyan .stat-value { color: var(--gold-400); }
.stat-card.cyan::after {
  background: radial-gradient(circle, rgba(245, 158, 11, 0.14), transparent 70%);
}

/* ── DataCard ── */
.cz-data-card,
.data-card {
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  transition: border-color 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.cz-data-card:hover,
.data-card:hover {
  border-color: var(--border-soft);
  transform: translateY(-2px);
  box-shadow: var(--app-shadow);
}

.cz-data-card__head,
.data-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.cz-data-card__title,
.data-card-title {
  font-size: var(--fluid-md);
  font-weight: 800;
  color: var(--text-primary);
}

.cz-data-card__body,
.data-card-body {
  color: var(--text-secondary);
  font-size: var(--fluid-sm);
  line-height: 1.6;
}

/* ── SegmentTabs ── */
.cz-segment-tabs,
.seg-tabs {
  display: inline-flex;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  padding: 5px;
  border-radius: 14px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}

.cz-segment-tab,
.seg-tab {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 700;
  padding: 9px 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  white-space: nowrap;
}

.cz-segment-tab:hover,
.seg-tab:hover {
  color: var(--text-primary);
}

.cz-segment-tab.active,
.cz-segment-tab[aria-selected="true"],
.seg-tab.active {
  background: var(--shell-active);
  color: var(--gold-300);
  box-shadow: 0 0 0 1px var(--border-glow) inset;
}

.cz-segment-tab:focus-visible,
.seg-tab:focus-visible {
  outline: 2px solid var(--gold-400);
  outline-offset: 2px;
}

/* ── LotteryBall ── */
.cz-lottery-ball,
.lottery-ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.35rem;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.cz-lottery-ball--main,
.lottery-ball.main,
.ball-red {
  background: linear-gradient(135deg, #fecaca, #f87171);
  color: #7f1d1d;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.25);
}

.cz-lottery-ball--extra,
.lottery-ball.extra,
.ball-gold {
  background: linear-gradient(135deg, #fef3c7, #fbbf24);
  color: #78350f;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.25);
}

.cz-lottery-ball--green,
.lottery-ball.green,
.ball-green {
  background: linear-gradient(135deg, #bbf7d0, #4ade80);
  color: #14532d;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.25);
}

/* Legacy .ball-blue → gold alias (no blue balls) */
.ball-blue,
.number.blue {
  background: linear-gradient(135deg, #fef3c7, #fbbf24);
  color: #78350f;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.25);
}

/* ── Skeleton ── */
.cz-skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-3, #181b2a) 25%,
    var(--surface-4, #1f2336) 50%,
    var(--surface-3, #181b2a) 75%
  );
  background-size: 200% 100%;
  border-radius: var(--radius-sm, 8px);
  animation: cz-skeleton-shimmer 1.5s infinite;
}

@keyframes cz-skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.cz-skeleton-card {
  padding: 16px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface-2);
}

.cz-skeleton-btn { width: 80px; height: 32px; }
.cz-skeleton-text { height: 1em; margin: 0.3em 0; border-radius: 4px; }
.cz-skeleton-circle { width: 36px; height: 36px; border-radius: 50%; }

.light-theme .cz-skeleton {
  background: linear-gradient(90deg, #e8e8ed 25%, #f5f5f7 50%, #e8e8ed 75%);
  background-size: 200% 100%;
}

/* Scan line decoration (gold only) */
.cz-scan-line {
  position: relative;
  overflow: hidden;
}

.cz-scan-line::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 40%,
    rgba(245, 158, 11, 0.06) 50%,
    transparent 60%
  );
  animation: cz-scan var(--cz-scan-duration) linear infinite;
  pointer-events: none;
}

@keyframes cz-scan {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

@media (prefers-reduced-motion: reduce) {
  .cz-skeleton { animation: none; }
  .cz-scan-line::after { animation: none; display: none; }
}

/* ── Toast ── */
.cz-toast,
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--surface-3);
  border: 1px solid var(--border-soft);
  color: var(--text-primary);
  padding: 12px 22px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  z-index: 2000;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.cz-toast.show,
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.cz-toast--ok,
.toast.ok { border-color: rgba(16, 185, 129, 0.4); }
.cz-toast--err,
.toast.err { border-color: rgba(239, 68, 68, 0.4); }

/* ── Modal / Dialog ── */
.cz-modal-overlay,
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 1500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.cz-modal-overlay.open,
.cz-modal-overlay[aria-hidden="false"],
.modal-overlay.open {
  display: flex;
}

.cz-modal,
.modal {
  width: 100%;
  max-width: 540px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  border-radius: 18px;
  padding: 26px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  animation: cz-fade-up 0.3s ease both;
}

.cz-modal:focus-visible,
.modal:focus-visible {
  outline: 2px solid var(--gold-400);
  outline-offset: 2px;
}

.cz-modal__head,
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.cz-modal__title,
.modal-head h3 {
  font-size: 19px;
  font-weight: 800;
  color: var(--text-primary);
}

.cz-modal__close,
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  line-height: 1;
  border-radius: 6px;
}

.cz-modal__close:hover,
.modal-close:hover { color: var(--text-primary); }

.cz-modal__close:focus-visible,
.modal-close:focus-visible {
  outline: 2px solid var(--gold-400);
  outline-offset: 2px;
}

@keyframes cz-fade-up {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .cz-modal,
  .modal { animation: none; }
}

/* ── Drawer ── */
.cz-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 1400;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.cz-drawer-overlay.open {
  opacity: 1;
  visibility: visible;
}

.cz-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(420px, 92vw);
  background: var(--surface-2);
  border-left: 1px solid var(--border-soft);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.45);
  z-index: 1401;
  transform: translateX(100%);
  transition: transform 0.32s var(--shell-ease);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.cz-drawer.open {
  transform: translateX(0);
}

.cz-drawer__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.cz-drawer__body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
}

.cz-drawer__close:focus-visible {
  outline: 2px solid var(--gold-400);
  outline-offset: 2px;
}

@media (max-width: 768px) {
  .cz-drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 88vh;
    border-left: none;
    border-top: 1px solid var(--border-soft);
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
  }

  .cz-drawer.open {
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .cz-drawer,
  .cz-drawer-overlay {
    transition: none;
  }
}

/* ── P4: empty / error / skeleton panel / letter badge ── */
.cz-skeleton-panel {
  min-height: 120px;
  padding: 14px;
  border-radius: var(--radius-md, 12px);
  background: var(--surface-2);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cz-skeleton-panel--compact { min-height: 88px; }

.cz-empty-state {
  min-height: 96px;
  padding: 16px;
  border-radius: var(--radius-md, 12px);
  background: var(--surface-2);
  border: 1px dashed var(--border-subtle);
  text-align: center;
}

.cz-empty-state__title { font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.cz-empty-state__body { margin: 0; font-size: 13px; color: var(--text-muted); }
.cz-empty-state__action {
  display: inline-flex; margin-top: 10px; font-size: 13px; font-weight: 700;
  color: var(--gold-400); text-decoration: none;
}

.cz-error-retry {
  min-height: 96px;
  padding: 16px;
  border-radius: var(--radius-md, 12px);
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.25);
  text-align: center;
}

.cz-error-retry__msg { margin: 0 0 10px; color: var(--red); font-size: 13px; }
.cz-error-retry__btn {
  border: 1px solid var(--border-glow);
  background: rgba(245, 158, 11, 0.1);
  color: var(--gold-400);
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 700;
  cursor: pointer;
}

.cz-letter-badge__bg { fill: rgba(245, 158, 11, 0.18); }
.cz-letter-badge__text {
  fill: var(--gold-400, #fbbf24);
  font-size: 16px;
  font-weight: 700;
  font-family: 'Noto Sans SC', system-ui, sans-serif;
}

.cz-letter-badge--green .cz-letter-badge__bg { fill: rgba(16, 185, 129, 0.18); }
.cz-letter-badge--green .cz-letter-badge__text { fill: var(--green, #10b981); }

