/*
 * Staff ERP as a PWA (doc 08 §4) — phone bottom bar (§1 MOBILE RULE), connection status, "new version" banner,
 * toasts. Unlayered on purpose (beats the ds layers); every class is mv-pwa-* so nothing else is touched.
 * Colours come from the ds brand tokens when present (Appearance settings), with neutral fallbacks.
 */
.mv-pwa-bar { display: none; }
/* Height of the bar without the iPhone home-indicator inset: body padding, toasts and sticky form buttons
   (employee-portal.css --ep-bottom-bar) sit above it, so nothing is hidden under the bar. */
:root { --mv-pwa-bar-h: 4rem; }

@media (max-width: 767.98px) {
  .mv-pwa-bar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1035;
    background: var(--ds-surface, #fff); border-top: var(--ds-border-width, 1px) solid var(--ds-border, rgba(0, 0, 0, .12));
    padding: var(--ds-space-1, 4px) max(var(--ds-space-1, 4px), env(safe-area-inset-right, 0px))
             calc(var(--ds-space-1, 4px) + env(safe-area-inset-bottom, 0px)) max(var(--ds-space-1, 4px), env(safe-area-inset-left, 0px));
    box-shadow: 0 -2px 10px rgba(0, 0, 0, .06);
  }
  .mv-pwa-bar__item {
    flex: 1 1 0; min-width: 0; min-height: 3.25rem; display: flex; flex-direction: column; align-items: center;
    justify-content: center; gap: 2px; border-radius: var(--ds-radius, 10px); text-decoration: none;
    color: var(--ds-text-muted, #5b6470); font-size: var(--ds-text-2xs, .75rem); line-height: var(--ds-leading-tight, 1.1);
    -webkit-tap-highlight-color: transparent;
  }
  .mv-pwa-bar__item .mdi { font-size: 1.45rem; line-height: 1; }
  .mv-pwa-bar__item.is-active, .mv-pwa-bar__item:active { color: var(--ds-accent, var(--ds-primary, #2f6fed)); background: var(--ds-surface-2, rgba(0, 0, 0, .04)); }
  .mv-pwa-bar__item:focus-visible { outline: var(--ds-focus-outline, 2px solid currentColor); outline-offset: calc(-1 * var(--ds-focus-width, 2px)); }
  .mv-pwa-bar__label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* the fixed "Actions" tab (Quick actions sheet): a filled brand mark, so it is found at a glance on every role */
  .mv-pwa-bar__quick-mark {
    display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: var(--ds-radius-pill, 999px);
    background: var(--ds-primary, #2f6fed); color: var(--ds-primary-ink, #fff);
  }
  .mv-pwa-bar__quick-mark .mdi { font-size: var(--ds-glyph-lg, 1.25rem); }
  .mv-pwa-bar__item--quick { color: var(--ds-text, #1d2433); font-weight: var(--ds-weight-semibold, 600); }
  body.mv-pwa-has-bar { padding-bottom: calc(var(--mv-pwa-bar-h) + env(safe-area-inset-bottom, 0px)); --ep-bottom-bar: var(--mv-pwa-bar-h); }
  body.mv-pwa-has-bar .mv-pwa-toast, body.mv-pwa-has-bar .mv-pwa-update, body.mv-pwa-has-bar .mv-print-notice { bottom: calc(var(--mv-pwa-bar-h) + var(--ds-space-2, 8px) + env(safe-area-inset-bottom, 0px)); }
}

/* Quick actions sheet (layouts/partials/pwa-bottom-bar): a bottom sheet over the bar, thumb-reach tiles. */
.ds-body .offcanvas.mv-pwa-sheet, .offcanvas.mv-pwa-sheet {
  height: auto; max-height: 85vh; max-height: 85dvh;
  border-top-left-radius: var(--ds-radius-lg, 14px); border-top-right-radius: var(--ds-radius-lg, 14px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.mv-pwa-sheet .offcanvas-title { margin: 0; }
.mv-pwa-sheet .offcanvas-body { padding-top: var(--ds-space-3, 12px); }

/* The five tiles (components/pwa/quick-actions): "sheet" = 2 per row with a hint line; "row" = one compact row. */
.mv-pwa-quick { display: grid; gap: var(--ds-space-2, 8px); }
.mv-pwa-quick__item {
  display: flex; align-items: center; gap: var(--ds-space-3, 12px); min-height: var(--ds-target, 44px); min-width: 0;
  padding: var(--ds-space-3, 12px); border: var(--ds-border-width, 1px) solid var(--ds-border, rgba(0, 0, 0, .12));
  border-radius: var(--ds-radius, 10px); background: var(--ds-surface, #fff); color: var(--ds-text, #1d2433);
  text-decoration: none; -webkit-tap-highlight-color: transparent;
  transition: background-color var(--ds-dur, 140ms) var(--ds-ease, ease), border-color var(--ds-dur, 140ms) var(--ds-ease, ease);
}
.mv-pwa-quick__item:hover, .mv-pwa-quick__item:active { background: var(--ds-hover, rgba(0, 0, 0, .04)); border-color: var(--ds-border-strong, rgba(0, 0, 0, .2)); color: var(--ds-text, #1d2433); }
.mv-pwa-quick__item:focus-visible { outline: var(--ds-focus-outline, 2px solid currentColor); outline-offset: var(--ds-focus-offset, 2px); }
.mv-pwa-quick__icon {
  flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: var(--ds-target, 44px); height: var(--ds-target, 44px);
  border-radius: var(--ds-radius-pill, 999px); background: var(--ds-surface-2, rgba(0, 0, 0, .04)); color: var(--ds-accent, var(--ds-primary, #2f6fed));
  font-size: 1.5rem; line-height: 1;
}
.mv-pwa-quick__text { display: flex; flex-direction: column; min-width: 0; }
.mv-pwa-quick__label { font-size: var(--ds-text-sm, .875rem); font-weight: var(--ds-weight-semibold, 600); line-height: var(--ds-leading-tight, 1.2); overflow-wrap: anywhere; }
.mv-pwa-quick__hint { font-size: var(--ds-text-xs, .8125rem); color: var(--ds-text-muted, #5b6470); line-height: var(--ds-leading-snug, 1.3); overflow-wrap: anywhere; }

.mv-pwa-quick--sheet { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mv-pwa-quick--sheet .mv-pwa-quick__item { flex-direction: column; align-items: flex-start; min-height: 7rem; }
/* an odd last tile takes the whole row instead of leaving a hole */
.mv-pwa-quick--sheet .mv-pwa-quick__item:last-child:nth-child(odd) { grid-column: 1 / -1; flex-direction: row; align-items: center; min-height: 4.5rem; }

.mv-pwa-quick--row { grid-template-columns: repeat(auto-fit, minmax(3.5rem, 1fr)); }
.mv-pwa-quick--row .mv-pwa-quick__item { flex-direction: column; justify-content: center; gap: var(--ds-space-1, 4px); min-height: 4.75rem; padding: var(--ds-space-2, 8px) var(--ds-space-1, 4px); text-align: center; }
.mv-pwa-quick--row .mv-pwa-quick__icon { width: 2.25rem; height: 2.25rem; font-size: var(--ds-glyph-xl, 1.375rem); }
.mv-pwa-quick--row .mv-pwa-quick__label { font-size: var(--ds-text-2xs, .75rem); }

@media print { .mv-pwa-bar, .mv-pwa-status, .mv-pwa-update, .mv-pwa-toast, .mv-pwa-install, .mv-print-notice { display: none !important; } }

/* Connection status (§4 "Show connection status") */
.mv-pwa-status {
  position: fixed; top: 8px; left: 50%; transform: translateX(-50%); z-index: 2000;
  padding: 6px 14px; border-radius: 999px; font-size: .85rem; font-weight: 600; color: #fff;
  background: #b42318; box-shadow: 0 2px 10px rgba(0, 0, 0, .2); display: none; align-items: center; gap: 6px;
}
.mv-pwa-status.is-visible { display: inline-flex; }
.mv-pwa-status.is-online { background: #067647; }

/* "New version available — Reload" (§4 Automatic updates) */
.mv-pwa-update {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 2000; width: fit-content; max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; gap: 12px; padding: 10px 12px 10px 16px; border-radius: 12px;
  background: #1d2939; color: #fff; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); font-size: .92rem;
}
.mv-pwa-update button {
  min-height: 40px; padding: 0 16px; border: 0; border-radius: 8px; font-weight: 600; cursor: pointer;
  background: var(--ds-primary, #2f6fed); color: var(--ds-primary-ink, #fff);
}

/* Print / Print PDF notice (public/assets/js/mv-print.js): "Preparing…", "Saved: file.pdf  [Share / Print]  ×" */
/* 16-Nov-2026: the bottom bars are pinned 16px from both edges and centred with auto margins (width: fit-content), not
   left: 50% + translateX(-50%) — that capped their width at half the screen, and on a phone the notice text (with
   overflow-wrap: anywhere) shrank to one letter per line. On a narrow screen the text takes the first row and the
   buttons wrap to a second row, right-aligned. */
.mv-print-notice {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 2001; width: fit-content; max-width: 560px; margin: 0 auto;
  display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-radius: 12px;
  background: #1d2939; color: #fff; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); font-size: .92rem;
  flex-wrap: wrap; row-gap: 6px; line-height: 1.35;
}
.mv-print-notice span { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.mv-print-notice span + button { margin-left: auto; }
.mv-print-notice button {
  min-height: 40px; padding: 0 14px; border: 0; border-radius: 8px; font-weight: 600; cursor: pointer; white-space: nowrap;
  background: var(--ds-primary, #2f6fed); color: var(--ds-primary-ink, #fff);
}
.mv-print-notice button.mv-print-notice__close { min-width: 40px; padding: 0; background: transparent; color: #fff; font-size: 1.3rem; }
.mv-print-notice[hidden] { display: none !important; }

.mv-pwa-toast {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 2001; width: fit-content; max-width: 560px; margin: 0 auto;
  padding: 10px 16px; border-radius: 10px; background: #1d2939; color: #fff; font-size: .9rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}

[data-pwa-install][hidden], [data-pwa-installed][hidden] { display: none !important; }
.mv-pwa-toast[hidden], .mv-pwa-update[hidden], .mv-pwa-bar [hidden] { display: none !important; }

/* Install banner (pwa.js installBanner): bottom card on phones (above the bottom bar), bottom-right on computers */
.mv-pwa-install {
  position: fixed; z-index: 1990; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 12px 14px; border-radius: 14px;
  background: var(--ds-surface, #fff); color: var(--ds-text, #1d2433); border: 1px solid var(--ds-border, rgba(0, 0, 0, .12));
  box-shadow: 0 6px 24px rgba(0, 0, 0, .18); font-size: .92rem;
}
.mv-pwa-install__text { flex: 1 1 220px; }
.mv-pwa-install__actions { display: inline-flex; gap: 6px; align-items: center; margin-left: auto; }
.mv-pwa-install__actions .btn { min-height: 40px; }
@media (min-width: 768px) { .mv-pwa-install { left: auto; right: 20px; bottom: 20px; max-width: 440px; } }
@media (max-width: 767.98px) { body.mv-pwa-has-bar .mv-pwa-install { bottom: calc(var(--mv-pwa-bar-h) + var(--ds-space-2, 8px) + env(safe-area-inset-bottom, 0px)); } }

/* "Actions" and "Menu" tabs of the bottom bar are <button>s (they open the sheet / the sidebar drawer): no browser button chrome. */
@media (max-width: 767.98px) {
  button.mv-pwa-bar__item { background: none; border: 0; padding: 0; font-family: inherit; cursor: pointer; }
}
