/* ============================================================
   Orders & Account Area
   ============================================================ */

/* ---- Orders index ---- */
.orders-page {
  padding-bottom: var(--space-16);
}

.orders-header {
  padding: var(--space-8) 0 var(--space-6);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-6);
}

.orders-header__eyebrow {
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-2);
}

.orders-header__title {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--navy-900);
  margin-bottom: var(--space-2);
}

.orders-header__description {
  font-size: var(--font-size-base);
  color: var(--text-muted);
  margin: 0;
}

/* Orders list */
.orders-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* Order card */
.order-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  transition: box-shadow var(--transition-base), border-color var(--transition-base);
}

.order-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--navy-200);
}

.order-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.order-card__number {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--navy-900);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.order-card__body {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.order-card__meta {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin: 0;
}

.order-card__sep {
  margin: 0 var(--space-2);
  color: var(--border-strong);
}

.order-card__items {
  font-size: var(--font-size-xs);
  color: var(--text-soft);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.order-card__total {
  font-size: var(--font-size-lg);
  font-weight: 700;
  color: var(--navy-900);
}

.order-card__link {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--navy-500);
  text-decoration: none;
  transition: color var(--transition-fast);
}

.order-card__link:hover {
  color: var(--navy-900);
  text-decoration: underline;
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  font-size: var(--font-size-xs);
  font-weight: 600;
  padding: 3px var(--space-3);
  border-radius: var(--radius-xl);
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.status-badge--lg {
  font-size: var(--font-size-sm);
  padding: var(--space-2) var(--space-4);
}

.status-badge--pending {
  background-color: #fef9c3;
  color: #854d0e;
}

.status-badge--confirmed {
  background-color: #dbeafe;
  color: #1e40af;
}

.status-badge--processing {
  background-color: var(--navy-100);
  color: var(--navy-700);
}

.status-badge--shipped {
  background-color: #d1fae5;
  color: #065f46;
}

.status-badge--delivered {
  background-color: var(--cta-soft);
  color: var(--cta);
}

.status-badge--cancelled {
  background-color: #fee2e2;
  color: var(--danger);
}

/* ---- Order detail page ---- */
.order-detail-page {
  padding-bottom: var(--space-16);
}

.order-detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-8) 0 var(--space-6);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-6);
}

.order-detail-header__title {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--navy-900);
  margin-bottom: var(--space-1);
}

.order-detail-header__date {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin: 0;
}

/* Two-column layout: items | sidebar */
.order-detail-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: var(--space-8);
  align-items: start;
  margin-bottom: var(--space-8);
}

/* Order items list */
.order-items {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.order-item {
  display: grid;
  grid-template-columns: 64px 1fr auto auto auto;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.order-item:last-child {
  border-bottom: none;
}

.order-item__media {
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}

.order-item__image {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background-color: var(--surface-muted);
  padding: var(--space-1);
  display: block;
}

.order-item__placeholder {
  width: 64px;
  height: 64px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background-color: var(--surface-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xs);
  color: var(--text-soft);
}

.order-item__content {
  min-width: 0;
}

.order-item__title {
  display: block;
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  line-height: var(--line-height-tight);
  margin-bottom: var(--space-1);
}

.order-item__title:hover {
  color: var(--navy-500);
}

.order-item__title--deleted {
  color: var(--text-muted);
}

.order-item__meta {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  margin: 0;
}

.order-item__sep {
  margin: 0 var(--space-1);
}

.order-item__quantity,
.order-item__price,
.order-item__subtotal {
  font-size: var(--font-size-sm);
  text-align: right;
  white-space: nowrap;
}

.order-item__qty-label,
.order-item__price-label {
  display: block;
  font-size: var(--font-size-xs);
  color: var(--text-soft);
  margin-bottom: 2px;
}

.order-item__subtotal {
  font-weight: 700;
  color: var(--navy-700);
}

/* Sidebar cards */
.order-status-panel,
.order-summary-card,
.order-comments,
.order-customer-info {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}

.order-status-panel:last-child,
.order-summary-card:last-child,
.order-comments:last-child,
.order-customer-info:last-child {
  margin-bottom: 0;
}

.order-status-panel__title,
.order-summary-card__title,
.order-comments__title,
.order-customer-info__title {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--navy-900);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

/* Timeline */
.order-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.timeline-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  position: relative;
  padding: var(--space-2) 0;
  font-size: var(--font-size-sm);
  color: var(--text-soft);
}

.timeline-item:not(:last-child) {
  padding-bottom: var(--space-4);
}

.timeline-item:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 7px;
  top: calc(var(--space-2) + 16px);
  width: 2px;
  height: calc(100% - var(--space-2));
  background-color: var(--border);
}

.timeline-item__dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: var(--border);
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

.timeline-item__label {
  line-height: var(--line-height-tight);
}

.timeline-item--active {
  color: var(--text);
}

.timeline-item--active .timeline-item__dot {
  background-color: var(--cta);
}

.timeline-item--active:not(:last-child)::after {
  background-color: var(--cta);
}

/* Summary card */
.order-summary-card__row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-3);
}

.order-summary-card__shipping {
  font-size: var(--font-size-xs);
  font-style: italic;
}

.order-summary-card__total {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--navy-900);
  padding-top: var(--space-3);
  border-top: 2px solid var(--border);
  margin-top: var(--space-1);
}

/* Comments */
.order-comments__text {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  line-height: var(--line-height-relaxed);
}

.order-comments__text p {
  margin-bottom: var(--space-2);
}

.order-comments__text p:last-child {
  margin-bottom: 0;
}

/* Customer info */
.order-customer-info__name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-1);
}

.order-customer-info__email,
.order-customer-info__rut {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-1);
}

/* Actions */
.order-actions {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* ---- Responsive ---- */

@media (max-width: 991px) {
  .order-detail-layout {
    grid-template-columns: 1fr;
  }

  .orders-header__title {
    font-size: var(--font-size-2xl);
  }

  .order-detail-header__title {
    font-size: var(--font-size-2xl);
  }
}

@media (max-width: 767px) {
  .order-detail-header {
    flex-direction: column;
    gap: var(--space-3);
  }

  .order-item {
    grid-template-columns: 56px 1fr;
    grid-template-rows: auto auto;
    gap: var(--space-2) var(--space-3);
  }

  .order-item__media {
    grid-row: 1 / 3;
    width: 56px;
    height: 56px;
    align-self: start;
  }

  .order-item__image,
  .order-item__placeholder {
    width: 56px;
    height: 56px;
  }

  .order-item__content {
    grid-column: 2;
    grid-row: 1;
  }

  .order-item__quantity,
  .order-item__price,
  .order-item__subtotal {
    grid-column: 2;
    grid-row: 2;
    text-align: left;
  }

  .order-item__quantity,
  .order-item__price {
    display: inline-flex;
    flex-direction: column;
  }

  .order-item__subtotal {
    font-size: var(--font-size-base);
    align-self: center;
  }
}
