/*
==============================================================================
MYNIAGA APP FOUNDATION A1
Global mobile / PWA / APK-ready foundation.
No business logic, pricing, stock, shipping or database changes.
==============================================================================
*/

:root{
    --app-safe-top: env(safe-area-inset-top, 0px);
    --app-safe-right: env(safe-area-inset-right, 0px);
    --app-safe-bottom: env(safe-area-inset-bottom, 0px);
    --app-safe-left: env(safe-area-inset-left, 0px);
    --app-touch-min: 44px;
    --app-mobile-gap: 14px;
    --app-vh: 1vh;
}

html{
    -webkit-text-size-adjust:100%;
    text-size-adjust:100%;
    scroll-behavior:smooth;
}

body.app-ready{
    min-width:0;
    max-width:100%;
    overflow-wrap:anywhere;
    -webkit-tap-highlight-color:rgba(23,106,89,.12);
}

body.app-ready img,
body.app-ready video,
body.app-ready canvas,
body.app-ready svg{
    max-width:100%;
}

body.app-ready img,
body.app-ready video{
    height:auto;
}

body.app-ready input,
body.app-ready select,
body.app-ready textarea,
body.app-ready button{
    max-width:100%;
}

body.app-ready button,
body.app-ready .btn,
body.app-ready summary,
body.app-ready input,
body.app-ready select,
body.app-ready textarea{
    touch-action:manipulation;
}

body.app-ready a,
body.app-ready button,
body.app-ready summary,
body.app-ready input,
body.app-ready select,
body.app-ready textarea{
    -webkit-tap-highlight-color:rgba(23,106,89,.12);
}

body.app-ready :focus-visible{
    outline:3px solid rgba(23,106,89,.28);
    outline-offset:2px;
}

body.app-ready .container{
    width:100%;
    max-width:1180px;
    margin-inline:auto;
    padding-left:max(24px, var(--app-safe-left));
    padding-right:max(24px, var(--app-safe-right));
}

body.app-ready .site-header{
    padding-top:var(--app-safe-top);
}

body.app-ready .site-footer{
    padding-bottom:max(0px, var(--app-safe-bottom));
}

body.app-ready [id]{
    scroll-margin-top:110px;
}

/* Prevent content and long identifiers from forcing the whole page wider. */
body.app-ready main,
body.app-ready main > *,
body.app-ready .card,
body.app-ready .field,
body.app-ready .grid-2,
body.app-ready .grid-3,
body.app-ready .dashboard-grid,
body.app-ready .shop-section,
body.app-ready .admin-panel,
body.app-ready .supplier-page{
    min-width:0;
}

body.app-ready pre,
body.app-ready code{
    white-space:pre-wrap;
    overflow-wrap:anywhere;
}

body.app-ready .table-wrap,
body.app-ready .vm-table-wrap{
    max-width:100%;
    overflow-x:auto;
    overscroll-behavior-inline:contain;
    -webkit-overflow-scrolling:touch;
    scrollbar-gutter:stable;
}

/* Menus must stay inside a phone viewport. */
body.app-ready .locale-menu,
body.app-ready .mobile-menu > div{
    max-width:calc(100vw - 24px - var(--app-safe-left) - var(--app-safe-right));
}

/* Large desktop cards/forms should never exceed their parent on phones. */
body.app-ready .form-card,
body.app-ready .supplier-edit,
body.app-ready .shop-filterbar label{
    width:min(100%, 100%);
}

/* Mobile viewport height helper, updated by app-foundation.js. */
body.app-ready .app-min-screen{
    min-height:calc(var(--app-vh) * 100);
}

/*
------------------------------------------------------------------------------
Phone / tablet foundation
------------------------------------------------------------------------------
*/
@media(max-width:850px){
    body.app-ready .container{
        padding-left:max(16px, var(--app-safe-left));
        padding-right:max(16px, var(--app-safe-right));
    }

    body.app-ready .retail-header .nav{
        min-height:64px;
    }

    body.app-ready .mobile-menu summary,
    body.app-ready .locale-picker summary,
    body.app-ready .retail-cart{
        min-height:var(--app-touch-min);
    }

    body.app-ready .mobile-menu summary{
        min-width:var(--app-touch-min);
        width:var(--app-touch-min);
        height:var(--app-touch-min);
    }

    body.app-ready .mobile-menu a,
    body.app-ready .locale-menu a{
        display:flex;
        align-items:center;
        min-height:var(--app-touch-min);
    }

    body.app-ready .global-search{
        min-height:46px;
    }

    body.app-ready .global-search input{
        min-height:44px;
        font-size:16px !important;
    }

    body.app-ready input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
    body.app-ready select,
    body.app-ready textarea{
        min-height:var(--app-touch-min);
        font-size:16px !important; /* prevents iOS focus zoom */
    }

    body.app-ready input[type="checkbox"],
    body.app-ready input[type="radio"]{
        min-width:20px;
        min-height:20px;
    }

    body.app-ready button,
    body.app-ready .btn,
    body.app-ready input[type="submit"],
    body.app-ready input[type="button"]{
        min-height:var(--app-touch-min);
    }

    body.app-ready textarea{
        min-height:112px;
    }

    body.app-ready .cta-row{
        gap:10px;
    }

    body.app-ready .section-head{
        align-items:flex-start;
    }

    body.app-ready .footer-grid{
        gap:24px !important;
    }

    body.app-ready .table-wrap::after,
    body.app-ready .vm-table-wrap::after{
        content:"";
        display:block;
        width:1px;
        height:1px;
    }
}

@media(max-width:600px){
    body.app-ready .container{
        padding-left:max(13px, var(--app-safe-left));
        padding-right:max(13px, var(--app-safe-right));
    }

    body.app-ready main > .section{
        padding-top:28px;
        padding-bottom:44px;
    }

    body.app-ready .section h1{
        font-size:clamp(28px,9vw,36px) !important;
        line-height:1.08;
    }

    body.app-ready .section h2{
        font-size:clamp(24px,7vw,32px) !important;
    }

    body.app-ready .form-card{
        width:100% !important;
        max-width:none !important;
        margin:12px auto !important;
        padding:18px !important;
    }

    body.app-ready .grid-2 > .card,
    body.app-ready .grid-3 > .card{
        padding:18px !important;
    }

    body.app-ready .dashboard-grid{
        grid-template-columns:1fr 1fr !important;
        gap:10px !important;
    }

    body.app-ready .dashboard-grid .stat{
        padding:15px !important;
    }

    body.app-ready .footer-grid{
        grid-template-columns:1fr !important;
    }

    body.app-ready .copyright{
        padding-bottom:max(18px, var(--app-safe-bottom)) !important;
    }

    body.app-ready .locale-picker summary{
        padding-inline:10px;
    }

    body.app-ready .retail-cart{
        padding-inline:10px !important;
    }

    body.app-ready .mobile-menu > div,
    body.app-ready .locale-menu{
        max-height:min(70vh, calc(var(--app-vh) * 70));
        overflow-y:auto;
        overscroll-behavior:contain;
    }

    body.app-ready .btn{
        white-space:normal;
        text-align:center;
        line-height:1.2;
    }
}

@media(max-width:390px){
    body.app-ready .container{
        padding-left:max(10px, var(--app-safe-left));
        padding-right:max(10px, var(--app-safe-right));
    }

    body.app-ready .retail-brand{
        font-size:16px !important;
        gap:7px;
    }

    body.app-ready .brand-mark{
        width:32px;
        height:32px;
    }

    body.app-ready .locale-picker summary{
        font-size:12px;
        padding-inline:8px;
    }

    body.app-ready .dashboard-grid{
        grid-template-columns:1fr !important;
    }
}

/*
------------------------------------------------------------------------------
Touch devices: desktop hover animation must not become a sticky touch state.
------------------------------------------------------------------------------
*/
@media(hover:none){
    body.app-ready .product-card:hover,
    body.app-ready .stat-link:hover{
        transform:none;
        box-shadow:inherit;
    }
}

/*
------------------------------------------------------------------------------
Standalone/PWA/APK webview hooks
------------------------------------------------------------------------------
*/
html.app-standalone body.app-ready .site-header{
    padding-top:var(--app-safe-top);
}

html.app-standalone body.app-ready{
    overscroll-behavior-y:none;
}

html.app-ios body.app-ready input,
html.app-ios body.app-ready select,
html.app-ios body.app-ready textarea{
    font-size:16px !important;
}

@media(prefers-reduced-motion:reduce){
    html{
        scroll-behavior:auto;
    }

    *,
    *::before,
    *::after{
        scroll-behavior:auto !important;
        animation-duration:.01ms !important;
        animation-iteration-count:1 !important;
        transition-duration:.01ms !important;
    }
}
