/* ── Education Formation Chatbot ── */

/* Les variables de couleur sont injectées inline par JS au démarrage */
:root {
  --ecb-primary:      #1a1a2e;
  --ecb-accent:       #16213e;
  --ecb-bg:           #f5f0eb;
  --ecb-bubble-bot:   #ffffff;
  --ecb-bubble-user:  #1a1a2e;
  --ecb-avatar-bg:    #1a1a2e;
  --ecb-button-bg:    #1a1a2e;
  --ecb-button-size:  60px;
  --ecb-text:         #1e293b;
  --ecb-text-light:   #64748b;
  --ecb-border:       #e2e0db;
  --ecb-input-bg:     #ffffff;
  --ecb-radius-lg:    24px;
  --ecb-radius-sm:    24px;
  --ecb-bottom-offset: 25px;
}

#ecb-chatbot-widget-container,
#ecb-chatbot-widget-container * {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Floating Button ── */
#ecb-floating-btn {
  position: fixed;
  bottom: var(--ecb-bottom-offset);
  right: 25px;
  width: var(--ecb-button-size);
  height: var(--ecb-button-size);
  background: var(--ecb-button-bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  z-index: 2147483647 !important;
  transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
#ecb-floating-btn:hover {
  transform: scale(1.08);
}
#ecb-floating-btn.ecb-attention {
  animation: ecb-attention-pop 1.1s ease-in-out 2;
}

@keyframes ecb-attention-pop {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  }
  20% {
    transform: scale(1.12) rotate(-4deg);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2), 0 0 0 8px rgba(26,26,46,0.08);
  }
  42% {
    transform: scale(1.04) rotate(4deg);
  }
  64% {
    transform: scale(1.1) rotate(0);
    box-shadow: 0 8px 24px rgba(0,0,0,0.2), 0 0 0 14px rgba(26,26,46,0);
  }
}

#ecb-floating-tooltip {
  position: fixed;
  bottom: calc(var(--ecb-bottom-offset) + calc(var(--ecb-button-size) / 2));
  right: calc(25px + var(--ecb-button-size) + 16px);
  transform: translateY(50%);
  background: #ffffff;
  color: #1e293b;
  padding: 10px 15px;
  border-radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.9rem;
  line-height: 1.35;
  box-shadow: 0 4px 20px rgba(0,0,0,0.12);
  z-index: 2147483646 !important;
  pointer-events: none;
  animation: ecb-pulse-tooltip 3s infinite;
  white-space: nowrap;
}
#ecb-floating-tooltip strong {
  font-weight: 600;
}
#ecb-floating-tooltip::after {
  content: '';
  position: absolute;
  top: 50%;
  right: -6px;
  transform: translateY(-50%);
  border-width: 6px 0 6px 6px;
  border-style: solid;
  border-color: transparent transparent transparent #ffffff;
}

@keyframes ecb-pulse-tooltip {
  0%, 100% { transform: translate(0, 50%); }
  50% { transform: translate(-4px, 50%); }
}

/* ── Layout principal (Modal) ─────────────────────────────────────────────── */
#ecb-chatbot-wrapper {
  position: fixed;
  bottom: calc(var(--ecb-bottom-offset) + var(--ecb-button-size) + 15px);
  right: 25px;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 620px;
  max-height: calc(100vh - 120px);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.65;
  color: var(--ecb-text);
  background: var(--ecb-bg);
  box-shadow: 0 10px 40px rgba(0,0,0,0.18);
  border-radius: var(--ecb-radius-lg);
  overflow: hidden;
  z-index: 2147483646 !important;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
#ecb-chatbot-wrapper.ecb-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

#ecb-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

/* ── Hero header (titre + sous-titre) ───────────────────────────────────────── */
#ecb-hero {
  padding: 1rem 1.25rem;
  background: var(--ecb-primary);
  color: #ffffff;
  position: relative;
  z-index: 2;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  display: flex;
  align-items: center;
  gap: 1rem;
}
#ecb-hero-icon-wrapper {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
#ecb-hero-icon-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#ecb-hero-icon-wrapper .ecb-icon-open {
  font-size: 1.5rem;
}
#ecb-hero-text {
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
#ecb-hero-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: -.02em;
  margin-bottom: 0.15rem;
  line-height: 1.2;
}
#ecb-hero-subtitle {
  font-size: .8rem;
  color: rgba(255,255,255,0.85);
  margin: 0;
  line-height: 1.4;
}

/* ── Zone de messages ─────────────────────────────────────────────────────── */
#ecb-messages {
  flex: 1;
  min-height: 0;
  padding: 1.5rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: var(--ecb-bg);
  scroll-behavior: smooth;
}
#ecb-messages::-webkit-scrollbar { width: 4px; }
#ecb-messages::-webkit-scrollbar-thumb { background: #ccc8c2; border-radius: 2px; }

/* ── Messages ─────────────────────────────────────────────────────────────── */
.ecb-msg {
  display: flex;
  align-items: flex-end;
  gap: .75rem;
  max-width: 82%;
  min-width: 0;
  animation: ecb-in .2s ease both;
}
@keyframes ecb-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ecb-msg.ecb-bot  { align-self: flex-start; }
.ecb-msg.ecb-user { align-self: flex-end; flex-direction: row-reverse; }

/* ── Avatar ───────────────────────────────────────────────────────────────── */
.ecb-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--ecb-avatar-bg);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .02em;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  text-transform: uppercase;
}
.ecb-avatar-user {
  background: #e8e4df;
  color: var(--ecb-text-light);
}

/* ── Bubbles ──────────────────────────────────────────────────────────────── */
.ecb-bubble {
  padding: 1rem 1.5rem !important;
  border-radius: 24px;
  font-size: .95rem;
  line-height: 1.5;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.ecb-bot .ecb-bubble {
  background: var(--ecb-bubble-bot);
  color: var(--ecb-text);
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 15px rgba(0,0,0,.05);
}
.ecb-user .ecb-bubble {
  background: var(--ecb-bubble-user);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 15px rgba(0,0,0,.1);
}
.ecb-user .ecb-bubble a { color: rgba(255,255,255,.85); }

#ecb-chatbot-widget-container .ecb-quick-replies {
  align-self: flex-start !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  gap: .55rem !important;
  max-width: 88% !important;
  margin: -.55rem 0 0 50px !important;
  padding: 0 !important;
  list-style: none !important;
  animation: ecb-in .2s ease both;
}

#ecb-chatbot-widget-container .ecb-quick-reply {
  appearance: none !important;
  -webkit-appearance: none !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  width: auto !important;
  max-width: 100% !important;
  min-height: 38px !important;
  margin: 0 !important;
  padding: .62rem .95rem !important;
  border: 1px solid #e5e7eb !important;
  border-radius: 999px !important;
  background: #f3f4f6 !important;
  background-image: none !important;
  color: #1f2937 !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
  font-size: .88rem !important;
  font-weight: 600 !important;
  line-height: 1.2 !important;
  text-align: left !important;
  text-decoration: none !important;
  text-shadow: none !important;
  white-space: normal !important;
  cursor: pointer !important;
  box-shadow: 0 4px 12px rgba(15, 23, 42, .06) !important;
  transition: background .18s ease, border-color .18s ease, color .18s ease, transform .18s ease, box-shadow .18s ease !important;
}

#ecb-chatbot-widget-container .ecb-quick-reply:hover,
#ecb-chatbot-widget-container .ecb-quick-reply:focus {
  border-color: #d1d5db !important;
  background: #e9edf2 !important;
  color: var(--ecb-primary) !important;
  outline: none !important;
  transform: translateY(-1px) !important;
  box-shadow: 0 7px 18px rgba(15, 23, 42, .1) !important;
}

#ecb-chatbot-widget-container .ecb-quick-reply:active {
  transform: translateY(0) !important;
  box-shadow: 0 3px 8px rgba(15, 23, 42, .08) !important;
}

/* ── Typing ───────────────────────────────────────────────────────────────── */
#ecb-typing {
  display: none;
  align-items: flex-end;
  gap: .75rem;
  padding: 0 1.25rem .5rem;
}
#ecb-typing.ecb-visible { display: flex; }
.ecb-typing-dots {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1rem 1.5rem !important;
  background: var(--ecb-bubble-bot);
  border-radius: 24px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 15px rgba(0,0,0,.05);
}
.ecb-typing-dots span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: ecb-bounce 1.3s infinite;
}
.ecb-typing-dots span:nth-child(2) { animation-delay: .2s; }
.ecb-typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes ecb-bounce {
  0%,80%,100% { transform: translateY(0); opacity:.45; }
  40%          { transform: translateY(-7px); opacity:1; }
}

/* ── Lead form ────────────────────────────────────────────────────────────── */
#ecb-lead-form-wrapper {
  display: none;
  background: #fff;
  border-top: 1px solid var(--ecb-border);
  padding: 1.25rem;
}
#ecb-lead-form-wrapper.ecb-visible { display: block; }
#ecb-lead-form-wrapper h3 {
  font-size: .9rem;
  font-weight: 700;
  color: var(--ecb-primary);
  margin-bottom: .875rem;
}
#ecb-chatbot-wrapper .ecb-form-row {
  display: flex !important;
  gap: .6rem !important;
  flex-wrap: wrap !important;
  margin-bottom: .6rem !important;
}
#ecb-chatbot-wrapper .ecb-form-row input {
  flex: 1 !important;
  min-width: 150px !important;
  padding: .65rem 1rem !important;
  border: 1.5px solid var(--ecb-border) !important;
  border-radius: 24px !important;
  font-size: .875rem !important;
  font-family: inherit !important;
  color: var(--ecb-text) !important;
  background: #fafafa !important;
  outline: none !important;
  transition: all .2s !important;
  margin: 0 !important;
  box-shadow: none !important;
  height: auto !important;
  line-height: 1.5 !important;
}
#ecb-chatbot-wrapper .ecb-form-row input:focus {
  border-color: var(--ecb-primary) !important;
  box-shadow: 0 0 0 3px rgba(26,26,46,.08) !important;
  background: #fff !important;
}
#ecb-chatbot-wrapper .ecb-form-row input::placeholder { color: #b0aaa3 !important; }

#ecb-chatbot-wrapper .ecb-form-actions { 
  display: flex !important; 
  gap: .6rem !important; 
  margin-top: .8rem !important; 
  flex-wrap: wrap !important; 
}
#ecb-chatbot-wrapper #ecb-lead-submit {
  background: var(--ecb-primary) !important;
  color: #fff !important;
  border: none !important;
  border-radius: 999px !important;
  padding: .65rem 1.375rem !important;
  cursor: pointer !important;
  font-size: .875rem !important;
  font-weight: 600 !important;
  font-family: inherit !important;
  transition: all .2s !important;
  margin: 0 !important;
}
#ecb-chatbot-wrapper #ecb-lead-submit:hover:not(:disabled) { opacity: .88 !important; transform: translateY(-1px) !important; }
#ecb-chatbot-wrapper #ecb-lead-submit:disabled { opacity: .55 !important; cursor: not-allowed !important; }

#ecb-chatbot-wrapper #ecb-lead-skip {
  background: transparent !important;
  color: var(--ecb-text-light) !important;
  border: 1.5px solid var(--ecb-border) !important;
  border-radius: 999px !important;
  padding: .65rem 1rem !important;
  cursor: pointer !important;
  font-size: .8rem !important;
  font-family: inherit !important;
  transition: all .2s !important;
  margin: 0 !important;
}
#ecb-chatbot-wrapper #ecb-lead-skip:hover { border-color: #94a3b8 !important; color: var(--ecb-text) !important; }
#ecb-chatbot-wrapper #ecb-form-error { color: #dc2626 !important; font-size: .8rem !important; margin-top: .4rem !important; }

/* ── CTA ──────────────────────────────────────────────────────────────────── */
#ecb-cta-wrapper {
  display: none;
  gap: .625rem;
  padding: .875rem 1.25rem;
  background: #fff;
  border-top: 1px solid var(--ecb-border);
  flex-wrap: wrap;
}
#ecb-cta-wrapper.ecb-visible { display: flex; }
#ecb-chatbot-wrapper .ecb-cta-btn {
  flex: 1 !important;
  min-width: 130px !important;
  padding: .75rem 1rem !important;
  border-radius: 999px !important;
  border: none !important;
  cursor: pointer !important;
  font-size: .875rem !important;
  font-weight: 600 !important;
  font-family: inherit !important;
  text-align: center !important;
  text-decoration: none !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: .4rem !important;
  transition: all .2s !important;
  margin: 0 !important;
}
#ecb-chatbot-wrapper .ecb-cta-btn:hover { opacity: .88 !important; transform: translateY(-1px) !important; }
#ecb-chatbot-wrapper .ecb-cta-rdv     { background: var(--ecb-primary) !important; color: #fff !important; }
#ecb-chatbot-wrapper .ecb-cta-contact { background: #fff !important; color: var(--ecb-primary) !important; border: 2px solid var(--ecb-primary) !important; }

/* ── Suggestions ──────────────────────────────────────────────────────────── */
#ecb-suggestions {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: .6rem !important;
  padding: .875rem 1.25rem !important;
  background: var(--ecb-bg) !important;
  border-top: 1px solid var(--ecb-border) !important;
  margin: 0 !important;
}
#ecb-chatbot-wrapper .ecb-suggestion {
  padding: .6rem 1.2rem !important;
  border: 1px solid #cbd5e1 !important;
  border-radius: 999px !important;
  font-size: .85rem !important;
  font-weight: 600 !important;
  font-family: inherit !important;
  cursor: pointer !important;
  background: #f1f5f9 !important;
  color: #334155 !important;
  transition: all .2s !important;
  white-space: nowrap !important;
  line-height: 1.2 !important;
  display: inline-block !important;
  margin: 0 !important;
  box-shadow: none !important;
  text-decoration: none !important;
  text-transform: none !important;
}
#ecb-chatbot-wrapper .ecb-suggestion:hover {
  background: #e2e8f0 !important;
  color: var(--ecb-primary) !important;
  transform: translateY(-1px) !important;
  border-color: #94a3b8 !important;
}

/* ── Input area ───────────────────────────────────────────────────────────── */
#ecb-input-area {
  background: var(--ecb-input-bg);
  border: 1px solid var(--ecb-border);
  border-radius: 30px;
  margin: 0 1.25rem 1rem 1.25rem;
  padding: .5rem .5rem .5rem 1.25rem;
  display: flex;
  align-items: flex-end;
  gap: .75rem;
  flex-shrink: 0;
  box-shadow: 0 4px 15px rgba(0,0,0,.03);
}
#ecb-input {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  font-size: .95rem;
  font-family: inherit;
  color: var(--ecb-text);
  line-height: 1.55;
  max-height: 130px;
  overflow-y: auto;
  margin-bottom: 0.35rem;
}
#ecb-input::placeholder { color: #aaa69f; }

#ecb-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--ecb-primary);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .2s, transform .15s;
}
#ecb-send:hover:not(:disabled) { opacity: .85; transform: scale(1.05); }
#ecb-send:disabled { opacity: .4; cursor: not-allowed; transform: none; }



/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  #ecb-chatbot-wrapper {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    overflow: hidden;
  }
  #ecb-layout {
    height: 100%;
    min-height: 0;
  }
  #ecb-floating-btn {
    bottom: var(--ecb-bottom-offset);
    right: 15px;
  }
  #ecb-hero {
    flex-shrink: 0;
    padding: 0.75rem 1rem;
  }
  #ecb-hero-title { font-size: 1rem; }
  #ecb-hero-subtitle { font-size: .76rem; }
  #ecb-messages {
    flex: 1 1 auto;
    min-height: 0;
    padding: 1rem 1rem 1.15rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
  .ecb-msg {
    max-width: 100%;
    width: 100%;
  }
  .ecb-msg.ecb-user {
    width: auto;
    max-width: 95%;
  }
  .ecb-bot .ecb-bubble {
    max-width: calc(100vw - 88px);
  }
  .ecb-user .ecb-bubble {
    max-width: calc(100vw - 88px);
  }
  #ecb-typing,
  #ecb-cta-wrapper,
  #ecb-suggestions,
  #ecb-input-area {
    flex-shrink: 0;
  }
  #ecb-input-area {
    margin: 0 .85rem max(.85rem, env(safe-area-inset-bottom));
  }
  #ecb-chatbot-widget-container .ecb-quick-replies {
    max-width: calc(100% - 50px) !important;
    margin-left: 50px !important;
  }
  #ecb-chatbot-widget-container .ecb-quick-reply {
    font-size: .85rem !important;
    padding: .58rem .82rem !important;
  }
  #ecb-floating-tooltip { display: none !important; }
}
