:root {
  color-scheme: light;
}

.order-history-page {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 12% 20%, #fff7ed, transparent 30%),
    radial-gradient(circle at 88% 18%, #eef2ff, transparent 32%),
    linear-gradient(180deg, #f8fafc, #eef2ff);
  color: var(--ui-text, #0f172a);
  font-family: var(--ui-font-body, "Rubik", "Segoe UI", sans-serif);
  padding: var(--ui-shell-padding, clamp(18px, 5vw, 64px))
    clamp(18px, 4vw, 48px)
    clamp(32px, 6vw, 88px);
}

.order-history-shell {
  width: min(var(--ui-content-max, 1200px), 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: clamp(18px, 3vw, 32px);
}

.order-history-hero {
  background: linear-gradient(135deg, rgba(255, 122, 24, 0.1), #fff);
  border: 1px solid rgba(17, 17, 17, 0.05);
  border-radius: var(--ui-radius-xl, 32px);
  padding: clamp(20px, 3vw, 36px);
  display: grid;
  gap: clamp(16px, 2vw, 24px);
  box-shadow: var(--ui-shadow-soft, 0 24px 55px rgba(15, 23, 42, 0.15));
}

.order-history-hero__lead h1 {
  margin: 6px 0 8px;
  font-size: clamp(1.8rem, 2.6vw, 2.35rem);
}

.order-history__eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ui-text-muted, #6b7280);
  margin: 0;
  font-weight: 600;
  font-size: 0.9rem;
}

.order-history__subhead {
  margin: 0 0 8px;
  color: var(--ui-text-muted, #6b7280);
}

.order-history-hero__actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.order-history-hero__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: clamp(12px, 2vw, 18px);
}

.order-history-stat {
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid rgba(17, 17, 17, 0.04);
  border-radius: var(--ui-radius-lg, 24px);
  padding: 14px 16px;
  box-shadow: var(--ui-shadow-card, 0 12px 30px rgba(15, 23, 42, 0.12));
}

.order-history-stat__label {
  margin: 0;
  color: var(--ui-text-muted, #6b7280);
  font-size: 0.92rem;
}

.order-history-stat__value {
  display: block;
  font-size: 1.6rem;
  margin: 4px 0 2px;
  color: var(--ui-text-strong, #0f172a);
}

.order-history-stat__hint {
  color: var(--ui-text-muted, #6b7280);
  font-size: 0.9rem;
}

.order-history-empty__card {
  background: var(--ui-surface, #ffffff);
  border: 1px solid var(--ui-border, rgba(17, 17, 17, 0.08));
  border-radius: var(--ui-radius-xl, 32px);
  padding: var(--ui-card-padding, clamp(20px, 2.6vw, 30px));
  display: grid;
  gap: 12px;
  align-items: center;
  box-shadow: var(--ui-shadow-card, 0 12px 30px rgba(15, 23, 42, 0.12));
}

.order-history-grid {
  display: grid;
  gap: clamp(14px, 2vw, 20px);
}

.order-history-card {
  background: var(--ui-surface, #ffffff);
  border-radius: var(--ui-radius-lg, 24px);
  border: 1px solid var(--ui-border, rgba(17, 17, 17, 0.08));
  padding: var(--ui-card-padding, clamp(20px, 2.6vw, 30px));
  box-shadow: var(--ui-shadow-card, 0 12px 30px rgba(15, 23, 42, 0.12));
  display: grid;
  grid-template-areas:
    "header"
    "details"
    "total"
    "footer";
  gap: 12px;
}

.order-history-card__header {
  grid-area: header;
  order: 0;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 12px;
  position: relative;
}

.order-history-card__summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.order-history-card__title {
  margin: 0;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  color: var(--ui-text-strong, #0f172a);
}

.order-history-card__meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 10px;
  margin: 4px 0 0;
  padding: 12px;
  border-radius: var(--ui-radius-md, 18px);
  background: linear-gradient(
    135deg,
    rgba(255, 122, 24, 0.08),
    rgba(15, 23, 42, 0.02)
  );
  border: 1px solid var(--ui-border, rgba(17, 17, 17, 0.08));
  box-shadow: 0 14px 32px rgba(15, 23, 42, 0.08);
}

.order-history-card__meta-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: #fff;
  border: 1px solid rgba(17, 17, 17, 0.05);
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.order-history-card__meta-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: linear-gradient(
    135deg,
    rgba(255, 122, 24, 0.16),
    rgba(224, 103, 12, 0.22)
  );
  color: #e0670c;
}

.order-history-card__meta-icon--accent {
  background: linear-gradient(
    135deg,
    rgba(34, 197, 94, 0.16),
    rgba(74, 222, 128, 0.26)
  );
  color: #15803d;
}

.order-history-card__meta-copy {
  min-width: 0;
}

.order-history-card__meta-label {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ui-text-muted, #6b7280);
}

.order-history-card__meta-value {
  margin: 2px 0 0;
  color: var(--ui-text-strong, #0f172a);
  font-weight: 700;
  line-height: 1.3;
  word-break: break-word;
}

.order-history-card__total {
  grid-area: total;
  order: 2;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 12px 16px;
  border-radius: 18px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  background: linear-gradient(
    120deg,
    var(--ui-primary, #ff7a18),
    #ff9a3c 48%,
    var(--ui-primary-dark, #e0670c)
  );
  color: #fff;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25),
    0 12px 32px rgba(224, 103, 12, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.order-history-card__total-label {
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.9;
  color: rgba(255, 255, 255, 0.88);
}

.order-history-card__total-value {
  font-weight: 800;
  font-size: 1.18rem;
  color: #ffffff;
  text-shadow: 0 10px 24px rgba(15, 23, 42, 0.24);
}

.order-history-card__total--below {
  margin-top: 12px;
  align-self: stretch;
}

@media (min-width: 641px) and (max-width: 1200px) {
  .order-history-card__header {
    grid-template-columns: minmax(0, 1.2fr) auto;
    gap: 12px 16px;
    align-items: start;
  }

  .order-history-card__summary {
    gap: 10px;
  }

  .order-history-card__meta {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    padding: 12px 14px;
  }

  .order-history-card__meta-item {
    gap: 10px;
  }

  .order-history-card__total {
    gap: 10px;
    align-self: stretch;
  }

  .order-history-card__badges {
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    flex-direction: row;
  }
}

.order-history-card__total-mobile {
  display: none;
  margin: 6px 0 0;
  color: #ffffff;
  font-weight: 700;
  gap: 8px;
  background: linear-gradient(
    120deg,
    var(--ui-primary, #ff7a18),
    #ff9a3c 48%,
    var(--ui-primary-dark, #e0670c)
  );
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: 0 14px 28px rgba(15, 23, 42, 0.14),
    0 10px 22px rgba(224, 103, 12, 0.2);
}

.order-history-card__header .order-history__eyebrow {
  display: inline-block;
}

.order-history-card__badges {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  justify-self: end;
  align-self: start;
  margin-left: auto;
}

.order-history-badge {
  border-radius: var(--ui-radius-pill, 999px);
  border: 1px solid var(--ui-border, rgba(17, 17, 17, 0.08));
  padding: 8px 12px;
  background: var(--ui-surface-muted, #f8f8fb);
  color: var(--ui-text, #0f172a);
  font-size: 0.95rem;
}

.order-history-badge--delivery {
  border-color: rgba(34, 197, 94, 0.3);
  background: rgba(34, 197, 94, 0.08);
}

.order-history-badge--pickup {
  border-color: rgba(234, 88, 12, 0.25);
  background: rgba(251, 146, 60, 0.12);
}

.order-history-details {
  grid-area: details;
  order: 1;
  border-radius: var(--ui-radius-md, 18px);
  border: 1px solid var(--ui-border, rgba(17, 17, 17, 0.08));
  background: var(--ui-surface-muted, #f8f8fb);
  padding: 10px 12px;
}

.order-history-details[open] .order-history-details__summary i {
  transform: rotate(180deg);
}

.order-history-details__summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 5px 0;
  font-weight: 700;
  color: var(--ui-text-strong, #0f172a);
  cursor: pointer;
  user-select: none;
}

.order-history-details summary::-webkit-details-marker {
  display: none;
}

.order-history-details__summary i {
  transition: transform 0.2s ease;
}

.order-history-items {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.order-history-item {
  background: #fff;
  border-radius: var(--ui-radius-md, 18px);
  border: 1px solid var(--ui-border, rgba(17, 17, 17, 0.08));
  padding: 10px 12px;
  display: grid;
  gap: 6px;
}

.order-history-item__head {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.order-history-item__info {
  flex: 1;
}

.order-history-item__thumb {
  width: 72px;
  height: 72px;
  min-width: 72px;
  min-height: 72px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--ui-border, rgba(17, 17, 17, 0.08));
  background: var(--ui-surface-muted, #f8f8fb);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-in;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.order-history-item__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.order-history-item__thumb--placeholder {
  width: 66px;
  height: 66px;
  min-width: 66px;
  min-height: 66px;
  border-radius: 16px;
  cursor: default;
}

.order-history-item__thumb--placeholder img {
  width: 54px;
  height: 54px;
  max-width: 78%;
  max-height: 78%;
  object-fit: contain;
  opacity: 0.75;
  padding: 4px;
}

.order-history-badge-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.order-history-item__name {
  margin: 0;
  font-weight: 600;
  color: var(--ui-text-strong, #0f172a);
}

.order-history-item__meta {
  color: var(--ui-text-muted, #6b7280);
  font-size: 0.95rem;
}

.order-history-item__extras,
.order-history-item__exclusions {
  margin: 6px 0 0;
  color: var(--ui-text-muted, #6b7280);
  font-size: 0.95rem;
}

.order-history-card__footer {
  grid-area: footer;
  order: 3;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  border-top: 1px dashed var(--ui-border, rgba(17, 17, 17, 0.08));
  padding-top: 10px;
  color: var(--ui-text-muted, #6b7280);
}

.order-history-card--active {
  outline: 2px solid var(--ui-primary, #ff7a18);
}
.order-history-card--delivery.order-history-card--active {
  border-color: #22c55e;
  outline-color: #22c55e;
}

.order-history-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.72);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  z-index: 10000;
  padding: 16px;
}

.order-history-lightbox__inner {
  position: relative;
  max-width: min(90vw, 720px);
  max-height: min(84vh, 820px);
  background: #0b1220;
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.order-history-lightbox__inner img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #0b1220;
}

.order-history-lightbox__close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  border-radius: 999px;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

@media (max-width: 640px) {
  .order-history-card__header {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .order-history-card__summary {
    gap: 10px;
  }

  .order-history-card__meta {
    grid-template-columns: 1fr;
    padding: 10px;
    margin-top: 2px;
    box-shadow: 0 10px 22px rgba(15, 23, 42, 0.08);
  }

  .order-history-card__meta-item {
    gap: 10px;
    padding: 10px;
  }

  .order-history-card__meta-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .order-history-card__total {
    gap: 10px;
  }

  .order-history-card__badges {
    width: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 0;
    justify-self: end;
  }

  .order-history-details {
    border: none;
    background: transparent;
    padding: 0;
  }

  .order-history-details__summary {
    padding: 10px 0;
    border-top: 1px solid var(--ui-border, rgba(17, 17, 17, 0.08));
  }

  .order-history-item {
    border: 1px solid var(--ui-border, rgba(17, 17, 17, 0.08));
    padding: 10px;
  }

  .order-history-item__head {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .order-history-item__thumb {
    width: 60px;
    height: 60px;
    min-width: 60px;
    min-height: 60px;
  }

  .order-history-item__thumb--placeholder {
    width: 54px;
    height: 54px;
  }

  .order-history-card__footer {
    gap: 6px;
  }
}

@media (max-width: 640px) {
  .order-history-item__head {
    align-items: flex-start;
    gap: 10px;
  }

  .order-history-item__thumb {
    order: 2;
  }

  .order-history-badge-row {
    justify-content: flex-end;
  }
}
