/* ══════════════════════════════════════════
   RESET & BASE
══════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  font-family: 'Figtree', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--surface);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

main { flex: 1; padding-top: var(--nav-h); }
img { max-width: 100%; height: auto; display: block; }
a { text-decoration: none; color: inherit; }
button { font: inherit; border: none; background: none; cursor: pointer; }

/* ══════════════════════════════════════════
   COULEURS DU LOGO UVILLAGE & UI
   Bleu: #1976D2 | Vert: #7CB342
══════════════════════════════════════════ */
:root {
  /* Primary - Bleu logo */
  --primary: #1976D2;
  --primary-light: #42A5F5;
  --primary-dark: #1565C0;
  --primary-50: #E3F2FD;
  --primary-100: #BBDEFB;
  --primary-200: #90CAF9;
  --primary-300: #64B5F6;
  --primary-400: #42A5F5;
  --primary-500: #1976D2;
  --primary-600: #1565C0;
  --primary-700: #0D47A1;

  /* Secondary - Vert logo */
  --secondary: #7CB342;
  --secondary-light: #9CCC65;
  --secondary-dark: #689F38;
  --secondary-50: #F1F8E9;
  --secondary-100: #DCEDC8;
  --secondary-200: #C5E1A5;
  --secondary-300: #AED581;
  --secondary-400: #9CCC65;
  --secondary-500: #7CB342;
  --secondary-600: #689F38;
  --secondary-700: #558B2F;

  /* Warning - Orange/Jaune */
  --warning: #F59E0B;
  --warning-50: #FFFBEB;
  --warning-100: #FDE68A;
  --warning-700: #92400E;

  /* Danger/Error - Rouge */
  --danger: #EF4444;
  --danger-50: #FEF2F2;
  --danger-100: #FECACA;
  --danger-700: #991B1B;

  /* Neutrals */
  --ink: #1A1A1A;
  --ink-light: #424242;
  --ink-muted: #757575;
  --ink-lighter: #BDBDBD;
  --line: #E0E0E0;
  --surface: #FFFFFF;
  --surface-alt: #FAFAFA;

  /* Spacing */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
  --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
  --sp-12: 48px; --sp-16: 64px;

  /* Radius */
  --r: 8px; --r-lg: 12px; --r-xl: 16px; --r-2xl: 24px; --r-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.12);

  /* Transitions */
  --transition: 0.2s ease;
  --transition-slow: 0.3s ease;

  /* Layout */
  --nav-h: 64px;
  --bottom-nav-h: 78px;
  --sticky-cta-h: 0px;
}

body.has-sticky-cta { --sticky-cta-h: 72px; }
@media (min-width: 1024px) { body.has-sticky-cta { --sticky-cta-h: 0px; } }
@media (min-width: 768px) { :root { --nav-h: 72px; } }
@media (min-width: 1024px) { :root { --nav-h: 80px; } }

/* ══════════════════════════════════════════
   TYPOGRAPHY & BUTTONS & LAYOUT & CARDS
══════════════════════════════════════════ */
.serif { font-family: 'Instrument Serif', serif; }
.h1 { font-family: 'Instrument Serif', serif; font-size: clamp(2rem, 5vw, 3.5rem); line-height: 1.1; font-weight: 400; }
.h2 { font-family: 'Instrument Serif', serif; font-size: clamp(1.5rem, 4vw, 2.5rem); line-height: 1.2; font-weight: 400; }
.h3 { font-size: 1.25rem; font-weight: 600; line-height: 1.3; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2); padding: 12px 24px; border-radius: var(--r-full); font-weight: 600; font-size: 14px; transition: all var(--transition); cursor: pointer; min-height: 44px; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: var(--secondary-dark); }
.btn-outline { border: 2px solid var(--primary); color: var(--primary); background: transparent; }
.btn-outline:hover { background: var(--primary); color: white; }
.btn-sm { padding: 8px 16px; font-size: 13px; min-height: 36px; }
.btn-lg { padding: 16px 32px; font-size: 15px; min-height: 52px; }

.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 var(--sp-4); }
@media (min-width: 640px) { .container { padding: 0 var(--sp-6); } }
@media (min-width: 1024px) { .container { padding: 0 var(--sp-8); } }
.section { padding: var(--sp-12) 0; }
@media (min-width: 768px) { .section { padding: var(--sp-16) 0; } }

.card { background: white; border-radius: var(--r-xl); border: 1px solid var(--line); overflow: hidden; transition: all var(--transition-slow); }
.card:hover { box-shadow: var(--shadow-lg); transform: translateY(-4px); }

.text-primary { color: var(--primary); } .text-secondary { color: var(--secondary); }
.bg-primary { background: var(--primary); } .bg-secondary { background: var(--secondary); }
.text-center { text-align: center; } .mt-4 { margin-top: var(--sp-4); } .mb-4 { margin-bottom: var(--sp-4); }

/* ══════════════════════════════════════════
   DJANGO MESSAGES (Flottant, Z-Index élevé)
══════════════════════════════════════════ */
.django-messages-container {
  position: fixed;
  top: calc(var(--nav-h) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 1050; /* Au-dessus de la navbar (1000) et des widgets (950) */
  width: 90%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none; /* Permet de cliquer à travers le conteneur vide */
}

.alert {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--r-lg);
  border: 1px solid transparent;
  box-shadow: var(--shadow-md);
  animation: slideDownFade 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  position: relative;
}

.alert-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}

.alert-text {
  flex: 1;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
}

.alert-close {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--r);
  opacity: 0.6;
  transition: opacity 0.2s, background 0.2s;
  margin-top: -4px;
  margin-right: -4px;
}
.alert-close:hover {
  opacity: 1;
  background: rgba(0,0,0,0.05);
}

/* Variantes de messages */
.alert-success {
  background: var(--secondary-50);
  color: var(--secondary-700);
  border-color: var(--secondary-200);
}
.alert-success .alert-icon { color: var(--secondary); }

.alert-error, .alert-danger {
  background: var(--danger-50);
  color: var(--danger-700);
  border-color: var(--danger-100);
}
.alert-error .alert-icon, .alert-danger .alert-icon { color: var(--danger); }

.alert-warning {
  background: var(--warning-50);
  color: var(--warning-700);
  border-color: var(--warning-100);
}
.alert-warning .alert-icon { color: var(--warning); }

.alert-info {
  background: var(--primary-50);
  color: var(--primary-700);
  border-color: var(--primary-200);
}
.alert-info .alert-icon { color: var(--primary); }

.alert-debug {
  background: var(--surface-alt);
  color: var(--ink-muted);
  border-color: var(--line);
}
.alert-debug .alert-icon { color: var(--ink-lighter); }

@keyframes slideDownFade {
  from { opacity: 0; transform: translateY(-20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ══════════════════════════════════════════
   FLOATING WIDGETS (WhatsApp + Chatbot)
══════════════════════════════════════════ */
.fab-whatsapp { position: fixed; right: var(--sp-4); bottom: calc(var(--bottom-nav-h) + var(--sticky-cta-h) + env(safe-area-inset-bottom) + var(--sp-3)); width: 56px; height: 56px; border-radius: var(--r-full); background: #25D366; color: white; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 20px rgba(37, 211, 102, 0.4); z-index: 950; transition: transform var(--transition), box-shadow var(--transition), bottom var(--transition); }
.fab-whatsapp svg { width: 28px; height: 28px; }
.fab-whatsapp::before { content: ''; position: absolute; inset: 0; border-radius: var(--r-full); background: #25D366; opacity: 0.55; animation: fabPulse 2.4s ease-out infinite; z-index: -1; }
@keyframes fabPulse { 0% { transform: scale(1); opacity: 0.45; } 70% { transform: scale(1.6); opacity: 0; } 100% { transform: scale(1.6); opacity: 0; } }
.fab-whatsapp:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 8px 26px rgba(37, 211, 102, 0.5); }
.fab-tooltip { position: absolute; right: calc(100% + 12px); top: 50%; transform: translateY(-50%) translateX(6px); background: var(--ink); color: white; font-size: 13px; font-weight: 600; padding: 7px 12px; border-radius: var(--r); white-space: nowrap; opacity: 0; visibility: hidden; transition: all var(--transition); pointer-events: none; }
.fab-tooltip::after { content: ''; position: absolute; left: 100%; top: 50%; transform: translateY(-50%); border: 5px solid transparent; border-left-color: var(--ink); }
.fab-whatsapp:hover .fab-tooltip { opacity: 1; visibility: visible; transform: translateY(-50%) translateX(0); }
@media (min-width: 1024px) { .fab-whatsapp { bottom: var(--sp-6); right: var(--sp-6); } }
@media (prefers-reduced-motion: reduce) { .fab-whatsapp::before { animation: none; display: none; } }

.chat-fab { position: fixed; left: var(--sp-4); bottom: calc(var(--bottom-nav-h) + var(--sticky-cta-h) + env(safe-area-inset-bottom) + var(--sp-3)); width: 60px; height: 60px; border-radius: var(--r-full); background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 20px rgba(25, 118, 210, 0.4); z-index: 950; transition: transform 0.3s, opacity 0.3s, visibility 0.3s, box-shadow var(--transition), bottom var(--transition); }
.chat-fab:hover { transform: translateY(-2px) scale(1.05); box-shadow: 0 8px 26px rgba(25, 118, 210, 0.5); }
.chat-fab svg { width: 27px; height: 27px; }
.chat-fab.hidden-state { transform: translateX(-90px); opacity: 0; visibility: hidden; pointer-events: none; }
.chat-fab-hide { position: absolute; top: -3px; right: -3px; width: 22px; height: 22px; border-radius: 50%; background: white; color: var(--ink-muted); border: 1.5px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 13px; line-height: 1; box-shadow: 0 2px 6px rgba(0,0,0,0.15); cursor: pointer; transition: all var(--transition); }
.chat-fab-hide:hover { background: var(--surface-alt); color: var(--ink); }
.chat-fab-badge { position: absolute; top: -2px; left: -2px; background: var(--secondary); color: white; font-size: 10px; font-weight: 700; width: 18px; height: 18px; border-radius: 50%; display: flex; align-items: center; justify-content: center; border: 2px solid white; }
.chat-restore-tab { position: fixed; left: 0; bottom: calc(var(--bottom-nav-h) + var(--sticky-cta-h) + env(safe-area-inset-bottom) + 46px); width: 16px; height: 56px; background: var(--primary); border-radius: 0 10px 10px 0; z-index: 950; box-shadow: 2px 0 10px rgba(0,0,0,0.14); display: flex; align-items: center; justify-content: center; color: white; cursor: pointer; opacity: 0; visibility: hidden; transition: all var(--transition); }
.chat-restore-tab.visible { opacity: 1; visibility: visible; }
.chat-restore-tab:hover { width: 20px; }
.chat-restore-tab svg { width: 12px; height: 12px; }
@media (min-width: 1024px) { .chat-fab { left: var(--sp-6); bottom: var(--sp-6); } .chat-restore-tab { bottom: calc(var(--sp-6) + 30px); } }

/* ══════════════════════════════════════════
   CHATBOT : FENÊTRE DE DISCUSSION
══════════════════════════════════════════ */
.chat-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 1199; opacity: 0; visibility: hidden; transition: all 0.3s; }
.chat-overlay.open { opacity: 1; visibility: visible; }
@media (min-width: 640px) { .chat-overlay { display: none; } }

.chat-panel { position: fixed; left: 0; right: 0; bottom: 0; height: min(75dvh, 560px); max-height: calc(100dvh - var(--nav-h) - var(--sp-4)); min-height: 320px; background: white; border-radius: 20px 20px 0 0; box-shadow: 0 -8px 40px rgba(0,0,0,0.18); z-index: 1200; display: flex; flex-direction: column; transform: translateY(100%); transition: transform 0.35s cubic-bezier(0.32, 0.72, 0, 1); }
.chat-panel.open { transform: translateY(0); }

.chat-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.chat-panel-title { display: flex; align-items: center; gap: 10px; }
.chat-avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--primary-50); display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0; overflow: hidden; }
.chat-panel-title strong { display: block; font-size: 14.5px; color: var(--ink); }
.chat-status { font-size: 12px; color: var(--secondary-dark); font-weight: 600; display: flex; align-items: center; gap: 5px; transition: color 0.3s ease; }
.chat-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--secondary); flex-shrink: 0; transition: background 0.3s ease, transform 0.3s ease; }
.chat-panel-close { width: 32px; height: 32px; border-radius: 50%; background: var(--surface-alt); color: var(--ink-muted); display: flex; align-items: center; justify-content: center; font-size: 18px; cursor: pointer; flex-shrink: 0; transition: background var(--transition); }
.chat-panel-close:hover { background: var(--line); }

.chat-panel-messages { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.chat-msg { max-width: 82%; padding: 10px 14px; border-radius: 16px; font-size: 13.5px; line-height: 1.5; }
.chat-msg.bot { align-self: flex-start; background: var(--surface-alt); color: var(--ink); border-bottom-left-radius: 4px; }
.chat-msg.user { align-self: flex-end; background: var(--primary); color: white; border-bottom-right-radius: 4px; }
.chat-typing { display: flex; gap: 4px; padding: 13px 16px; }
.chat-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-lighter); animation: chatTypingBounce 1.2s infinite ease-in-out; }
.chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes chatTypingBounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

.chat-panel-quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px 12px; flex-shrink: 0; }
.chat-quick-btn { font-size: 12.5px; font-weight: 600; color: var(--primary); background: var(--primary-50); border: none; padding: 7px 12px; border-radius: var(--r-full); cursor: pointer; transition: background var(--transition); white-space: nowrap; }
.chat-quick-btn:hover { background: var(--primary-100); }

.chat-panel-input { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); flex-shrink: 0; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.chat-panel-input input { flex: 1; border: 1.5px solid var(--line); border-radius: var(--r-full); padding: 10px 16px; font-size: 15px; font-family: inherit; outline: none; transition: border-color var(--transition); color: var(--ink); }
.chat-panel-input input:focus { border-color: var(--primary); }
.chat-panel-input button { width: 40px; height: 40px; border-radius: 50%; background: var(--primary); color: white; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background var(--transition); }
.chat-panel-input button:hover { background: var(--primary-dark); }
.chat-panel-input button svg { width: 18px; height: 18px; }

@media (min-width: 640px) {
  .chat-panel { left: var(--sp-6); right: auto; bottom: calc(var(--sp-6) + 76px); width: 360px; height: min(500px, calc(100dvh - var(--nav-h) - var(--sp-6) - 76px - var(--sp-6))); max-height: calc(100dvh - var(--nav-h) - var(--sp-6) - 76px - var(--sp-6)); min-height: 320px; border-radius: 20px; transform: translateY(16px) scale(0.96); opacity: 0; visibility: hidden; transition: transform 0.25s ease, opacity 0.25s ease, visibility 0.25s ease; }
  .chat-panel.open { transform: translateY(0) scale(1); opacity: 1; visibility: visible; }
}
@media (min-width: 1024px) {
  .chat-panel { bottom: calc(var(--sp-6) + 76px); height: min(500px, calc(100dvh - var(--nav-h) - var(--sp-6) - 76px - var(--sp-6))); max-height: calc(100dvh - var(--nav-h) - var(--sp-6) - 76px - var(--sp-6)); }
}

/* ══════════════════════════════════════════
   CHATBOT : CARTES DE DOCUMENTS CLIQUABLES
══════════════════════════════════════════ */
.chat-doc-link {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1.5px solid var(--primary-200);
  border-radius: var(--r); padding: 10px 14px; margin-top: 8px;
  text-decoration: none; color: var(--ink);
  transition: all var(--transition); box-shadow: var(--shadow-sm); cursor: pointer;
}
.chat-doc-link:hover { background: var(--primary-50); border-color: var(--primary); transform: translateY(-1px); box-shadow: var(--shadow); }
.chat-doc-link:active { transform: translateY(0); }

.chat-doc-icon { flex-shrink: 0; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; background: var(--primary-50); border-radius: var(--r); color: var(--primary); }
.chat-doc-info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-doc-name { font-size: 13.5px; font-weight: 600; color: var(--primary-dark); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-doc-size { font-size: 11.5px; color: var(--ink-muted); margin-top: 2px; }
.chat-doc-action { flex-shrink: 0; color: var(--primary); display: flex; align-items: center; justify-content: center; transition: transform var(--transition); }
.chat-doc-link:hover .chat-doc-action { transform: translateX(3px); }

/* ══════════════════════════════════════════
   CHATBOT : STATUT "EN TRAIN D'ÉCRIRE"
══════════════════════════════════════════ */
.chat-status.typing { color: var(--primary); }
.chat-status.typing::before { background: var(--primary); animation: statusPulse 1.2s infinite ease-in-out; }
@keyframes statusPulse { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(1.4); opacity: 0.6; } }