/*
 * NMSL Patient Services - app shell.
 * Native-style chrome for installed (PWABuilder / TWA) sessions: bottom tab
 * navigation, safe-area handling, connectivity and update banners.
 */

:root {
    --nmsl-green: #004010;
    --nmsl-green2: #007a3d;
    --nmsl-tabbar-height: 62px;
    --nmsl-safe-top: env(safe-area-inset-top, 0px);
    --nmsl-safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ---------------------------------------------------------------- */
/* Standalone chrome                                                  */
/* ---------------------------------------------------------------- */

html.is-standalone,
html.is-standalone body {
    overscroll-behavior-y: contain;
}

html.is-standalone body {
    padding-top: var(--nmsl-safe-top);
    -webkit-tap-highlight-color: transparent;
}

/* App-like text selection: allow it only where content is meant to be copied. */
html.is-standalone body {
    -webkit-user-select: none;
    user-select: none;
}

html.is-standalone input,
html.is-standalone textarea,
html.is-standalone select,
html.is-standalone [contenteditable="true"],
html.is-standalone .selectable,
html.is-standalone table {
    -webkit-user-select: text;
    user-select: text;
}

/* Hide browser-only affordances inside the installed app. */
html.is-standalone .hide-in-app {
    display: none !important;
}

html:not(.is-standalone) .app-only {
    display: none !important;
}

/* ---------------------------------------------------------------- */
/* Bottom tab bar - primary navigation, no hamburger menus            */
/* ---------------------------------------------------------------- */

.app-tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1040;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    gap: 0;
    padding-bottom: var(--nmsl-safe-bottom);
    background: rgba(255, 255, 255, .96);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid rgba(0, 64, 16, .12);
    box-shadow: 0 -6px 24px rgba(0, 64, 16, .1);
}

.app-tabbar__item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: var(--nmsl-tabbar-height);
    padding: .35rem .2rem;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .01em;
    color: #6b7280;
    text-decoration: none;
    background: none;
    border: 0;
    transition: color .15s ease, transform .15s ease;
}

.app-tabbar__item i {
    font-size: 1.32rem;
    line-height: 1;
}

.app-tabbar__item:active {
    transform: scale(.94);
}

.app-tabbar__item.is-active,
.app-tabbar__item:hover {
    color: var(--nmsl-green);
}

.app-tabbar__item.is-active::before {
    content: "";
    position: absolute;
    top: 0;
    width: 34px;
    height: 3px;
    border-radius: 0 0 4px 4px;
    background: linear-gradient(90deg, var(--nmsl-green), var(--nmsl-green2));
}

.app-tabbar__item {
    position: relative;
}

.app-tabbar__badge {
    position: absolute;
    top: 6px;
    right: calc(50% - 22px);
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 999px;
    font-size: .6rem;
    font-weight: 800;
    line-height: 17px;
    color: #fff;
    background: #d71920;
}

/* Keep page content clear of the tab bar. */
body.has-tabbar {
    padding-bottom: calc(var(--nmsl-tabbar-height) + var(--nmsl-safe-bottom) + 12px);
}

/* ---------------------------------------------------------------- */
/* App header                                                         */
/* ---------------------------------------------------------------- */

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    display: flex;
    align-items: center;
    gap: .75rem;
    min-height: 56px;
    padding: .5rem 1rem;
    color: #fff;
    background: linear-gradient(135deg, var(--nmsl-green), var(--nmsl-green2));
}

.app-topbar__back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    color: #fff;
    background: rgba(255, 255, 255, .16);
}

.app-topbar__title {
    flex: 1 1 auto;
    margin: 0;
    font-size: 1.02rem;
    font-weight: 800;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-topbar__action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    color: #fff;
    background: rgba(255, 255, 255, .16);
}

/* ---------------------------------------------------------------- */
/* Connectivity + update banners                                      */
/* ---------------------------------------------------------------- */

.nmslcs-connectivity {
    position: fixed;
    left: 50%;
    bottom: calc(var(--nmsl-tabbar-height) + var(--nmsl-safe-bottom) + 14px);
    z-index: 1080;
    transform: translate(-50%, 140%);
    max-width: min(92vw, 420px);
    padding: .65rem 1.1rem;
    border-radius: 999px;
    font-size: .82rem;
    font-weight: 700;
    text-align: center;
    color: #fff;
    background: #b91c1c;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .22);
    transition: transform .28s ease;
}

.nmslcs-connectivity.is-visible {
    transform: translate(-50%, 0);
}

.nmslcs-connectivity[data-online="true"] {
    background: var(--nmsl-green2);
}

.nmslcs-update-banner {
    position: fixed;
    left: 50%;
    top: calc(var(--nmsl-safe-top) + 12px);
    z-index: 1090;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: .8rem;
    max-width: min(94vw, 480px);
    padding: .7rem .8rem .7rem 1.1rem;
    border-radius: 16px;
    font-size: .85rem;
    font-weight: 600;
    color: #fff;
    background: var(--nmsl-green);
    box-shadow: 0 14px 34px rgba(0, 64, 16, .32);
}

.nmslcs-update-btn {
    flex-shrink: 0;
    padding: .4rem .85rem;
    border: 0;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 800;
    color: var(--nmsl-green);
    background: #fff;
}

/* ---------------------------------------------------------------- */
/* Biometric lock overlay                                             */
/* ---------------------------------------------------------------- */

.app-lock {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem 1.5rem;
    text-align: center;
    color: #fff;
    background: linear-gradient(160deg, var(--nmsl-green), #00260a);
}

.app-lock[hidden] {
    display: none;
}

.app-lock i {
    font-size: 3.2rem;
}

.app-lock button {
    min-width: 220px;
    min-height: 52px;
    border: 0;
    border-radius: 14px;
    font-weight: 800;
    color: var(--nmsl-green);
    background: #fff;
}

/* ---------------------------------------------------------------- */
/* Touch ergonomics                                                   */
/* ---------------------------------------------------------------- */

@media (max-width: 992px) {
    .form-control,
    .form-select,
    .btn {
        min-height: 50px;
        font-size: 1rem;
    }
}

@media (display-mode: standalone) {
    .hide-in-app {
        display: none !important;
    }
}
