/* La Reco — Design system bleu · vert · blanc + accessibilité */

:root {
  --blue: #185FA5;
  --blue-light: #E6F1FB;
  --blue-dark: #0F4C81;
  --sky: #38BDF8;
  --sky-light: #E0F2FE;
  --green: #16A34A;
  --green-bright: #22C55E;
  --green-light: #DCFCE7;
  --white: #FFFFFF;
  --bg: #FAFAF8;
  --bg2: #F3F2EF;
  --txt: #1A1A18;
  --txt2: #6B6B68;
  --focus: #185FA5;
  --focus-offset: 3px;
}

html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  overflow-x: clip;
}

body {
  font-family: 'DM Sans', sans-serif;
  background-color: var(--bg);
  color: var(--txt);
  overflow-x: clip;
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

.font-syne { font-family: 'Syne', sans-serif; }

/* Accessibilité */
.skip-link {
  position: absolute; top: -100px; left: 1rem; z-index: 200;
  background: var(--blue); color: white; padding: 0.75rem 1rem;
  border-radius: 8px; font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 1rem; outline: 3px solid var(--green-bright); outline-offset: 2px; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: var(--focus-offset);
}

button:focus:not(:focus-visible), a:focus:not(:focus-visible) { outline: none; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Layout principal + sidebar gauche */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.layout-shell {
  display: flex;
  flex: 1;
  width: 100%;
  max-width: 90rem;
  margin: 0 auto;
}

.side-nav {
  width: 11rem;
  flex-shrink: 0;
  padding: 1.5rem 0.75rem;
  border-right: 1px solid rgba(0,0,0,.06);
  background: var(--white);
  position: sticky;
  top: 3.5rem;
  align-self: flex-start;
  max-height: calc(100vh - 3.5rem);
  max-height: calc(100dvh - 3.5rem);
  overflow-y: auto;
}

@media (min-width: 640px) {
  .side-nav {
    top: 4rem;
    max-height: calc(100vh - 4rem);
    max-height: calc(100dvh - 4rem);
  }
}

.side-nav nav { display: flex; flex-direction: column; gap: 0.25rem; }

.side-nav a {
  display: block;
  padding: 0.625rem 0.875rem;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--txt2);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}

.side-nav a:hover { background: var(--blue-light); color: var(--blue); }
.side-nav a.active { background: var(--green-light); color: var(--green); font-weight: 600; }

.side-nav .side-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--blue-dark);
  padding: 0 0.875rem 0.5rem;
  margin-top: 0.5rem;
}

#page { flex: 1; min-width: 0; }

@media (max-width: 1023px) {
  .layout-shell { flex-direction: column; }
  .side-nav {
    width: 100%; position: static; max-height: none;
    border-right: none; border-bottom: 1px solid rgba(0,0,0,.06);
    padding: 0.625rem 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .side-nav::-webkit-scrollbar { display: none; }
  .side-nav nav {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.375rem;
    padding: 0 0.75rem;
    min-width: min-content;
  }
  .side-nav .side-label {
    width: auto;
    margin: 0 0 0 0.75rem;
    padding: 0.625rem 0.5rem 0.625rem 0;
    white-space: nowrap;
    flex-shrink: 0;
    align-self: center;
  }
  .side-nav a {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 0.5rem 0.875rem;
  }
}

@media (max-width: 639px) {
  .side-nav nav { padding: 0 0.5rem; }
  .side-nav .side-label { margin-left: 0.5rem; font-size: 0.625rem; }
}

/* Pivot profil : bleu ciel → vert vif */
.pivot-badge { background: var(--white); border: 1px solid rgba(0,0,0,.06); }
.pivot-ancien { color: var(--sky); font-weight: 500; }
.pivot-nouveau { color: var(--green-bright); font-weight: 600; }

.text-sky { color: var(--sky); }
.text-green-bright { color: var(--green-bright); }
.bg-brand-blue { background-color: var(--blue); }
.bg-brand-green { background-color: var(--green); }
.hover-brand-blue:hover { background-color: var(--blue-dark); }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toastIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes toastOut {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(120%); opacity: 0; }
}

.page-enter { animation: fadeIn 0.3s ease; }

.overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 90; opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.overlay.active { opacity: 1; pointer-events: auto; }

.modal {
  position: fixed; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  z-index: 100; max-height: min(90vh, 90dvh); overflow-y: auto;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  width: min(28rem, calc(100vw - 2rem));
}
.modal.active { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }

.modal-box { max-height: min(90vh, 90dvh); overflow-y: auto; }

.contact-panel {
  position: fixed; top: 0; right: 0; height: 100%; height: 100dvh; width: 100%; max-width: 420px;
  background: white; z-index: 95; transform: translateX(100%);
  transition: transform 0.3s ease; box-shadow: -4px 0 24px rgba(0,0,0,.1);
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.contact-panel.active { transform: translateX(0); }

@media (max-width: 639px) {
  .contact-panel { max-width: 100%; }
}

.mobile-menu {
  position: fixed; inset: 0; background: white; z-index: 85;
  transform: translateY(-100%); transition: transform 0.3s ease;
  padding-top: calc(4rem + env(safe-area-inset-top, 0));
  padding-bottom: env(safe-area-inset-bottom, 0);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.mobile-menu.active { transform: translateY(0); }

.toast {
  position: fixed; bottom: calc(1.5rem + env(safe-area-inset-bottom, 0)); right: 1.5rem; z-index: 110;
  background: var(--txt); color: white; padding: 0.875rem 1.25rem;
  border-radius: 12px; font-size: 0.875rem; max-width: min(320px, calc(100vw - 2rem));
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
  animation: toastIn 0.35s ease forwards;
}
.toast.hide { animation: toastOut 0.35s ease forwards; }

@media (max-width: 639px) {
  .toast {
    left: 1rem;
    right: 1rem;
    bottom: calc(4.5rem + env(safe-area-inset-bottom, 0));
    max-width: none;
  }
}

.float-review {
  position: fixed; bottom: calc(1.5rem + env(safe-area-inset-bottom, 0)); left: 1.5rem; z-index: 60;
  background: var(--green); color: white; padding: 0.75rem 1.25rem;
  border-radius: 999px; font-size: 0.8125rem; font-weight: 600;
  box-shadow: 0 4px 16px rgba(22,163,74,.35);
  transition: transform 0.2s, background 0.2s;
  max-width: calc(100vw - 2rem);
  text-align: center;
}
.float-review:hover { background: var(--green-bright); transform: translateY(-2px); }

@media (max-width: 639px) {
  .float-review {
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0.625rem 1rem;
    font-size: 0.75rem;
  }
  .float-review:hover { transform: translateX(-50%) translateY(-2px); }
}

.chat-bubble-me { background: var(--blue); color: white; border-radius: 16px 16px 4px 16px; padding: 0.625rem 0.875rem; max-width: 80%; margin-left: auto; }
.chat-bubble-them { background: var(--bg2); color: var(--txt); border-radius: 16px 16px 16px 4px; padding: 0.625rem 0.875rem; max-width: 80%; }

.accordion-content { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; }
.accordion-content.open { max-height: 500px; }

.star-btn { cursor: pointer; transition: transform 0.15s; min-width: 2rem; min-height: 2rem; }
.star-btn:hover { transform: scale(1.15); }

.dot-available { background: var(--green-bright); }
.dot-soon { background: #F59E0B; }
.dot-unavailable { background: #9E9E9B; }

.trust-logos { align-items: center; }

.trust-logo-img {
  max-height: 2.5rem;
  max-width: 8rem;
  width: auto;
  height: auto;
  object-fit: contain;
  filter: grayscale(100%);
  opacity: 0.72;
  transition: opacity 0.2s, filter 0.2s;
}

.trust-logo-item:hover .trust-logo-img,
.trust-logo-img:focus-visible {
  filter: grayscale(0%);
  opacity: 1;
}

.trust-strip--empty { min-height: auto; }

.tjm-bar { transition: width 0.6s ease; }
.chat-scroll { max-height: 280px; overflow-y: auto; }

.ai-score-bar { height: 6px; border-radius: 999px; background: var(--bg2); overflow: hidden; }
.ai-score-fill { height: 100%; background: linear-gradient(90deg, var(--blue), var(--green-bright)); transition: width 0.5s ease; }

.compte-dropdown { position: relative; }
.compte-menu {
  position: absolute; right: 0; top: calc(100% + 0.5rem);
  background: white; border: 1px solid rgba(0,0,0,.08);
  border-radius: 12px; min-width: 12rem; box-shadow: 0 8px 24px rgba(0,0,0,.1);
  display: none; z-index: 60;
}
.compte-menu.open { display: block; }

@media (max-width: 639px) {
  .compte-menu {
    right: 0;
    left: auto;
    min-width: 11rem;
    max-width: calc(100vw - 1.5rem);
  }
}

/* Compte — onglets scrollables sur mobile */
.compte-tabs {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 0.25rem;
  margin-bottom: 0.5rem;
}
.compte-tabs::-webkit-scrollbar { display: none; }
.compte-tabs button { flex-shrink: 0; white-space: nowrap; }

@media (min-width: 768px) {
  .compte-tabs {
    flex-direction: column;
    overflow-x: visible;
    padding-bottom: 0;
    margin-bottom: 0;
  }
  .compte-tabs button { white-space: normal; }
}

/* Tableaux scrollables */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0 -0.25rem;
  padding: 0 0.25rem;
}
.table-scroll table { min-width: 32rem; }

/* Hero tagline — retours à la ligne propres */
.hero-tagline {
  line-height: 1.5;
  word-break: break-word;
}

/* Cartes mission — actions empilées sur petit écran */
@media (max-width: 479px) {
  .mission-card-actions {
    flex-direction: column;
    align-items: stretch !important;
    width: 100%;
  }
  .mission-card-actions button,
  .mission-card-actions .mission-card-cta {
    width: 100%;
    text-align: center;
  }
}

/* Navbar header safe area */
.site-header {
  padding-top: env(safe-area-inset-top, 0);
}

/* Footer newsletter */
@media (max-width: 639px) {
  #newsletter-form {
    flex-direction: column;
  }
  #newsletter-form button {
    width: 100%;
  }
}

/* Geo autocomplete */
.geo-field { position: relative; }
.geo-suggest {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 40;
  max-height: 220px;
  overflow-y: auto;
  margin: 0;
  padding: 0.25rem 0;
  list-style: none;
  background: var(--white);
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}
.geo-suggest.hidden { display: none; }
.geo-suggest li {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  cursor: pointer;
}
.geo-suggest li:hover,
.geo-suggest li.active {
  background: var(--blue-light);
  color: var(--blue-dark);
}
.geo-input[aria-invalid="true"] {
  outline: 2px solid #ef4444;
}

.dash-sidebar {
  background: var(--white);
  border: 1px solid #e5e7eb;
  border-radius: 1rem;
  padding: 0.5rem;
}
@media (max-width: 1023px) {
  .dash-sidebar {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    gap: 0.5rem;
    padding: 0.75rem;
  }
  .dash-sidebar button {
    white-space: nowrap;
    flex-shrink: 0;
  }
}
.register-steps { scrollbar-width: thin; }

/* Reco'Bot — widget coin inférieur droit */
.recobot {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right, 0));
  bottom: max(1rem, env(safe-area-inset-bottom, 0));
  z-index: 9000;
  font-family: inherit;
}
.recobot-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.875rem;
  border: none;
  border-radius: 9999px;
  background: var(--blue-dark, #1e3a5f);
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.875rem;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.recobot-toggle:hover { transform: translateY(-1px); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22); }
.recobot-toggle-icon { font-size: 1rem; line-height: 1; }
.recobot-toggle-label { color: var(--green-bright); }
.recobot-panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.75rem);
  width: min(17rem, calc(100vw - 2rem));
  max-height: min(22rem, calc(100vh - 6rem));
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 0.875rem;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.14);
  overflow: hidden;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.recobot-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.recobot-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  background: var(--green-light);
  border-bottom: 1px solid #bbf7d0;
}
.recobot-title { margin: 0; font-weight: 700; font-size: 0.9375rem; color: var(--green); }
.recobot-sub { margin: 0.1rem 0 0; font-size: 0.6875rem; color: #64748b; }
.recobot-close {
  border: none;
  background: transparent;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: #64748b;
  padding: 0 0.25rem;
}
.recobot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 6.5rem;
}
.recobot-msg p { margin: 0; font-size: 0.8125rem; line-height: 1.4; }
.recobot-msg-bot {
  align-self: flex-start;
  max-width: 92%;
  padding: 0.5rem 0.625rem;
  background: #f8fafc;
  border-radius: 0.625rem 0.625rem 0.625rem 0.25rem;
  color: #1e293b;
}
.recobot-msg-user {
  align-self: flex-end;
  max-width: 92%;
  padding: 0.5rem 0.625rem;
  background: var(--blue-dark, #1e3a5f);
  color: #fff;
  border-radius: 0.625rem 0.625rem 0.25rem 0.625rem;
}
.recobot-form {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
  padding: 0.5rem 0.625rem 0.625rem;
  border-top: 1px solid #f1f5f9;
}
.recobot-form textarea {
  width: 100%;
  resize: vertical;
  min-height: 2.125rem;
  max-height: 4.5rem;
  padding: 0.375rem 0.5rem;
  border: 1px solid #e2e8f0;
  border-radius: 0.5rem;
  font: inherit;
  font-size: 0.8125rem;
}
.recobot-form button { align-self: flex-end; font-size: 0.8125rem; padding: 0.375rem 0.75rem; }
@media (max-width: 480px) {
  .recobot-toggle-label { display: none; }
  .recobot-panel { width: min(16rem, calc(100vw - 1.5rem)); max-height: min(20rem, calc(100vh - 5rem)); }
}
