/**
 * Homepage Mobile Navigation - App Style
 * Load in <head> to prevent FOUC
 */

/* Hide mobile elements on desktop */
.mobile-app-header,
.mobile-bottom-nav,
.search-overlay {
    display: none;
}

/* Hide desktop header on mobile - CRITICAL */
@media (max-width: 768px) {
    .header {
        display: none !important;
        visibility: hidden !important;
    }
}

/* ============================================
   MOBILE APP HEADER
   ============================================ */
@media (max-width: 768px) {
    /* Hide desktop header & footer */
    .header, .footer {
        display: none !important;
    }

    /* Body padding for fixed elements */
    body {
        padding-top: 70px !important;
        padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Show mobile header */
    .mobile-app-header {
        position: fixed !important;
        top: 0;
        left: 0;
        right: 0;
        z-index: 9999;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        padding: 8px 16px;
        padding-top: calc(8px + env(safe-area-inset-top));
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        height: 60px;
    }

    .mobile-header-logo {
        display: flex;
        align-items: center;
    }

    .mobile-header-logo img {
        height: 70px;
        width: auto;
    }

    .mobile-header-icon {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        background: var(--bg, #f8fafc);
        color: var(--text, #1a1a2e);
        transition: all 0.2s;
    }

    .mobile-header-icon:active {
        transform: scale(0.9);
        background: rgba(255, 82, 0, 0.1);
    }
}

/* ============================================
   MOBILE BOTTOM NAVIGATION
   ============================================ */
@media (max-width: 768px) {
    .mobile-bottom-nav {
        position: fixed !important;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 9999;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        display: flex !important;
        justify-content: space-around;
        align-items: center;
        padding: 8px 0;
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    }

    .mobile-bottom-nav .nav-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        padding: 6px 4px;
        color: var(--text-light, #64748b);
        text-decoration: none;
        font-size: 10px;
        font-weight: 500;
        transition: color 0.2s;
    }

    .mobile-bottom-nav .nav-item.active {
        color: var(--primary, #ff5200);
    }

    .mobile-bottom-nav .nav-item svg {
        width: 24px;
        height: 24px;
        stroke-width: 1.8;
    }

    .mobile-bottom-nav .nav-item.active svg {
        stroke-width: 2.2;
    }

    .mobile-bottom-nav .nav-item-label {
        font-size: 10px;
        font-weight: 500;
    }
}

/* ============================================
   SEARCH OVERLAY
   ============================================ */
@media (max-width: 768px) {
    .search-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 10001;
        background: var(--white, #fff);
    }

    .search-overlay.active {
        display: block;
    }

    .search-overlay-header {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 16px;
        padding-top: calc(12px + env(safe-area-inset-top));
        background: var(--white, #fff);
        border-bottom: 1px solid var(--border, #e2e8f0);
    }

    .search-overlay-back {
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        cursor: pointer;
    }

    .search-overlay-back:active {
        background: rgba(0,0,0,0.05);
    }

    .search-overlay-back svg {
        width: 24px;
        height: 24px;
        color: var(--text, #1a1a2e);
    }

    .search-overlay-input {
        flex: 1;
    }

    .search-overlay-input input {
        width: 100%;
        padding: 12px 16px;
        border: none;
        background: var(--bg, #f8fafc);
        border-radius: 12px;
        font-size: 16px;
        font-family: inherit;
        outline: none;
    }

    .search-overlay-body {
        padding: 16px;
    }

    .search-section-title {
        font-size: 12px;
        font-weight: 600;
        color: var(--text-light, #64748b);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 12px;
    }

    .search-suggestions {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .search-suggestion {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px;
        border-radius: 12px;
        cursor: pointer;
        transition: background 0.2s;
    }

    .search-suggestion:active {
        background: var(--bg, #f8fafc);
    }

    .search-suggestion svg {
        width: 20px;
        height: 20px;
        color: var(--text-light, #64748b);
    }

    .search-suggestion-text {
        font-size: 15px;
        color: var(--text, #1a1a2e);
    }
}

/* ============================================
   DARK MODE SUPPORT
   ============================================ */
@media (max-width: 768px) {
    [data-theme="dark"] .mobile-app-header {
        background: rgba(26, 26, 46, 0.98);
        box-shadow: 0 1px 0 rgba(255,255,255,0.05);
    }

    [data-theme="dark"] .mobile-header-icon {
        background: rgba(255,255,255,0.1);
        color: #fff;
    }

    [data-theme="dark"] .mobile-bottom-nav {
        background: rgba(26, 26, 46, 0.98);
        box-shadow: 0 -1px 0 rgba(255,255,255,0.05);
    }

    [data-theme="dark"] .mobile-bottom-nav .nav-item {
        color: rgba(255,255,255,0.6);
    }

    [data-theme="dark"] .mobile-bottom-nav .nav-item.active {
        color: var(--primary, #ff5200);
    }

    [data-theme="dark"] .search-overlay {
        background: #1a1a2e;
    }

    [data-theme="dark"] .search-overlay-header {
        background: #1a1a2e;
        border-bottom-color: rgba(255,255,255,0.1);
    }

    [data-theme="dark"] .search-overlay-back svg {
        color: #fff;
    }

    [data-theme="dark"] .search-overlay-input input {
        background: rgba(255,255,255,0.1);
        color: #fff;
    }

    [data-theme="dark"] .search-suggestion-text {
        color: #fff;
    }
}

/* ============================================
   MOBILE FIXED BOTTOM WRAPPER
   Groups bottom nav + widget + toggle so Chrome
   viewport resize moves them all together
   ============================================ */
@media (max-width: 768px) {
    .mobile-fixed-bottom {
        position: fixed !important;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 9999;
        pointer-events: none;
    }

    .mobile-fixed-bottom > * {
        pointer-events: auto;
    }

    .mobile-fixed-bottom .mobile-bottom-nav {
        position: relative !important;
    }

    .mobile-fixed-bottom .wa-widget {
        position: absolute !important;
        bottom: 100%;
        right: 12px;
        margin-bottom: 10px;
    }

    .mobile-fixed-bottom .theme-toggle {
        position: absolute !important;
        bottom: 100%;
        left: 16px;
        margin-bottom: 10px;
    }
}

/* ============================================
   SAFE AREA SUPPORT
   ============================================ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media (max-width: 768px) {
        body {
            padding-bottom: calc(70px + env(safe-area-inset-bottom));
        }
    }
}

/* Skip to content link (accessibility) */
.skip-link { position: absolute; top: -100px; left: 0; background: #000; color: #fff; padding: 0.75rem 1.5rem; z-index: 10000; font-size: 0.95rem; font-weight: 600; text-decoration: none; border-radius: 0 0 8px 0; transition: top 0.2s; }
.skip-link:focus { top: 0; }
