/* Mobile PWA shell styles */

:root {
    --safe-area-inset-top: env(safe-area-inset-top, 0px);
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0px);
    --pwa-tabbar-height: 64px;
}

/* PWA bottom nav: hidden by default on ALL screens, shown only in PWA mode */
.pwa-bottom-nav {
    display: none !important;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    height: calc(var(--pwa-tabbar-height) + var(--safe-area-inset-bottom));
    padding: 0 8px var(--safe-area-inset-bottom);
    background: rgba(5, 10, 20, 0.92);
    backdrop-filter: blur(24px) saturate(160%);
    -webkit-backdrop-filter: blur(24px) saturate(160%);
    border-top: 0.5px solid rgba(255, 255, 255, 0.12);
    align-items: center;
    justify-content: space-around;
    z-index: 9999;
}

@media (max-width: 768px) {
    html,
    body {
        -webkit-tap-highlight-color: transparent;
    }

    html.pwa-native,
    html.pwa-native body {
        overscroll-behavior-y: none;
    }

    input,
    textarea,
    .markdown-content {
        user-select: text !important;
        -webkit-user-select: text !important;
    }

    .pwa-nav-item {
        display: flex;
        flex: 1;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        color: #94a3b8;
        text-decoration: none;
        font-size: 10px;
        font-weight: 600;
        letter-spacing: 0.01em;
        transition: color 0.18s ease, transform 0.12s ease;
        position: relative;
    }

    .pwa-nav-item:active {
        transform: scale(0.92);
    }

    .pwa-nav-item i {
        font-size: 18px;
        line-height: 1;
    }

    .pwa-nav-item.active {
        color: #22d3ee;
    }

    /* Active indicator pill above icon (iOS tab bar pattern) */
    .pwa-nav-item.active::before {
        content: '';
        position: absolute;
        top: -2px;
        left: 50%;
        transform: translateX(-50%);
        width: 20px;
        height: 3px;
        border-radius: 2px;
        background: linear-gradient(90deg, #667eea, #22d3ee);
    }

    .pwa-nav-item.active i {
        transform: translateY(-1px);
    }
}

html.pwa-native body {
    padding-top: 0 !important;
    overflow-x: hidden !important;
}

html.pwa-native #luxuryNav {
    display: none !important;
}

html.pwa-native #mobileSearchDropdown {
    display: none !important;
}

html.pwa-native .ai-chat-fab,
html.pwa-native footer,
html.pwa-native #pwaInstallBanner {
    display: none !important;
}

@media all and (display-mode: standalone), all and (display-mode: fullscreen) {
    body {
        padding-top: 0 !important;
        overflow-x: hidden !important;
    }

    #luxuryNav {
        display: none !important;
    }

    #mobileSearchDropdown,
    .ai-chat-fab,
    footer,
    #pwaInstallBanner {
        display: none !important;
    }

    .pwa-bottom-nav {
        display: flex !important;
    }
}

@media (max-width: 1024px) {
    html.pwa-native body {
        min-height: 100dvh;
    }

    html.pwa-native main {
        min-height: calc(100dvh - var(--pwa-tabbar-height) - var(--safe-area-inset-bottom));
        padding-top: calc(var(--safe-area-inset-top) + 8px);
        padding-bottom: calc(var(--pwa-tabbar-height) + var(--safe-area-inset-bottom) + 10px);
    }

    html.pwa-native .flash-message-stack {
        top: calc(var(--safe-area-inset-top) + 10px) !important;
    }

    html.pwa-native .pwa-bottom-nav {
        display: flex !important;
    }
}

/* PWA standalone native polish */
@media all and (display-mode: standalone), all and (display-mode: fullscreen) {
    /* Disable text selection on non-input elements */
    body {
        -webkit-user-select: none;
        user-select: none;
    }

    /* Allow selection on inputs and text content */
    input, textarea, [contenteditable], .markdown-content, pre, code {
        -webkit-user-select: text;
        user-select: text;
    }

    /* Disable long-press context menu */
    body {
        -webkit-touch-callout: none;
    }

    /* Allow long-press on links and images */
    a, img {
        -webkit-touch-callout: default;
    }

    /* Hide scrollbars in PWA mode */
    * {
        scrollbar-width: none !important;
        -ms-overflow-style: none !important;
    }
    *::-webkit-scrollbar {
        display: none !important;
    }

    /* Prevent overscroll bounce */
    html, body {
        overscroll-behavior: none;
        overflow: hidden;
    }

    main {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Same polish for pwa-native class */
html.pwa-native {
    overscroll-behavior: none;
}

html.pwa-native body {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

html.pwa-native input,
html.pwa-native textarea,
html.pwa-native [contenteditable],
html.pwa-native .markdown-content,
html.pwa-native pre,
html.pwa-native code {
    -webkit-user-select: text;
    user-select: text;
}

html.pwa-native * {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

html.pwa-native *::-webkit-scrollbar {
    display: none;
}
