/*
 * SaloCart V5.2.6 — Mobile dialog + navigation layering repair
 * Keeps every SaloCart dialog above the fixed mobile navigation and gives
 * bottom sheets a consistent, scroll-safe alignment on phones and tablets.
 */

:root {
  /* Leave room below the browser maximum (2,147,483,647) while always
     outranking Bootstrap, sticky headers, and legacy mobile navigation. */
  --sc-layer-modal: 2147483000;
  --sc-layer-notice: 2147483200;
  --sc-layer-toast: 2147483400;
}

/* The roots are true viewport layers, never part of a page stacking context. */
#modal-root,
#notice-root,
#toast-root {
  isolation: isolate !important;
}

#modal-root {
  position: fixed !important;
  z-index: var(--sc-layer-modal) !important;
  inset: 0 !important;
  transform: translateZ(0);
}

#modal-root .modal-backdrop-sc {
  z-index: var(--sc-layer-modal) !important;
}

#notice-root {
  z-index: var(--sc-layer-notice) !important;
}

#toast-root {
  z-index: var(--sc-layer-toast) !important;
}

/* The regular app navigation must never compete with an open dialog. */
.mobile-nav {
  z-index: var(--sc-layer-nav, 1020) !important;
}

@media (max-width: 991.98px) {
  /* A modal owns the screen. Hiding the fixed navigation avoids a visible or
     clickable bar below a bottom sheet, even when an older stylesheet has
     created a separate stacking context. */
  body.sc-modal-locked .mobile-nav {
    visibility: hidden !important;
    pointer-events: none !important;
  }

  /* Keep every dialog inside the real visual viewport and above navigation. */
  #modal-root .modal-backdrop-sc {
    display: flex !important;
    align-items: flex-end !important;
    justify-content: center !important;
    width: 100vw !important;
    min-width: 100vw !important;
    min-height: 100svh !important;
    height: 100svh !important;
    padding: 0 !important;
    overflow: hidden !important;
    background: rgba(5, 25, 18, .62) !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  #modal-root .modal-sheet,
  #modal-root .modal-sheet.cart-sheet,
  #modal-root .cart-sheet {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-height: calc(100svh - max(8px, env(safe-area-inset-top))) !important;
    margin: 0 !important;
    border-radius: 22px 22px 0 0 !important;
    box-shadow: 0 -14px 34px rgba(0, 0, 0, .20) !important;
  }

  /* Title, subtitle, and close button remain aligned even with long names. */
  #modal-root .sheet-head {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) auto !important;
    align-items: start !important;
    gap: 10px !important;
    min-width: 0 !important;
    padding: 14px 16px 11px !important;
  }

  #modal-root .sheet-head > div {
    min-width: 0 !important;
  }

  #modal-root .sheet-head h2 {
    min-width: 0 !important;
    font-size: clamp(1rem, 4.8vw, 1.18rem) !important;
    line-height: 1.18 !important;
    overflow-wrap: anywhere !important;
  }

  #modal-root .sheet-subtitle {
    margin-top: 4px !important;
    font-size: .73rem !important;
    line-height: 1.45 !important;
    overflow-wrap: anywhere !important;
  }

  #modal-root .close-sheet {
    width: 38px !important;
    height: 38px !important;
    min-width: 38px !important;
    border-radius: 12px !important;
  }

  #modal-root .sheet-body {
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 14px 16px max(18px, env(safe-area-inset-bottom)) !important;
    overflow: auto !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Compact authentication dialogs remain centered when their content fits;
     longer registration forms retain the stable bottom-sheet behavior. */
  #modal-root .auth-sheet {
    width: min(calc(100vw - 16px), 480px) !important;
    max-width: calc(100vw - 16px) !important;
    max-height: calc(100svh - max(16px, env(safe-area-inset-top)) - max(16px, env(safe-area-inset-bottom))) !important;
    margin-bottom: max(8px, env(safe-area-inset-bottom)) !important;
    border-radius: 20px !important;
  }

  #modal-root .auth-sheet .sheet-head {
    grid-template-columns: 1fr auto !important;
    padding: 8px 10px 0 !important;
  }

  #modal-root .auth-sheet .sheet-body {
    padding: 0 15px 16px !important;
  }
}

@media (max-width: 360px) {
  #modal-root .sheet-head {
    gap: 8px !important;
    padding-inline: 13px !important;
  }

  #modal-root .sheet-body {
    padding-inline: 13px !important;
  }

  #modal-root .close-sheet {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.sc-modal-locked .mobile-nav {
    transition: none !important;
  }
}
