/* Purchase history — align chrome with Profile + ShellNavBar */

.dz-phist {
  /* Body pad-top only (shell navbar hidden on this route) */
  --dz-phist-top-offset: 12px;
  position: relative;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
  isolation: isolate;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Full-bleed to stage edges (body.is-no-tabbar is already 100% wide) */
.dz-phist__wash {
  position: absolute;
  top: calc(-1 * var(--dz-phist-top-offset));
  left: 0;
  right: 0;
  width: auto;
  height: calc(var(--dz-phist-top-offset) + 280px);
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(
    180deg,
    rgba(93, 24, 159, 0.30) 0%,
    rgba(93, 24, 159, 0.16) 42%,
    rgba(93, 24, 159, 0.05) 72%,
    transparent 100%
  );
}

@media (prefers-color-scheme: dark) {
  .dz-phist__wash {
    background: linear-gradient(
      180deg,
      rgba(159, 88, 225, 0.22) 0%,
      rgba(159, 88, 225, 0.10) 45%,
      transparent 100%
    );
  }
}

/* Same outer width as tab bar / profile column */
.dz-phist__header {
  position: relative;
  z-index: 5;
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  width: min(calc(100% - 40px), 440px);
  max-width: 440px;
  margin: 0 auto 8px;
  padding: 0;
  border-radius: 30px;
  background: var(--dz-primary, #350066);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--dz-primary) 30%, transparent);
  box-sizing: border-box;
  direction: rtl;
}

@media (min-width: 900px) {
  .dz-phist__header {
    width: calc(100% - 32px);
    max-width: none;
    margin-left: 16px;
    margin-right: 16px;
  }
}

@media (prefers-color-scheme: dark) {
  .dz-phist__header {
    background: var(--dz-secondary, #8A2BE2);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  }
}

.dz-phist__header-title {
  grid-column: 2;
  margin: 0;
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.4;
  padding-bottom: 2px;
}

.dz-phist__back {
  grid-column: 3;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  background: transparent;
  color: #fff;
  cursor: pointer;
  padding: 0;
}

.dz-phist__back .dz-ico {
  width: 18px;
  height: 18px;
}

.dz-phist__header-spacer {
  grid-column: 1;
  width: 40px;
  height: 40px;
}

/* Pinned top (summary+filters) + scrolling list — same column as tab bar */
.dz-phist__content {
  position: relative;
  z-index: 1;
  width: min(calc(100% - 40px), 440px);
  max-width: 440px;
  margin: 0 auto;
  padding: 0;
  box-sizing: border-box;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

@media (min-width: 900px) {
  .dz-phist__content {
    width: 100%;
    max-width: none;
    padding-left: 16px;
    padding-right: 16px;
  }
}

.dz-phist__top {
  flex: 0 0 auto;
  padding-top: 4px;
}

/* Summary card */
.dz-phist__summary {
  margin: 0 0 8px;
  padding: 12px 16px;
  border-radius: 16px;
  background: var(--dz-surface, #fff);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
}

@media (prefers-color-scheme: dark) {
  .dz-phist__summary {
    background: #404040;
  }
}

.dz-phist__stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}

.dz-phist__stat-value {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--dz-primary-dark, #5D189F);
  line-height: 1.35;
}

.dz-phist__stat-value.is-fail {
  color: #e53935;
}

@media (prefers-color-scheme: dark) {
  .dz-phist__stat-value,
  .dz-phist__stat-value.is-fail {
    color: #fff;
  }
}

.dz-phist__stat-label {
  margin: 0;
  font-size: 10px;
  color: var(--dz-gray-400, #919191);
}

.dz-phist__stat-bar {
  width: 32px;
  height: 3px;
  border-radius: 2px;
}

.dz-phist__stat-bar--buy { background: #43a047; }
.dz-phist__stat-bar--top { background: #1e88e5; }
.dz-phist__stat-bar--fail { background: #e53935; }

/* Filter chips */
.dz-phist__filters {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 0 6px;
  margin-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  justify-content: flex-start;
  direction: rtl;
}

.dz-phist__filters::-webkit-scrollbar {
  display: none;
}

.dz-phist__chip {
  flex: 0 0 auto;
  border: 0;
  border-radius: 20px;
  padding: 7px 14px;
  font-family: inherit;
  font-size: 13px;
  background: var(--dz-gray-100, #e1e1e1);
  color: var(--dz-gray-600, #404040);
  cursor: pointer;
  white-space: nowrap;
}

.dz-phist__chip.is-on {
  background: var(--dz-primary, #350066);
  color: #fff;
  font-weight: 700;
}

@media (prefers-color-scheme: dark) {
  .dz-phist__chip {
    background: #404040;
    color: #e0e0e0;
  }
  .dz-phist__chip.is-on {
    background: var(--dz-secondary, #8A2BE2);
  }
}

/* List — only this region scrolls (Maui CollectionView) */
.dz-phist__list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  /* block flow so rows keep natural height (flex would shrink them) */
  display: block;
  padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  scrollbar-width: thin;
  /* Scrollbar on the left (Chrome/Edge Windows). */
  transform: scaleX(-1);
}

.dz-phist__list > * {
  transform: scaleX(-1);
}

.dz-phist__card {
  flex-shrink: 0;
  margin: 4px 0;
  border-radius: 12px;
  background: var(--dz-surface, #fff);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.07);
  overflow: hidden;
  display: grid;
  grid-template-columns: 5px auto 1fr auto;
  direction: rtl;
  align-items: stretch;
}

@media (prefers-color-scheme: dark) {
  .dz-phist__card {
    background: #404040;
  }
}

.dz-phist__strip {
  width: 5px;
  min-height: 100%;
}

.dz-phist__strip--buy { background: #43a047; }
.dz-phist__strip--top { background: #1e88e5; }
.dz-phist__strip--fail { background: #e53935; }

.dz-phist__thumb {
  width: 56px;
  height: 56px;
  margin: 10px 10px 10px 0;
  border-radius: 10px;
  object-fit: cover;
  background: var(--dz-gray-100, #eee);
  display: block;
}

.dz-phist__wallet {
  width: 56px;
  height: 56px;
  margin: 10px 10px 10px 0;
  border-radius: 28px;
  background: #e3f2fd;
  color: #1e88e5;
  display: grid;
  place-items: center;
}

.dz-phist__wallet .dz-ico {
  width: 26px;
  height: 26px;
}

.dz-phist__info {
  margin: 10px 5px 10px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 0;
}

.dz-phist__name {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--dz-primary-dark, #5D189F);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dz-phist__date {
  margin: 0;
  font-size: 11px;
  color: var(--dz-gray-400, #919191);
}

.dz-phist__method {
  align-self: flex-start;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 10px;
  background: var(--dz-gray-100, #e1e1e1);
  color: var(--dz-gray-600, #404040);
}

@media (prefers-color-scheme: dark) {
  .dz-phist__name { color: #fff; }
  .dz-phist__method {
    background: #555;
    color: #ddd;
  }
}

.dz-phist__meta {
  /* Extra space from the physical left edge of the card (amount column in RTL) */
  margin: 10px 12px 10px 16px;
  padding-left: 4px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
}

.dz-phist__amount {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--dz-primary-dark, #5D189F);
  text-align: end;
  white-space: nowrap;
}

@media (prefers-color-scheme: dark) {
  .dz-phist__amount { color: #fff; }
}

.dz-phist__fail-badge {
  padding: 2px 6px;
  border-radius: 6px;
  background: #e53935;
  color: #fff;
  font-size: 10px;
  line-height: 1.3;
}

.dz-phist__empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 50px;
  padding: 20px;
  text-align: center;
}

.dz-phist__empty-ico {
  color: var(--dz-gray-300, #acacac);
}

.dz-phist__empty-ico .dz-ico {
  width: 50px;
  height: 50px;
}

.dz-phist__empty-msg {
  margin: 0;
  font-size: 14px;
  color: var(--dz-gray-400, #919191);
  white-space: pre-line;
  line-height: 1.6;
}

.dz-phist__more {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 56px;
  color: var(--dz-primary-dark);
}

.dz-phist__sentinel {
  height: 48px;
  width: 100%;
}

.dz-phist__skel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dz-phist__skel-card {
  height: 76px;
  margin: 4px 0;
  border-radius: 12px;
  background: var(--dz-surface, #fff);
  display: grid;
  grid-template-columns: 5px auto 1fr auto;
  direction: rtl;
  overflow: hidden;
}

@media (prefers-color-scheme: dark) {
  .dz-phist__skel-card { background: #404040; }
}

.dz-phist__skel-strip {
  background: var(--dz-gray-200, #c8c8c8);
}

.dz-phist__skel-box {
  background: var(--dz-gray-100, #e1e1e1);
  border-radius: 4px;
}

@media (prefers-color-scheme: dark) {
  .dz-phist__skel-strip,
  .dz-phist__skel-box { background: #555; }
}

.dz-phist__skel-thumb {
  width: 56px;
  height: 56px;
  margin: 10px 10px 10px 0;
  border-radius: 10px;
}

.dz-phist__skel-thumb.is-round {
  border-radius: 28px;
}

.dz-phist__skel-info {
  margin: 14px 5px 14px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
}

.dz-phist__skel-line {
  height: 14px;
  width: 130px;
}

.dz-phist__skel-line.is-sm {
  height: 10px;
  width: 90px;
}

.dz-phist__skel-amt {
  width: 70px;
  height: 14px;
  margin: 20px 12px 20px 5px;
  align-self: center;
}
