/* The installed app's own pieces (web/js/pwa/): the install entry and hint, the sheets, the
   "new version" banner, the "no connection" bar and the device card in Cuenta > Notificaciones.
   Colours and radii are the app's tokens (styles.css); nothing here defines a colour of its own.

   Layers: the hint sits under the phone's section bar sheet (z 45); the banner and the bar are
   in the page's flow under the header and have no layer of their own, so a drawer or a dialog
   opens over them; a sheet is the top layer (z 10040), under a confirm (10050), because one
   opens from inside Cuenta. */

/* ── Installed window ─────────────────────────────────────────────────────── */
@media (display-mode: standalone) {
    /* No pull-to-refresh: it reloads the app under a thumb that was only scrolling a list.
       «Recargar» is in Cuenta > Preferencias. */
    html, body { overscroll-behavior-y: none; }
}

/* ── Controls: a finger needs 44px ────────────────────────────────────────── */
@media (pointer: coarse) {
    .pwa-sheet .btn, .pwa-hint .btn, .pwa-update .btn, .pwa-device .btn { min-height: 44px; }
}

/* ── The link under the login form ────────────────────────────────────────── */
.pwa-login-install { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.pwa-login-install-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    width: 100%; min-height: 44px; padding: 0 16px;
    background: transparent; border: 1px solid var(--border-light); border-radius: 6px;
    color: var(--text); font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer;
}
.pwa-login-install-btn:hover { background: var(--surface-hover); }
.pwa-login-install-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.pwa-login-install-btn svg { width: 16px; height: 16px; flex: none; }
.pwa-login-install .login-hint { margin-top: 8px; }

/* ── The one-time hint on a phone ─────────────────────────────────────────── */
.pwa-hint {
    position: fixed; left: 12px; right: 12px; z-index: 45;
    bottom: calc(56px + env(safe-area-inset-bottom) + 12px);     /* above the section bar */
    display: flex; flex-direction: column; gap: 12px; padding: 14px;
    background: var(--surface-2); border: 1px solid var(--border-light); border-radius: 12px;
    box-shadow: var(--card-shadow); color: var(--text);
}
/* An open bell reaches down to the section bar, and this hint sits right above that bar: the
   bell's last rows and its «Configurar notificaciones» were under it, and a tap on them landed
   on «Instalar app». The hint waits until the bell is closed. */
body:has(#notifications-dropdown:not(.hidden)) .pwa-hint { display: none; }
.pwa-hint-top { display: flex; align-items: flex-start; gap: 12px; }
.pwa-hint-logo { width: 40px; height: 40px; flex: none; border-radius: 9px; }
.pwa-hint-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pwa-hint-t b { font-size: 14px; font-weight: 600; line-height: 1.3; }
.pwa-hint-t span { font-size: 12.5px; line-height: 1.45; color: var(--text-muted); }
.pwa-hint-x {
    width: 44px; height: 44px; margin: -10px -10px 0 0; flex: none;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: 0; border-radius: 8px; color: var(--text-muted); cursor: pointer;
}
.pwa-hint-x:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.pwa-hint-x svg { width: 16px; height: 16px; }
.pwa-hint-actions { display: flex; gap: 8px; }
.pwa-hint-actions .btn-fill { flex: 1; }
.pwa-hint .btn svg { width: 16px; height: 16px; }

/* ── Sheets ───────────────────────────────────────────────────────────────── */
.pwa-sheet-backdrop {
    position: fixed; inset: 0; z-index: 10040;
    display: flex; align-items: center; justify-content: center; padding: 16px;
    background: var(--modal-overlay);
}
.pwa-sheet {
    width: 100%; max-width: 440px; max-height: 100%; overflow-y: auto;
    display: flex; flex-direction: column; gap: 14px; padding: 24px;
    background: var(--surface); border: 1px solid var(--border-light); border-radius: 14px;
    box-shadow: 0 24px 60px rgba(0,0,0,0.45); color: var(--text); outline: none;
}
/* The head row: title and lead on the left, the × on the right (only a sheet that may be
   dismissed has one). The × looks like the hint's; its 44px target reaches into the sheet's
   padding, so the icon sits level with the title. */
.pwa-sheet-head { display: flex; align-items: flex-start; gap: 12px; }
.pwa-sheet-head-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.pwa-sheet-title { margin: 0; font-size: 18px; font-weight: 600; line-height: 1.3; }
.pwa-sheet-lead { margin: 0; font-size: 13px; line-height: 1.5; color: var(--text-muted); }
.pwa-sheet-x {
    width: 44px; height: 44px; margin: -8px -10px 0 0; flex: none;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: 0; border-radius: 8px; color: var(--text-muted); cursor: pointer;
}
.pwa-sheet-x:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.pwa-sheet-x svg { width: 16px; height: 16px; }
.pwa-sheet-note { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--text-muted); }
.pwa-sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.pwa-sheet-actions:empty { display: none; }
.pwa-sheet-actions .btn { width: 100%; justify-content: center; }
.pwa-steps { list-style: none; margin: 0; padding: 0; }
.pwa-step { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.pwa-step:last-child { border-bottom: 1px solid var(--border); }
.pwa-step-n {
    flex: none; width: 26px; height: 26px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary-glow-strong); color: var(--primary-text); font-size: 13px; font-weight: 600;
}
.pwa-step-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pwa-step-t b { font-size: 14px; font-weight: 600; }
.pwa-step-t span { font-size: 12.5px; line-height: 1.45; color: var(--text-muted); }
.pwa-step-ico {
    flex: none; width: 40px; height: 40px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface-2); border: 1px solid var(--border-light); color: var(--text);
}
.pwa-countdown { margin: 0; font-size: 40px; font-weight: 600; line-height: 1; text-align: center; font-variant-numeric: tabular-nums; }
@media (max-width: 768px) {
    /* On a phone the sheet rises from the bottom edge and clears the home indicator. */
    .pwa-sheet-backdrop { align-items: flex-end; padding: 0; }
    .pwa-sheet {
        max-width: none; max-height: 92%; border-radius: 18px 18px 0 0; border-width: 1px 0 0;
        padding: 22px 20px calc(20px + env(safe-area-inset-bottom));
    }
}
@media (prefers-reduced-motion: no-preference) {
    .pwa-sheet { animation: pwa-rise .2s cubic-bezier(0.22, 1, 0.36, 1) backwards; }
    @keyframes pwa-rise { from { opacity: 0; transform: translateY(12px); } }
}

/* ── «Hay una versión nueva» bar, in the page's flow under the header ──────── */
/* No position and no z-index, on purpose. As a floating card it sat on a drawer's «Guardar»,
   on Venta's sale bar and on Contabilidad's save bar, and a mistaken tap on its «Recargar»
   lost the form. In the flow it pushes the screen down and covers nothing. One row: the title
   and its line sit side by side and wrap where the screen is narrow; the buttons keep their size. */
.pwa-update {
    display: flex; align-items: center; gap: 12px; padding: 6px 16px;
    background: var(--surface); border-bottom: 1px solid var(--border); color: var(--text);
}
.pwa-update-ico { flex: none; display: flex; color: var(--primary-text); }
.pwa-update-t { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; }
.pwa-update-t b { font-size: 13.5px; font-weight: 600; line-height: 1.4; }
.pwa-update-t span { font-size: 12.5px; line-height: 1.4; color: var(--text-muted); }
.pwa-update .btn { flex: none; }
.pwa-update-x {
    flex: none; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
    background: transparent; border: 0; border-radius: 6px; color: var(--text-muted); cursor: pointer;
}
.pwa-update-x:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
@media (pointer: coarse) { .pwa-update-x { width: 44px; height: 44px; margin-right: -6px; } }

/* ── «Sin conexión» bar, in the page's flow under the header ───────────────── */
.pwa-offline-bar {
    display: flex; align-items: center; gap: 8px; padding: 8px 16px;
    background: var(--warning-bg); border-bottom: 1px solid var(--warning-border);
    color: var(--text); font-size: 12.5px; line-height: 1.4;
}
.pwa-offline-bar svg { flex: none; width: 16px; height: 16px; color: var(--warning); }
.pwa-offline-bar b { font-weight: 600; }

/* ── Cuenta > Notificaciones: this device ─────────────────────────────────── */
.pwa-device { padding-top: 16px; padding-bottom: 16px; display: flex; flex-direction: column; gap: 10px; }
.pwa-device-t { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pwa-device-t b { font-size: 13.5px; font-weight: 600; }
.pwa-device-b { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--text-muted); }
.pwa-device-actions { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 768px) { .pwa-device-actions .btn { flex: 1; justify-content: center; } }
/* «En la app», «En el dispositivo» and email together: one more column than the screen's own grid. */
.acct-np-wide .acct-nphead, .acct-np-wide .acct-nprow { grid-template-columns: minmax(0, 1fr) 100px 100px 100px; }
@media (max-width: 860px) {
    .acct-np-wide .acct-nphead, .acct-np-wide .acct-nprow { grid-template-columns: minmax(0, 1fr) 64px 64px 64px; }
}
