/* ===================================================
   PARTNER GATEWAY — MOBILE / PWA LAYER
   Login + Client & Supplier registration only.
   Every rule starts with html.pg-pwa (added only on these pages),
   so nothing here can affect the public site, admin, staff or /m/ app.
=================================================== */


/* ---------- Base ---------- */

html.pg-pwa {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
}

html.pg-pwa,
html.pg-pwa body {
    overflow-x: hidden;
}

html.pg-pwa a,
html.pg-pwa button,
html.pg-pwa input,
html.pg-pwa select,
html.pg-pwa textarea,
html.pg-pwa label {
    touch-action: manipulation;
}

html.pg-pwa :focus-visible {
    outline: 2px solid rgba(255, 255, 255, .7);
    outline-offset: 2px;
}

html.pg-pwa .glass-card {
    width: 100%;
    box-sizing: border-box;
}

html.pg-pwa .glass-card .row>* {
    min-width: 0;
}


/* Password eye button: bigger tap area without moving the icon */

html.pg-pwa .pg-pw-toggle::before {
    content: "";
    position: absolute;
    inset: -10px -12px;
}


/* ---------- Popups (Forgot password, Terms, Privacy, Verify code) ---------- */

html.pg-pwa .modal-backdrop-custom {
    padding: 1rem !important;
    overscroll-behavior: contain;
}

html.pg-pwa .modal-backdrop-custom>.glass-card {
    max-height: calc(100vh - 2rem) !important;
    max-height: calc(100dvh - 2rem) !important;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

html.pg-modal-open,
html.pg-modal-open body {
    overflow: hidden;
}


/* ---------- Submit button loading state ---------- */

html.pg-pwa .is-loading {
    opacity: .75;
    pointer-events: none;
}

html.pg-pwa .pg-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: .45rem;
    vertical-align: -2px;
    border: 2px solid rgba(255, 255, 255, .35);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: pgSpin .7s linear infinite;
}

@keyframes pgSpin {
    to {
        transform: rotate(360deg);
    }
}


/* ---------- Notice (offline, etc.) ---------- */

html.pg-pwa .pg-notice {
    position: fixed;
    left: 50%;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    z-index: 2000;
    width: max-content;
    max-width: min(92vw, 400px);
    padding: .75rem 1rem;
    border-radius: 12px;
    background: rgba(15, 23, 42, .94);
    color: #ffffff;
    font-size: 13px;
    line-height: 1.4;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
    opacity: 0;
    transform: translate(-50%, 140%);
    transition: transform .3s ease, opacity .3s ease;
    pointer-events: none;
}

html.pg-pwa .pg-notice.show {
    opacity: 1;
    transform: translate(-50%, 0);
}


/* ---------- Phones ---------- */

@media (max-width: 576px) {
    html.pg-pwa .glass-card {
        padding: 1.6rem 1.15rem !important;
        border-radius: 18px;
    }
    /* Side-by-side fields stack */
    html.pg-pwa .glass-card .row>.col-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    /* Fields: 16px text stops iPhone auto-zoom; taller = easier to tap */
    html.pg-pwa .formal-input,
    html.pg-pwa .form-select.formal-input {
        font-size: 16px !important;
        min-height: 46px;
    }
    html.pg-pwa textarea.formal-input {
        min-height: 90px;
    }
    html.pg-pwa .formal-label {
        font-size: 11px;
    }
    html.pg-pwa .pg-pw-wrap .formal-input {
        padding-right: 48px !important;
    }
    /* Readable small text */
    html.pg-pwa .pg-alert {
        font-size: 12px !important;
        padding: .6rem .75rem !important;
    }
    html.pg-pwa .pg-link-sm {
        font-size: 12px !important;
        display: inline-block;
        padding: .35rem 0;
    }
    html.pg-pwa .pg-agree {
        font-size: 12.5px !important;
    }
    html.pg-pwa .pg-note {
        font-size: 11.5px !important;
    }
    html.pg-pwa .pg-hint {
        font-size: 10.5px !important;
    }
    html.pg-pwa .pg-cat-label {
        font-size: 13px !important;
    }
    html.pg-pwa .pg-match-msg {
        font-size: 12px !important;
    }
    html.pg-pwa .pg-legal-text {
        font-size: 13px !important;
    }
    /* Checkboxes */
    html.pg-pwa .form-check-input {
        width: 20px;
        height: 20px;
    }
    html.pg-pwa .form-check {
        display: flex;
        align-items: center;
        gap: .55rem;
        min-height: 36px;
        padding-left: 0;
        margin-bottom: .25rem !important;
    }
    html.pg-pwa .form-check .form-check-input {
        float: none;
        margin: 0;
        flex-shrink: 0;
    }
    /* Buttons */
    html.pg-pwa .btn-pg-primary {
        min-height: 48px;
        font-size: 14px;
    }
    html.pg-pwa .pg-actions {
        gap: .6rem !important;
    }
    html.pg-pwa .pg-actions>.btn {
        flex: 0 0 auto;
        display: inline-flex;
        align-items: center;
        min-height: 48px;
        font-size: 13px !important;
    }
    html.pg-pwa .pg-actions>.btn-pg-primary {
        flex: 1 1 auto;
    }
    /* LOGIN / REGISTER switch */
    html.pg-pwa .pg-switch {
        width: 100%;
        max-width: 360px;
    }
    html.pg-pwa .pg-switch>.btn {
        flex: 1 1 50%;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 40px;
    }
    /* "New partner?" buttons */
    html.pg-pwa .pg-register-links {
        flex-direction: column;
    }
    html.pg-pwa .pg-register-links>a {
        width: 100%;
        min-height: 44px;
        display: flex !important;
        align-items: center;
        justify-content: center;
        font-size: 12.5px !important;
    }
    /* Upload box */
    html.pg-pwa .upload-dashed-box {
        padding: 1.25rem !important;
    }
    /* Stepper spacing */
    html.pg-pwa .pg-steps {
        margin-bottom: 1.75rem !important;
    }
}


/* ---------- Small phones: stepper shows only the current step's label ---------- */

@media (max-width: 420px) {
    html.pg-pwa .pg-steps .pg-step {
        font-size: 0 !important;
        white-space: nowrap;
    }
    html.pg-pwa .pg-steps .pg-step .num {
        font-size: 12px !important;
    }
    html.pg-pwa .pg-steps .pg-step .num i {
        font-size: 10px;
    }
    html.pg-pwa .pg-steps .pg-step.active {
        font-size: 11px !important;
    }
    html.pg-pwa .pg-steps .line {
        flex: 1 1 12px;
        min-width: 12px;
    }
}


/* ---------- Respect "reduce motion" ---------- */

@media (prefers-reduced-motion: reduce) {
    html.pg-pwa *,
    html.pg-pwa *::before,
    html.pg-pwa *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}


/* ===================================================
   PHONE FRAME: compact header, card spacing, stepper
=================================================== */

@media (max-width: 576px) {
    /* Page frame: side margins so nothing touches the screen edges */
    html.pg-pwa body.pg-body {
        padding: calc(1rem + env(safe-area-inset-top, 0px)) .85rem calc(1.25rem + env(safe-area-inset-bottom, 0px)) !important;
        min-height: 100vh;
        min-height: 100dvh;
        background-attachment: scroll !important;
    }
    /* Compact header so the form starts near the top */
    html.pg-pwa .badge-header {
        font-size: 9px !important;
        padding: .25rem .7rem !important;
        margin-bottom: .5rem !important;
    }
    html.pg-pwa .main-title {
        font-size: 2rem !important;
        line-height: 1.1 !important;
        margin: .25rem 0 .2rem !important;
    }
    html.pg-pwa .sub-title {
        font-size: 11px !important;
        margin-bottom: 1rem !important;
    }
    html.pg-pwa .pg-switch {
        margin-bottom: 1rem !important;
    }
    /* Card centered with breathing room */
    html.pg-pwa .glass-card {
        margin-left: auto !important;
        margin-right: auto !important;
    }
    /* Stepper: always fits, only the current step shows its label */
    html.pg-pwa .pg-steps {
        display: flex !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: center !important;
        gap: .35rem !important;
        width: 100%;
        overflow: hidden;
        margin-bottom: 1.5rem !important;
    }
    html.pg-pwa .pg-steps .pg-step {
        flex: 0 0 auto !important;
        display: flex !important;
        align-items: center !important;
        gap: .35rem;
        white-space: nowrap;
        font-size: 0 !important;
    }
    html.pg-pwa .pg-steps .pg-step .num {
        font-size: 12px !important;
        flex-shrink: 0;
    }
    html.pg-pwa .pg-steps .pg-step .num i {
        font-size: 10px !important;
    }
    html.pg-pwa .pg-steps .pg-step.active {
        font-size: 11px !important;
    }
    html.pg-pwa .pg-steps .line {
        flex: 1 1 auto !important;
        width: auto !important;
        min-width: 10px !important;
    }
    html.pg-pwa p.footer-copy {
        margin-top: 1.25rem !important;
    }
}


/* ===================================================
   "Back to Website" button (login page)
=================================================== */

html.pg-pwa .pg-home-link {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    min-height: 40px;
    margin-bottom: 1rem;
    padding: .45rem 1.15rem;
    border-radius: 999px;
    background: rgba(0, 0, 0, .25);
    border: 1px solid rgba(255, 255, 255, .22);
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .3px;
    text-decoration: none;
    transition: background .2s ease, transform .15s ease;
}

html.pg-pwa .pg-home-link:hover {
    background: rgba(0, 0, 0, .4);
    color: #ffffff;
}

html.pg-pwa .pg-home-link:active {
    transform: scale(.97);
}

html.pg-pwa .pg-home-link:focus-visible {
    outline: 2px solid rgba(255, 255, 255, .8);
    outline-offset: 2px;
}

html.pg-pwa .pg-home-link i {
    font-size: 11px;
}

@media (max-width: 576px) {
    html.pg-pwa .pg-home-link {
        min-height: 44px;
        margin-bottom: .85rem;
        font-size: 13px;
    }
}