/* ============================================================
   chatbot.css — chat.iapourtoi.fr
   Couvre : la structure statique de chatbot_index.html ET les Ã©lÃ©ments
   gÃ©nÃ©rÃ©s dynamiquement par chatbot.js / par les rÃ©ponses du Worker
   (boutons .quick-reply, .urgency-btn, .custom-option, .confirm-btn...).
   ============================================================ */

:root{
  --ia-violet: #385D8D;
  --ia-violet-dark: #5b21b6;
  --ia-violet-light: #ede9fe;
  --ia-green: #059669;
  --ia-amber: #f59e0b;
  --ia-red: #ef4444;
  --ia-blue: #0ea5e9;
  --ia-text: #1e293b;
  --ia-text-muted: #64748b;
  --ia-border: #e2e8f0;
  --ia-bg: #f8fafc;
  --ia-white: #ffffff;
  --ia-radius: 14px;
  --ia-radius-sm: 8px;
  --ia-shadow: 0 8px 24px rgba(30, 41, 59, 0.12);
}

*{ box-sizing: border-box; }

html, body{
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--ia-bg);
  color: var(--ia-text);
}

/* â”€â”€ CONTENEUR PRINCIPAL â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */

.chat-container{
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--ia-white);
  box-shadow: var(--ia-shadow);
  overflow: hidden;
}

@media (min-width: 600px){
  .chat-container{
    height: min(720px, 92vh);
    margin-top: 4vh;
    border-radius: var(--ia-radius);
  }
}

.chat-container.rtl{ direction: rtl; }

/* â”€â”€ HEADER â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */

.chat-header{
  background: linear-gradient(135deg, var(--ia-violet), var(--ia-violet-dark));
  color: var(--ia-white);
  padding: 18px 20px 14px;
  flex-shrink: 0;
}

.chat-header h1{
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-header p{
  margin: 4px 0 0;
  font-size: 13px;
  color: rgba(255,255,255,0.85);
}

.connection-status{
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
  background: #94a3b8;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.35);
}
.status-online{ background: #4ade80; }
.status-offline{ background: #94a3b8; }
.status-error{ background: var(--ia-red); }

/* â”€â”€ SÃ‰LECTEUR DE LANGUE â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */

.lang-selector{
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  background: var(--ia-violet-light);
  border-bottom: 1px solid var(--ia-border);
  flex-shrink: 0;
}

.lang-btn{
  flex: 1;
  border: 1px solid transparent;
  background: var(--ia-white);
  color: var(--ia-text);
  padding: 7px 6px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.lang-btn:hover{ transform: translateY(-1px); }
.lang-btn.active{
  border-color: var(--ia-violet);
  color: var(--ia-violet);
  background: var(--ia-white);
}
.lang-btn:focus-visible,
.send-btn:focus-visible,
.footer-buttons button:focus-visible,
#userInput:focus-visible{
  outline: 2px solid var(--ia-violet);
  outline-offset: 2px;
}

/* â”€â”€ BARRE DE PROGRESSION â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */

.progress-bar-wrapper{
  padding: 0;
  flex-shrink: 0;
}
.progress-bar-track{
  height: 4px;
  background: var(--ia-border);
  width: 100%;
}
.progress-bar-fill{
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--ia-violet), #8fa9bf);
  transition: width 0.35s ease;
}

/* â”€â”€ ZONE DE MESSAGES â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */

.chat-messages{
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--ia-bg);
  scroll-behavior: smooth;
}

.message{
  max-width: 82%;
  padding: 10px 14px;
  border-radius: var(--ia-radius);
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  animation: ia-msg-in 0.2s ease;
}

@keyframes ia-msg-in{
  from{ opacity: 0; transform: translateY(4px); }
  to{ opacity: 1; transform: translateY(0); }
}

.message.bot{
  background: var(--ia-white);
  border: 1px solid var(--ia-border);
  color: var(--ia-text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.chat-container.rtl .message.bot{ border-bottom-left-radius: var(--ia-radius); border-bottom-right-radius: 4px; }

.message.user{
  background: var(--ia-violet);
  color: var(--ia-white);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.chat-container.rtl .message.user{ border-bottom-right-radius: var(--ia-radius); border-bottom-left-radius: 4px; }

.message.system{
  align-self: center;
  background: #fef3c7;
  color: #92400e;
  font-size: 12.5px;
  text-align: center;
  border-radius: 999px;
  padding: 6px 14px;
  max-width: 90%;
}

/* Indicateur "en train d'Ã©crire" */
.typing-indicator{
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  align-self: flex-start;
}
.typing-indicator span{
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: ia-typing 1.1s infinite ease-in-out;
}
.typing-indicator span:nth-child(2){ animation-delay: 0.15s; }
.typing-indicator span:nth-child(3){ animation-delay: 0.3s; }
@keyframes ia-typing{
  0%, 60%, 100%{ transform: translateY(0); opacity: 0.5; }
  30%{ transform: translateY(-4px); opacity: 1; }
}

/* â”€â”€ BOUTONS GÃ‰NÃ‰RÃ‰S PAR LE WORKER (rÃ©ponses dans buildResp) â”€â”€
   Ces classes sont injectÃ©es via innerHTML dans les messages bot â€” elles
   ne sont pas dans chatbot_index.html mais doivent Ãªtre stylÃ©es ici pour
   ne jamais s'afficher "nues". */

.urgency-buttons,
.confirm-buttons{
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.quick-reply,
.urgency-btn,
.custom-option{
  border: 1px solid var(--ia-violet);
  background: var(--ia-white);
  color: var(--ia-violet);
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}
.quick-reply:hover,
.urgency-btn:hover,
.custom-option:hover{
  background: var(--ia-violet);
  color: var(--ia-white);
  transform: translateY(-1px);
}

/* Urgence : couleurs sÃ©mantiques cohÃ©rentes avec les emojis renvoyÃ©s par
   uEmoji() cÃ´tÃ© Worker (ðŸ”´ðŸŸ ðŸŸ¡ðŸŸ¢) */
.urgency-1{ border-color: var(--ia-red); color: var(--ia-red); }
.urgency-1:hover{ background: var(--ia-red); color: var(--ia-white); }
.urgency-2{ border-color: var(--ia-amber); color: var(--ia-amber); }
.urgency-2:hover{ background: var(--ia-amber); color: var(--ia-white); }
.urgency-3{ border-color: #eab308; color: #a16207; }
.urgency-3:hover{ background: #eab308; color: var(--ia-white); }
.urgency-4{ border-color: var(--ia-green); color: var(--ia-green); }
.urgency-4:hover{ background: var(--ia-green); color: var(--ia-white); }

.confirm-btn{
  border: none;
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 700;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.confirm-btn:hover{ transform: translateY(-1px); opacity: 0.92; }
.confirm-yes{ background: var(--ia-green); color: var(--ia-white); }
.confirm-no{ background: var(--ia-border); color: var(--ia-text); }

/* â”€â”€ ZONE DE SAISIE â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */

.chat-input{
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--ia-border);
  background: var(--ia-white);
  flex-shrink: 0;
}

#userInput{
  flex: 1;
  border: 1px solid var(--ia-border);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: inherit;
  background: var(--ia-bg);
  color: var(--ia-text);
}
#userInput:disabled{
  opacity: 0.6;
  cursor: not-allowed;
}
#userInput:focus{ border-color: var(--ia-violet); background: var(--ia-white); }

.send-btn{
  border: none;
  background: var(--ia-violet);
  color: var(--ia-white);
  font-weight: 700;
  font-size: 13px;
  padding: 0 18px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.send-btn:hover{ background: var(--ia-violet-dark); }
.send-btn:disabled{
  opacity: 0.5;
  cursor: not-allowed;
}

/* â”€â”€ PIED DE PAGE (reset / export) â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */

.footer-buttons{
  display: flex;
  gap: 8px;
  padding: 10px 14px 14px;
  background: var(--ia-white);
  flex-shrink: 0;
}

.footer-buttons button{
  flex: 1;
  border: 1px solid var(--ia-border);
  background: var(--ia-bg);
  color: var(--ia-text-muted);
  padding: 8px 10px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: var(--ia-radius-sm);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.footer-buttons button:hover{
  background: var(--ia-violet-light);
  color: var(--ia-violet);
}

/* â”€â”€ SCROLLBAR (esthÃ©tique, dÃ©grade proprement si non supportÃ©) â”€ */

.chat-messages::-webkit-scrollbar{ width: 6px; }
.chat-messages::-webkit-scrollbar-thumb{ background: #cbd5e1; border-radius: 999px; }
.chat-messages::-webkit-scrollbar-track{ background: transparent; }

/* â”€â”€ RESPONSIVE MOBILE â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */

@media (max-width: 380px){
  .chat-header h1{ font-size: 15px; }
  .message{ max-width: 88%; font-size: 13.5px; }
  .lang-btn{ font-size: 11px; padding: 6px 4px; }
}

/* â”€â”€ RÃ‰DUCTION DES ANIMATIONS (prÃ©fÃ©rence systÃ¨me) â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€ */

@media (prefers-reduced-motion: reduce){
  .message{ animation: none; }
  .typing-indicator span{ animation: none; opacity: 0.7; }
  .progress-bar-fill{ transition: none; }
}
