/*
 * Mobile app (Capacitor) UI enhancements.
 * All rules are scoped under `body.mobile-app-mode`, which is added by
 * assets/js/mobile_app_ui.js ONLY when running inside the native app.
 * The normal website is unaffected.
 */

/* room for the fixed bottom nav so content isn't hidden behind it */
body.mobile-app-mode {
    padding-bottom: calc(60px + env(safe-area-inset-bottom, 0px)) !important;
}

/* the bottom tab bar */
.mobile-app-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    height: 60px;
    background: #ffffff;
    border-top: 1px solid #ececec;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
    z-index: 1030; /* below Bootstrap modals (1050) so dialogs sit on top */
    padding-bottom: env(safe-area-inset-bottom, 0px);
    --mobile-nav-accent: #d8392f; /* brand red — fixed active-tab colour */
}

.mobile-app-bottom-nav a {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: #8b8b8b;
    font-size: 11px;
    line-height: 1;
    padding: 7px 0 5px;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s ease;
}

.mobile-app-bottom-nav a svg {
    width: 23px;
    height: 23px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.mobile-app-bottom-nav a .mobile-nav-label {
    font-weight: 500;
    letter-spacing: 0.2px;
}

.mobile-app-bottom-nav a.active {
    color: var(--mobile-nav-accent);
}

.mobile-app-bottom-nav a:active {
    opacity: 0.6;
}

/* keep RISE's toast alerts above the bottom tab bar (they're fixed at the bottom) */
body.mobile-app-mode .app-alert {
    bottom: calc(74px + env(safe-area-inset-bottom, 0px)) !important;
    z-index: 1060 !important;
}

/* move RISE's chat bubble to the bottom-left, lifted above the tab bar */
body.mobile-app-mode #js-init-chat-icon {
    left: 14px !important;
    right: auto !important;
    bottom: calc(74px + env(safe-area-inset-bottom, 0px)) !important;
}
body.mobile-app-mode #js-rise-chat-wrapper {
    left: 10px !important;
    right: auto !important;
    bottom: calc(74px + env(safe-area-inset-bottom, 0px)) !important;
}

/* floating "Add task" button (FAB) — styled like the chat bubble */
body.mobile-app-mode .m-fab {
    position: fixed;
    right: 16px;
    bottom: calc(74px + env(safe-area-inset-bottom, 0px));
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: #d8392f;
    color: #fff !important;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
    z-index: 1031;
    text-decoration: none;
}
body.mobile-app-mode .m-fab:active {
    filter: brightness(0.92);
}
body.mobile-app-mode .m-fab .icon-20 {
    width: 24px;
    height: 24px;
}

/* ---- global action FAB (expandable) ---- */
body.mobile-app-mode .m-fab-menu {
    position: fixed;
    right: 16px;
    bottom: calc(74px + env(safe-area-inset-bottom, 0px));
    z-index: 1032;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}
body.mobile-app-mode .m-fab-trigger {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: #d8392f;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.22);
}
body.mobile-app-mode .m-fab-trigger svg {
    width: 26px;
    height: 26px;
    stroke: #fff;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.2s ease;
}
body.mobile-app-mode .m-fab-menu.open .m-fab-trigger svg {
    transform: rotate(45deg);
}
body.mobile-app-mode .m-fab-sheet {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    margin-bottom: 14px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity 0.18s ease, transform 0.18s ease;
}
body.mobile-app-mode .m-fab-menu.open .m-fab-sheet {
    opacity: 1;
    pointer-events: auto;
    transform: none;
}
body.mobile-app-mode .m-fab-item {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}
body.mobile-app-mode .m-fab-item-label {
    background: #fff;
    color: #333;
    font-size: 13px;
    padding: 7px 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}
body.mobile-app-mode .m-fab-item-ic {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}
body.mobile-app-mode .m-fab-item-ic svg {
    width: 20px;
    height: 20px;
    stroke: #d8392f;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ============================================================
   App-like login screen (native app only, incl. logged-out)
   ============================================================ */
body.native-app { background: #f5f6f8; }

body.native-app .form-signin {
    max-width: 440px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 28px 24px calc(28px + env(safe-area-inset-bottom, 0px));
    box-sizing: border-box;
}

/* strip the card chrome — go full-bleed app style */
body.native-app .form-signin .card,
body.native-app .form-signin .card-header,
body.native-app .form-signin .card-body {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}
body.native-app .form-signin .card { margin: 0 !important; }
body.native-app .form-signin .card-header { padding-top: 0 !important; margin-bottom: 8px; }
body.native-app .form-signin .card-body { padding-top: 0 !important; padding-bottom: 0 !important; }

body.native-app .form-signin .card-header img {
    max-width: 132px;
    height: auto;
    padding: 0 !important;
}

/* inputs — large, rounded, touch-friendly */
body.native-app .form-signin .form-control {
    height: 54px;
    border-radius: 13px;
    background: #ffffff;
    border: 1px solid #e3e3ea;
    font-size: 16px;              /* >=16px stops iOS zoom-on-focus */
    padding: 0 16px;
    margin-bottom: 13px;
    box-shadow: none;
    -webkit-appearance: none;
}
body.native-app .form-signin .form-control:focus {
    border-color: #d8392f;
    box-shadow: 0 0 0 3px rgba(216, 57, 47, 0.12);
}
body.native-app .form-signin .form-group { margin-bottom: 0; }

/* primary button — brand red, matches the nav */
body.native-app .form-signin .btn-primary {
    height: 54px;
    border-radius: 13px;
    background: #d8392f;
    border: none;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 0.2px;
    box-shadow: 0 6px 18px rgba(216, 57, 47, 0.28);
    margin-top: 6px;
    width: 100%;
}
body.native-app .form-signin .btn-primary:active { filter: brightness(0.94); }

/* links */
body.native-app .form-signin a { color: #d8392f; font-weight: 500; }
body.native-app .form-signin .mt5 { margin-top: 16px !important; }
body.native-app .form-signin .mt20 { margin-top: 22px !important; color: #8a8a8a; }

/* remember-me / checkbox row spacing */
body.native-app .form-signin .checkbox,
body.native-app .form-signin label { color: #666; }

/* linkified URLs inside notes/comments */
.m-link { color: #d8392f; text-decoration: underline; word-break: break-all; }

/* app login: hide forgot-password + signup links */
body.native-app .form-signin .mt5,
body.native-app .form-signin .mt20 { display: none !important; }
