/* Visual sorting simulation view, scoped from the existing sandbox views. */

.app-shell[data-active-view="simulation"] .visual-sorting-view,
.app-shell[data-active-view="inbound"] .visual-sorting-view,
.app-shell[data-active-view="twin"] .visual-sorting-view {
  display: none;
}

.app-shell[data-active-view="sorting"] .decision-grid,
.app-shell[data-active-view="sorting"] .insight-grid,
.app-shell[data-active-view="sorting"] .digital-twin-view,
.app-shell[data-active-view="sorting"] .inbound-identity-view {
  display: none;
}

.visual-sorting-view {
  margin-top: 16px;
}

.sorting-hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 14px;
  padding: 16px 18px;
  border: 1px solid rgba(11, 92, 173, 0.15);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(237, 247, 255, 0.9)),
    #ffffff;
  box-shadow: 0 14px 36px rgba(9, 24, 44, 0.1);
}

.sorting-hero h2 {
  margin-bottom: 4px;
  color: var(--ink);
  font-size: clamp(1.5rem, 2vw, 2rem);
  letter-spacing: 0;
}

.sorting-hero p:last-child {
  margin: 0;
  color: var(--muted);
  font-weight: 750;
}

.sorting-status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 9px 13px;
  border: 1px solid rgba(20, 194, 204, 0.3);
  border-radius: var(--radius);
  background: #effbff;
  color: #075985;
  font-weight: 950;
  white-space: nowrap;
}

.sorting-status-pill span {
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 999px;
  background: var(--route-cyan);
  box-shadow: 0 0 0 6px rgba(20, 194, 204, 0.13);
}

.sorting-status-pill.is-blocked {
  border-color: rgba(225, 75, 75, 0.28);
  background: #fff1f0;
  color: #a62626;
}

.sorting-status-pill.is-blocked span {
  background: var(--alert);
  box-shadow: 0 0 0 6px rgba(225, 75, 75, 0.12);
}

.sorting-layout {
  display: grid;
  grid-template-columns: minmax(760px, 1fr) 370px;
  gap: 16px;
  align-items: start;
}

.sorting-stage-card,
.sorting-console .panel {
  border: 1px solid rgba(9, 24, 44, 0.1);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.sorting-stage-card {
  min-width: 0;
  padding: 16px;
}

.sorting-stage-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 12px;
}

.sorting-stage-head h2,
.sorting-console h2 {
  margin-bottom: 6px;
  font-size: 1.1rem;
}

.sorting-score {
  display: grid;
  min-width: 136px;
  padding: 10px 12px;
  border: 1px solid rgba(20, 194, 204, 0.22);
  border-radius: var(--radius);
  background: #f6fcff;
}

.sorting-score span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
}

.sorting-score strong {
  color: var(--official-blue);
  font-size: 1.8rem;
  line-height: 1;
}

.sorting-scene {
  position: relative;
  min-height: 590px;
  overflow: hidden;
  border: 1px solid rgba(11, 92, 173, 0.14);
  border-radius: var(--radius);
  background: #dfeef8;
}

.sorting-scene::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(90deg, rgba(7, 24, 39, 0.05), rgba(7, 24, 39, 0) 42%, rgba(255, 255, 255, 0.1)),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(6, 31, 57, 0.12));
  pointer-events: none;
}

.sorting-scene-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.sorting-camera-tag,
.sorting-result-card,
.sorting-route-card,
.sorting-detection-box {
  position: absolute;
  z-index: 5;
}

.sorting-camera-tag {
  top: 116px;
  left: 44%;
  padding: 8px 11px;
  border: 1px solid rgba(20, 194, 204, 0.3);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.88);
  color: #075985;
  font-size: 0.82rem;
  font-weight: 950;
  box-shadow: 0 12px 26px rgba(9, 24, 44, 0.13);
}

.sorting-detection-box {
  border: 2px solid rgba(20, 194, 204, 0.75);
  border-radius: 8px;
  background: rgba(20, 194, 204, 0.08);
  box-shadow: 0 0 0 6px rgba(20, 194, 204, 0.08), 0 0 24px rgba(20, 194, 204, 0.2);
  opacity: 0;
  transition: opacity 180ms ease, border-color 180ms ease, background 180ms ease;
}

.sorting-detection-box span {
  position: absolute;
  top: -32px;
  left: 0;
  padding: 5px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.88);
  color: #075985;
  font-size: 0.75rem;
  font-weight: 950;
  white-space: nowrap;
}

.box-main {
  left: 34%;
  top: 36%;
  width: 24%;
  height: 18%;
}

.box-normal {
  left: 43%;
  top: 60%;
  width: 16%;
  height: 31%;
  border-color: rgba(39, 189, 117, 0.75);
  background: rgba(39, 189, 117, 0.08);
}

.box-cold {
  left: 61%;
  top: 62%;
  width: 18%;
  height: 28%;
  border-color: rgba(11, 92, 173, 0.72);
  background: rgba(11, 92, 173, 0.08);
}

.box-fragile {
  left: 77%;
  top: 54%;
  width: 15%;
  height: 27%;
  border-color: rgba(242, 153, 74, 0.75);
  background: rgba(242, 153, 74, 0.08);
}

.box-exception {
  left: 90%;
  top: 43%;
  width: 10%;
  height: 27%;
  border-color: rgba(225, 75, 75, 0.72);
  background: rgba(225, 75, 75, 0.08);
}

.sorting-scene.capture .box-main,
.sorting-scene.detect .box-main,
.sorting-scene.classify .box-main,
.sorting-scene.divert .box-main,
.sorting-scene.record .box-main,
.sorting-scene.blocked .box-main,
.sorting-scene.divert.case-normal .box-normal,
.sorting-scene.record.case-normal .box-normal,
.sorting-scene.divert.case-cold .box-cold,
.sorting-scene.record.case-cold .box-cold,
.sorting-scene.divert.case-fragile .box-fragile,
.sorting-scene.record.case-fragile .box-fragile,
.sorting-scene.divert.case-damaged .box-exception,
.sorting-scene.record.case-damaged .box-exception,
.sorting-scene.blocked .box-exception {
  opacity: 1;
}

.sorting-scan-beam {
  position: absolute;
  z-index: 4;
  left: 30%;
  top: 16%;
  width: 32%;
  height: 32%;
  opacity: 0;
  background: linear-gradient(105deg, rgba(20, 194, 204, 0.38), rgba(20, 194, 204, 0));
  clip-path: polygon(45% 0, 100% 100%, 0 100%);
  pointer-events: none;
}

.sorting-scene.capture .sorting-scan-beam,
.sorting-scene.detect .sorting-scan-beam,
.sorting-scene.classify .sorting-scan-beam,
.sorting-scene.blocked .sorting-scan-beam {
  opacity: 1;
  animation: sortingScanPulse 1.35s ease-in-out infinite;
}

.sorting-result-card,
.sorting-route-card {
  width: 220px;
  padding: 12px;
  border: 1px solid rgba(11, 92, 173, 0.22);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 12px 28px rgba(9, 24, 44, 0.12);
}

.sorting-result-card {
  left: 28px;
  bottom: 30px;
}

.sorting-route-card {
  right: 30px;
  top: 30px;
  border-color: rgba(20, 194, 204, 0.34);
  background: rgba(236, 252, 255, 0.88);
}

.sorting-result-card p,
.sorting-route-card p {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.sorting-result-card strong,
.sorting-route-card strong {
  color: var(--ink);
  font-size: 1rem;
}

.sorting-scene.blocked .sorting-result-card {
  border-color: rgba(225, 75, 75, 0.35);
  background: #fff5f3;
}

.sorting-flow {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.sorting-flow li {
  min-height: 74px;
  padding: 10px;
  border: 1px solid rgba(9, 24, 44, 0.09);
  border-radius: var(--radius);
  background: #f7fbff;
  color: #31516b;
}

.sorting-flow li.is-active {
  border-color: rgba(11, 92, 173, 0.38);
  background: #edf6ff;
  box-shadow: inset 0 0 0 2px rgba(11, 92, 173, 0.08);
}

.sorting-flow li.is-done {
  border-color: rgba(39, 189, 117, 0.28);
  background: #f0fbf5;
}

.sorting-flow li.is-error {
  border-color: rgba(225, 75, 75, 0.32);
  background: #fff5f3;
}

.sorting-flow span {
  display: block;
  margin-bottom: 6px;
  color: var(--official-blue);
  font-size: 0.74rem;
  font-weight: 950;
}

.sorting-flow strong {
  display: block;
  font-size: 0.86rem;
  line-height: 1.35;
}

.sorting-lesson-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.sorting-lesson-grid article {
  min-height: 104px;
  padding: 12px;
  border: 1px solid rgba(9, 24, 44, 0.08);
  border-radius: var(--radius);
  background: #fbfdff;
}

.sorting-lesson-grid span {
  display: block;
  margin-bottom: 6px;
  color: var(--official-blue);
  font-size: 0.78rem;
  font-weight: 950;
}

.sorting-lesson-grid p {
  margin: 0;
  color: var(--dock-slate);
  font-size: 0.9rem;
  line-height: 1.5;
}

.sorting-console {
  display: grid;
  gap: 12px;
}

.sorting-console .panel {
  padding: 14px;
}

.sorting-data-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.sorting-data-grid article {
  display: grid;
  min-height: 82px;
  align-content: center;
  padding: 10px;
  border: 1px solid rgba(9, 24, 44, 0.08);
  border-radius: var(--radius);
  background: #f7fbff;
}

.sorting-data-grid span {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
}

.sorting-data-grid strong {
  margin-top: 4px;
  color: var(--ink);
  font-size: 1.05rem;
}

.sorting-reason-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

#sortingRiskBadge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #effbff;
  color: #075985;
  font-size: 0.74rem;
  font-weight: 950;
  white-space: nowrap;
}

.sorting-reason-panel.is-risk #sortingRiskBadge {
  background: #fff4e5;
  color: #9a5400;
}

.sorting-reason-panel.is-blocked #sortingRiskBadge {
  background: #fff1f0;
  color: #a62626;
}

.sorting-check-list {
  display: grid;
  gap: 8px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
}

.sorting-check-list li {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid rgba(9, 24, 44, 0.08);
  border-radius: var(--radius);
  background: #fbfdff;
  color: var(--dock-slate);
  font-size: 0.88rem;
  font-weight: 800;
}

.sorting-check-list span {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #b8c5d2;
}

.sorting-check-list li.is-pass span {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(39, 189, 117, 0.1);
}

.sorting-check-list li.is-fail span {
  background: var(--alert);
  box-shadow: 0 0 0 5px rgba(225, 75, 75, 0.1);
}

#sortingReasonText {
  margin: 0;
  padding: 10px 12px;
  border-left: 4px solid var(--amber);
  border-radius: var(--radius);
  background: #fff9eb;
  color: #684608;
  font-size: 0.9rem;
  font-weight: 850;
  line-height: 1.45;
}

@keyframes sortingScanPulse {
  0%,
  100% {
    filter: saturate(1);
    transform: scale(0.98);
  }
  50% {
    filter: saturate(1.2);
    transform: scale(1.02);
  }
}

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

  .sorting-console {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .sorting-reason-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 820px) {
  .sorting-hero,
  .sorting-stage-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .sorting-scene {
    min-height: 620px;
  }

  .sorting-flow,
  .sorting-lesson-grid,
  .sorting-console {
    grid-template-columns: 1fr;
  }

  .sorting-camera-tag {
    left: 34%;
    top: 94px;
  }

  .sorting-result-card,
  .sorting-route-card {
    width: 190px;
  }
}

@media (max-width: 520px) {
  .sorting-data-grid {
    grid-template-columns: 1fr;
  }
}
