/* Widget « Assistant BMD » (chat IA) — chargé sur tout le site par le thème (inc/chat-widget.php).
   Variables locales : le widget ne dépend ni de Bootstrap ni des tokens du thème. */
#bmd-chat-widget {
  --navy: #00306A; --yellow: #FFFE02; --blue: #5B82B2; --dark: #2C3337; --light: #F9F9F9; --border: #DDDDDD;
  --radius: 8px; --shadow: 0 2px 12px rgba(4,50,104,.08); --shadow-hover: 0 6px 24px rgba(4,50,104,.16); --transition: .2s ease;
  font: 14px/1.4 "Helvetica Neue", Helvetica, Arial, sans-serif;
  box-sizing: border-box;
}
#bmd-chat-widget *, #bmd-chat-widget *::before, #bmd-chat-widget *::after { box-sizing: border-box; }
#bmd-chat-widget svg { width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -.15em; }
.bmd-chat-toggle svg { width: 26px; height: 26px; }
.bmd-product-card .bmd-product-card-link { display: block; margin-top: 2px; font-size: .78rem; font-weight: 700; color: var(--navy); }
.bmd-product-card:hover .bmd-product-card-link { text-decoration: underline; }
#bmd-chat-widget {
  position: fixed;
  bottom: 200px; /* au-dessus du badge Avis Garantis (bas droite) */
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

/* Toggle button */
.bmd-chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--dark);
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(255,254,2,.40);
  transition: transform .2s ease, background .2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.bmd-chat-toggle:hover {
  background: var(--navy);
  transform: scale(1.08);
}
/* Pulse — stops once user opens the widget (.bmd-no-pulse added by JS) */
.bmd-chat-toggle:not(.bmd-no-pulse) {
  animation: bmd-pulse 2.5s 4s infinite;
}
@keyframes bmd-pulse {
  0%, 60%, 100% { box-shadow: 0 4px 16px rgba(255,254,2,.40); }
  30%           { box-shadow: 0 4px 16px rgba(255,254,2,.40),
                              0 0 0 8px  rgba(255,254,2,.18),
                              0 0 0 18px rgba(255,254,2,.06); }
}

/* Chat panel */
.bmd-chat-panel {
  display: none;
  flex-direction: column;
  width: 340px;
  max-width: calc(100vw - 2rem);
  height: 480px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(4,50,104,.22);
  margin-bottom: .75rem;
  overflow: hidden;
}
.bmd-chat-panel.bmd-chat-open {
  display: flex;
}

/* Header */
.bmd-chat-header {
  background: var(--navy);
  color: #fff;
  padding: .75rem 1rem;
  display: flex;
  align-items: center;
  gap: .6rem;
  flex-shrink: 0;
}
.bmd-chat-header-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--yellow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--navy);
  font-size: .9rem;
}
.bmd-chat-header-info {
  flex: 1;
}
.bmd-chat-header-name {
  font-weight: 700;
  font-size: .88rem;
  line-height: 1.2;
}
.bmd-chat-header-status {
  font-size: .73rem;
  opacity: .75;
}
.bmd-chat-restart,
.bmd-chat-close {
  background: none;
  border: none;
  color: rgba(255,255,255,.65);
  cursor: pointer;
  padding: .2rem .3rem;
  line-height: 1;
  transition: color .15s;
}
.bmd-chat-restart { font-size: .82rem; }
.bmd-chat-close   { font-size: 1.3rem; }
.bmd-chat-restart:hover { color: var(--yellow); }
.bmd-chat-close:hover   { color: #fff; }

/* Messages area */
.bmd-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: .9rem;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  background: #f8fafd;
}

/* Bubbles */
.bmd-msg {
  max-width: 82%;
  padding: .55rem .8rem;
  border-radius: 14px;
  font-size: .84rem;
  line-height: 1.45;
  word-wrap: break-word;
}
.bmd-msg a {
  color: inherit;
  text-decoration: underline;
  font-weight: 600;
}
.bmd-msg-assistant {
  background: #fff;
  color: var(--dark);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}
.bmd-msg-user {
  background: var(--navy);
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}

/* Typing indicator (inline, inside a message bubble) */
.bmd-typing-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: .15rem 0;
}
.bmd-typing-inline span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #aab;
  display: block;
  animation: bmd-bounce .9s infinite ease-in-out;
}
.bmd-typing-inline span:nth-child(2) { animation-delay: .15s; }
.bmd-typing-inline span:nth-child(3) { animation-delay: .3s; }
@keyframes bmd-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-6px); }
}

/* Input area */
.bmd-chat-footer {
  padding: .65rem .75rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: .5rem;
  background: #fff;
  flex-shrink: 0;
}
.bmd-chat-footer input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: .45rem .9rem;
  font-size: .84rem;
  outline: none;
  font-family: inherit;
  transition: border-color .15s;
}
.bmd-chat-footer input:focus {
  border-color: var(--blue);
}
.bmd-chat-footer input:disabled {
  background: #f4f7fb;
}
.bmd-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--navy);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  transition: background .15s;
  flex-shrink: 0;
}
.bmd-chat-send:hover   { background: var(--blue); }
.bmd-chat-send:disabled { background: #aab; cursor: default; }

/* Product cards */
.bmd-product-cards {
  display: flex;
  gap: .5rem;
  overflow-x: auto;
  padding: .25rem 0;
  align-self: stretch;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.bmd-product-cards::-webkit-scrollbar { display: none; }

.bmd-product-card {
  flex: 0 0 128px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  text-decoration: none;
  color: var(--dark);
  display: flex;
  flex-direction: column;
  transition: border-color .15s, box-shadow .15s;
}
.bmd-product-card:hover {
  border-color: var(--blue);
  box-shadow: var(--shadow-hover);
}
.bmd-product-card img {
  width: 100%;
  height: 76px;
  object-fit: contain;
  background: #f4f7fb;
  padding: .4rem;
}
.bmd-product-no-img {
  width: 100%;
  height: 76px;
  background: #f4f7fb;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #aab;
  font-size: 1.6rem;
}
.bmd-product-card-info {
  padding: .4rem .5rem .5rem;
  flex: 1;
}
.bmd-product-card-name {
  font-size: .72rem;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.bmd-product-card-price {
  font-size: .72rem;
  color: var(--navy);
  font-weight: 700;
  margin-top: .25rem;
}

/* Email recap form */
.bmd-email-form {
  background: #eef6ff;
  border: 1.5px solid #b8d9f8;
  border-radius: 10px;
  padding: .65rem .85rem;
  align-self: stretch;
}
.bmd-email-prompt {
  font-size: .8rem;
  font-weight: 600;
  color: var(--navy);
  margin: 0 0 .5rem;
}
.bmd-email-row {
  display: flex;
  gap: .4rem;
}
.bmd-email-row input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: .35rem .8rem;
  font-size: .8rem;
  font-family: inherit;
  outline: none;
  transition: border-color .15s;
}
.bmd-email-row input:focus { border-color: var(--blue); }
.bmd-email-btn {
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 20px;
  padding: .35rem .9rem;
  font-size: .8rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.bmd-email-btn:hover     { background: var(--blue); }
.bmd-email-btn:disabled  { background: #aab; cursor: default; }
#bmd-email-result        { font-size: .78rem; margin-top: .4rem; }
.bmd-email-ok  { color: #8BBD06; }
.bmd-email-err { color: #dc3545; }

/* Suggestions rapides */
.bmd-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  padding: .25rem 0 .1rem;
  align-self: flex-start;
}
.bmd-suggestion {
  background: #fff;
  border: 1.5px solid var(--blue);
  color: var(--blue);
  border-radius: 20px;
  padding: .35rem .85rem;
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.bmd-suggestion:hover {
  background: var(--blue);
  color: #fff;
}
/* Feedback 👍 👎 */
.bmd-feedback {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .4rem .85rem;
  font-size: .76rem;
  color: #9aabb8;
  align-self: flex-start;
  flex-wrap: wrap;
}
.bmd-feedback-btn {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: .2rem .55rem;
  font-size: .9rem;
  line-height: 1.4;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.bmd-feedback-btn:hover { border-color: var(--blue); background: #f0f7ff; }
.bmd-feedback-result    { font-size: .76rem; color: #9aabb8; }

.bmd-suggestions-hint {
  width: 100%;
  font-size: .72rem;
  color: #9aabb8;
  margin-top: .2rem;
  font-style: italic;
}

@media (max-width: 400px) {
  .bmd-chat-panel { width: calc(100vw - 2rem); }
  #bmd-chat-widget { right: 1rem; bottom: 190px; }
}

/* Intégration dans le thème WordPress : Bootstrap ne doit pas restyler le header/footer du thème */
.site-header a, .site-footer a, .main-nav a { text-decoration: none; }
.bmd-app-wrap { min-height: 60vh; }
