/* PayStubCheck Mobile Preview v2
   Scope: Free and Basic generators only. Presentation layer only. */

[data-mobile-preview-v2] .psc-mobile-preview-bar,
[data-mobile-preview-v2] .psc-mobile-preview-sheet {
  display: none;
}

@media (max-width: 767px) {
  body[data-mobile-preview-v2].psc-mobile-preview-ready {
    --psc-preview-safe-bottom: env(safe-area-inset-bottom, 0px);
    padding-bottom: calc(92px + var(--psc-preview-safe-bottom));
  }

  body[data-mobile-preview-v2].psc-mobile-preview-ready .generator-body {
    padding-bottom: calc(112px + var(--psc-preview-safe-bottom));
  }

  /* The full inline document is replaced by a one-tap mobile preview bar.
     Checkout remains in its existing place and keeps its existing behavior. */
  body[data-mobile-preview-v2].psc-mobile-preview-ready .preview-panel > .preview-wrapper {
    display: none;
  }

  body[data-mobile-preview-v2] .psc-mobile-preview-bar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: calc(12px + var(--psc-preview-safe-bottom));
    z-index: 7600;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 68px;
    padding: 10px 10px 10px 16px;
    border: 1px solid rgba(188, 216, 154, 0.38);
    border-radius: 18px;
    background: rgba(31, 55, 9, 0.97);
    box-shadow: 0 16px 44px rgba(20, 37, 6, 0.30);
    color: #fff;
    font-family: 'DM Sans', sans-serif;
    -webkit-backdrop-filter: blur(14px);
    backdrop-filter: blur(14px);
    transition: opacity 0.18s ease, transform 0.18s ease;
  }

  body[data-mobile-preview-v2].psc-mobile-keyboard-open .psc-mobile-preview-bar,
  body[data-mobile-preview-v2].psc-mobile-preview-open .psc-mobile-preview-bar {
    opacity: 0;
    pointer-events: none;
    transform: translateY(14px);
  }

  .psc-mobile-preview-bar-copy {
    min-width: 0;
    display: grid;
    gap: 2px;
  }

  .psc-mobile-preview-bar-label {
    color: #d9edc0;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.11em;
    line-height: 1.2;
    text-transform: uppercase;
  }

  .psc-mobile-preview-bar-value {
    overflow: hidden;
    color: #fff;
    font-family: 'JetBrains Mono', monospace;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .psc-mobile-preview-open-button {
    flex: 0 0 auto;
    min-width: 108px;
    min-height: 48px;
    padding: 0 17px;
    border: 0;
    border-radius: 14px;
    background: #71c600;
    color: #fff;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    font-size: 15px;
    font-weight: 800;
    touch-action: manipulation;
    box-shadow: 0 7px 18px rgba(113, 198, 0, 0.28);
  }

  .psc-mobile-preview-open-button:active {
    transform: scale(0.98);
  }

  body[data-mobile-preview-v2] .psc-mobile-preview-sheet {
    position: fixed;
    inset: 0;
    z-index: 12000;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    background: #eef4e8;
    color: #18200e;
    font-family: 'DM Sans', sans-serif;
    transform: translateY(12px);
    transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s linear 0.18s;
  }

  body[data-mobile-preview-v2] .psc-mobile-preview-sheet.is-open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
    transition-delay: 0s;
  }

  body[data-mobile-preview-v2].psc-mobile-preview-open {
    overflow: hidden;
    overscroll-behavior: none;
  }

  .psc-mobile-preview-header {
    position: relative;
    z-index: 2;
    display: grid;
    gap: 10px;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 12px 10px;
    border-bottom: 1px solid #d6e3c8;
    background: #fff;
    box-shadow: 0 3px 16px rgba(31, 55, 9, 0.08);
  }

  .psc-mobile-preview-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .psc-mobile-preview-heading {
    min-width: 0;
  }

  .psc-mobile-preview-eyebrow {
    color: #64873c;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.11em;
    text-transform: uppercase;
  }

  .psc-mobile-preview-title {
    margin: 1px 0 0;
    overflow: hidden;
    color: #18200e;
    font-family: 'Bricolage Grotesque', sans-serif;
    font-size: 19px;
    font-weight: 800;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .psc-mobile-preview-close {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #d2dfc2;
    border-radius: 13px;
    background: #f7faf4;
    color: #29490d;
    cursor: pointer;
    font-size: 25px;
    line-height: 1;
    touch-action: manipulation;
  }

  .psc-mobile-preview-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .psc-mobile-preview-controls::-webkit-scrollbar { display: none; }

  .psc-mobile-preview-mode,
  .psc-mobile-preview-zoom {
    min-height: 44px;
    flex: 0 0 auto;
    border: 1px solid #cdddbb;
    border-radius: 12px;
    background: #fff;
    color: #355815;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    font-weight: 800;
    touch-action: manipulation;
  }

  .psc-mobile-preview-mode {
    min-width: 72px;
    padding: 0 14px;
  }

  .psc-mobile-preview-mode[aria-pressed="true"] {
    border-color: #67b900;
    background: #ecf9dd;
    color: #285600;
    box-shadow: inset 0 0 0 1px rgba(103, 185, 0, 0.18);
  }

  .psc-mobile-preview-zoom {
    width: 44px;
    padding: 0;
    font-size: 20px;
  }

  .psc-mobile-preview-zoom:disabled {
    opacity: 0.42;
    cursor: default;
  }

  .psc-mobile-preview-viewport {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    padding: 12px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    background:
      linear-gradient(45deg, rgba(31, 55, 9, 0.025) 25%, transparent 25%) 0 0 / 18px 18px,
      linear-gradient(-45deg, rgba(31, 55, 9, 0.025) 25%, transparent 25%) 0 9px / 18px 18px,
      #eef4e8;
  }

  .psc-mobile-preview-stage {
    position: relative;
    margin: 0 auto;
    transform-origin: top left;
  }

  /* The existing preview DOM is moved into this sheet while it is open.
     Existing generator renderers continue updating the same #doc-preview node. */
  .psc-mobile-preview-sheet #preview-body.psc-mobile-preview-source {
    position: absolute;
    inset: 0 auto auto 0;
    width: 780px !important;
    max-width: none !important;
    max-height: none !important;
    overflow: visible !important;
    box-sizing: border-box;
    padding: 14px !important;
    border: 1px solid #d5dfca;
    border-radius: 10px;
    background: #fff;
    cursor: default;
    box-shadow: 0 14px 38px rgba(31, 55, 9, 0.18);
    transform-origin: top left;
  }

  .psc-mobile-preview-sheet #preview-body.psc-mobile-preview-source .doc-preview {
    width: 100% !important;
    max-width: none !important;
    overflow: visible !important;
  }

  .psc-mobile-preview-sheet #preview-body.psc-mobile-preview-source .basic-generic-preview {
    max-width: 610px !important;
  }

  /* Restore document fidelity inside the viewer even though the phone viewport
     still matches the site's generic mobile media query. */
  .psc-mobile-preview-sheet .bgp-info-grid,
  .psc-mobile-preview-sheet .bgp-bottom-grid {
    grid-template-columns: 1fr 1fr !important;
  }

  .psc-mobile-preview-sheet .bgp-topbar {
    flex-direction: row !important;
  }

  .psc-mobile-preview-sheet .bgp-datebox {
    min-width: 150px !important;
  }

  .psc-mobile-preview-sheet .preview-zoom-hint {
    display: none !important;
  }

  .psc-mobile-preview-sheet .preview-watermark {
    border-radius: 10px;
  }

  .psc-mobile-preview-footer {
    position: relative;
    z-index: 2;
    display: grid;
    grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr);
    gap: 10px;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #d6e3c8;
    background: #fff;
    box-shadow: 0 -4px 18px rgba(31, 55, 9, 0.08);
  }

  .psc-mobile-preview-footer button {
    min-height: 50px;
    border-radius: 14px;
    cursor: pointer;
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    font-weight: 800;
    touch-action: manipulation;
  }

  .psc-mobile-preview-edit {
    border: 1px solid #cdddbb;
    background: #fff;
    color: #355815;
  }

  .psc-mobile-preview-continue {
    border: 0;
    background: #67bd00;
    color: #fff;
    box-shadow: 0 8px 20px rgba(103, 189, 0, 0.24);
  }

  @media (max-width: 360px) {
    body[data-mobile-preview-v2] .psc-mobile-preview-bar {
      left: 8px;
      right: 8px;
      bottom: calc(8px + var(--psc-preview-safe-bottom));
      padding-left: 13px;
    }

    .psc-mobile-preview-open-button {
      min-width: 96px;
      padding-inline: 13px;
    }

    .psc-mobile-preview-footer {
      grid-template-columns: 1fr;
    }

    .psc-mobile-preview-edit {
      order: 2;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    body[data-mobile-preview-v2] .psc-mobile-preview-bar,
    body[data-mobile-preview-v2] .psc-mobile-preview-sheet {
      transition: none;
    }
  }
}
