/**
 * Upload + Processing Animation Styles
 */

/* Stage header */
.stage-rail {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--rule);
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 32px;
}

.stage {
  background: var(--paper);
  padding: 16px 20px;
  transition: background .3s ease;
}

.stage.active {
  background: var(--teal-soft);
}

.stage.complete {
  background: var(--teal);
}

.stage-num {
  font-family: var(--data);
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}

.stage.active .stage-num,
.stage.complete .stage-num {
  color: var(--teal);
}

.stage.complete .stage-num {
  color: var(--paper);
}

.stage-title {
  font-family: var(--display);
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
}

.stage.complete .stage-title {
  color: var(--paper);
}

@media (max-width: 600px) {
  .stage-rail {
    grid-template-columns: 1fr;
  }
  .stage {
    padding: 12px 16px;
  }
  .stage-title {
    font-size: 13px;
  }
}

/* Main canvas */
.proc-canvas {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 24px;
  min-height: 420px;
}

@media (max-width: 900px) {
  .proc-canvas {
    grid-template-columns: 1fr;
  }
}

/* Document panel */
.doc-panel {
  background: var(--ink);
  border-radius: 8px;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.doc-preview {
  position: relative;
  background: var(--paper);
  border-radius: 4px;
  height: 320px;
  overflow: hidden;
}

.doc-lines {
  padding: 16px;
}

.doc-line {
  height: 8px;
  background: var(--rule);
  border-radius: 2px;
  margin-bottom: 8px;
  opacity: 0.5;
  transition: opacity .2s, background .2s;
}

.doc-line.scanned {
  opacity: 1;
  background: var(--teal-line);
}

.doc-line:nth-child(1) { width: 60%; }
.doc-line:nth-child(2) { width: 85%; }
.doc-line:nth-child(3) { width: 75%; }
.doc-line:nth-child(4) { width: 90%; }
.doc-line:nth-child(5) { width: 70%; }
.doc-line:nth-child(6) { width: 80%; }
.doc-line:nth-child(7) { width: 65%; }
.doc-line:nth-child(8) { width: 88%; }
.doc-line:nth-child(9) { width: 72%; }
.doc-line:nth-child(10) { width: 78%; }
.doc-line:nth-child(11) { width: 82%; }
.doc-line:nth-child(12) { width: 68%; }

/* Scan line */
.scan-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, var(--teal) 50%, transparent 100%);
  box-shadow: 0 0 20px var(--teal), 0 0 40px var(--teal);
  opacity: 0;
  transition: opacity .3s;
  pointer-events: none;
}

.scan-line.active {
  opacity: 1;
}

@keyframes scan-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

.scan-line.active {
  animation: scan-pulse 0.8s ease-in-out infinite;
}

.doc-status {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  color: var(--paper);
  font-family: var(--data);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.doc-status-text {
  display: flex;
  align-items: center;
  gap: 8px;
}

.doc-status-text::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--teal);
  border-radius: 50%;
  animation: pulse-dot 1s ease-in-out infinite;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 0.5; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* Checks panel */
.checks-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.checks-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.checks-title {
  font-family: var(--data);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--ink);
  text-transform: uppercase;
}

.checks-subtitle {
  font-family: var(--body);
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.checks-stats {
  display: flex;
  gap: 24px;
}

@media (max-width: 600px) {
  .checks-header {
    flex-direction: column;
    gap: 16px;
  }
  .checks-stats {
    gap: 16px;
  }
  .check-stat-value {
    font-size: 22px;
  }
}

.check-stat {
  text-align: right;
}

.check-stat-label {
  font-family: var(--data);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
}

.check-stat-value {
  font-family: var(--data);
  font-size: 28px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1;
  margin-top: 4px;
}

.check-stat-value.flag {
  color: var(--flag);
}

.check-stat-value.warn {
  color: var(--warn);
}

/* Check grid - 56 checks: 8 columns × 7 rows */
.check-grid {
  display: grid;
  grid-template-columns: repeat(8, 24px);
  grid-template-rows: repeat(7, 24px);
  gap: 4px;
  padding: 12px;
  background: var(--paper-2);
  border-radius: 8px;
  width: fit-content;
}

.check-cell {
  width: 24px;
  height: 24px;
  background: var(--rule-soft);
  border-radius: 3px;
  transition: background .15s ease, transform .15s ease;
}

.check-cell.pass {
  background: var(--teal-line);
}

.check-cell.flag {
  background: var(--flag);
  animation: cell-flag 0.3s ease;
}

.check-cell.warn {
  background: var(--warn);
}

.check-cell.skip {
  background: var(--rule);
}

@keyframes cell-flag {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* Check families */
.check-families {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  overflow-x: auto;
}

.check-family {
  font-family: var(--data);
  font-size: 10px;
  padding: 5px 10px;
  background: var(--paper-2);
  border-radius: 4px;
  color: var(--muted);
  transition: all .2s;
  white-space: nowrap;
}

.check-family.active {
  background: var(--teal-soft);
  color: var(--teal);
}

.check-family.complete {
  background: var(--teal);
  color: var(--paper);
}

/* Extracted data panel */
.extracted-panel {
  background: var(--paper-2);
  border-radius: 8px;
  padding: 16px 20px;
  margin-top: 24px;
}

.extracted-title {
  font-family: var(--data);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 12px;
}

.extracted-items {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

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

@media (max-width: 480px) {
  .extracted-items {
    grid-template-columns: 1fr;
  }
  .extracted-item {
    padding: 8px 12px;
  }
}

.extracted-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--paper);
  border-radius: 6px;
  opacity: 0;
  transform: translateY(8px) scale(0.95);
  transition: all .4s var(--ease);
}

.extracted-item.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.extracted-item-label {
  font-family: var(--data);
  font-size: 10px;
  letter-spacing: 0.05em;
  color: var(--muted);
  text-transform: uppercase;
  flex-shrink: 0;
}

.extracted-item-value {
  font-family: var(--data);
  font-size: 12px;
  font-weight: 500;
  color: var(--ink);
  flex: 1;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.extracted-item-check {
  color: var(--teal);
  opacity: 0;
  transition: opacity .3s;
  flex-shrink: 0;
  font-size: 14px;
}

.extracted-item.visible .extracted-item-check {
  opacity: 1;
}

/* Playback controls */
.playback {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 0;
  border-top: 1px solid var(--rule);
  margin-top: 24px;
}

.play-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--teal);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s, background .2s;
}

.play-btn:hover {
  transform: scale(1.05);
  background: var(--ink);
}

.play-btn svg {
  width: 18px;
  height: 18px;
  fill: var(--paper);
}

.play-btn.paused .pause-icon { display: none; }
.play-btn.paused .play-icon { display: block; }
.play-btn:not(.paused) .pause-icon { display: block; }
.play-btn:not(.paused) .play-icon { display: none; }

.timeline {
  flex: 1;
  height: 6px;
  background: var(--rule);
  border-radius: 3px;
  cursor: pointer;
  position: relative;
}

.timeline-progress {
  height: 100%;
  background: var(--teal);
  border-radius: 3px;
  width: 0;
  transition: width 0.05s linear;
}

.timeline-markers {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
}

.timeline-marker {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 14px;
  background: var(--rule-soft);
}

.timeline-marker:nth-child(1) { left: 27.3%; }  /* 3s / 11s */
.timeline-marker:nth-child(2) { left: 63.6%; }  /* 7s / 11s */

.time-display {
  font-family: var(--data);
  font-size: 13px;
  color: var(--muted);
  min-width: 80px;
  text-align: right;
}

/* Results panel (phase 3) */
.results-panel {
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 8px;
  margin-top: 24px;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  transition: all .4s var(--ease);
}

.results-panel.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--rule);
}

@media (max-width: 480px) {
  .results-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
  }
  .result-flag {
    padding: 12px 16px;
  }
}

.results-title {
  font-family: var(--display);
  font-size: 16px;
  font-weight: 600;
}

.results-risk {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--data);
  font-size: 13px;
}

.risk-label {
  color: var(--muted);
}

.risk-value {
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity .4s var(--ease), background .3s var(--ease);
}

.risk-value.high,
.risk-value.medium,
.risk-value.low {
  opacity: 1;
}

.risk-value.high {
  background: var(--flag);
  color: white;
}

.risk-value.medium {
  background: var(--warn);
  color: white;
}

.risk-value.low {
  background: var(--teal);
  color: white;
}

.results-flags {
  padding: 0;
  margin: 0;
  list-style: none;
}

.result-flag {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--rule-soft);
  opacity: 0;
  transform: translateX(-10px);
  transition: all .4s var(--ease);
}

.result-flag.visible {
  opacity: 1;
  transform: translateX(0);
}

.result-flag:last-child {
  border-bottom: none;
}

.flag-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
}

.flag-icon.flag {
  background: var(--flag);
  color: white;
}

.flag-icon.warn {
  background: var(--warn);
  color: white;
}

.flag-icon svg {
  width: 12px;
  height: 12px;
}

.flag-content {
  flex: 1;
}

.flag-id {
  font-family: var(--data);
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}

.flag-message {
  font-family: var(--body);
  font-size: 14px;
  color: var(--ink);
  line-height: 1.4;
}

/* Upload dropzone */
.dropzone {
  border: 2px dashed var(--rule);
  border-radius: 12px;
  padding: 48px;
  text-align: center;
  cursor: pointer;
  transition: all .3s ease;
  background: var(--paper);
}

@media (max-width: 480px) {
  .dropzone {
    padding: 32px 20px;
  }
  .dropzone-icon {
    width: 36px;
    height: 36px;
  }
  .dropzone-title {
    font-size: 16px;
  }
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.dropzone-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  color: var(--muted);
}

.dropzone-title {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
}

.dropzone-subtitle {
  font-size: 14px;
  color: var(--muted);
}

.dropzone-demo {
  margin-top: 20px;
  font-family: var(--data);
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--teal);
  background: none;
  border: 1px solid var(--teal);
  padding: 8px 16px;
  border-radius: 4px;
  cursor: pointer;
  transition: all .2s;
}

.dropzone-demo:hover {
  background: var(--teal);
  color: var(--paper);
}

/* Error panel */
.error-panel {
  background: var(--flag-soft, #fcecea);
  border: 1px solid var(--flag);
  border-radius: 8px;
  padding: 20px 24px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.error-icon {
  width: 32px;
  height: 32px;
  background: var(--flag);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.error-message {
  font-size: 14px;
  color: var(--flag);
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  .scan-line,
  .check-cell,
  .extracted-item,
  .result-flag,
  .results-panel {
    animation: none;
    transition: none;
  }

  .scan-line.active {
    opacity: 0;
  }
}
