/* ==========================================================
   MiroCrowd Step 5: 加载进度页 (Wave 4)
   契约约束: docs/branch-4/PLAN.md
   - 覆盖 #step-5-stage 铺满视口 (底部为 footer 留白 60px)
   - 深色背景配浅色手绘简笔风格
   - 不引入任何持续动画（仅性能可控的 CSS transition）
   ========================================================== */

#step-5-stage {
  position: fixed !important;
  left: 0 !important;
  top: 0 !important;
  right: 0 !important;
  bottom: 60px !important;
  width: 100% !important;
  height: calc(100% - 60px) !important;
  margin: 0 !important;
  padding: 0 !important;
  transform: none !important;
  box-sizing: border-box;
  z-index: 6;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: stretch;
  background: radial-gradient(ellipse at 50% 30%, #1e222a 0%, #101216 100%) !important;
  color: #f3f4f6;
  font-family: "FuturaHandwritten", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.35s ease-out, visibility 0.35s;
}

#step-5-stage.active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* 页面整包容器 */
.loading-page-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
  padding: 16px 28px 12px;
  max-width: 1360px;
  margin: 0 auto;
}

/* ==========================================================
   1. 顶部文字信息区
   ========================================================== */
.loading-header {
  margin-top: 52px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(18, 20, 24, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 14px 20px 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.loading-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.loading-title {
  margin: 0;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 0.5px;
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
}

.loading-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.loading-badge {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  padding: 2px 10px;
  border-radius: 12px;
  user-select: none;
  white-space: nowrap;
}

.loading-badge-stage {
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #7dd3fc;
}

.loading-badge-status {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: #fcd34d;
}

/* 商品卡摘要 */
.loading-product-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: #cbd5e1;
}

.loading-product-label {
  color: #94a3b8;
}

.loading-product-val {
  color: #f1f5f9;
  font-weight: 500;
}

.loading-product-sep {
  color: rgba(255, 255, 255, 0.2);
  margin: 0 4px;
}

/* 进度条与百分比 */
.loading-progress-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 2px;
}

.loading-progress-track {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.loading-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #38bdf8 0%, #60a5fa 60%, #818cf8 100%);
  border-radius: 4px;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}

.loading-percent-text {
  flex-shrink: 0;
  font-size: 15px;
  font-weight: 600;
  min-width: 44px;
  text-align: right;
  color: #38bdf8;
  font-variant-numeric: tabular-nums;
}

/* 统计与费用行 */
.loading-stats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 13px;
  color: #94a3b8;
  padding-top: 2px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}

.loading-counts-text {
  color: #e2e8f0;
}

.loading-costs-text {
  color: #cbd5e1;
  white-space: nowrap;
}

/* ==========================================================
   2. 中部小人 Canvas 区域（主面积）
   ========================================================== */
.loading-main {
  flex: 1;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 8px 0;
  overflow: hidden;
}

.loading-crowd-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.loading-crowd-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.5));
}

/* ==========================================================
   3. 底部通知与操作按钮区
   ========================================================== */
.loading-footer-area {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-height: 48px;
}

/* 提示与问题定位框 */
.loading-notice-box {
  width: 100%;
  max-width: 760px;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(251, 191, 36, 0.35);
  border-radius: 8px;
  padding: 8px 16px;
  box-sizing: border-box;
  text-align: center;
  color: #fef08a;
  font-size: 13.5px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.loading-notice-text {
  line-height: 1.4;
}

.loading-issues-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.loading-issue-item {
  color: #fca5a5;
  font-size: 13px;
  padding-left: 12px;
  position: relative;
  line-height: 1.4;
}

.loading-issue-item::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #ef4444;
}

/* 操作按钮容器 */
.loading-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

/* 确保 hidden 元素在所有情况下彻底隐藏，不被跨组件 display 覆盖，且不可聚焦 */
[hidden],
.loading-btn[hidden],
.btn-results[hidden] {
  display: none !important;
}

/* 手绘简笔风格操作按钮 */
.loading-btn {
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  padding: 8px 26px;
  border-radius: 20px;
  cursor: pointer;
  outline: none;
  user-select: none;
  transition: transform 0.12s ease, filter 0.12s ease, background-color 0.12s ease;
  box-sizing: border-box;
}

.loading-btn:focus-visible {
  outline: 2px dashed #ffffff;
  outline-offset: 3px;
}

.loading-btn-primary {
  background: #000000;
  border: 2px solid #ffffff;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.6);
}

.loading-btn-primary:hover {
  transform: scale(1.03);
  filter: brightness(1.15);
  background: #111111;
}

.loading-btn-primary:active {
  transform: scale(0.97);
}

.loading-btn-secondary {
  background: rgba(0, 0, 0, 0.6);
  border: 1.5px solid rgba(255, 255, 255, 0.45);
  color: #f3f4f6;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.loading-btn-secondary:hover {
  border-color: #ffffff;
  transform: scale(1.02);
  background: rgba(0, 0, 0, 0.8);
}

.loading-btn-secondary:active {
  transform: scale(0.97);
}

/* 小屏适配 (1280x720 等视口) */
@media (max-height: 760px) {
  .loading-page-wrapper {
    padding: 10px 18px 8px;
  }
  .loading-header {
    padding: 10px 16px 8px;
    gap: 6px;
  }
  .loading-title {
    font-size: 20px;
  }
  .loading-btn {
    font-size: 14.5px;
    padding: 6px 20px;
  }
}
