/* ╔══════════════════════════════════════════════════════════════════╗
   ║  Sprint 26z14q — Premium Mobile Navigation CSS (All-in)          ║
   ╠══════════════════════════════════════════════════════════════════╣
   ║  Variables PROCESPHERE héritées de app.css (--navy, --amber).    ║
   ║  Bottom tab bar + FAB + scroll progress + pull-refresh + transitions.║
   ║  Mobile-first ; desktop hide les éléments mobile.                ║
   ╚══════════════════════════════════════════════════════════════════╝ */

:root {
  --psf-navy-deep: #0E1A3A;
  --psf-navy: #1F3F8C;
  --psf-gold: #F4C465;
  --psf-copper: #C97F1F;
  --psf-tab-h: 64px;
}

/* ════════════════════════════════════════════════
   1. SCROLL PROGRESS BAR (top, doré)
   ════════════════════════════════════════════════ */
#psf-scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--psf-gold), var(--psf-copper));
  z-index: 9999;
  transition: width .08s linear;
  pointer-events: none;
  box-shadow: 0 0 10px rgba(244, 196, 101, .55);
  will-change: width;
}

/* ════════════════════════════════════════════════
   2. BOTTOM TAB BAR (mobile uniquement)
   ════════════════════════════════════════════════ */
.psf-tab-bar {
  display: none;
}

@media (max-width: 768px) {
  .psf-tab-bar {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    justify-content: space-around;
    align-items: stretch;
    background: rgba(14, 26, 58, 0.92);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    border-top: 1px solid rgba(244, 196, 101, .18);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, .22);
    padding: .35rem .25rem calc(.35rem + env(safe-area-inset-bottom, 0px));
    min-height: var(--psf-tab-h);
  }

  /* Décale le body pour ne pas masquer le contenu derrière la tab bar */
  body {
    padding-bottom: calc(var(--psf-tab-h) + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* Sprint 26z14r — Décale le widget chatbot PROCESPHERE (.psf-chat-bubble) au-dessus
     de la tab bar pour éviter le chevauchement avec le 5ème onglet. */
  .psf-chat-bubble,
  .psf-chat-root.psf-chat-bubble,
  #chatbot-launcher,
  [class*="chatbot-launcher"],
  iframe[name*="chat"] {
    bottom: calc(var(--psf-tab-h) + 18px + env(safe-area-inset-bottom, 0px)) !important;
    right: 16px !important;
  }
  /* Le panneau chat ouvert reste plein écran sur mobile (déjà géré par chatbot.js
     mais on s'assure qu'il passe AU-DESSUS de la tab bar) */
  .psf-chat-panel.psf-open {
    z-index: 1005 !important;
  }
}

.psf-tab-bar a,
.psf-tab-bar .psf-tab-menu {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .18rem;
  padding: .35rem .15rem;
  color: rgba(255, 255, 255, .58);
  text-decoration: none;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  transition: color .18s ease, transform .12s ease;
  min-height: 48px;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  background: transparent;
  border: none;
  font-family: inherit;
  cursor: pointer;
}

.psf-tab-bar a:active,
.psf-tab-bar .psf-tab-menu:active {
  transform: scale(.92);
}

.psf-tab-bar a.active,
.psf-tab-bar .psf-tab-menu.active {
  color: var(--psf-gold);
}

.psf-tab-bar a.active::before,
.psf-tab-bar .psf-tab-menu.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  background: var(--psf-gold);
  border-radius: 0 0 3px 3px;
  box-shadow: 0 0 8px rgba(244, 196, 101, .6);
}

.psf-tab-bar .psf-tab-icon {
  width: 22px;
  height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.psf-tab-bar .psf-tab-label {
  font-size: .6rem;
  line-height: 1;
  white-space: nowrap;
}

/* ════════════════════════════════════════════════
   3. FAB DIAGNOSTIC (mobile uniquement, bottom-left pour éviter conflit chatbot)
   ════════════════════════════════════════════════ */
.psf-fab {
  display: none;
}

@media (max-width: 768px) {
  .psf-fab {
    display: inline-flex;
    position: fixed;
    bottom: calc(var(--psf-tab-h) + 14px + env(safe-area-inset-bottom, 0px));
    left: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--psf-gold) 0%, var(--psf-copper) 100%);
    color: white;
    text-decoration: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 28px rgba(201, 127, 31, .42),
                0 2px 8px rgba(0, 0, 0, .18),
                inset 0 1px 0 rgba(255, 255, 255, .25);
    z-index: 999;
    transition: transform .22s cubic-bezier(.16, 1, .3, 1), box-shadow .22s;
    -webkit-tap-highlight-color: transparent;
  }

  .psf-fab:active {
    transform: scale(.92);
  }

  .psf-fab::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(244, 196, 101, .45) 0%, transparent 70%);
    z-index: -1;
    animation: psf-fab-pulse 2.6s ease-in-out infinite;
  }

  .psf-fab .psf-fab-icon {
    width: 26px;
    height: 26px;
    stroke: white;
    fill: none;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
}

@keyframes psf-fab-pulse {
  0%, 100% { opacity: .35; transform: scale(.92); }
  50%      { opacity: .8;  transform: scale(1.18); }
}

@media (prefers-reduced-motion: reduce) {
  .psf-fab::before { animation: none; }
}

/* ════════════════════════════════════════════════
   4. PULL-TO-REFRESH INDICATOR
   ════════════════════════════════════════════════ */
#psf-pull-indicator {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translate(-50%, -100px);
  width: 44px;
  height: 44px;
  background: white;
  border-radius: 50%;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .18), 0 1px 3px rgba(0, 0, 0, .1);
  z-index: 998;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .15s ease;
  pointer-events: none;
  will-change: transform, opacity;
}

.psf-pull-spinner {
  width: 22px;
  height: 22px;
  border: 2.5px solid rgba(14, 26, 58, .15);
  border-top-color: var(--psf-gold);
  border-radius: 50%;
  transition: transform .25s ease, border-top-color .15s;
}

#psf-pull-indicator.ready .psf-pull-spinner {
  border-top-color: var(--psf-copper);
  transform: rotate(180deg);
}

#psf-pull-indicator.refreshing .psf-pull-spinner {
  animation: psf-spin .85s linear infinite;
}

@keyframes psf-spin {
  to { transform: rotate(360deg); }
}

/* ════════════════════════════════════════════════
   5. VIEW TRANSITIONS API (animations cross-page)
   ════════════════════════════════════════════════ */
@media (prefers-reduced-motion: no-preference) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: .32s;
    animation-timing-function: cubic-bezier(.4, 0, .2, 1);
  }
  /* Forward (swipe gauche, click suivant) */
  html[data-transition="forward"] ::view-transition-old(root) {
    animation-name: psf-vt-out-left;
  }
  html[data-transition="forward"] ::view-transition-new(root) {
    animation-name: psf-vt-in-right;
  }
  /* Back (swipe droite, click précédent) */
  html[data-transition="back"] ::view-transition-old(root) {
    animation-name: psf-vt-out-right;
  }
  html[data-transition="back"] ::view-transition-new(root) {
    animation-name: psf-vt-in-left;
  }
  @keyframes psf-vt-out-left  { to   { transform: translateX(-18%); opacity: 0; } }
  @keyframes psf-vt-in-right  { from { transform: translateX(18%);  opacity: 0; } }
  @keyframes psf-vt-out-right { to   { transform: translateX(18%);  opacity: 0; } }
  @keyframes psf-vt-in-left   { from { transform: translateX(-18%); opacity: 0; } }
}

/* ════════════════════════════════════════════════
   6. PJAX LOADING STATE (barre top en attente)
   ════════════════════════════════════════════════ */
body.psf-loading {
  cursor: progress;
}
body.psf-loading::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 10000;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--psf-gold) 50%,
    var(--psf-copper) 100%);
  background-size: 200% 100%;
  animation: psf-loading-bar 1s ease-in-out infinite;
  pointer-events: none;
}
@keyframes psf-loading-bar {
  0%   { background-position: 200% 0;  opacity: .7; }
  50%  { opacity: 1; }
  100% { background-position: -100% 0; opacity: .7; }
}

/* ════════════════════════════════════════════════
   7. BOTTOM SHEET MENU (12 destinations groupées)
   ════════════════════════════════════════════════ */
.psf-bottom-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-radius: 24px 24px 0 0;
  transform: translateY(100%);
  transition: transform .35s cubic-bezier(.16, 1, .3, 1);
  z-index: 1010;
  box-shadow: 0 -20px 56px rgba(0, 0, 0, .22);
  max-height: 88vh;
  overflow-y: auto;
  padding: 0 1.25rem calc(1.5rem + env(safe-area-inset-bottom, 0px));
  -webkit-overflow-scrolling: touch;
  visibility: hidden;
}
.psf-bottom-sheet.psf-open {
  transform: translateY(0);
  visibility: visible;
}
.psf-bottom-sheet-handle {
  width: 44px;
  height: 4px;
  background: #d8dde5;
  border-radius: 2px;
  margin: 12px auto 0;
  flex-shrink: 0;
}
.psf-bottom-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(14, 26, 58, .48);
  opacity: 0;
  pointer-events: none;
  transition: opacity .28s ease;
  z-index: 1009;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.psf-bottom-sheet-backdrop.psf-visible {
  opacity: 1;
  pointer-events: auto;
}

/* Contenu du menu */
.psf-sheet-title {
  text-align: center;
  font-family: Georgia, serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--psf-navy-deep);
  margin: 1rem 0 1.5rem;
  letter-spacing: -.01em;
}
.psf-sheet-group {
  margin-bottom: 1.4rem;
}
.psf-sheet-group:last-of-type {
  margin-bottom: .6rem;
}
.psf-sheet-group-label {
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--psf-copper);
  margin: 0 0 .55rem .35rem;
  display: flex;
  align-items: center;
  gap: .4rem;
}
.psf-sheet-group a {
  display: flex;
  align-items: center;
  padding: .85rem 1rem;
  color: var(--psf-navy-deep);
  text-decoration: none;
  font-size: .96rem;
  font-weight: 600;
  border-radius: 12px;
  transition: background .14s ease, color .14s ease, transform .12s ease;
  min-height: 44px;
  position: relative;
}
.psf-sheet-group a::after {
  content: '›';
  margin-left: auto;
  color: #94a3b8;
  font-size: 1.4rem;
  font-weight: 400;
  line-height: 1;
  transition: transform .12s, color .14s;
}
.psf-sheet-group a:hover {
  background: #fef9ee;
  color: var(--psf-copper);
}
.psf-sheet-group a:hover::after {
  color: var(--psf-copper);
  transform: translateX(3px);
}
.psf-sheet-group a:active {
  transform: scale(.985);
}
.psf-sheet-group a.active {
  background: linear-gradient(135deg, rgba(244,196,101,.18) 0%, rgba(201,127,31,.08) 100%);
  color: var(--psf-copper);
  font-weight: 700;
}
.psf-sheet-group a.active::after {
  content: '✓';
  color: var(--psf-copper);
  font-weight: 700;
  font-size: 1rem;
}
.psf-sheet-foot {
  text-align: center;
  margin: 1.2rem 0 .6rem;
  font-size: .75rem;
  color: #64748b;
}
.psf-sheet-foot a {
  color: #64748b;
  text-decoration: none;
}
.psf-sheet-foot a:hover {
  color: var(--psf-copper);
  text-decoration: underline;
}

/* Empêche le scroll body quand le sheet est ouvert */
body.psf-sheet-open {
  overflow: hidden !important;
  touch-action: none;
}

/* ════════════════════════════════════════════════
   8. SKELETON SCREENS (utilitaire, Phase 3)
   ════════════════════════════════════════════════ */
.psf-skeleton {
  background: linear-gradient(90deg, #f0f2f5 25%, #f8fafc 50%, #f0f2f5 75%);
  background-size: 200% 100%;
  animation: psf-skel-shimmer 1.4s linear infinite;
  border-radius: 8px;
  color: transparent !important;
  user-select: none;
  pointer-events: none;
}
@keyframes psf-skel-shimmer {
  to { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .psf-skeleton { animation: none; }
}

/* ════════════════════════════════════════════════
   9. ACCESSIBILITÉ : focus visible sur tab bar / FAB
   ════════════════════════════════════════════════ */
.psf-tab-bar a:focus-visible,
.psf-fab:focus-visible {
  outline: 2px solid var(--psf-gold);
  outline-offset: 2px;
}
