/* MiroCrowd Results Stage Styles (Wave 4) */

#step-6-stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: calc(100% - var(--footer-height, 60px));
  left: 0;
  top: 0;
  transform: none;
  max-height: none;
  overflow-y: auto;
  overflow-x: hidden;
  box-sizing: border-box;
  z-index: 10;
  padding: 20px 24px 40px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.3s ease-out, visibility 0.3s;
}

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

/* 结果页主容器 */
.results-container {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  color: #2c3e50;
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

.results-container,
.results-container * {
  box-sizing: border-box;
}

/* 顶部操作与标题栏 */
.results-header-bar {
  margin-top: 48px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 24px;
  background: rgba(255, 253, 248, 0.94);
  border: 2px solid #2c3e50;
  border-radius: 16px;
  box-shadow: 2px 3px 0 rgba(44, 62, 80, 0.15);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.header-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.results-main-title {
  margin: 0;
  font-family: "FuturaHandwritten", sans-serif;
  font-size: 32px;
  font-weight: bold;
  letter-spacing: 1px;
  color: #1a1a1a;
  line-height: 1.1;
}

.results-task-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  color: #64748b;
  letter-spacing: 0.5px;
}

.header-actions-group {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* 保证 hidden 属性不被 .btn-results 等 display 规则覆盖 */
[hidden],
.btn-results[hidden] {
  display: none !important;
}

/* 手绘风格按钮 */
.btn-results {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 18px;
  background: #faf5ee;
  color: #1a1a1a;
  border: 2px solid #1a1a1a;
  border-radius: 20px 18px 22px 19px / 18px 22px 19px 20px;
  font-family: "FuturaHandwritten", sans-serif;
  font-size: 18px;
  font-weight: bold;
  letter-spacing: 0.5px;
  white-space: nowrap;
  box-shadow: 2px 3px 0 rgba(26, 26, 26, 0.9);
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.btn-results:hover:not(:disabled) {
  transform: translate(-1px, -1px);
  box-shadow: 3px 4px 0 rgba(26, 26, 26, 0.9);
  background: #fffdf9;
}

.btn-results:active:not(:disabled) {
  transform: translate(1px, 2px);
  box-shadow: 1px 1px 0 rgba(26, 26, 26, 0.9);
}

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

.btn-download-csv {
  background: #eef7ee;
  border-color: #27ae60;
  color: #1e824c;
}

.btn-download-csv:hover:not(:disabled) {
  background: #dff0df;
}

/* 下载通知条 */
.download-notice-alert {
  width: 100%;
  margin-top: 8px;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
}

.notice-info {
  background: #f0f7ff;
  border-color: #bee3f8;
  color: #2b6cb0;
}

.notice-success {
  background: #f0fff4;
  border-color: #c6f6d5;
  color: #276749;
}

.notice-warning {
  background: #fffaf0;
  border-color: #feebc8;
  color: #c05621;
}

.notice-error {
  background: #fff5f5;
  border-color: #fed7d7;
  color: #c53030;
}

/* 概览卡片区 */
.results-overview {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
}

@media (max-width: 1180px) {
  .results-overview {
    grid-template-columns: 1fr;
  }
}

.overview-card {
  background: rgba(255, 253, 248, 0.94);
  border: 2px solid #2c3e50;
  border-radius: 16px;
  box-shadow: 2px 3px 0 rgba(44, 62, 80, 0.15);
  padding: 18px 20px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
}

.overview-card-title {
  margin: 0 0 14px 0;
  font-family: "FuturaHandwritten", sans-serif;
  font-size: 20px;
  font-weight: bold;
  color: #1a1a1a;
  border-bottom: 1.5px dashed #cbd5e1;
  padding-bottom: 6px;
}

/* 任务状态卡片 */
.task-meta-card .meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 14px;
  flex-wrap: wrap;
}

.meta-label {
  font-weight: 600;
  color: #475569;
}

.meta-value {
  color: #1e293b;
  font-weight: 500;
}

.meta-status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: bold;
  border: 1px solid #2c3e50;
}

.status-completed {
  background: #e6fffa;
  color: #234e52;
  border-color: #319795;
}

.status-completed_with_errors {
  background: #fffaf0;
  color: #7b341e;
  border-color: #dd6b20;
}

.status-failed {
  background: #fff5f5;
  color: #742a2a;
  border-color: #e53e3e;
}

.status-running {
  background: #ebf8ff;
  color: #2a4365;
  border-color: #3182ce;
}

.status-queued {
  background: #f7fafc;
  color: #4a5568;
  border-color: #a0aec0;
}

.cost-risk-tag {
  background: #feebc8;
  color: #744210;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

.partial-notice-tag {
  background: #e2e8f0;
  color: #334155;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
  font-weight: 600;
  border: 1px dashed #64748b;
}

/* 商品卡 */
.product-fields-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  font-size: 13px;
}

.product-field-item {
  display: flex;
  flex-direction: column;
  background: rgba(248, 250, 252, 0.7);
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.product-field-label {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
  margin-bottom: 2px;
}

.product-field-value {
  color: #1e293b;
  font-weight: 500;
  word-break: break-all;
}

/* 全批推演计数 */
.counts-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

@media (max-width: 900px) {
  .counts-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.count-item-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 6px;
  border-radius: 10px;
  border: 1px solid #cbd5e1;
  background: #f8fafc;
  text-align: center;
}

.count-num {
  font-size: 22px;
  font-weight: bold;
  color: #1e293b;
  line-height: 1.1;
  font-family: "FuturaHandwritten", sans-serif;
}

.count-label {
  font-size: 11px;
  color: #64748b;
  margin-top: 3px;
  font-weight: 600;
}

.count-succeeded .count-num { color: #27ae60; }
.count-failed .count-num { color: #e74c3c; }
.count-valid_count .count-num { color: #2980b9; }

/* 筛选工具栏 */
.results-filter-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: rgba(255, 253, 248, 0.94);
  border: 2px solid #2c3e50;
  border-radius: 14px;
  box-shadow: 2px 3px 0 rgba(44, 62, 80, 0.12);
}

.filter-label {
  font-size: 14px;
  font-weight: 600;
  color: #334155;
}

.results-status-filter {
  padding: 6px 14px;
  border: 2px solid #1a1a1a;
  border-radius: 12px;
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  color: #1e293b;
  outline: none;
  cursor: pointer;
  box-shadow: 1px 2px 0 rgba(26, 26, 26, 0.6);
}

.filter-total-info {
  margin-left: auto;
  font-size: 13px;
  color: #64748b;
  font-weight: 500;
}

/* 结果表格 */
.results-table-wrapper {
  overflow-x: auto;
  max-width: 100%;
  border: 2px solid #2c3e50;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 2px 3px 0 rgba(44, 62, 80, 0.15);
  max-height: 480px;
  overflow-y: auto;
}

.results-data-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 2400px;
  font-size: 13px;
  color: #1e293b;
}

.sticky-th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #f4eee1;
  padding: 10px 14px;
  font-weight: 700;
  text-align: left;
  border-bottom: 2px solid #2c3e50;
  border-right: 1px solid #dcd3c5;
  white-space: nowrap;
  font-family: "FuturaHandwritten", sans-serif;
  font-size: 16px;
  color: #1a1a1a;
  letter-spacing: 0.5px;
}

.col-meta { background: #ede2cf; }
.col-persona { background: #f5edd8; }
.col-answer { background: #faf4e5; }

.results-row {
  cursor: pointer;
  transition: background 0.15s ease;
}

.results-row:nth-child(even) {
  background: #faf8f5;
}

.results-row:hover {
  background: #f2ebe0;
}

.results-row.expanded {
  background: #ebe0cf;
}

.results-row:focus-visible {
  outline: 2px solid #3182ce;
  outline-offset: -2px;
}

.results-row td {
  padding: 8px 12px;
  border-bottom: 1px solid #e8decb;
  border-right: 1px solid #e8decb;
  white-space: nowrap;
}

.cell-row-no {
  font-family: ui-monospace, monospace;
  font-weight: 600;
  text-align: center;
}

.btn-toggle-expand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 11px;
  line-height: 1.3;
  border: 1px solid #718096;
  border-radius: 4px;
  background: #fffdf8;
  color: #2c3e50;
  cursor: pointer;
  vertical-align: middle;
  transition: all 0.15s ease;
}

.btn-toggle-expand:hover {
  background: #2c3e50;
  color: #fffdf8;
  border-color: #2c3e50;
}

.btn-toggle-expand:focus-visible {
  outline: 2px solid #3182ce;
  outline-offset: 1px;
}

.cell-uid {
  font-family: ui-monospace, monospace;
  font-weight: 600;
  color: #2b6cb0;
}

.member-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid transparent;
}

.badge-succeeded { background: #e6fffa; color: #234e52; border-color: #38b2ac; }
.badge-failed { background: #fff5f5; color: #742a2a; border-color: #e53e3e; }
.badge-running { background: #ebf8ff; color: #2a4365; border-color: #3182ce; }
.badge-pending { background: #f7fafc; color: #4a5568; border-color: #cbd5e0; }
.badge-retry_wait { background: #fffaf0; color: #744210; border-color: #ed8936; }
.badge-cancelled { background: #edf2f7; color: #718096; border-color: #a0aec0; }

.cell-error-code {
  font-family: ui-monospace, monospace;
  color: #c53030;
  font-size: 12px;
}

.no-answer-cell {
  text-align: center;
  color: #718096;
  font-style: italic;
  background: rgba(0, 0, 0, 0.03);
  font-weight: 500;
}

.empty-table-cell {
  text-align: center;
  padding: 40px;
  color: #718096;
  font-size: 16px;
  font-style: italic;
}

/* 详情展开行 */
.results-detail-row {
  background: #fbf8f2;
}

.detail-td-container {
  padding: 16px 24px;
  border-bottom: 2px solid #2c3e50;
  border-right: none;
}

.row-detail-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #ffffff;
  border: 1.5px solid #2c3e50;
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 1px 2px 0 rgba(44, 62, 80, 0.1);
}

.detail-summary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  border-bottom: 1px dashed #cbd5e1;
  padding-bottom: 8px;
}

.detail-section-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
}

.detail-summary-tags {
  display: flex;
  gap: 10px;
  align-items: center;
}

.detail-tag {
  font-size: 12px;
  color: #475569;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.tag-error {
  background: #fff5f5;
  color: #c53030;
  border-color: #feb2b2;
}

.detail-sub-title {
  margin: 4px 0 0 0;
  font-size: 13px;
  font-weight: 700;
  color: #475569;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px 14px;
}

@media (max-width: 1000px) {
  .detail-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.detail-grid-item {
  display: flex;
  flex-direction: column;
  background: #f8fafc;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.detail-grid-label {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
}

.detail-grid-value {
  font-size: 13px;
  color: #1e293b;
  font-weight: 500;
  word-break: break-all;
}

.detail-no-answer-banner {
  grid-column: 1 / -1;
  padding: 10px;
  background: #fffaf0;
  border: 1px dashed #ed8936;
  border-radius: 6px;
  color: #c05621;
  text-align: center;
  font-size: 13px;
  font-style: italic;
}

/* 分页栏 */
.results-pagination-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 14px 20px;
  background: rgba(255, 253, 248, 0.94);
  border: 2px solid #2c3e50;
  border-radius: 14px;
  box-shadow: 2px 3px 0 rgba(44, 62, 80, 0.12);
}

.btn-pager {
  padding: 5px 14px;
  background: #faf5ee;
  color: #1a1a1a;
  border: 2px solid #1a1a1a;
  border-radius: 16px 14px 18px 15px / 14px 18px 15px 16px;
  font-family: "FuturaHandwritten", sans-serif;
  font-size: 16px;
  font-weight: bold;
  box-shadow: 1px 2px 0 rgba(26, 26, 26, 0.8);
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-pager:hover:not(:disabled) {
  transform: translate(-1px, -1px);
  box-shadow: 2px 3px 0 rgba(26, 26, 26, 0.8);
}

.btn-pager:active:not(:disabled) {
  transform: translate(1px, 1px);
  box-shadow: none;
}

.btn-pager:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

.pager-info-text {
  font-size: 14px;
  font-weight: 600;
  color: #334155;
}

/* 错误面板 */
.error-card {
  padding: 24px;
  background: #fff5f5;
  border: 2px solid #e53e3e;
  border-radius: 16px;
  box-shadow: 2px 3px 0 rgba(229, 62, 62, 0.2);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.error-title {
  margin: 0;
  font-family: "FuturaHandwritten", sans-serif;
  font-size: 24px;
  color: #9b2c2c;
}

.error-message {
  margin: 0;
  font-size: 14px;
  color: #742a2a;
  max-width: 600px;
}

.pre-run-disabled-card {
  padding: 24px;
  background: rgba(255, 253, 248, 0.94);
  border: 2px dashed #e53e3e;
  border-radius: 16px;
  box-shadow: 2px 3px 0 rgba(44, 62, 80, 0.1);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.pre-run-title {
  margin: 0;
  font-family: "FuturaHandwritten", sans-serif;
  font-size: 24px;
  color: #c53030;
}

.pre-run-desc {
  margin: 0;
  font-size: 14px;
  color: #4a5568;
}

.error-code-badge {
  display: inline-block;
  padding: 3px 10px;
  background: #fed7d7;
  color: #9b2c2c;
  border-radius: 6px;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  font-weight: bold;
}

.issues-subheading {
  margin: 12px 0 4px 0;
  font-size: 14px;
  color: #2d3748;
}

.issues-list {
  text-align: left;
  margin: 0;
  padding-left: 20px;
  font-size: 13px;
  color: #4a5568;
}

.issue-list-item {
  margin-bottom: 4px;
}
