/* Floating pill tab bar — Maui CustomTabBar parity */

.dz-app-shell {
  position: relative;
}

.dz-app-shell__body {
  /*
   * Full-stage scroller (not the narrow column):
   * - scrollbar sits on the stage edge
   * - card shadows can paint into the side inset
   * - position:fixed modals cover the whole stage (no scaleX containing-block)
   * Content column width matches tab bar via horizontal padding below.
   */
  width: 100%;
  max-width: none;
  margin-left: 0;
  margin-right: 0;
  /* ≥20px sides; center a ≤440px column like former body width */
  padding-left: max(20px, calc((100% - 440px) / 2));
  padding-right: max(20px, calc((100% - 440px) / 2));
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  /*
   * Maui: bottom chrome padding = 0 + ScrollEndSpacer so content draws under TabBar,
   * with TabBarFadeOverlay on top. Use padding-bottom (not margin) so rows can scroll
   * into the fade zone; margin would leave empty bg and the fade looks invisible.
   */
  padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
  margin-bottom: 0;
  box-sizing: border-box;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Nested profile pages hide the tab bar — fill stage; list scrolls inside page */
/* Profile tab: full stage width so purple wash reaches left/right edges (like purchase history). */
.dz-app-shell__body.is-profile-bleed {
  width: 100%;
  max-width: none;
  padding-left: 0;
  padding-right: 0;
}

.dz-app-shell__body.is-profile-bleed .dz-shell-navbar {
  width: min(calc(100% - 40px), 440px);
  max-width: 440px;
  margin-left: auto;
  margin-right: auto;
}

.dz-app-shell__body.is-no-tabbar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Full stage width so page washes can bleed edge-to-edge (overflow clips negatives) */
  width: 100%;
  max-width: none;
  padding-left: 0;
  padding-right: 0;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  margin-bottom: 0;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}

/* Storage owns its own safe-area on the action bar — avoid double inset (Safari lift). */
.dz-app-shell__body.is-no-tabbar:has(.dz-stmgmt) {
  padding-bottom: 0;
}

/* Lock shell to the viewport so the body scrolls inside (no phantom page scroll past last content). */
@media (max-width: 899px) {
  .dz-app-shell {
    /* svh = small viewport (Safari chrome visible); avoids bottom clip on iOS */
    height: 100%;
    height: 100svh;
    height: 100dvh;
    max-height: 100%;
    max-height: 100svh;
    max-height: 100dvh;
    overflow: hidden;
  }

  .dz-app-mid,
  .dz-app-stage {
    min-height: 0;
    height: 100%;
    max-width: 100%;
    overflow: hidden;
  }
}

@media (min-width: 900px) {
  .dz-app-shell__body {
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
    /* Desktop stage: fixed side gutters (keep tabbar reserve from base rule) */
    padding-left: 16px;
    padding-right: 16px;
  }

  .dz-app-shell__body.is-profile-bleed {
    padding-left: 0;
    padding-right: 0;
  }

  .dz-app-shell__body.is-profile-bleed .dz-shell-navbar {
    width: calc(100% - 32px);
    max-width: none;
    margin-left: 16px;
    margin-right: 16px;
  }

  .dz-app-shell__body.is-no-tabbar {
    margin-bottom: 0;
  }
}

/* Shell title bar — same width as tab bar (full body width) */
.dz-shell-navbar {
  position: relative;
  z-index: 5; /* above profile purple wash that extends under the header */
  width: 100%;
  height: 40px;
  margin: 0 0 8px;
  padding: 0 16px;
  border-radius: 30px;
  background: var(--dz-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--dz-primary) 30%, transparent);
}

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

.dz-shell-navbar__title {
  color: #fff;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  line-height: 1.4;
  padding-bottom: 2px;
}

/* Offline banner — Option A */
.dz-offline-banner {
  position: sticky;
  top: 0;
  z-index: 950;
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 8px 10px;
  padding: 10px 12px;
  background: var(--dz-offline-bg);
  color: var(--dz-offline-accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
  border-radius: 0 0 10px 10px;
  direction: rtl;
  text-align: right;
}

.dz-offline-banner__icon {
  display: inline-flex;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  color: var(--dz-offline-accent);
}

.dz-offline-banner__icon .dz-ico {
  width: 20px;
  height: 20px;
}

.dz-offline-banner__copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1 1 auto;
}

.dz-offline-banner__title {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--dz-offline-accent);
  line-height: 1.3;
}

.dz-offline-banner__sub {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--dz-offline-muted);
  line-height: 1.35;
}

.dz-offline-banner__retry {
  flex-shrink: 0;
  appearance: none;
  border: 1px solid color-mix(in srgb, var(--dz-offline-accent) 45%, transparent);
  margin: 0;
  padding: 6px 10px;
  border-radius: 8px;
  background: color-mix(in srgb, var(--dz-offline-accent) 12%, transparent);
  color: var(--dz-offline-accent);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  line-height: 1.2;
  white-space: nowrap;
}

.dz-offline-banner__retry:disabled {
  opacity: 0.65;
  cursor: wait;
}

/* Fade above floating tab bar — avoid 100vw (iOS overflow); inset from safe areas */
.dz-tabbar-fade {
  position: fixed;
  left: env(safe-area-inset-left, 0px);
  right: env(safe-area-inset-right, 0px);
  bottom: 0px;
  width: auto;
  max-width: 600px;
  margin-inline: auto;
  height: calc(100px + env(safe-area-inset-bottom, 0px));
  z-index: 850;
  pointer-events: none;
  background: linear-gradient(
    to top,
    var(--dz-background) 0%,
    color-mix(in srgb, var(--dz-background) 70%, transparent) 45%,
    transparent 100%
  );
}

/* Profile stack without tab bar — keep a lighter bottom fade */
.dz-tabbar-fade.is-no-tabbar {
  height: calc(72px + env(safe-area-inset-bottom, 0px));
}

.dz-tabbar-host {
  position: fixed;
  left: env(safe-area-inset-left, 0px);
  right: env(safe-area-inset-right, 0px);
  bottom: calc(30px + env(safe-area-inset-bottom, 0px));
  /* left+right + explicit width + margin auto — centers without 100vw overflow on iOS */
  width: min(440px, calc(100% - 40px));
  max-width: 100%;
  margin-inline: auto;
  z-index: 900;
  pointer-events: none;
  box-sizing: border-box;
}

/* دسکتاپ: تب‌بار داخل قاب استیج، نه نسبت به کل مانیتور */
@media (min-width: 900px) {
  .dz-tabbar-fade {
    position: absolute;
    width: 100%;
    left: 0;
    right: 0;
    margin: 0;
  }

  .dz-tabbar-host {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 22px;
    width: auto;
    margin: 0 20px;
  }
}

.dz-tabbar {
  pointer-events: auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: stretch;
  height: 62px;
  padding: 5px 4px 6px;
  border-radius: 31px;
  background: #ffffff;
  box-shadow: 0 5px 18px rgba(0, 0, 0, 0.18);
  direction: rtl; /* Home on the right, like Maui FlowDirection=RTL */
}

@media (prefers-color-scheme: dark) {
  .dz-tabbar {
    background: #1e1528;
    box-shadow: 0 5px 18px rgba(0, 0, 0, 0.45);
  }
}

.dz-tabbar__item {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  background: transparent;
  color: var(--dz-primary);
  cursor: pointer;
  font-family: inherit;
  padding: 2px 2px 4px;
  border-radius: 26px;
  min-width: 0;
  transition: color 0.15s ease;
}

.dz-tabbar__item.is-active {
  color: var(--dz-primary-dark);
  font-weight: 700;
}

.dz-tabbar__item.is-active::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 24px;
  background: #e8e8ec;
  z-index: 0;
}

@media (prefers-color-scheme: dark) {
  .dz-tabbar__item {
    color: #9a8aad;
  }
  .dz-tabbar__item.is-active {
    color: #e1bee7;
  }
  .dz-tabbar__item.is-active::before {
    background: #3a2a52;
  }
}

.dz-tabbar__icon,
.dz-tabbar__label {
  position: relative;
  z-index: 1;
}

.dz-tabbar__icon {
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dz-tabbar__icon .dz-ico {
  width: 24px;
  height: 24px;
}

.dz-tabbar__label {
  font-size: 0.74rem;
  line-height: 1.45;
  padding-bottom: 2px;
  white-space: nowrap;
  overflow: visible;
  max-width: 100%;
}

.dz-tab-page {
  min-height: 40vh;
}

.dz-tab-page__title {
  margin: 0 0 8px;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--dz-text);
  text-align: right;
}

.dz-tab-page__hint {
  margin: 0;
  color: var(--dz-text-muted);
  font-size: 0.92rem;
  line-height: 1.7;
  text-align: right;
}
