/* =====================================================
   HealthyRizz — Mobile-First App UX
   Makes the web feel like a native iOS/Android app
   ===================================================== */

/* ---- iOS/Android App Meta ---- */
:root {
    --app-green: #10b981;
    --app-green-dark: #059669;
    --app-green-glow: rgba(16, 185, 129, 0.25);
    --app-bg: #000000;
    --app-surface: #111111;
    --app-surface-2: #1a1a1a;
    --app-border: rgba(255, 255, 255, 0.08);
    --app-text: #ffffff;
    --app-text-muted: #888888;
    --app-header-h: 56px;
    --app-nav-h: 70px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --app-radius: 16px;
    --app-radius-sm: 10px;
}

/* =====================================================
   GLOBAL MOBILE APP FEEL
   ===================================================== */

@media (max-width: 768px) {

    /* Disable browser tap highlight (native feel) */
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
    }

    /* Smooth scrolling like native */
    html {
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
    }

    body {
        overscroll-behavior-y: none; /* prevent pull-to-refresh browser chrome */
        background-color: var(--app-bg);
    }

    /* =====================================================
       TOP MOBILE APP HEADER
       Replaces the website burger-menu header on mobile
       ===================================================== */

    /* Hide the ENTIRE old desktop-style sticky header on mobile */
    body > header.sticky,
    body > header.bg-darker,
    body > header:not(#app-mobile-header) {
        display: none !important;
    }

    /* Hide the old desktop-style burger header row (fallback) */
    header .flex.md\:hidden {
        display: none !important;
    }

    /* Hide the mobile dropdown menu (hamburger style) */
    #mobile-menu {
        display: none !important;
    }

    /* Show the new app header instead */
    #app-mobile-header {
        display: flex !important;
    }

    /* =====================================================
       BOTTOM NAV — upgraded to premium app tab bar
       ===================================================== */

    /* Push page content so it's not behind the fixed bars */
    body.has-mobile-menu {
        padding-top: 0 !important;
        padding-bottom: calc(var(--app-nav-h) + var(--safe-bottom) + 8px) !important;
    }

    main {
        margin-top: 0 !important;
        padding-top: calc(var(--app-header-h) + var(--safe-top)) !important; /* exact space for the app header */
    }

    /* Ensure bottom nav doesn't show on desktop */
    .mobile-app-menu {
        display: flex !important;
    }
}

/* Hide bottom nav on desktop */
@media (min-width: 769px) {
    .mobile-app-menu {
        display: none !important;
    }
    #app-mobile-header {
        display: none !important;
    }
}

/* =====================================================
   NEW APP MOBILE HEADER
   ===================================================== */

#app-mobile-header {
    display: none; /* shown only on mobile via media query above */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 999;
    height: var(--app-header-h);
    background: rgba(10, 10, 10, 0.92);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-bottom: 1px solid var(--app-border);
    padding-top: var(--safe-top);
    align-items: center;
    padding-left: 16px;
    padding-right: 16px;
    justify-content: space-between;
}

#app-mobile-header .app-header-logo {
    height: 32px;
    width: auto;
}

#app-mobile-header .app-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

#app-mobile-header .app-header-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s ease, transform 0.15s ease;
    text-decoration: none;
}

#app-mobile-header .app-header-btn:active {
    transform: scale(0.9);
    background: rgba(16, 185, 129, 0.3);
}

#app-mobile-header .app-header-btn.profile-btn {
    background: var(--app-green);
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.5px;
}

/* Page title in app header (optional, set per-page) */
#app-mobile-header .app-header-title {
    font-size: 17px;
    font-weight: 600;
    color: #fff;
    letter-spacing: -0.3px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    pointer-events: none;
}

/* =====================================================
   BOTTOM APP TAB BAR — Premium Redesign
   ===================================================== */

.mobile-app-menu {
    position: fixed !important;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--app-nav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: rgba(10, 10, 10, 0.95);
    backdrop-filter: blur(24px) saturate(200%);
    -webkit-backdrop-filter: blur(24px) saturate(200%);
    border-top: 1px solid var(--app-border);
    z-index: 998;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mobile-app-menu.hide-nav {
    transform: translateY(100%);
}

.mobile-app-menu-container {
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
    height: var(--app-nav-h);
    padding: 8px 4px 0;
    max-width: 100%;
}

/* Individual tab item */
.mobile-app-menu-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    flex: 1;
    padding: 6px 4px;
    border-radius: var(--app-radius-sm);
    color: var(--app-text-muted);
    text-decoration: none;
    transition: color 0.2s ease;
    position: relative;
    cursor: pointer;
    -webkit-user-select: none;
    user-select: none;
    min-width: 0;
}

.mobile-app-menu-item:focus {
    outline: none;
}

/* Icon wrapper with animated background pill */
.mobile-app-menu-item .nav-icon-wrap {
    width: 44px;
    height: 28px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.25s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

.mobile-app-menu-item .mobile-app-menu-icon {
    font-size: 18px;
    line-height: 1;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.2s ease;
    display: block;
}

.mobile-app-menu-item .mobile-app-menu-label {
    font-size: 10px;
    font-weight: 500;
    line-height: 1;
    text-align: center;
    transition: color 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 56px;
}

/* ACTIVE state — iOS-style indicator pill */
.mobile-app-menu-item.active {
    color: var(--app-green);
}

.mobile-app-menu-item.active .nav-icon-wrap {
    background: rgba(16, 185, 129, 0.15);
}

.mobile-app-menu-item.active .mobile-app-menu-icon {
    transform: scale(1.15);
    color: var(--app-green);
}

.mobile-app-menu-item.active .mobile-app-menu-label {
    color: var(--app-green);
    font-weight: 600;
}

/* Tap press effect */
.mobile-app-menu-item:active .nav-icon-wrap {
    transform: scale(0.88);
    background: rgba(16, 185, 129, 0.12);
}

/* ---- Center "featured" button (Calculator) ---- */
.mobile-app-menu-item.center-action .nav-icon-wrap {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    background: var(--app-green);
    margin-top: -20px;
    box-shadow:
        0 4px 15px rgba(16, 185, 129, 0.5),
        0 2px 6px rgba(0, 0, 0, 0.3);
    color: #fff;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease;
}

.mobile-app-menu-item.center-action .mobile-app-menu-icon {
    font-size: 20px;
    color: #fff;
}

.mobile-app-menu-item.center-action:active .nav-icon-wrap {
    transform: scale(0.88);
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

.mobile-app-menu-item.center-action.active .nav-icon-wrap {
    background: var(--app-green-dark);
}

.mobile-app-menu-item.center-action .mobile-app-menu-label {
    margin-top: 6px;
}

/* ---- Profile avatar in nav ---- */
.mobile-app-menu-item.profile .nav-icon-wrap {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--app-green);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    margin-top: 0;
    border: 2px solid transparent;
}

.mobile-app-menu-item.profile.active .nav-icon-wrap {
    border-color: var(--app-green);
    background: var(--app-green-dark);
    box-shadow: 0 0 0 2px var(--app-green-glow);
}

/* Notification dot */
.nav-badge {
    position: absolute;
    top: 0;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    border: 1.5px solid var(--app-bg);
}

/* =====================================================
   APP-STYLE PAGE TRANSITIONS
   ===================================================== */

@media (max-width: 768px) {

    /* Subtle fade-slide on content load */
    @keyframes appPageIn {
        from {
            opacity: 0;
            transform: translateY(12px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    main {
        animation: appPageIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) both;
    }

    /* =====================================================
       MOBILE CARDS / SECTIONS — native app look
       ===================================================== */

    /* Section cards that look like native UI cards */
    .app-card {
        background: var(--app-surface);
        border-radius: var(--app-radius);
        border: 1px solid var(--app-border);
        overflow: hidden;
        margin-bottom: 12px;
    }

    /* Inset grouped list (iOS Settings style) */
    .app-list-group {
        background: var(--app-surface);
        border-radius: var(--app-radius);
        overflow: hidden;
        margin: 0 0 12px;
    }

    .app-list-item {
        display: flex;
        align-items: center;
        padding: 14px 16px;
        border-bottom: 1px solid var(--app-border);
        color: var(--app-text);
        text-decoration: none;
        transition: background 0.15s ease;
        gap: 12px;
    }

    .app-list-item:last-child {
        border-bottom: none;
    }

    .app-list-item:active {
        background: rgba(255,255,255,0.05);
    }

    /* =====================================================
       SECTION HEADER LABELS (iOS "GROUPED" style)
       ===================================================== */
    .app-section-label {
        font-size: 12px;
        font-weight: 600;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: var(--app-text-muted);
        padding: 0 16px 6px;
        margin-top: 20px;
    }

    /* =====================================================
       FLOATING ACTION BUTTON adjustments on mobile
       ===================================================== */

    /* Push WhatsApp FAB above the bottom nav */
    .fixed.bottom-24.right-6,
    .fixed.bottom-6.right-6 {
        bottom: calc(var(--app-nav-h) + var(--safe-bottom) + 12px) !important;
    }

    /* =====================================================
       TOUCH-OPTIMISED BUTTONS
       ===================================================== */

    .btn,
    button[type="submit"],
    a.btn,
    .app-btn {
        min-height: 50px;
        border-radius: 14px;
        font-size: 15px;
        font-weight: 600;
        letter-spacing: 0.2px;
        transition: transform 0.15s ease, box-shadow 0.15s ease;
    }

    .btn:active,
    button[type="submit"]:active,
    a.btn:active {
        transform: scale(0.97);
    }

    /* =====================================================
       PULL-DOWN SCROLL HEADER HIDE (auto-hide on scroll)
       ===================================================== */

    /* The header hides when scrolling down, reveals on scroll up */
    #app-mobile-header {
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    #app-mobile-header.header-hidden {
        transform: translateY(-100%);
    }

    /* =====================================================
       MISC MOBILE POLISH
       ===================================================== */

    /* Remove box-shadow from images on mobile (cleaner) */
    img {
        -webkit-user-drag: none;
    }

    /* Prevent text selection on tap */
    h1, h2, h3, h4, button, a {
        -webkit-user-select: none;
        user-select: none;
    }

    /* Larger touch targets for links */
    nav a, footer a {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    /* Smoother input focus */
    input, textarea, select {
        border-radius: var(--app-radius-sm) !important;
        padding: 14px 16px !important;
        font-size: 16px !important; /* Prevents zoom on iOS */
    }

    /* Flash messages – app-style toast */
    .flash-messages-container {
        top: calc(var(--app-header-h) + 8px) !important;
        left: 12px !important;
        right: 12px !important;
    }

    .flash-message {
        border-radius: 12px !important;
        box-shadow: 0 8px 24px rgba(0,0,0,0.4) !important;
    }
}

/* =====================================================
   RIPPLE animation for tab taps
   ===================================================== */
@keyframes appRipple {
    0% { transform: scale(0); opacity: 0.5; }
    100% { transform: scale(2.5); opacity: 0; }
}

.nav-ripple {
    position: absolute;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    background: rgba(16, 185, 129, 0.3);
    transform: scale(0);
    animation: appRipple 0.5s ease-out forwards;
    pointer-events: none;
    top: 50%;
    left: 50%;
    margin-top: -20px;
    margin-left: -20px;
}

/* =====================================================
   SPLASH / LOADING STATE (optional PWA splash)
   ===================================================== */
#app-splash {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    transition: opacity 0.4s ease;
}

#app-splash.fade-out {
    opacity: 0;
    pointer-events: none;
}

#app-splash img {
    width: 80px;
    height: 80px;
    border-radius: 18px;
}

#app-splash .splash-loader {
    width: 32px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.1);
    overflow: hidden;
}

#app-splash .splash-loader::after {
    content: '';
    display: block;
    height: 100%;
    width: 40%;
    background: var(--app-green);
    border-radius: 2px;
    animation: splashLoad 1.2s ease-in-out infinite;
}

@keyframes splashLoad {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(350%); }
}

/* =====================================================
   ADDITIONAL MOBILE LAYOUT FIXES
   Fixes layout issues caused by CSS conflicts
   ===================================================== */

@media (max-width: 768px) {

    /* ---- Hero Section: Remove the pt-20 that conflicts with our header padding ---- */
    /* The index page uses pt-20 md:pt-0 on the hero section, which we need to neutralize
       because our main{padding-top} already accounts for header height */
    main > section:first-child,
    main .hero-section,
    main section.relative.min-h-\\[95vh\\] {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }

    /* But the hero section's own content needs internal top spacing */
    main > section:first-child .container,
    main > section:first-child > .container {
        padding-top: 1.5rem;
    }

    /* ---- Promo Banner: Position correctly below app header ---- */
    #promo-banner {
        position: sticky;
        top: var(--app-header-h);
        z-index: 40;
    }

    /* ---- Fix heading gradient text from mobile-fresh.css bleeding through ---- */
    /* mobile-fresh.css sets -webkit-text-fill-color: transparent on ALL h1-h6
       which breaks headings that should be white/gray. Reset for normal headings. */
    h1:not(.gradient-text-green):not(.hero-gradient-text),
    h2:not(.gradient-text-green):not(.hero-gradient-text),
    h3:not(.gradient-text-green):not(.hero-gradient-text),
    h4:not(.gradient-text-green):not(.hero-gradient-text),
    h5:not(.gradient-text-green):not(.hero-gradient-text),
    h6:not(.gradient-text-green):not(.hero-gradient-text) {
        -webkit-text-fill-color: inherit;
        background: none;
        background-clip: unset;
        -webkit-background-clip: unset;
    }

    /* ---- Inputs: Prevent iOS zoom (font-size must be >= 16px) ---- */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="tel"],
    input[type="search"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px !important;
    }

    /* ---- Subscribe/Trial buttons: ensure full-width on mobile ---- */
    .subscribe-btn {
        width: 100% !important;
        justify-content: center !important;
    }

    /* ---- Meal plan cards: proper spacing ---- */
    .meal-plan-card {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* ---- Fix WhatsApp FAB z-index to appear above content ---- */
    .fixed.bottom-24.right-6 {
        z-index: 45 !important;
    }

    /* ---- Frequency selector: wrap on small screens ---- */
    .frequency-selector {
        flex-wrap: wrap !important;
    }

    /* ---- Footer extra bottom spacing for bottom nav ---- */
    footer {
        padding-bottom: calc(var(--app-nav-h) + var(--safe-bottom) + 1rem) !important;
    }

    /* ---- Flash messages repositioned below app header ---- */
    .flash-messages-container {
        top: calc(var(--app-header-h) + var(--safe-top) + 8px) !important;
    }

    /* ---- Action row: stack buttons vertically on mobile ---- */
    .action-row {
        flex-direction: column !important;
        gap: 0.75rem !important;
    }

    /* ---- Profile page: tab nav horizontal scroll ---- */
    .profile-tabs {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        flex-wrap: nowrap !important;
        scrollbar-width: none;
        padding-bottom: 8px !important;
    }
    .profile-tabs::-webkit-scrollbar { display: none; }
    .profile-tabs a {
        white-space: nowrap !important;
    }

    /* ---- Profile page: premium cards & layout ---- */
    .tab-content .bg-black {
        background: var(--app-surface) !important;
        border: 1px solid var(--app-border) !important;
        border-radius: var(--app-radius) !important;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4) !important;
        overflow: hidden !important;
    }

    .tab-content .bg-primary.text-white.p-4 {
        background: rgba(255, 255, 255, 0.02) !important;
        border-bottom: 1px solid var(--app-border) !important;
        color: #ffffff !important;
        padding: 16px 20px !important;
    }

    .tab-content .bg-primary.text-white.p-4 h2 {
        font-size: 16px !important;
        font-weight: 600 !important;
        letter-spacing: -0.2px !important;
    }

    /* Redesign button chaos in profile page */
    .tab-content a.bg-primary,
    .tab-content button.bg-primary {
        background: var(--app-green) !important;
        transition: opacity 0.2s ease !important;
    }
    .tab-content a.bg-primary:active,
    .tab-content button.bg-primary:active {
        opacity: 0.8 !important;
    }

    .tab-content a.bg-blue-500,
    .tab-content button.bg-blue-500,
    .tab-content button.bg-purple-500,
    .tab-content button.bg-yellow-500 {
        background: rgba(255, 255, 255, 0.08) !important;
        color: #ffffff !important;
        border: 1px solid rgba(255, 255, 255, 0.05) !important;
        font-weight: 500 !important;
    }

    .tab-content button.bg-red-500 {
        background: rgba(239, 68, 68, 0.1) !important;
        color: #ef4444 !important;
        border: 1px solid rgba(239, 68, 68, 0.2) !important;
        font-weight: 500 !important;
    }

    .tab-content button.bg-red-500:active {
        background: rgba(239, 68, 68, 0.2) !important;
    }

    .tab-content .border-gray-700 {
        border-color: var(--app-border) !important;
    }

    /* ---- Section paddings & margins on mobile ---- */
    section.py-24 {
        padding-top: 2.5rem !important;
        padding-bottom: 2.5rem !important;
    }
    section.py-20 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    section.py-16 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }
    
    .mb-20, .mb-16 {
        margin-bottom: 1.5rem !important;
    }
    
    section h2.text-3xl.md\:text-5xl,
    section h2.text-3xl {
        font-size: 1.6rem !important;
        letter-spacing: -0.5px !important;
        line-height: 1.25 !important;
    }
    
    section p.text-lg {
        font-size: 0.95rem !important;
        line-height: 1.4 !important;
    }

    /* ---- Auth Pages Layout ---- */
    main > div.min-h-screen.flex.items-center.justify-center.py-12 {
        min-height: calc(100vh - var(--app-header-h) - var(--app-nav-h) - var(--safe-top) - var(--safe-bottom)) !important;
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
        align-items: flex-start !important;
    }
    
    /* Decouple stacked inputs on mobile */
    form .rounded-md.shadow-sm.-space-y-px {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
        box-shadow: none !important;
    }
    
    form .rounded-md.shadow-sm.-space-y-px > div {
        margin-top: 0 !important;
    }
    
    form input[type="text"],
    form input[type="email"],
    form input[type="password"],
    form input[type="tel"] {
        border-radius: 12px !important;
        border: 1px solid rgba(255, 255, 255, 0.12) !important;
        background: #111111 !important;
        color: #ffffff !important;
        font-size: 16px !important;
        padding: 14px 16px !important;
        transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
    }
    
    form input[type="text"]:focus,
    form input[type="email"]:focus,
    form input[type="password"]:focus,
    form input[type="tel"]:focus {
        border-color: var(--app-green) !important;
        box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15) !important;
    }
    
    .bg-darkest img.mx-auto {
        max-height: 72px !important;
        width: auto !important;
        margin-bottom: 8px !important;
    }
    
    div.max-w-md.w-full.space-y-8.bg-dark.p-8 {
        padding: 1.5rem !important;
        border-radius: 16px !important;
        border: 1px solid rgba(255, 255, 255, 0.08) !important;
        margin-top: 1rem !important;
        background: var(--app-surface) !important;
    }

    /* ---- Checkout: stack sections cleanly ---- */
    .checkout-container {
        flex-direction: column !important;
    }

    /* ---- Ensure nav links in footer don't get 44px min-height treatment ---- */
    footer a {
        min-height: unset !important;
        display: inline !important;
    }

    /* ---- Blog grid: single column ---- */
    .blog-grid {
        grid-template-columns: 1fr !important;
    }
}

