/* ============================================================
   orders.css — "meus pedidos" (lista) e detalhe do pedido (US-5.1)
   ============================================================ */

.orders-page,
.order-page { padding-block: 32px 64px; }
.orders-page [hidden],
.order-page [hidden] { display: none !important; }

.orders-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.orders-head h1 { font-size: 40px; line-height: 1.1; }
.orders-meta { font-size: 13px; color: var(--muted); }
.orders-loading { color: var(--muted); padding: 40px 0; }
.orders-empty-cta { margin-top: 18px; }

/* ---------- Selo de status ---------- */
.order-status {
  display: inline-block;
  border-radius: var(--r-pill);
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .2px;
  background: var(--line-2);
  color: var(--muted);
  white-space: nowrap;
}
.order-status.is-pending_payment { background: #FBF2E6; color: #8A6127; }
.order-status.is-paid { background: #EDF1E7; color: #566246; }
.order-status.is-processing,
.order-status.is-shipped { background: var(--sage-tint); color: var(--sage-deep); }
.order-status.is-delivered { background: #E7EEF1; color: #3F5A66; }
.order-status.is-canceled { background: #FBEDE9; color: #8A4B3B; }

/* ---------- Lista ---------- */
.order-list { list-style: none; display: grid; gap: 12px; }

.order-card-link {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r);
  padding: 14px 18px;
  transition: border-color .18s, transform .18s, box-shadow .25s;
}
.order-card-link:hover {
  border-color: var(--sage);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.order-card-link:focus-visible { outline: 2px solid var(--sage); outline-offset: 2px; }

.order-thumb {
  width: 60px;
  height: 72px;
  flex: none;
  border-radius: var(--r-sm);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.order-thumb img { width: 100%; height: 100%; object-fit: cover; }
.order-thumb .art { width: 56%; height: 56%; }

.order-info { flex: 1; min-width: 0; display: grid; gap: 2px; }
.order-number { font-family: var(--font-serif); font-size: 19px; font-weight: 600; }
.order-summary {
  font-size: 13.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.order-date { font-size: 12.5px; color: var(--faint); }

.order-right { display: grid; gap: 8px; justify-items: end; text-align: right; }
.order-total { font-size: 15px; font-weight: 500; white-space: nowrap; }

.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 28px; }
.pager-info { font-size: 13px; color: var(--muted); }

/* ---------- Detalhe ---------- */
.order-head { margin-bottom: 24px; }
.order-head .back-link { display: inline-block; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.order-head .back-link:hover { color: var(--ink); }
.order-head h1 { font-size: 34px; line-height: 1.15; }
.order-placed { font-size: 13.5px; color: var(--muted); margin: 4px 0 12px; }

.order-layout {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 24px;
  align-items: start;
}
.order-main { display: grid; gap: 20px; }

.order-items { list-style: none; margin-bottom: 14px; }
.order-item {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-2);
}
.order-item:last-child { border-bottom: none; }
.order-item-info { display: grid; gap: 2px; }
.order-item-name { font-size: 14.5px; }
.order-item-unit { font-size: 12.5px; color: var(--muted); }
.order-item-total { font-size: 14.5px; font-weight: 500; white-space: nowrap; }

.sum-row { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; color: var(--muted); padding: 6px 0; }
.sum-row span:last-child { color: var(--ink); font-weight: 500; }
.sum-total { border-top: 1px solid var(--line-2); margin-top: 6px; padding-top: 12px; }
.sum-total span:last-child { font-family: var(--font-serif); font-size: 24px; font-weight: 600; }

/* ---------- Linha do tempo ---------- */
.timeline { list-style: none; position: relative; padding-left: 26px; }
.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 8px;
  bottom: 12px;
  width: 1px;
  background: var(--line);
}
.timeline-step { position: relative; padding: 0 0 20px; }
.timeline-step:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -26px;
  top: 4px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--line);
}
.timeline-step.is-current .timeline-dot { border-color: var(--sage); background: var(--sage); }
.timeline-step.is-canceled.is-current .timeline-dot { border-color: var(--rose); background: var(--rose); }
.timeline-body { display: grid; gap: 2px; }
.timeline-label { font-size: 14.5px; font-weight: 500; }
.timeline-date { font-size: 12.5px; color: var(--faint); }
.timeline-note { font-size: 13px; color: var(--muted); margin-top: 2px; }
.timeline-empty { color: var(--muted); font-size: 13.5px; }

.order-side { position: sticky; top: 88px; }
.order-side h2 { margin-bottom: 12px; }
.order-side-actions { margin-top: 16px; display: grid; gap: 8px; }
.account-orders { margin-top: 18px; }

/* ---------- Responsivo ---------- */
@media (max-width: 820px) {
  .order-layout { grid-template-columns: 1fr; }
  .order-side { position: static; }
}
@media (max-width: 620px) {
  .orders-head h1 { font-size: 32px; }
  .order-head h1 { font-size: 27px; }
  .order-card-link { gap: 12px; padding: 12px 14px; }
  .order-thumb { width: 48px; height: 58px; }
  .order-number { font-size: 17px; }
  .order-status { font-size: 11px; padding: 3px 9px; }
}

/* ---------- Rastreio da entrega (US-5.3) ---------- */

/* Régua de etapas: pontos ligados por uma linha, com rótulo embaixo. */
.delivery-track {
  list-style: none;
  display: flex;
  margin: 4px 0 22px;
}
.track-step {
  flex: 1;
  position: relative;
  text-align: center;
  padding-top: 20px;
}
/* Linha entre um ponto e o anterior. */
.track-step::before {
  content: '';
  position: absolute;
  top: 6px;
  right: 50%;
  left: -50%;
  height: 2px;
  background: var(--line);
}
.track-step:first-child::before { display: none; }
.track-step.is-done::before,
.track-step.is-current::before { background: var(--sage); }

.track-dot {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--card);
  border: 2px solid var(--line);
}
.track-step.is-done .track-dot { background: var(--sage); border-color: var(--sage); }
.track-step.is-current .track-dot {
  background: var(--sage);
  border-color: var(--sage);
  box-shadow: 0 0 0 4px var(--sage-tint);
}

.track-label {
  display: block;
  font-size: 12px;
  line-height: 1.3;
  color: var(--faint);
  padding: 0 4px;
}
.track-step.is-done .track-label { color: var(--muted); }
.track-step.is-current .track-label { color: var(--ink); font-weight: 600; }

.delivery-facts {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  margin-bottom: 18px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  font-size: 13.5px;
}
.delivery-facts div { display: flex; justify-content: space-between; gap: 12px; }
.delivery-facts span { color: var(--muted); }
.delivery-facts strong { font-weight: 500; text-align: right; }
.delivery-facts #trackingCode { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .3px; }
.delivery-facts:not(:has(div:not([hidden]))) { display: none; }

.delivery-events .timeline-note { color: var(--muted); }

@media (max-width: 620px) {
  .delivery-track { flex-wrap: wrap; gap: 14px 0; }
  .track-step { flex: 0 0 33.333%; }
  /* Com quebra de linha, a régua contínua confunde: cada ponto fica solto. */
  .track-step::before { display: none; }
  .track-label { font-size: 11.5px; }
}
