/* order-saga: order form, shared services, swimlane timeline. */

.panel h2.with-action { display: flex; align-items: center; }

.text-link {
  margin-left: auto;
  font: inherit;
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: none;
  background: none;
  color: #60a5fa;
  cursor: pointer;
}

.panel .empty { font-size: 0.72rem; color: #475569; list-style: none; }

/* ── Order form ── */
.products {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.product {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0.5rem 0.6rem;
  border: 1px solid #1e293b;
  border-radius: 9px;
  background: #0f1117;
  font-size: 0.74rem;
}

.product.picked { border-color: #6366f1; }

.product-info { flex: 1; min-width: 0; }
.product-name { color: #cbd5e1; }
.product-meta { font-size: 0.62rem; color: #475569; }
.product-meta.low { color: #f59e0b; }
.product-meta.out { color: #ef4444; }

.stepper { display: flex; align-items: center; gap: 4px; }

.stepper button {
  width: 24px;
  height: 24px;
  border: 1px solid #1e293b;
  border-radius: 6px;
  background: #13192a;
  color: #a5b4fc;
  font: inherit;
  cursor: pointer;
}

.stepper button:disabled { opacity: 0.35; cursor: default; }

.stepper output {
  min-width: 1.2rem;
  text-align: center;
  font-family: 'Courier New', monospace;
  color: #a5b4fc;
}

.order-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 0.9rem;
  margin-top: 0.8rem;
}

.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.field select {
  max-width: 100%;
  font: inherit;
  font-size: 0.76rem;
  padding: 5px 8px;
  border: 1px solid #1e293b;
  border-radius: 8px;
  background: #0f1117;
  color: #a5b4fc;
}

.faults {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px 14px;
  margin-top: 0.8rem;
  padding: 0.6rem 0.7rem 0.7rem;
  border: 1px dashed #2a3550;
  border-radius: 9px;
}

.faults legend { padding: 0 4px; }

.faults label {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 6px;
  font-size: 0.72rem;
  color: #cbd5e1;
  cursor: pointer;
}

.faults input { accent-color: #ef4444; }
.faults em { font-style: normal; font-size: 0.62rem; color: #475569; }

.order-actions {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  margin-top: 0.9rem;
}

.order-total {
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  color: #a5b4fc;
}

.form-error { margin-top: 0.6rem; font-size: 0.74rem; color: #ef4444; }

/* ── Services ── */
.services {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 14px;
}

.services-label {
  margin-bottom: 0.45rem;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #475569;
}

.services-label span { text-transform: none; letter-spacing: 0; color: #334155; }

.key-reserved {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: #f59e0b;
}

.stock { list-style: none; display: flex; flex-direction: column; gap: 7px; }

.stock-row {
  display: grid;
  grid-template-columns: 6.5rem minmax(0, 1fr) 3.2rem;
  align-items: center;
  gap: 8px;
  font-size: 0.68rem;
  color: #94a3b8;
}

.stock-bar {
  position: relative;
  display: flex;
  height: 8px;
  border-radius: 999px;
  background: #1e293b;
  overflow: hidden;
}

.stock-bar .free { background: linear-gradient(90deg, #34d399, #60a5fa); transition: width 0.3s ease; }
.stock-bar .held { background: #f59e0b; transition: width 0.3s ease; }

.stock-count {
  text-align: right;
  font-family: 'Courier New', monospace;
  color: #a5b4fc;
}

.ledger {
  display: grid;
  grid-template-columns: auto auto;
  gap: 4px 10px;
  font-size: 0.68rem;
}

.ledger dt { color: #64748b; }
.ledger dd { text-align: right; font-family: 'Courier New', monospace; color: #a5b4fc; }
.ledger dd.held { color: #f59e0b; }
.ledger dd.good { color: #34d399; }

/* ── Timeline ── */
.outcome {
  margin-bottom: 0.7rem;
  padding: 0.55rem 0.7rem;
  border-radius: 9px;
  font-size: 0.74rem;
  line-height: 1.45;
  background: #1e293b;
  color: #cbd5e1;
}

.outcome b { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.68rem; margin-right: 6px; }
.outcome.running    { background: rgba(96,165,250,.12); }
.outcome.running b  { color: #60a5fa; }
.outcome.confirmed  { background: rgba(52,211,153,.12); }
.outcome.confirmed b { color: #34d399; }
.outcome.cancelled, .outcome.compensating { background: rgba(245,158,11,.12); }
.outcome.cancelled b, .outcome.compensating b { color: #f59e0b; }
.outcome.needs-attention { background: rgba(239,68,68,.14); }
.outcome.needs-attention b { color: #ef4444; }
.outcome .warning { display: block; margin-top: 3px; color: #f59e0b; font-size: 0.68rem; }

.timeline-wrap {
  display: grid;
  grid-template-columns: 4.6rem minmax(0, 1fr);
  --lane: 3.4rem;
}

.lanes {
  list-style: none;
  display: grid;
  grid-auto-rows: var(--lane);
  row-gap: 5px;
}

.lanes li {
  display: flex;
  align-items: center;
  font-size: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #475569;
}

.timeline-scroll {
  scrollbar-color: #334155 transparent;
  overflow-x: auto;
  padding-bottom: 4px;
}

.timeline {
  display: grid;
  /* one 8rem column per action; the count is set from JS */
  grid-template-rows: repeat(5, var(--lane));
  gap: 5px;
}

.lane-track {
  grid-column: 1 / -1;
  align-self: center;
  height: 1px;
  background: #1e293b;
}

.chip {
  position: relative;
  align-self: center;
  z-index: 0;
  min-width: 0;
  padding: 4px 6px;
  border-radius: 7px;
  border: 1px solid;
  font-size: 0.6rem;
  line-height: 1.3;
  animation: chip-in 0.25s ease-out;
}

.chip-action {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: 'Courier New', monospace;
  font-size: 0.64rem;
}

.chip-detail {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  color: #94a3b8;
  overflow-wrap: anywhere;
}

.chip.forward    { border-color: rgba(52,211,153,.45); background: rgba(52,211,153,.1); color: #34d399; }
.chip.retry      { border-color: rgba(96,165,250,.45); background: rgba(96,165,250,.1); color: #60a5fa; }
.chip.error      { border-color: rgba(239,68,68,.5);  background: rgba(239,68,68,.1);  color: #ef4444; }
.chip.compensate { border-color: rgba(245,158,11,.5); background: rgba(245,158,11,.1); color: #f59e0b; }
.chip.pending    { border-style: dashed; border-color: #334155; color: #64748b; animation: blink 0.9s ease-in-out infinite; }

.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 0.6rem;
  font-size: 0.62rem;
  color: #64748b;
}

.legend li::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 5px;
  border-radius: 2px;
  vertical-align: -1px;
}

.legend .forward::before    { background: #34d399; }
.legend .retry::before      { background: #60a5fa; }
.legend .error::before      { background: #ef4444; }
.legend .compensate::before { background: #f59e0b; }

/* ── Recent orders ── */
.recent { list-style: none; display: flex; flex-direction: column; gap: 5px; }

.recent button {
  width: 100%;
  display: grid;
  grid-template-columns: 4.2rem 6.8rem minmax(0, 1fr) 4rem;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid #1e293b;
  border-radius: 8px;
  background: #0f1117;
  font: inherit;
  font-size: 0.68rem;
  color: #94a3b8;
  text-align: left;
  cursor: pointer;
}

.recent button.selected { border-color: #6366f1; }

.recent-id { font-family: monospace; color: #475569; }
.recent-items { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-total { text-align: right; font-family: 'Courier New', monospace; color: #a5b4fc; }

.tag {
  justify-self: start;
  padding: 1px 7px;
  border-radius: 999px;
  font-family: monospace;
  font-size: 0.62rem;
  background: #1e293b;
  color: #60a5fa;
}

.tag.confirmed { background: rgba(52,211,153,.14); color: #34d399; }
.tag.cancelled, .tag.compensating { background: rgba(245,158,11,.14); color: #f59e0b; }
.tag.needs-attention { background: rgba(239,68,68,.14); color: #ef4444; }

@keyframes chip-in { from { opacity: 0; transform: translateY(3px); } }
@keyframes blink { 50% { opacity: 0.45; } }

@media (max-width: 700px) {
  .products, .faults, .services { grid-template-columns: 1fr; }
  .recent button { grid-template-columns: 6.8rem minmax(0, 1fr) 4rem; }
  .recent-id { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .chip, .chip.pending { animation: none; }
  .stock-bar .free, .stock-bar .held { transition: none; }
}
