/* ===========================================================================
   PharmaX — écran de démarrage, bannière d'installation, bouton d'installation
   =========================================================================== */

:root {
  --pwa-vert: #007d50;
  --pwa-vert-fonce: #00663f;
  --pwa-vert-clair: #e6f6f0;
  --pwa-ligne: #e2e8f0;
  --pwa-texte: #0f172a;
  --pwa-gris: #556274;
}

/* ---------------------------------------------------------------------------
   Logos dans les en-têtes
   --------------------------------------------------------------------------- */
.brand-logo {
  height: 30px;
  width: auto;
  display: block;
}

.brand-logo-icon {
  height: 32px;
  width: 32px;
  object-fit: contain;
  display: block;
}

/* ---------------------------------------------------------------------------
   1. Écran de démarrage
   --------------------------------------------------------------------------- */
body.splash-actif { overflow: hidden; }

/* L'écran de démarrage ne concerne que le mobile : sur poste fixe, la page
   s'affiche directement, sans écran intermédiaire. */
.pharmax-splash { display: none; }

@media (max-width: 900px) {
  .pharmax-splash { display: flex; }
}

.pharmax-splash {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  background: radial-gradient(circle at 50% 38%, #ffffff 0%, #eef8f3 60%, #e3f3ec 100%);
  transition: opacity .45s ease, visibility .45s ease;
}

.pharmax-splash.splash-sortie {
  opacity: 0;
  visibility: hidden;
}

.splash-logo-zone {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Halo pulsé derrière le logo */
.splash-logo-zone::before,
.splash-logo-zone::after {
  content: "";
  position: absolute;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: rgba(0, 168, 107, 0.14);
  animation: splashPulse 2.4s ease-out infinite;
}

.splash-logo-zone::after { animation-delay: 1.2s; }

@keyframes splashPulse {
  0%   { transform: scale(0.65); opacity: 0.85; }
  100% { transform: scale(1.5);  opacity: 0; }
}

.pharmax-splash img {
  position: relative;
  width: 120px;
  height: auto;
  animation: splashApparition .8s cubic-bezier(.16, 1, .3, 1) both;
}

@keyframes splashApparition {
  from { opacity: 0; transform: scale(.72) translateY(14px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.splash-titre {
  text-align: center;
  animation: splashApparition .8s .18s cubic-bezier(.16, 1, .3, 1) both;
}

.splash-titre strong {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: var(--pwa-texte);
  letter-spacing: -0.01em;
}

.splash-titre small {
  display: block;
  margin-top: 4px;
  font-size: 12.5px;
  color: var(--pwa-gris);
}

/* Indicateur de chargement discret */
.splash-loader {
  width: 130px;
  height: 3px;
  border-radius: 999px;
  background: rgba(0, 168, 107, 0.16);
  overflow: hidden;
  animation: splashApparition .8s .3s ease both;
}

.splash-loader span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: 999px;
  background: var(--pwa-vert);
  animation: splashChargement 1.1s ease-in-out infinite;
}

@keyframes splashChargement {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(325%); }
}

@media (prefers-reduced-motion: reduce) {
  .pharmax-splash img,
  .splash-titre,
  .splash-loader { animation: none; }
  .splash-logo-zone::before,
  .splash-logo-zone::after { animation: none; opacity: 0; }
  .splash-loader span { animation: none; width: 100%; }
}

/* ---------------------------------------------------------------------------
   2. Bannière d'installation
   --------------------------------------------------------------------------- */
.pwa-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 2147482000;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 480px;
  margin: 0 auto;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid var(--pwa-ligne);
  box-shadow: 0 12px 34px -10px rgba(15, 40, 30, 0.28);
  backdrop-filter: blur(10px);
  transform: translateY(140%);
  opacity: 0;
  transition: transform .35s cubic-bezier(.16, 1, .3, 1), opacity .35s ease;
}

.pwa-banner.visible {
  transform: translateY(0);
  opacity: 1;
}

.pwa-banner-logo {
  width: 42px;
  height: 42px;
  object-fit: contain;
  flex-shrink: 0;
}

.pwa-banner-texte { flex: 1; min-width: 0; }

.pwa-banner-texte strong {
  display: block;
  font-size: 14.5px;
  color: var(--pwa-texte);
}

.pwa-banner-texte small {
  display: block;
  margin-top: 2px;
  font-size: 12.5px;
  color: var(--pwa-gris);
  line-height: 1.4;
}

.pwa-banner-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.pwa-btn-installer {
  border: none;
  background: var(--pwa-vert);
  color: white;
  font-size: 13.5px;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: 22px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
}

.pwa-btn-installer:hover { background: var(--pwa-vert-fonce); }

.pwa-btn-fermer {
  border: none;
  background: none;
  color: #556274;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 8px;
}

.pwa-btn-fermer:hover { background: #f1f5f9; color: var(--pwa-texte); }

/* La bannière ne doit pas masquer la barre de navigation basse */
@media (max-width: 900px) {
  .pwa-banner { bottom: 72px; }
}

/* ---------------------------------------------------------------------------
   3. Bouton d'installation de la page d'accueil (mobile)
   --------------------------------------------------------------------------- */
@media (max-width: 900px) {
  /* Bouton d'installation, révélé par le script si le navigateur le permet */
  .btn-installer-flow {
    width: 100%;
    margin-top: 14px;
    padding: 13px;
    border-radius: 24px;
    border: none;
    background: var(--pwa-vert);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  .btn-installer-flow:active { transform: scale(.98); }
}

/* Caché tant que le navigateur ne permet pas l'installation (display: flex l'emportait sur hidden :
   le bouton restait affiché et ne faisait rien). */
.btn-installer-flow[hidden] { display: none !important; }

.aide-installation {
  margin: 10px 0 0; padding: 10px 12px; border-radius: 12px;
  background: #ecfdf3; color: #14532d; font-size: 13px; line-height: 1.45; text-align: left;
}
.aide-installation[hidden] { display: none; }

/* L'installation d'une application n'a de sens que sur mobile */
@media (min-width: 901px) {
  .btn-installer-flow { display: none; }
}

/* Logo en <picture> (WebP + PNG de repli) : pas de boîte propre, l'image se comporte
   comme un enfant direct de son conteneur (templates/_logo.html). */
picture.logo-pharmax { display: contents; }

/* Menu ouvert (site ou console) : la bannière d'installation ne recouvre pas ses derniers liens. */
body.nav-drawer-open .pwa-banner,
body.sidebar-open .pwa-banner { display: none; }
