/* Mobile app-like shell: safe areas, drawer nav, bottom bar, touch UX */

:root {
    --app-header-height: 56px;
    --app-bottom-bar-height: 62px;
    --app-safe-top: env(safe-area-inset-top, 0px);
    --app-safe-bottom: env(safe-area-inset-bottom, 0px);
    --app-safe-left: env(safe-area-inset-left, 0px);
    --app-safe-right: env(safe-area-inset-right, 0px);
}

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

body.mobile-app-shell {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

body.mobile-nav-open {
    overflow: hidden;
    touch-action: none;
}

/* Fixed header with notch support */
@media (max-width: 991.98px) {
    header.fixed-top {
        padding-top: var(--app-safe-top);
    }

    header.fixed-top .navbar {
        min-height: var(--app-header-height);
    }

    body.has-mobile-bottom-bar {
        padding-bottom: calc(var(--app-bottom-bar-height) + var(--app-safe-bottom));
    }

    body.has-mobile-bottom-bar .footer {
        margin-bottom: calc(var(--app-bottom-bar-height) + var(--app-safe-bottom));
    }

    /* Full-screen drawer navigation */
    .mobile-nav-backdrop {
        position: fixed;
        inset: 0;
        z-index: 1040;
        background: rgba(15, 23, 42, 0.45);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.25s ease, visibility 0.25s ease;
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
    }

    .mobile-nav-backdrop.is-visible {
        opacity: 1;
        visibility: visible;
    }

    .navbar-collapse.collapse {
        display: block !important;
    }

    .navbar-collapse.collapsing {
        height: auto !important;
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    .navbar-collapse {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        left: auto !important;
        width: min(320px, 88vw) !important;
        max-height: none !important;
        margin: 0 !important;
        padding: calc(18px + var(--app-safe-top)) 18px calc(18px + var(--app-safe-bottom)) !important;
        border-radius: 0 !important;
        box-shadow: -8px 0 32px rgba(15, 23, 42, 0.18) !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        transform: translateX(105%) !important;
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1) !important;
        z-index: 1050 !important;
        display: block !important;
        visibility: hidden;
    }

    .navbar-collapse.show,
    .navbar-collapse.collapsing {
        visibility: visible;
    }

    .navbar-collapse.show {
        transform: translateX(0) !important;
    }

    html[dir="rtl"] .navbar-collapse {
        right: auto !important;
        left: 0 !important;
        transform: translateX(-105%) !important;
        box-shadow: 8px 0 32px rgba(15, 23, 42, 0.18) !important;
    }

    html[dir="rtl"] .navbar-collapse.show {
        transform: translateX(0) !important;
    }

    .navbar-nav {
        gap: 2px;
    }

    .navbar-nav .nav-link {
        min-height: 48px;
        border-radius: 12px;
        padding: 12px 14px !important;
        margin-bottom: 4px;
        border-bottom: none !important;
        text-align: start !important;
        justify-content: flex-start !important;
    }

    .navbar-nav .nav-link:active {
        background: rgba(140, 199, 62, 0.12);
    }

    .navbar-nav .nav-link.active {
        background: rgba(140, 199, 62, 0.15);
        color: var(--secondary-color, #8CC73E) !important;
        font-weight: 600;
    }

    .navbar-cta-group {
        margin-top: 16px !important;
        padding-top: 16px;
        border-top: 1px solid rgba(15, 23, 42, 0.08);
    }

    .navbar-cta-group__btn {
        width: 100%;
        min-height: 48px;
        border-radius: 14px !important;
    }

    /* Bottom action bar */
    .mobile-bottom-bar {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1030;
        display: flex;
        align-items: center;
        min-height: var(--app-bottom-bar-height);
        padding-bottom: var(--app-safe-bottom);
        background: rgba(255, 255, 255, 0.96);
        border-top: 1px solid rgba(15, 23, 42, 0.08);
        box-shadow: 0 -8px 24px rgba(15, 23, 42, 0.08);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }

    .mobile-bottom-bar__item {
        flex: 1 1 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        min-width: 0;
        height: var(--app-bottom-bar-height);
        padding: 6px 4px;
        border: none;
        background: transparent;
        color: #64748b;
        font-size: 0.65rem;
        font-weight: 600;
        text-decoration: none;
        line-height: 1.1;
        transition: color 0.2s ease, background 0.2s ease;
    }

    .mobile-bottom-bar__item i {
        font-size: 1.05rem;
    }

    .mobile-bottom-bar__item span {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mobile-bottom-bar__item:active,
    .mobile-bottom-bar__item.is-active {
        color: var(--secondary-color, #8CC73E);
        background: rgba(140, 199, 62, 0.08);
    }

    .mobile-bottom-bar__item--primary {
        color: var(--secondary-color, #8CC73E);
        background: transparent;
        margin: 0;
        border-radius: 0;
    }

    .mobile-bottom-bar__item--primary i {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 28px;
        height: 28px;
        border-radius: 50%;
        font-size: 0.85rem;
        color: #fff;
        background: linear-gradient(135deg, #8CC73E 0%, #3BB2E6 100%);
    }

    .mobile-bottom-bar__item--primary:active {
        color: var(--secondary-color, #8CC73E);
        background: rgba(140, 199, 62, 0.08);
    }

    .mobile-bottom-bar__item--primary:active i {
        opacity: 0.92;
    }

    /* WhatsApp: use bottom bar on mobile instead of floating button */
    body.has-mobile-bottom-bar .whatsapp-float {
        display: none !important;
    }

    /* Prevent iOS input zoom */
    input,
    select,
    textarea,
    .form-control,
    .form-select {
        font-size: 16px !important;
    }

    /* Card-style sections on small screens */
    .our-partner-item,
    .country-item,
    .service-card,
    .testimonial-card {
        border-radius: 16px !important;
    }

    .modal-dialog {
        margin: calc(12px + var(--app-safe-top)) 12px calc(12px + var(--app-bottom-bar-height) + var(--app-safe-bottom)) !important;
        max-width: calc(100% - 24px) !important;
    }
}

@media (min-width: 992px) {
    .mobile-nav-backdrop,
    .mobile-bottom-bar {
        display: none !important;
    }
}
