/* ================================================================
   AutoBénin Connect — Senior Level CSS
   Niveau : UI/UX Senior 15 ans d'expérience

   Ce fichier couvre les 8 manques identifiés :
   ① Navbar scroll-aware (transparente → opaque)
   ② Micro-interactions (ripple, pulse, hover états)
   ③ Toast / notification system
   ④ Skeleton premium & états vides
   ⑤ Form validation inline (états visuels)
   ⑥ Mobile bottom navigation
   ⑦ Dark mode tokens (prêt à activer)
   ⑧ Patterns avancés (image blur-up, price diff, badge pulse)
   ================================================================ */


/* ── 0. TOKENS SUPPLÉMENTAIRES ─────────────────────────────── */
:root{
  /* Transitions unifiées */
  --t-fast:  120ms cubic-bezier(.22,1,.36,1);
  --t-mid:   240ms cubic-bezier(.22,1,.36,1);
  --t-slow:  400ms cubic-bezier(.22,1,.36,1);
  --t-spring:300ms cubic-bezier(.34,1.56,.64,1);

  /* Élévation cohérente */
  --elev-0: none;
  --elev-1: 0 1px 2px rgba(14,52,112,.06), 0 2px 8px rgba(14,52,112,.06);
  --elev-2: 0 4px 12px rgba(14,52,112,.10), 0 12px 32px rgba(14,52,112,.10);
  --elev-3: 0 8px 24px rgba(14,52,112,.14), 0 24px 56px rgba(14,52,112,.14);
  --elev-float: 0 20px 60px rgba(14,52,112,.20);

  /* Couleurs sémantiques — états */
  --c-success: #0a7d4d;
  --c-success-bg: #eaf7ef;
  --c-success-bord: #bfe8cf;
  --c-error:   #c0392b;
  --c-error-bg:#fbeaea;
  --c-error-bord:#eecaca;
  --c-warn:    #9a5b00;
  --c-warn-bg: #fff4e5;
  --c-warn-bord:#ffd9a8;
  --c-info:    #15489a;
  --c-info-bg: #eaf1fb;
  --c-info-bord:#cfe0f5;

  /* Focus ring */
  --focus-ring: 0 0 0 3px rgba(21,72,154,.28);
}


/* ── ① NAVBAR SCROLL-AWARE ─────────────────────────────────── */
/*
  JS ajoute .entete--scrolled quand scroll > 20px.
  La navbar passe d'un fond blanc pur à un fond légèrement flouté,
  ombre renforcée — signal visuel subtil que l'on a scrollé.
*/
.entete{
  transition: box-shadow var(--t-mid), background var(--t-mid),
              border-color var(--t-mid);
  will-change: box-shadow;
}
.entete--scrolled{
  background: rgba(255,255,255,.96) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 1px 0 #e3e9f1, 0 4px 24px rgba(14,52,112,.10) !important;
}

/* Barre de progression de lecture (top de page) */
#lecture-progress{
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--bleu), var(--or));
  z-index: 9999;
  transition: width 80ms linear;
  pointer-events: none;
}


/* --- Navbar : légère élévation une fois qu'on a scrollé --- */
.entete{ transition: box-shadow var(--t-fast), background var(--t-fast); }
.entete.scrolled{ box-shadow: 0 4px 18px rgba(11,21,38,.12); }
[data-theme="dark"] .entete.scrolled{ box-shadow: 0 4px 18px rgba(0,0,0,.5); }

/* ── ② MICRO-INTERACTIONS ──────────────────────────────────── */

/* --- Ripple effet sur tous les boutons --- */
.btn{
  position: relative;
  overflow: hidden;
  /* isole le ripple */
}
.btn .ripple{
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,.35);
  transform: scale(0);
  animation: ripple-expand 500ms linear forwards;
  pointer-events: none;
}
@keyframes ripple-expand{
  to{ transform: scale(4); opacity: 0; }
}

/* --- WhatsApp button — pulsation verte --- */
.btn-wa, .btn-wacircle, .btn-whatsapp{
  position: relative;
}
.btn-wa::after, .btn-wacircle::after, .btn-whatsapp::after{
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  background: var(--whats, #25d366);
  opacity: 0;
  animation: wa-pulse 2.4s ease-out infinite;
  pointer-events: none;
  z-index: -1;
}
@keyframes wa-pulse{
  0%  { transform: scale(1);   opacity: .35; }
  70% { transform: scale(1.22); opacity: 0; }
  100%{ transform: scale(1.22); opacity: 0; }
}

/* --- Input focus amélioré --- */
input[type=text]:focus,
input[type=email]:focus,
input[type=password]:focus,
input[type=number]:focus,
input[type=search]:focus,
select:focus, textarea:focus{
  border-color: var(--bleu) !important;
  box-shadow: var(--focus-ring) !important;
  outline: none;
}

/* --- Checkbox / Radio custom --- */
input[type=checkbox],
input[type=radio]{
  accent-color: var(--bleu);
  width: 17px;
  height: 17px;
  cursor: pointer;
}

/* --- Nav links underline spring --- */
.nav > a::after,
.menu-lien::after{
  transition: right var(--t-spring) !important;
}

/* --- Carte véhicule image zoom --- */
.vcarte .media img{
  transition: transform 400ms var(--t-slow);
}
.vcarte:hover .media img{
  transform: scale(1.04);
}

/* --- Badge vérifié — petit pulse --- */
.badge-verif, .badge-certifie{
  animation: badge-appear 500ms var(--t-spring) both;
}
@keyframes badge-appear{
  from{ transform: scale(.6); opacity: 0; }
  to  { transform: scale(1);  opacity: 1; }
}

/* --- CTA principal — shimmer sur hover --- */
.nav-cta, .btn-lg.btn{
  position: relative;
  overflow: hidden;
}
.nav-cta::after, .btn-lg.btn::after{
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.25), transparent);
  transition: left 400ms ease;
  pointer-events: none;
}
.nav-cta:hover::after, .btn-lg.btn:hover::after{
  left: 150%;
}

/* Reduced motion : désactiver toutes les animations déco */
@media (prefers-reduced-motion: reduce){
  .btn .ripple,
  .btn-wa::after, .btn-wacircle::after, .btn-whatsapp::after,
  .badge-verif, .badge-certifie,
  .nav-cta::after, .btn-lg.btn::after,
  #lecture-progress{ animation: none !important; transition: none !important; }
  .vcarte .media img{ transition: none; }
}


/* ── ③ TOAST / NOTIFICATION SYSTEM ────────────────────────── */
/*
 * Usage JS : window.toast('Message', 'success' | 'error' | 'info' | 'warn')
 * Le toast apparaît en bas à droite, disparaît après 4s.
 */
#toast-container{
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast{
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 300px;
  max-width: 400px;
  background: #fff;
  border: 1px solid var(--bord);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--elev-3);
  pointer-events: all;
  animation: toast-in 280ms cubic-bezier(.34,1.56,.64,1) both;
  will-change: transform, opacity;
}
.toast.toast-out{
  animation: toast-out 200ms ease-in forwards;
}
@keyframes toast-in{
  from{ transform: translateY(16px) scale(.96); opacity: 0; }
  to  { transform: none; opacity: 1; }
}
@keyframes toast-out{
  to{ transform: translateX(110%); opacity: 0; }
}

/* Barre de progression du timer */
.toast::before{
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  border-radius: 0 0 14px 14px;
  width: 100%;
  animation: toast-timer 4s linear forwards;
}
.toast{ position: relative; overflow: hidden; }
@keyframes toast-timer{
  from{ width: 100%; }
  to  { width: 0%; }
}

/* Variantes */
.toast-success{ border-left: 4px solid var(--c-success); }
.toast-success::before{ background: var(--c-success); }
.toast-success .toast-ico{ color: var(--c-success); }

.toast-error{ border-left: 4px solid var(--c-error); }
.toast-error::before{ background: var(--c-error); }
.toast-error .toast-ico{ color: var(--c-error); }

.toast-warn{ border-left: 4px solid var(--c-warn); }
.toast-warn::before{ background: var(--or); }
.toast-warn .toast-ico{ color: var(--c-warn); }

.toast-info{ border-left: 4px solid var(--c-info); }
.toast-info::before{ background: var(--c-info); }
.toast-info .toast-ico{ color: var(--c-info); }

.toast-ico{
  font-size: 20px;
  flex-shrink: 0;
  margin-top: 1px;
}
.toast-body{ flex: 1; min-width: 0; }
.toast-title{ font-weight: 700; color: var(--navy, #0e2440); font-size: 14px; }
.toast-msg{ color: var(--grey, #5a6b7e); font-size: 13.5px; margin-top: 2px; line-height: 1.4; }
.toast-close{
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--grey);
  font-size: 16px;
  padding: 2px;
  line-height: 1;
  opacity: .6;
  transition: opacity var(--t-fast);
}
.toast-close:hover{ opacity: 1; }


/* ── ④ SKELETON PREMIUM & ÉTATS VIDES ─────────────────────── */

/* Skeleton avec shimmer orienté */
@keyframes shimmer-h{
  0%  { background-position: -600px 0; }
  100%{ background-position: 600px 0; }
}
.skel{
  background: linear-gradient(90deg,
    #e8eef5 25%, #f4f7fc 50%, #e8eef5 75%);
  background-size: 1200px 100%;
  animation: shimmer-h 1.5s ease-in-out infinite;
  border-radius: 8px;
}
.skel-txt    { height: 14px; }
.skel-txt-lg { height: 20px; }
.skel-img    { height: 180px; border-radius: 0; }
.skel-btn    { height: 40px; border-radius: 9px; }
.skel-avatar { width: 42px; height: 42px; border-radius: 50%; }
.skel-badge  { height: 24px; width: 80px; border-radius: 999px; }

/* État vide redesigné */
.vide{
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 60px 24px;
  border: 2px dashed var(--bord);
  border-radius: 16px;
  background: #fff;
}
.vide-ico{
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: var(--bleu-clair, #eaf1fb);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--bleu);
  margin-bottom: 20px;
}
.vide h3{ font-size: 18px; color: var(--bleu-fonce); margin: 0 0 8px; }
.vide p { color: var(--grey); font-size: 14px; max-width: 320px; margin: 0 0 20px; line-height: 1.6; }


/* ── ⑤ FORM VALIDATION INLINE ──────────────────────────────── */
/*
 * JS ajoute .champ--valid ou .champ--error sur le .champ parent.
 * L'icône ✓ ou ✗ apparaît à droite de l'input.
 */
.champ{ position: relative; }

/* Icône d'état dans le champ */
.champ-icon{
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 17px;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast);
}
.champ--valid .champ-icon,
.champ--error .champ-icon{ opacity: 1; }
.champ--valid .champ-icon{ color: var(--c-success); }
.champ--error .champ-icon{ color: var(--c-error); }

/* Bordures d'état */
.champ--valid input,
.champ--valid select,
.champ--valid textarea{
  border-color: var(--c-success) !important;
  box-shadow: 0 0 0 3px rgba(10,125,77,.14) !important;
  padding-right: 40px;
}
.champ--error input,
.champ--error select,
.champ--error textarea{
  border-color: var(--c-error) !important;
  box-shadow: 0 0 0 3px rgba(192,57,43,.12) !important;
  padding-right: 40px;
}

/* Message d'erreur inline */
.champ-erreur-msg{
  display: none;
  font-size: 12.5px;
  font-weight: 600;
  margin-top: 5px;
  color: var(--c-error);
  align-items: center;
  gap: 5px;
}
.champ--error .champ-erreur-msg{ display: flex; }

/* Animation entrée du message d'erreur */
.champ-erreur-msg{
  animation: erreur-in 180ms var(--t-spring) both;
}
@keyframes erreur-in{
  from{ transform: translateY(-4px); opacity: 0; }
  to  { transform: none; opacity: 1; }
}

/* Label flottant (optionnel — activez avec JS) */
.champ-float{
  position: relative;
  margin-bottom: 20px;
}
.champ-float label{
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 15px;
  font-weight: 500;
  color: var(--grey);
  pointer-events: none;
  transition: all var(--t-mid);
  background: transparent;
  padding: 0 2px;
}
.champ-float input:focus + label,
.champ-float input:not(:placeholder-shown) + label{
  top: 0;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--bleu);
  background: #fff;
  padding: 0 5px;
}
.champ-float input{ padding-top: 14px; }


/* ── ⑥ MOBILE BOTTOM NAVIGATION ────────────────────────────── */
/*
 * Visible uniquement < 768px.
 * Ajoutez l'HTML au bas du <body> (voir integration guide).
 * Les icônes utilisent Bootstrap Icons.
 */
#bottom-nav{
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 800;
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--bord);
  box-shadow: 0 -4px 20px rgba(14,52,112,.10);
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
}
.bn-items{
  display: flex;
  justify-content: space-around;
  align-items: center;
  max-width: 480px;
  margin: 0 auto;
}
.bn-item{
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 56px;
  min-height: 44px;
  padding: 4px 8px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--grey);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: transparent;
  font-family: inherit;
  transition: color var(--t-fast), background var(--t-fast), transform var(--t-fast);
  position: relative;
}
.bn-item:active{ transform: scale(.92); }
.bn-item.actif{
  color: var(--bleu-fonce);
  background: var(--bleu-clair);
}
.bn-item .bn-ico{
  font-size: 22px;
  line-height: 1;
  position: relative;
}
.bn-item .bn-badge{
  position: absolute;
  top: -4px;
  right: -6px;
  background: var(--c-error);
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  min-width: 17px;
  height: 17px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
}

/* Décale le contenu pour éviter l'overlap */
.has-bottom-nav .pied,
.has-bottom-nav .pied-pro{
  margin-bottom: 64px;
}

/* Bouton flottant "Publier" centré */
.bn-publish{
  background: linear-gradient(135deg, var(--or), var(--or-fonce));
  color: var(--navy);
  width: 52px;
  height: 52px;
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(201,135,12,.40);
  font-size: 26px;
  transform: translateY(-6px);
}
.bn-publish.actif{ background: var(--bleu-fonce); color: #fff; }

@media(max-width: 768px){
  #bottom-nav{ display: block; }
  /* Compense le bas de page */
  body.has-bottom-nav{ padding-bottom: 74px; }
}


/* ── ⑦ Bouton de bascule mode sombre ─────────────────────────
 * Les tokens et la couverture par composant du mode sombre
 * vivent maintenant dans dark-mode.css (palette ambre, cohérente
 * avec le reste du site) — un seul système, plus de doublon avec
 * des variables --bleu-* qui n'existaient nulle part ailleurs. */
#dark-toggle{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--light);
  color: var(--navy);
  border: 1px solid var(--bord);
  cursor: pointer;
  font-size: 16px;
  transition: background var(--t-fast), transform var(--t-fast);
  margin-right: 6px;
}
#dark-toggle:hover{ transform: rotate(12deg); background: var(--bg); }
[data-theme="dark"] #dark-toggle{ background: var(--surface); color: var(--or); border-color: var(--bord); }


/* ── ⑧ PATTERNS AVANCÉS ────────────────────────────────────── */

/* --- Image blur-up (lazy load premium) ---
 * L'image s'affiche d'abord floutée (placeholder base64),
 * puis se nettoie quand data-src est chargé.
 */
img.blur-up{
  filter: blur(8px);
  transition: filter 400ms ease;
}
img.blur-up.loaded{
  filter: none;
}

/* --- Price diff badge (comparateur) ---
 * Affiche +X% ou -X% en vert/rouge sur le comparateur
 */
.prix-diff{
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.prix-diff--moins{
  background: var(--c-success-bg);
  color: var(--c-success);
}
.prix-diff--plus{
  background: var(--c-error-bg);
  color: var(--c-error);
}

/* --- Chip / Filtre sélectionnable ---
 * Remplace les <select> pour les filtres de recherche
 */
.chip-groupe{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}
.chip{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1.5px solid var(--bord);
  background: #fff;
  color: var(--txt);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--t-fast);
  user-select: none;
  white-space: nowrap;
}
.chip:hover{
  border-color: var(--bleu);
  color: var(--bleu-fonce);
  background: var(--bleu-clair);
}
.chip.actif{
  background: var(--bleu-fonce);
  border-color: var(--bleu-fonce);
  color: #fff;
  box-shadow: 0 4px 12px rgba(14,52,112,.22);
}
.chip .chip-close{
  font-size: 14px;
  opacity: .7;
  margin-left: 2px;
}
.chip:focus-visible{ box-shadow: var(--focus-ring); outline: none; }

/* --- Tooltip natif premium --- */
[data-tooltip]{
  position: relative;
  cursor: help;
}
[data-tooltip]::after{
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  background: #0b1f36;
  color: #fff;
  font-size: 12.5px;
  font-weight: 500;
  padding: 6px 11px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast), transform var(--t-fast);
  z-index: 100;
  box-shadow: var(--elev-2);
}
[data-tooltip]:hover::after{
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
/* triangle */
[data-tooltip]::before{
  content: '';
  position: absolute;
  bottom: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #0b1f36;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast);
  z-index: 100;
}
[data-tooltip]:hover::before{ opacity: 1; }

/* --- Skip to main content (accessibilité) --- */
.skip-link{
  position: absolute;
  top: -100%;
  left: 16px;
  background: var(--bleu-fonce);
  color: #fff;
  padding: 10px 18px;
  border-radius: 0 0 10px 10px;
  font-weight: 700;
  font-size: 14px;
  z-index: 9999;
  text-decoration: none;
  transition: top var(--t-fast);
}
.skip-link:focus{ top: 0; }

/* --- Scroll to top button --- */
#haut-page{
  transition: opacity var(--t-mid), transform var(--t-mid), visibility var(--t-mid) !important;
}
#haut-page:hover{
  transform: translateY(-3px) !important;
  box-shadow: var(--elev-3) !important;
}

/* --- Copier-coller feedback --- */
.copie-ok{
  animation: copie-flash 600ms ease both;
}
@keyframes copie-flash{
  0%  { background: var(--c-success-bg); color: var(--c-success); }
  100%{ background: revert; color: revert; }
}
