/* IFPA Poitiers — Chatbot v0.1 (couleurs marque + accessibilité) */

#ifpa-chatbot-container {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: 360px;
  max-width: calc(100vw - 40px);
  border: 1px solid var(--c-line, #ececf2);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(26,26,46,.20);
  background: #fff;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  display: none;
  z-index: 9998;
  max-height: 75vh;
  overflow: hidden;
  flex-direction: column;
  animation: ifpa-chat-in .25s ease-out;
}
@keyframes ifpa-chat-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

#ifpa-chatbot-header {
  background: linear-gradient(135deg, var(--c-accent, #d0124d) 0%, var(--c-accent-2, #a40e3e) 100%);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: .95rem;
}
#ifpa-chatbot-header span.chat-title {
  display: flex; align-items: center; gap: .55rem;
}
#ifpa-chatbot-header span.chat-status {
  font-size: .72rem; font-weight: 500;
  display: inline-flex; align-items: center; gap: .4rem;
  opacity: .85;
}
#ifpa-chatbot-header .status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #2ecc71;
  box-shadow: 0 0 0 3px rgba(46,204,113,.25);
}

#ifpa-chatbot-close {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0;
  width: 28px; height: 28px;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  transition: background .15s ease;
}
#ifpa-chatbot-close:hover, #ifpa-chatbot-close:focus-visible {
  background: rgba(255,255,255,.30);
  outline: 2px solid #fff;
  outline-offset: 2px;
}

#ifpa-chatbot-messages {
  height: 360px;
  overflow-y: auto;
  padding: 16px;
  background: linear-gradient(180deg, #fafafd 0%, #fff 100%);
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: var(--c-accent, #d0124d) transparent;
}
#ifpa-chatbot-messages::-webkit-scrollbar { width: 6px; }
#ifpa-chatbot-messages::-webkit-scrollbar-thumb {
  background: var(--c-accent, #d0124d);
  border-radius: 3px;
}

.ifpa-chat-message {
  margin: 8px 0;
  padding: 10px 14px;
  border-radius: 16px;
  max-width: 85%;
  line-height: 1.45;
  font-size: .9rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.ifpa-chat-user {
  background: var(--c-accent, #d0124d);
  color: #fff;
  margin-left: auto;
  border-bottom-right-radius: 4px;
}
.ifpa-chat-bot {
  background: #f3f3f7;
  color: var(--c-ink, #1a1a2e);
  margin-right: auto;
  border-bottom-left-radius: 4px;
}
.ifpa-chat-bot a {
  color: var(--c-accent-2, #a40e3e);
  text-decoration: underline;
  font-weight: 600;
}
.ifpa-chat-typing {
  display: inline-flex; gap: 3px;
  padding: 6px 0;
}
.ifpa-chat-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--c-accent, #d0124d);
  animation: ifpa-typing 1.4s infinite ease-in-out;
}
.ifpa-chat-typing span:nth-child(2) { animation-delay: .2s; }
.ifpa-chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ifpa-typing {
  0%, 60%, 100% { transform: scale(.6); opacity: .4; }
  30% { transform: scale(1); opacity: 1; }
}

.ifpa-chat-suggests {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin: 10px 0 4px;
}
.ifpa-chat-suggest {
  background: #fff;
  border: 1.5px solid var(--c-accent, #d0124d);
  color: var(--c-accent, #d0124d);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: .78rem; font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, color .15s;
}
.ifpa-chat-suggest:hover, .ifpa-chat-suggest:focus-visible {
  background: var(--c-accent, #d0124d);
  color: #fff;
  outline: none;
}

#ifpa-chatbot-input {
  display: flex;
  padding: 12px;
  border-top: 1px solid var(--c-line, #ececf2);
  background: #fff;
  gap: 8px;
}
#ifpa-user-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--c-line, #ececf2);
  border-radius: 999px;
  font-size: .92rem;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
#ifpa-user-input:focus {
  border-color: var(--c-accent, #d0124d);
  box-shadow: 0 0 0 3px rgba(208,18,77,.15);
}
#ifpa-send-button {
  padding: 0 14px;
  background: var(--c-accent, #d0124d);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px; height: 40px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .15s;
}
#ifpa-send-button:hover, #ifpa-send-button:focus-visible {
  background: var(--c-accent-2, #a40e3e);
  transform: scale(1.06);
  outline: 2px solid var(--c-accent, #d0124d);
  outline-offset: 2px;
}

#ifpa-chatbot-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: linear-gradient(135deg, var(--c-accent, #d0124d) 0%, var(--c-accent-2, #a40e3e) 100%);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 62px; height: 62px;
  font-size: 26px;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(208,18,77,.40);
  z-index: 9997;
  transition: transform .2s, box-shadow .2s;
  display: inline-flex; align-items: center; justify-content: center;
}
#ifpa-chatbot-toggle:hover, #ifpa-chatbot-toggle:focus-visible {
  transform: scale(1.08);
  box-shadow: 0 14px 36px rgba(208,18,77,.50);
  outline: 3px solid var(--c-accent, #d0124d);
  outline-offset: 3px;
}
#ifpa-chatbot-toggle .badge-new {
  position: absolute;
  top: -4px; right: -4px;
  background: #2ecc71;
  border: 2px solid #fff;
  width: 14px; height: 14px;
  border-radius: 50%;
  animation: ifpa-pulse 2s ease-in-out infinite;
}
@keyframes ifpa-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(46,204,113,.7); }
  50% { box-shadow: 0 0 0 8px rgba(46,204,113,0); }
}

@media (prefers-reduced-motion: reduce) {
  #ifpa-chatbot-container, .ifpa-chat-typing span, #ifpa-chatbot-toggle .badge-new {
    animation: none !important;
  }
}

@media (max-width: 480px) {
  #ifpa-chatbot-container {
    right: 10px; left: 10px;
    width: auto;
    bottom: 90px;
  }
  #ifpa-chatbot-messages { height: 50vh; }
}
