/**
 * Mobile App Shell — layout/navigation only.
 * Desktop (≥1200px / xl) remains unchanged.
 */

:root {
    --app-header-height: 56px;
    --app-bottom-nav-height: 64px;
    --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);
}

/* ========== Mobile only ========== */
@media screen and (max-width: 1199.98px) {
    body.has-app-shell {
        height: 100dvh;
        max-height: 100dvh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        padding-left: var(--app-safe-left);
        padding-right: var(--app-safe-right);
    }

    /*
     * AOS listens to window scroll only. On mobile the real scroll lives in
     * #app-shell-content, so fade animations never fire and cards stay invisible.
     */
    body.has-app-shell [data-aos] {
        opacity: 1 !important;
        transform: none !important;
        pointer-events: auto !important;
        transition: none !important;
    }

    /* Hide website chrome on mobile */
    body.has-app-shell .header-primary,
    body.has-app-shell .footer-area {
        display: none !important;
    }

    /* App header */
    .mobile-app-header {
        position: sticky;
        top: 0;
        z-index: 1040;
        flex-shrink: 0;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        min-height: calc(var(--app-header-height) + var(--app-safe-top));
        padding: var(--app-safe-top) 16px 0;
        background-color: var(--brand-white, #fff);
        border-bottom: 1px solid rgba(37, 37, 37, 0.08);
    }

    .mobile-app-header__side {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 44px;
        min-height: 44px;
    }

    .mobile-app-header__side--end {
        justify-content: flex-end;
    }

    .mobile-app-header__title {
        flex: 1 1 auto;
        min-width: 0;
        margin: 0;
        text-align: center;
        font-family: var(--main-font-family, "Cairo", sans-serif);
        font-size: 17px;
        font-weight: 700;
        color: var(--brand-black, #252525);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        line-height: 1.3;
    }

    .mobile-app-header__btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        padding: 0;
        border: 0;
        background: transparent;
        color: var(--brand-navy, #083A66);
        text-decoration: none;
        cursor: pointer;
    }

    .mobile-app-header__btn:hover,
    .mobile-app-header__btn:focus {
        color: var(--brand-orange, #FF8A00);
    }

    .mobile-app-header__logo {
        width: 36px;
        height: 36px;
        object-fit: contain;
    }

    /* Scrollable content region */
    .app-shell-content {
        flex: 1 1 auto;
        min-height: 0;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior-y: contain;
        padding-bottom: calc(var(--app-bottom-nav-height) + var(--app-safe-bottom) + 16px);
    }

    /* Bottom navigation */
    .mobile-bottom-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1045;
        display: flex;
        align-items: stretch;
        justify-content: space-around;
        min-height: calc(var(--app-bottom-nav-height) + var(--app-safe-bottom));
        padding: 6px 4px var(--app-safe-bottom);
        background-color: var(--brand-white, #fff);
        border-top: 1px solid rgba(37, 37, 37, 0.08);
        box-shadow: 0 -2px 12px rgba(8, 58, 102, 0.06);
    }

    .mobile-bottom-nav__item {
        flex: 1 1 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        min-height: 48px;
        padding: 4px 2px;
        color: var(--brand-navy, #083A66);
        text-decoration: none;
        font-size: 11px;
        font-weight: 500;
        line-height: 1.2;
        opacity: 0.72;
        border: 0;
        background: transparent;
        cursor: pointer;
    }

    .mobile-bottom-nav__item i,
    .mobile-bottom-nav__item svg {
        font-size: 20px;
        width: 22px;
        height: 22px;
        display: block;
    }

    .mobile-bottom-nav__item.active,
    .mobile-bottom-nav__item:hover,
    .mobile-bottom-nav__item:focus {
        color: var(--brand-orange, #FF8A00);
        opacity: 1;
        text-decoration: none;
    }

    .mobile-bottom-nav__label {
        max-width: 72px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Floating Action Button */
    .mobile-fab {
        position: fixed;
        right: 16px;
        bottom: calc(var(--app-bottom-nav-height) + var(--app-safe-bottom) + 16px);
        z-index: 1046;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background-color: var(--brand-orange, #FF8A00);
        color: #fff !important;
        text-decoration: none !important;
        box-shadow: 0 6px 18px rgba(255, 138, 0, 0.35);
    }

    body.lang-rtl .mobile-fab {
        right: auto;
        left: 16px;
    }

    .mobile-fab:hover,
    .mobile-fab:focus {
        color: #fff !important;
        filter: brightness(1.05);
    }

    .mobile-fab i {
        font-size: 22px;
    }

    /* Filter sheet trigger */
    .mobile-filter-trigger {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        min-height: 44px;
        padding: 8px 14px;
        border: 1px solid rgba(11, 79, 138, 0.15);
        border-radius: 8px;
        background: var(--brand-white, #fff);
        color: var(--brand-navy, #083A66);
        font-weight: 600;
        font-size: 14px;
        cursor: pointer;
    }

    .mobile-filter-trigger i {
        color: var(--brand-orange, #FF8A00);
    }

    /* Bottom sheet (Bootstrap offcanvas bottom) */
    .mobile-filter-sheet.offcanvas-bottom {
        height: auto;
        max-height: 85dvh;
        border-top-left-radius: 16px;
        border-top-right-radius: 16px;
        padding-bottom: var(--app-safe-bottom);
    }

    .mobile-filter-sheet .offcanvas-header {
        padding: 16px 20px 8px;
        border-bottom: 1px solid rgba(37, 37, 37, 0.08);
    }

    .mobile-filter-sheet .offcanvas-body {
        padding: 16px 20px 24px;
        overflow-y: auto;
    }

    .mobile-filter-sheet .offcanvas-title {
        font-size: 17px;
        font-weight: 700;
        color: var(--brand-black, #252525);
    }

    /* Dashboard shell adaptations */
    body.has-app-shell.dashboard-app-shell > .d-xl-flex {
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
        max-width: 100%;
        height: 100%;
        display: flex !important;
        flex-direction: column;
        overflow: hidden;
    }

    body.has-app-shell.dashboard-app-shell > .d-xl-flex > .flex-grow-1 {
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
        max-width: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        margin: 0 !important;
    }

    /* Kill desktop sidebar offset on mobile (LTR + RTL) */
    body.has-app-shell.dashboard-app-shell .dashboard-header,
    body.has-app-shell.dashboard-app-shell .dashboard-main,
    body.lang-rtl.has-app-shell.dashboard-app-shell .dashboard-header,
    body.lang-rtl.has-app-shell.dashboard-app-shell .dashboard-main,
    html[dir="rtl"] body.has-app-shell.dashboard-app-shell .dashboard-header,
    html[dir="rtl"] body.has-app-shell.dashboard-app-shell .dashboard-main {
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        left: auto !important;
        right: auto !important;
    }

    body.has-app-shell.dashboard-app-shell .dashboard-header {
        position: sticky;
        top: 0;
        z-index: 1040;
        flex-shrink: 0;
        min-height: calc(var(--app-header-height) + var(--app-safe-top));
        padding-top: calc(10px + var(--app-safe-top)) !important;
        padding-inline: 12px !important;
        padding-bottom: 10px !important;
        gap: 8px;
    }

    body.has-app-shell.dashboard-app-shell .dashboard-header .mobile-app-header__title {
        text-align: start;
        margin-inline-start: 4px;
        font-size: 16px;
    }

    /* Don't flip the back chevron twice — keep logical back direction */
    body.has-app-shell.dashboard-app-shell .mobile-app-header__btn .fa-arrow-left,
    body.has-app-shell.dashboard-app-shell .mobile-app-header__btn .fa-arrow-right {
        transform: none !important;
    }

    body.lang-rtl.has-app-shell.dashboard-app-shell .mobile-app-header__btn .fa-arrow-left,
    html[dir="rtl"] body.has-app-shell.dashboard-app-shell .mobile-app-header__btn .fa-arrow-left {
        transform: scaleX(-1) !important;
    }

    body.has-app-shell.dashboard-app-shell .app-shell-content {
        flex: 1 1 auto;
        min-height: 0;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: calc(var(--app-bottom-nav-height) + var(--app-safe-bottom) + 16px);
    }

    /* Dashboard page content: full-bleed, thumb-friendly */
    body.has-app-shell.dashboard-app-shell .dashboard-main {
        min-height: auto !important;
        padding: 16px 14px 24px !important;
        box-sizing: border-box;
    }

    body.has-app-shell.dashboard-app-shell .dashboard-main .row {
        margin-left: 0;
        margin-right: 0;
    }

    body.has-app-shell.dashboard-app-shell .dashboard-main .row > [class*="col-"] {
        padding-left: 0;
        padding-right: 0;
        max-width: 100%;
        flex: 0 0 100%;
    }

    body.has-app-shell.dashboard-app-shell .dashboard-main .pb-110 {
        padding-bottom: 24px !important;
    }

    body.has-app-shell.dashboard-app-shell .gig-info-card,
    body.has-app-shell.dashboard-app-shell .gig-info-body,
    body.has-app-shell.dashboard-app-shell .form-container {
        max-width: 100%;
    }

    body.has-app-shell.dashboard-app-shell .gig-info-body {
        padding: 16px !important;
    }

    body.has-app-shell.dashboard-app-shell .form-control,
    body.has-app-shell.dashboard-app-shell .form-select,
    body.has-app-shell.dashboard-app-shell .nice-select {
        max-width: 100%;
    }

    /* Bottom nav respects document direction */
    body.lang-rtl .mobile-bottom-nav,
    html[dir="rtl"] .mobile-bottom-nav {
        direction: rtl;
    }

    body.lang-ltr .mobile-bottom-nav,
    html[dir="ltr"] .mobile-bottom-nav {
        direction: ltr;
    }

    .mobile-bottom-nav__label {
        max-width: 64px;
        font-size: 10px;
    }

    /* Hide oversized dashboard user name on very small screens */
    body.has-app-shell.dashboard-app-shell .dashboard-user-name {
        display: none;
    }

    /* Compact header actions on mobile */
    body.has-app-shell.dashboard-app-shell .dashboard-header-btns {
        gap: 6px !important;
    }

    body.has-app-shell.dashboard-app-shell .dashboard-header-btns .dashboard-header-btn {
        width: 40px !important;
        height: 40px !important;
    }

    body.has-app-shell.dashboard-app-shell .dashboard-user-profile-link .w-56 {
        width: 36px !important;
        height: 36px !important;
    }

    /* Mobile dashboard drawer — opens from language start side */
    .mobile-dashboard-drawer {
        width: min(86vw, 320px) !important;
        max-width: 320px;
        border: 0;
        background: var(--brand-white, #fff);
        padding-bottom: var(--app-safe-bottom);
    }

    .mobile-dashboard-drawer.offcanvas-start {
        left: 0;
        right: auto;
        border-inline-end: 1px solid rgba(37, 37, 37, 0.08);
    }

    .mobile-dashboard-drawer.offcanvas-end {
        right: 0;
        left: auto;
        border-inline-start: 1px solid rgba(37, 37, 37, 0.08);
    }

    .mobile-dashboard-drawer__header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        padding: calc(12px + var(--app-safe-top)) 16px 12px;
        border-bottom: 1px solid rgba(37, 37, 37, 0.08);
    }

    .mobile-dashboard-drawer__title {
        margin: 0;
        font-size: 16px;
        font-weight: 700;
        color: var(--brand-black, #252525);
    }

    .mobile-dashboard-drawer__header .btn-close {
        position: static !important;
        width: 32px;
        height: 32px;
        margin: 0;
        padding: 0;
        background-color: var(--dark-50, #eee);
        border-radius: 50%;
        opacity: 1;
    }

    .mobile-dashboard-drawer__body {
        padding: 0 !important;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        height: calc(100% - 56px - var(--app-safe-top));
    }

    .mobile-dashboard-drawer__sidebar {
        position: relative !important;
        width: 100% !important;
        min-height: 0 !important;
        height: 100% !important;
        max-height: 100% !important;
        margin: 0 !important;
        left: auto !important;
        right: auto !important;
        border: 0 !important;
        box-shadow: none !important;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .mobile-dashboard-drawer__sidebar .sidebar-nav {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .mobile-dashboard-drawer__sidebar .dashboard-sidebar-footer {
        flex-shrink: 0;
    }

    /* Override absolute close from style.css inside drawer body */
    .mobile-dashboard-drawer .offcanvas-body > .btn-close {
        display: none;
    }
}

/* Desktop / tablet xl+: ensure mobile chrome never shows */
@media screen and (min-width: 1200px) {
    .mobile-app-header,
    .mobile-bottom-nav,
    .mobile-fab,
    .mobile-filter-trigger,
    .mobile-only {
        display: none !important;
    }

    .app-shell-content {
        /* no special layout on desktop */
        overflow: visible;
        padding-bottom: 0;
    }
}
