/* App (PWA) do portal do paciente. Complementa portal.css. */

/* Tela cheia, instalado na tela inicial */
@media (display-mode: standalone) {
  .preview-bar, .prev-fab { display: none !important; }
  body.portal { overscroll-behavior-y: contain; }
  .p-top { padding-top: calc(.7rem + env(safe-area-inset-top, 0px)); }
}
body.is-standalone .preview-bar, body.is-standalone .prev-fab { display: none !important; }
body.is-standalone .p-top { padding-top: calc(.7rem + env(safe-area-inset-top, 0px)); }

/* Convite para instalar */
.app-install { display: flex; gap: 1rem; align-items: flex-start; margin-top: 1.25rem; background: var(--sky-2); border-color: var(--sky); }
.app-install__icon { flex: none; width: 56px; height: 56px; border-radius: 14px; }
.app-install__body { flex: 1; min-width: 0; }
.app-install .card__title { margin-bottom: .35rem; }
.app-install .actions { justify-content: flex-start; flex-wrap: wrap; margin-top: .9rem; }
.app-install .actions .btn:last-child { flex: 0 1 auto; }
.ios-steps { margin: .4rem 0 0; padding-left: 1.2rem; display: grid; gap: .35rem; color: var(--text); }
.ios-steps .icon { width: 1.1rem; height: 1.1rem; vertical-align: -3px; color: var(--blue-700); }
@media (max-width: 479px) { .app-install { flex-direction: column; } }

/* Barra de baixo no celular: 4 atalhos + Mais */
.p-nav__more { display: none; }
.p-nav__morebtn { width: 100%; display: flex; align-items: center; gap: .75rem; border: 0; background: none; font: inherit; color: var(--ink-2); cursor: pointer; }
.p-nav__morebtn .icon { width: 1.2rem; height: 1.2rem; color: var(--muted); }
@media (max-width: 899px) {
  .p-nav li.p-nav__x { display: none; }
  .p-nav li.p-nav__more { display: block; order: 3; }
  .p-nav ul { overflow: visible; }
  .p-nav li { flex: 1 1 0; }
  .p-nav a, .p-nav__morebtn { min-width: 0; flex-direction: column; justify-content: center; gap: .15rem; min-height: 56px; padding: .2rem .25rem; font-size: 12px; font-weight: 600; text-align: center; border-radius: 10px; }
  .p-nav__morebtn.is-active { background: var(--sky); color: var(--blue-700); }
  .p-nav__morebtn.is-active .icon { color: var(--blue-700); }
}

/* Folha "Mais" */
.sheet { width: min(100%, 32rem); max-width: 100%; margin: auto auto 0; padding: .75rem .75rem calc(1rem + env(safe-area-inset-bottom, 0px)); border: 0; border-radius: 18px 18px 0 0; background: #fff; color: var(--text); }
.sheet::backdrop { background: rgba(11, 21, 80, .45); }
.sheet__grip { width: 40px; height: 4px; margin: .1rem auto .75rem; border-radius: 4px; background: var(--line-2, #c9d6e6); }
.sheet h2 { margin: 0 .5rem .5rem; font-size: 17px; font-weight: 800; color: var(--ink); }
.sheet ul { display: grid; gap: .1rem; margin: 0; padding: 0; list-style: none; }
.sheet a { display: flex; align-items: center; gap: .8rem; min-height: 52px; padding: 0 .75rem; border-radius: 12px; color: var(--ink); text-decoration: none; font-weight: 600; }
.sheet a .icon { width: 1.25rem; height: 1.25rem; color: var(--muted); }
.sheet a:hover, .sheet a[aria-current="page"] { background: var(--sky); color: var(--blue-700); }
.sheet form { margin-top: .5rem; }
@media (min-width: 900px) { .sheet { margin: auto; border-radius: 18px; } }

/* Sem conexão: dados de saúde não ficam no aparelho */
.offline-panel { display: none; max-width: 32rem; margin: 2rem auto; text-align: center; }
.offline-panel .ic { display: grid; place-items: center; width: 72px; height: 72px; margin: 0 auto 1rem; border-radius: 50%; background: var(--sky); color: var(--blue-700); }
.offline-panel .ic .icon { width: 34px; height: 34px; }
.offline-panel h1 { font-size: 24px; font-weight: 800; color: var(--ink); margin-bottom: .5rem; }
.offline-panel .note { margin-top: 1rem; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-size: 14px; text-align: left; }
body.is-offline .p-main > .view { display: none !important; }
body.is-offline .offline-panel { display: block; }

/* Nova versão */
.app-update { position: fixed; z-index: 70; left: 50%; top: calc(12px + env(safe-area-inset-top, 0px)); translate: -50% 0; display: flex; align-items: center; gap: .75rem; width: max-content; max-width: calc(100vw - 32px); padding: .5rem .5rem .5rem 1rem; border-radius: 14px; background: var(--ink); color: #fff; font-size: 15px; font-weight: 600; box-shadow: var(--shadow); }
.app-update button { min-height: 44px; padding: 0 1rem; border: 0; border-radius: 10px; background: #fff; color: var(--blue-700); font: inherit; font-weight: 700; cursor: pointer; }

/* Aviso simulado (prévia, sem permissão do navegador) */
.sim-notif { position: fixed; z-index: 80; left: 50%; top: calc(12px + env(safe-area-inset-top, 0px)); translate: -50% -140%; display: flex; gap: .75rem; align-items: flex-start; width: min(calc(100vw - 24px), 24rem); padding: .8rem .9rem; border-radius: 16px; background: rgba(255, 255, 255, .97); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--ink); transition: translate .25s; }
.sim-notif.is-on { translate: -50% 0; }
.sim-notif img { flex: none; width: 36px; height: 36px; border-radius: 9px; }
.sim-notif p { margin: 0; font-size: 14px; line-height: 1.4; }
.sim-notif small { display: block; color: var(--muted); font-size: 12px; }
@media (prefers-reduced-motion: reduce) { .sim-notif { transition: none; } }

/* Cartão "App e avisos" */
.app-status { display: flex; align-items: center; gap: .6rem; margin-bottom: .9rem; font-weight: 600; color: var(--ink); }
.app-status .icon { color: var(--blue); }
.app-card .actions { justify-content: flex-start; flex-wrap: wrap; margin-top: .75rem; }
.app-card .actions .btn:last-child, .app-card .actions .btn-s:last-child { flex: 0 1 auto; }
.app-card .sub { margin-top: 1.1rem; }
