/* ============================================================
   MAPAYER PWA Shell — coque application native
   ============================================================
   Mode standalone (app installée) :
   - masque header / footer / marketing du site web
   - app bar + drawer + bottom nav (Express / Direct / P2P)
   ============================================================ */

:root {
    --mp-pwa-topbar-height: 56px;
    --mp-pwa-topbar-safe: calc(var(--mp-pwa-topbar-height) + env(safe-area-inset-top, 0px));
    --mp-pwa-tabbar-height: 64px;
    --mp-pwa-tabbar-safe: calc(var(--mp-pwa-tabbar-height) + env(safe-area-inset-bottom, 0px));
    --mp-pwa-header-safe: env(safe-area-inset-top, 0px);
    --mp-pwa-sidebar-width: 80px;
}

/* Masquer le chrome site web en PWA */
html.mp-pwa-standalone .mp-header,
html.mp-pwa-standalone .mp-footer,
html.mp-pwa-standalone .inner-hero,
html.mp-pwa-standalone .mp-scroll-top,
html.mp-pwa-standalone .cookies-card,
html.mp-pwa-standalone .mp-breadcrumb {
    display: none !important;
}

html.mp-pwa-standalone.mp-pwa-shell-ready #mpDashSidebar,
html.mp-pwa-standalone.mp-pwa-shell-ready #udashSidebar,
html.mp-pwa-standalone.mp-pwa-shell-ready .udash-header,
html.mp-pwa-standalone.mp-pwa-shell-ready #udashOverlay,
html.mp-pwa-standalone.mp-pwa-shell-ready #mpDashOverlay {
    display: none !important;
}

html.mp-pwa-standalone.mp-pwa-shell-ready .udash-wrapper {
    min-height: 100vh;
}

html.mp-pwa-standalone.mp-pwa-shell-ready .udash-main {
    margin-left: 0 !important;
    width: 100% !important;
    min-height: 100vh;
}

/* Marketing / contenu site hors périmètre app */
html.mp-pwa-standalone .mp-web-only,
html.mp-pwa-standalone .mp-hero-left,
html.mp-pwa-standalone .mp-form-page-intro,
html.mp-pwa-standalone .mp-stats,
html.mp-pwa-standalone .mp-section,
html.mp-pwa-standalone section.mp-section,
html.mp-pwa-standalone .mp-tab-nav--triple,
html.mp-pwa-standalone .page-wrapper > section:not(.mp-hero),
html.mp-pwa-standalone .mp-ads-hero {
    display: none !important;
}

html.mp-pwa-standalone .mp-hero .row > [class*="col-lg-8"],
html.mp-pwa-standalone .mp-hero--form-page .row > .order-lg-2 {
    flex: 0 0 100%;
    max-width: 100%;
}

html.mp-pwa-standalone .mp-hero,
html.mp-pwa-standalone .mp-hero--form-page {
    min-height: auto;
    padding-top: 8px;
    padding-bottom: 8px;
}

html.mp-pwa-standalone .mp-hero-orb-1,
html.mp-pwa-standalone .mp-hero-orb-2 {
    opacity: 0.25;
}

html.mp-pwa-standalone .page-wrapper {
    padding-top: 0;
    padding-bottom: 0;
    min-height: 100vh;
}

/* ── App bar ───────────────────────────────────────────────────────── */

.mp-pwa-appbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 99990;
    display: none;
    align-items: center;
    gap: 8px;
    height: var(--mp-pwa-topbar-safe);
    padding: env(safe-area-inset-top, 0px) 8px 0;
    background: var(--mp-tabbar-bg, #0d1117);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

html.mp-pwa-standalone .mp-pwa-appbar:not([hidden]) {
    display: flex !important;
}

html.mp-pwa-standalone .mp-pwa-tabbar:not([hidden]) {
    display: block !important;
}

.mp-pwa-appbar__btn {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: var(--mp-tabbar-fg, #8b949e);
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.mp-pwa-appbar__btn:active {
    background: rgba(255, 255, 255, 0.06);
    color: var(--mp-tabbar-active, #2ea043);
}

.mp-pwa-appbar__brand {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.mp-pwa-appbar__logo {
    height: 28px;
    width: auto;
    max-width: 100px;
    object-fit: contain;
}

.mp-pwa-appbar__title {
    font-size: 16px;
    font-weight: 600;
    color: var(--mp-install-fg, #e6edf3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Drawer ────────────────────────────────────────────────────────── */

.mp-pwa-drawer-backdrop {
    position: fixed;
    inset: 0;
    z-index: 99995;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.28s ease;
}

.mp-pwa-drawer-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

.mp-pwa-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 99999;
    width: min(320px, 88vw);
    background: var(--mp-sidebar-bg, #0d1117);
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    transform: translateX(-105%);
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
    display: flex;
    flex-direction: column;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
}

.mp-pwa-drawer.is-open {
    transform: translateX(0);
}

.mp-pwa-drawer__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.mp-pwa-drawer__logo {
    width: 40px;
    height: 40px;
    object-fit: contain;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    padding: 4px;
}

.mp-pwa-drawer__meta {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.mp-pwa-drawer__meta strong {
    font-size: 15px;
    color: var(--mp-install-fg, #e6edf3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mp-pwa-drawer__meta span {
    font-size: 12px;
    color: var(--mp-install-muted, #8b949e);
}

.mp-pwa-drawer__close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--mp-install-muted, #8b949e);
    font-size: 18px;
    cursor: pointer;
}

.mp-pwa-drawer__body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0 16px;
    -webkit-overflow-scrolling: touch;
}

.mp-pwa-drawer__section {
    padding: 8px 0;
}

.mp-pwa-drawer__section-title {
    padding: 8px 20px 6px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--mp-install-muted, #8b949e);
}

.mp-pwa-drawer__link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 20px;
    color: var(--mp-sidebar-fg, #c9d1d9);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}

.mp-pwa-drawer__link i {
    width: 22px;
    font-size: 20px;
    text-align: center;
    color: var(--mp-tabbar-fg, #8b949e);
}

.mp-pwa-drawer__link:active,
.mp-pwa-drawer__link.is-active {
    background: rgba(10, 125, 75, 0.12);
    color: var(--mp-tabbar-active, #2ea043);
}

.mp-pwa-drawer__link.is-active i {
    color: var(--mp-tabbar-active, #2ea043);
}

.mp-pwa-drawer__link.is-danger {
    color: #f85149;
}

.mp-pwa-drawer__link.is-danger i {
    color: #f85149;
}

/* ── Bottom tab bar (3 onglets : Express / Direct / P2P) ───────────── */

.mp-pwa-tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 99990;
    display: none;
    height: var(--mp-pwa-tabbar-safe);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--mp-tabbar-bg, #0d1117);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

.mp-pwa-tabbar__list {
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    height: var(--mp-pwa-tabbar-height);
    list-style: none;
    margin: 0;
    padding: 0;
}

.mp-pwa-tabbar__item {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mp-pwa-tabbar__link {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    width: 100%;
    height: 100%;
    padding: 8px 4px;
    color: var(--mp-tabbar-fg, #8b949e);
    text-decoration: none;
    font-size: 11px;
    font-weight: 600;
    transition: color 0.15s ease;
    position: relative;
}

.mp-pwa-tabbar__link:active {
    color: var(--mp-tabbar-active, #2ea043);
}

.mp-pwa-tabbar__icon {
    width: 26px;
    height: 26px;
    font-size: 24px;
    line-height: 1;
}

.mp-pwa-tabbar__label {
    line-height: 1.1;
    text-align: center;
}

.mp-pwa-tabbar__link.is-active {
    color: var(--mp-tabbar-active, #2ea043);
}

.mp-pwa-tabbar__link.is-active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    background: var(--mp-tabbar-active, #2ea043);
    border-radius: 0 0 3px 3px;
}

.mp-pwa-tabbar__lock {
    position: absolute;
    top: 4px;
    right: calc(50% - 16px);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #f39c12;
    color: #fff;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Masquer le preloader au-dessus de la coque en PWA une fois chargé */
html.mp-pwa-standalone body.mp-pwa-drawer-open {
    overflow: hidden;
}

html.mp-pwa-standalone .mp-preloader.hidden {
    z-index: -1;
}

/* ── Bannière d'installation (navigateur) ─────────────────────────── */

.mp-pwa-install-banner {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    z-index: 1075;
    max-width: 480px;
    margin: 0 auto;
    padding: 14px 16px;
    background: var(--mp-install-bg, #161b22);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    gap: 12px;
    transform: translateY(140%);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.35s ease;
    padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
}

.mp-pwa-install-banner.is-visible {
    display: flex;
    transform: translateY(0);
    opacity: 1;
}

.mp-pwa-install-banner__icon {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 10px;
    background: rgba(10, 125, 75, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--mp-tabbar-active, #2ea043);
    font-size: 22px;
}

.mp-pwa-install-banner__body {
    flex: 1;
    min-width: 0;
}

.mp-pwa-install-banner__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--mp-install-fg, #e6edf3);
    margin-bottom: 2px;
}

.mp-pwa-install-banner__text {
    font-size: 12px;
    color: var(--mp-install-muted, #8b949e);
    line-height: 1.4;
}

.mp-pwa-install-banner__actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.mp-pwa-install-banner__btn {
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.1s ease, background 0.15s ease;
}

.mp-pwa-install-banner__btn:active {
    transform: scale(0.96);
}

.mp-pwa-install-banner__btn--primary {
    background: var(--mp-tabbar-active, #2ea043);
    color: #fff;
}

.mp-pwa-install-banner__btn--ghost {
    background: transparent;
    color: var(--mp-install-muted, #8b949e);
    padding: 8px;
    font-size: 16px;
}

/* ── Thème clair / sombre ─────────────────────────────────────────── */

[data-theme="light"] {
    --mp-tabbar-bg: #ffffff;
    --mp-tabbar-fg: #6e7681;
    --mp-tabbar-active: #0a7d4b;
    --mp-sidebar-bg: #ffffff;
    --mp-sidebar-fg: #24292f;
    --mp-sidebar-active: #0a7d4b;
    --mp-install-bg: #ffffff;
    --mp-install-fg: #1f2328;
    --mp-install-muted: #6e7681;
}

[data-theme="dark"] {
    --mp-tabbar-bg: #0d1117;
    --mp-tabbar-fg: #8b949e;
    --mp-tabbar-active: #2ea043;
    --mp-sidebar-bg: #0d1117;
    --mp-sidebar-fg: #c9d1d9;
    --mp-sidebar-active: #e6edf3;
    --mp-install-bg: #161b22;
    --mp-install-fg: #e6edf3;
    --mp-install-muted: #8b949e;
}
