/* ============================================================
   EmploiServices — Chat Widget flottant (DRAFT LOCAL)
   ------------------------------------------------------------
   Design moderne & propre. TOUTES les couleurs passent par les
   variables CSS ci-dessous : le futur rebranding ne touche que
   ce bloc. RTL (ar) / LTR (fr) gérés via propriétés logiques.
   ============================================================ */

#emploi-chat {
  /* ---------- Palette identité (navy / teal / gold) ---------- */
  --es-navy: #00387C;
  --es-navy-deep: #00244f;
  --es-teal: #03989E;
  --es-teal-dark: #027e83;
  --es-gold: #C9A227;
  --es-gold-dark: #a3831c;

  /* ---------- Surface / texte ---------- */
  --es-bg: #f2f6fb;
  --es-surface: #ffffff;
  --es-text: #16283f;
  --es-muted: #5b6b81;
  --es-border: #dde5ee;
  --es-bot-bubble: #eaf1f9;
  --es-user-bubble: var(--es-teal);

  /* ---------- Forme / ombres ---------- */
  --es-radius: 18px;
  --es-radius-sm: 12px;
  --es-shadow: 0 20px 55px rgba(0, 28, 61, 0.30);
  --es-shadow-soft: 0 4px 14px rgba(0, 28, 61, 0.10);
  --es-focus: 0 0 0 3px rgba(201, 162, 39, 0.35);

  /* ---------- Typo ---------- */
  --es-font: "Segoe UI", Tahoma, Arial, sans-serif;
  --es-font-size: 13.5px;

  /* ---------- Positionnement ---------- */
  position: fixed;
  inset-block-end: 22px;
  inset-inline-start: 22px; /* LTR → gauche · RTL → droite (miroir du site) */
  z-index: 99990;
  font-family: var(--es-font);
  font-size: var(--es-font-size);
  color: var(--es-text);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

#emploi-chat[hidden] { display: none !important; }

#emploi-chat *,
#emploi-chat *::before,
#emploi-chat *::after { box-sizing: border-box; }

/* ============ Bouton flottant ============ */
.emploi-chat-toggle {
  position: relative;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: linear-gradient(135deg, var(--es-navy) 0%, var(--es-teal) 100%);
  box-shadow: var(--es-shadow);
  transition: transform .22s ease, box-shadow .22s ease;
}

.emploi-chat-toggle:hover { transform: translateY(-3px); box-shadow: 0 22px 60px rgba(0, 28, 61, 0.38); }
.emploi-chat-toggle:focus-visible { outline: none; box-shadow: var(--es-shadow), var(--es-focus); }

.emploi-chat-toggle-ico,
.emploi-chat-toggle-x {
  position: absolute;
  inset: 0;
  margin: auto;
  transition: opacity .22s ease, transform .28s ease;
}

.emploi-chat-toggle-x { opacity: 0; transform: rotate(-90deg) scale(.6); }

#emploi-chat.is-open .emploi-chat-toggle-ico { opacity: 0; transform: rotate(90deg) scale(.6); }
#emploi-chat.is-open .emploi-chat-toggle-x  { opacity: 1; transform: rotate(0) scale(1); }

/* ============ Panneau ============ */
.emploi-chat-panel {
  position: absolute;
  inset-block-end: calc(100% + 14px);
  inset-inline-start: 0;
  width: min(400px, calc(100vw - 32px));
  height: min(560px, calc(100dvh - 110px));
  min-height: 380px;
  display: flex;
  flex-direction: column;
  background: var(--es-surface);
  border: 1px solid var(--es-border);
  border-radius: var(--es-radius);
  overflow: hidden;
  box-shadow: var(--es-shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px) scale(.97);
  transform-origin: bottom;
  transition: opacity .22s ease, transform .26s ease, visibility .22s;
}

#emploi-chat.is-open .emploi-chat-panel { opacity: 1; visibility: visible; transform: translateY(0) scale(1); }

/* ============ En-tête ============ */
.emploi-chat-head {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 16px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--es-navy) 0%, var(--es-teal) 135%);
}

/* Liseré or sous l'en-tête */
.emploi-chat-head::after {
  content: "";
  position: absolute;
  inset-inline: 0;
  inset-block-end: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--es-gold), rgba(201, 162, 39, 0.25));
}

.emploi-chat-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.emploi-chat-logo {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: block;
  object-fit: contain;
  border-radius: 10px;
}

.emploi-chat-bot-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .6px;
  color: var(--es-gold);
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 1px 7px;
  margin-inline-start: 6px;
  vertical-align: 2px;
  text-transform: uppercase;
}

.emploi-chat-brand-text { min-width: 0; }

.emploi-chat-title {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.emploi-chat-subtitle {
  margin: 1px 0 0;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.88);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.emploi-chat-head-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

.emploi-chat-lang {
  padding: 5px 11px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  background: transparent;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .6px;
  cursor: pointer;
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}

.emploi-chat-lang:hover { background: var(--es-gold); border-color: var(--es-gold); color: var(--es-navy-deep); }
.emploi-chat-lang:focus-visible { outline: none; box-shadow: var(--es-focus); }

.emploi-chat-close {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: rgba(255, 255, 255, 0.92);
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
  transition: background .18s ease;
}

.emploi-chat-close:hover { background: rgba(255, 255, 255, 0.16); }
.emploi-chat-close:focus-visible { outline: none; box-shadow: var(--es-focus); }

/* ============ Messages ============ */
.emploi-chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--es-bg);
  overscroll-behavior: contain;
}

.emploi-chat-messages::-webkit-scrollbar { width: 6px; }
.emploi-chat-messages::-webkit-scrollbar-thumb { background: var(--es-border); border-radius: 999px; }
.emploi-chat-messages::-webkit-scrollbar-thumb:hover { background: var(--es-teal); }
.emploi-chat-messages::-webkit-scrollbar-track { background: transparent; }

.emploi-chat-msg {
  max-width: 82%;
  padding: 9px 14px;
  font-size: var(--es-font-size);
  border-radius: 14px;
  box-shadow: var(--es-shadow-soft);
  overflow-wrap: break-word;
  white-space: pre-wrap;
  animation: emploi-chat-in .24s ease both;
}

.emploi-chat-msg--bot {
  align-self: flex-start;
  margin-inline-end: auto;
  background: var(--es-bot-bubble);
  color: var(--es-text);
  border-start-start-radius: 4px;
}

.emploi-chat-msg--user {
  align-self: flex-end;
  margin-inline-start: auto;
  background: linear-gradient(135deg, var(--es-teal), var(--es-teal-dark));
  color: #ffffff;
  border-end-end-radius: 4px;
}

.emploi-chat-msg--error {
  background: #fdf1f1;
  color: #8a2f2f;
  border-inline-start: 3px solid #c95b5b;
}

@keyframes emploi-chat-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============ Indicateur de frappe ============ */
.emploi-chat-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  align-self: flex-start;
  margin-inline-end: auto;
  margin-block: 2px 0;
  padding: 11px 16px;
  background: var(--es-bot-bubble);
  border-radius: 14px;
  border-start-start-radius: 4px;
  width: fit-content;
  box-shadow: var(--es-shadow-soft);
}

.emploi-chat-typing[hidden] { display: none; }

.emploi-chat-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--es-teal);
  animation: emploi-chat-dot 1.15s infinite ease-in-out;
}

.emploi-chat-typing span:nth-child(2) { animation-delay: .18s; background: var(--es-navy); }
.emploi-chat-typing span:nth-child(3) { animation-delay: .36s; background: var(--es-gold); }

@keyframes emploi-chat-dot {
  0%, 70%, 100% { transform: translateY(0); opacity: .45; }
  35%           { transform: translateY(-5px); opacity: 1; }
}

/* ============ Réponses rapides (chips) ============ */
.emploi-chat-replies {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 14px 4px;
  background: var(--es-bg);
}

.emploi-chat-chip {
  padding: 8px 15px;
  border: 1.5px solid var(--es-teal);
  border-radius: 999px;
  background: var(--es-surface);
  color: var(--es-navy);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.emploi-chat-chip:hover:not(:disabled) { background: var(--es-teal); border-color: var(--es-teal); color: #ffffff; }
.emploi-chat-chip:focus-visible { outline: none; box-shadow: var(--es-focus); }
.emploi-chat-chip:disabled { opacity: .45; cursor: default; }

.emploi-chat-chip--gold { border-color: var(--es-gold); color: var(--es-gold-dark); }
.emploi-chat-chip--gold:hover:not(:disabled) { background: var(--es-gold); border-color: var(--es-gold); color: var(--es-navy-deep); }

/* ============ Pied (mot-clé optionnel) ============ */
.emploi-chat-foot {
  flex: 0 0 auto;
  padding: 10px 12px 8px;
  background: var(--es-surface);
  border-top: 1px solid var(--es-border);
}

.emploi-chat-form { display: flex; gap: 8px; margin: 0; }

.emploi-chat-keyword {
  flex: 1 1 auto;
  min-width: 0;
  padding: 9px 15px;
  border: 1px solid var(--es-border);
  border-radius: 999px;
  background: var(--es-bg);
  font-family: inherit;
  font-size: 13px;
  color: var(--es-text);
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.emploi-chat-keyword::placeholder { color: var(--es-muted); opacity: .85; }
.emploi-chat-keyword:focus { outline: none; border-color: var(--es-teal); background: var(--es-surface); box-shadow: 0 0 0 3px rgba(3, 152, 158, 0.16); }

.emploi-chat-send {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--es-teal), var(--es-navy));
  color: #ffffff;
  cursor: pointer;
  transition: transform .18s ease, opacity .18s ease, box-shadow .18s ease;
}

.emploi-chat-send:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--es-shadow-soft); }
.emploi-chat-send:focus-visible { outline: none; box-shadow: var(--es-focus); }
.emploi-chat-send:disabled { opacity: .5; cursor: default; }

.emploi-chat-note {
  margin: 6px 4px 0;
  text-align: center;
  font-size: 10.5px;
  color: var(--es-muted);
}

/* ============ Mobile : panneau pleine hauteur ============ */
@media (max-width: 520px) {
  #emploi-chat { inset-block-end: 16px; inset-inline-start: 16px; }

  .emploi-chat-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    border-radius: 0;
    border: none;
    transform: translateY(24px) scale(.98);
  }

  .emploi-chat-toggle { width: 56px; height: 56px; }
}

/* ============ Liens d'action ============ */
.emploi-chat-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 14px 0;
}
.emploi-chat-links[hidden] { display: none; }
.emploi-chat-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: var(--es-navy, #00387C);
  background: var(--es-teal-soft, #e6f4f4);
  border: 1px solid var(--es-teal, #03989E);
  border-radius: 999px;
  text-decoration: none;
  transition: background .18s ease, color .18s ease;
}
.emploi-chat-link:hover { background: var(--es-teal, #03989E); color: #fff; }
.emploi-chat-link::before { content: '↗'; font-size: 11px; }

/* ============ Accessibilité ============ */
@media (prefers-reduced-motion: reduce) {
  #emploi-chat *,
  #emploi-chat *::before,
  #emploi-chat *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
