/* =====================================================
   MauriceBot — Chatbot flottant Loca'Gonfle
   codebless.io · v1.0.0
   Palette : Rose #d50b6a · Violet #412a6a · Fond #FAF9FC
   ===================================================== */

:root {
  --mb-primary:     #fc00a3;
  --mb-primary-dk:  #d4008a;
  --mb-secondary:   #412a6a;
  --mb-bg:          #FAF9FC;
  --mb-white:       #ffffff;
  --mb-grey-light:  #f0edf5;
  --mb-grey-text:   #6b6580;
  --mb-radius:      18px;
  --mb-radius-sm:   10px;
  --mb-shadow:      0 8px 32px rgba(65, 42, 106, 0.22);
  --mb-shadow-lg:   0 16px 48px rgba(65, 42, 106, 0.28);
  --mb-font:        'Poppins', system-ui, -apple-system, sans-serif;
  --mb-z:           999999;
  --mb-w:           370px;
  --mb-h:           540px;
}

/* === Conteneur racine === */
#mauricebot-root {
  position: fixed !important;
  bottom: 16px !important;
  right: 16px !important;
  z-index: 2147483647 !important; /* valeur max int32 — impossible à dépasser */
  isolation: isolate;
  font-family: var(--mb-font);
  font-size: 14px;
  line-height: 1.4;
}

/* === Bulle flottante === */
#mauricebot-bubble {
  position: relative;
  z-index: 999999;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--mb-primary);
  color: var(--mb-white);
  border: none;
  border-radius: 22px;
  height: 44px;
  padding: 0 18px 0 10px;
  cursor: pointer;
  box-shadow: var(--mb-shadow);
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), box-shadow 0.25s ease, background 0.2s;
  position: relative;
  font-family: var(--mb-font);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.01em;
  outline: none;
  line-height: 1;
}

#mauricebot-bubble:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: var(--mb-shadow-lg);
  background: var(--mb-primary-dk);
}

#mauricebot-bubble:active {
  transform: scale(0.97);
}

.mb-bubble-icon {
  width: 36px;
  height: 36px;
  object-fit: cover;
  flex-shrink: 0;
  border-radius: 50%;
  display: block;
}

.mb-bubble-label {
  white-space: nowrap;
}

.mb-bubble-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ff4444;
  color: white;
  font-size: 11px;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

/* === Fenêtre du chat === */
.mb-window {
  position: fixed;
  bottom: 76px;
  right: 16px;
  z-index: 999999;
  width: var(--mb-w);
  height: var(--mb-h);
  background: var(--mb-bg);
  border-radius: var(--mb-radius);
  box-shadow: var(--mb-shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transition: transform 0.3s cubic-bezier(.34,1.2,.64,1), opacity 0.25s ease;
}

.mb-window--closed {
  transform: scale(0.85) translateY(12px);
  opacity: 0;
  pointer-events: none;
}

.mb-window--open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* === En-tête === */
.mb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 14px 16px;
  background: var(--mb-secondary);
  color: var(--mb-white);
  flex-shrink: 0;
}

.mb-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mb-avatar {
  width: 42px;
  height: 42px;
  object-fit: cover;
  flex-shrink: 0;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  padding: 2px;
}

.mb-header-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
}

.mb-header-sub {
  font-size: 11px;
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
}

.mb-online-dot {
  width: 7px;
  height: 7px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
  animation: mb-pulse 2s ease-in-out infinite;
}

@keyframes mb-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.mb-header-actions {
  display: flex;
  gap: 4px;
}

.mb-btn-icon {
  background: rgba(255,255,255,0.1);
  border: none;
  color: white;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

.mb-btn-icon svg {
  width: 16px;
  height: 16px;
}

.mb-btn-icon:hover {
  background: rgba(255,255,255,0.25);
}

/* === Zone messages === */
.mb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.mb-messages::-webkit-scrollbar { width: 4px; }
.mb-messages::-webkit-scrollbar-track { background: transparent; }
.mb-messages::-webkit-scrollbar-thumb { background: #d0cce0; border-radius: 4px; }

/* Bulles messages */
.mb-msg {
  display: flex;
  gap: 8px;
  animation: mb-msg-in 0.3s cubic-bezier(.34,1.2,.64,1);
}

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

.mb-msg--bot { align-self: flex-start; max-width: 88%; }
.mb-msg--user { align-self: flex-end; flex-direction: row-reverse; max-width: 80%; }

.mb-msg-avatar {
  width: 34px;
  height: 34px;
  object-fit: cover;
  flex-shrink: 0;
  margin-top: 2px;
  border-radius: 50%;
  background: var(--mb-grey-light);
}

/* Surcharge règles WooCommerce qui écrasent les img du plugin */
#mauricebot-root img,
.woocommerce #mauricebot-root img,
.woocommerce-page #mauricebot-root img {
  width: auto;
  height: auto;
  max-width: none;
}

#mauricebot-root .mb-bubble-icon {
  width: 36px !important;
  height: 36px !important;
  max-width: 36px !important;
}

#mauricebot-root .mb-avatar {
  width: 42px !important;
  height: 42px !important;
  max-width: 42px !important;
}

#mauricebot-root .mb-msg-avatar {
  width: 34px !important;
  height: 34px !important;
  max-width: 34px !important;
}

.mb-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.6;
}

.mb-msg--bot .mb-msg-bubble {
  background: var(--mb-white);
  color: #2d1a44;
  border: 1px solid rgba(65,42,106,0.1);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(65,42,106,0.07);
}

.mb-msg--user .mb-msg-bubble {
  background: var(--mb-primary);
  color: var(--mb-white);
  border-bottom-right-radius: 4px;
}

/* Formatage markdown basique dans les bulles */
.mb-msg-bubble strong { font-weight: 700; }
.mb-msg-bubble em     { font-style: italic; }
.mb-msg-bubble br     { display: block; margin-bottom: 4px; content: ""; }

/* Bloc RECAP masqué visuellement mais lisible */
.mb-recap-block {
  background: var(--mb-grey-light);
  border: 1px solid rgba(65,42,106,0.2);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  margin-top: 8px;
  white-space: pre-wrap;
  font-family: monospace;
  color: var(--mb-secondary);
}

/* CTA devis dans les messages bot */
.mb-devis-btn {
  display: inline-block;
  margin-top: 10px;
  background: var(--mb-primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s, transform 0.15s;
}

.mb-devis-btn:hover {
  background: var(--mb-primary-dk);
  transform: translateY(-1px);
}

/* === Indicateur de frappe === */
.mb-typing {
  padding: 8px 20px 4px;
  display: flex;
  gap: 5px;
  align-items: center;
  flex-shrink: 0;
}

.mb-typing span {
  width: 7px;
  height: 7px;
  background: var(--mb-secondary);
  border-radius: 50%;
  opacity: 0.4;
  animation: mb-type 1.2s ease-in-out infinite;
}

.mb-typing span:nth-child(2) { animation-delay: 0.2s; }
.mb-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes mb-type {
  0%, 100% { opacity: 0.2; transform: translateY(0); }
  50%       { opacity: 1;   transform: translateY(-4px); }
}

/* === Zone saisie === */
.mb-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(65,42,106,0.1);
  background: var(--mb-white);
  flex-shrink: 0;
}

.mb-input {
  flex: 1;
  border: 1px solid rgba(65,42,106,0.2);
  border-radius: 12px;
  padding: 9px 13px;
  font-family: var(--mb-font);
  font-size: 13.5px;
  color: #2d1a44;
  background: var(--mb-bg);
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  min-height: 40px;
  max-height: 100px;
  overflow-y: auto;
  line-height: 1.5;
}

.mb-input:focus {
  border-color: var(--mb-primary);
}

.mb-input::placeholder { color: #a09bb5; }

.mb-send-btn {
  width: 40px;
  height: 40px;
  background: var(--mb-primary);
  border: none;
  border-radius: 12px;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}

.mb-send-btn:hover  { background: var(--mb-primary-dk); transform: scale(1.05); }
.mb-send-btn:active { transform: scale(0.95); }
.mb-send-btn:disabled { background: #ccc; cursor: not-allowed; transform: none; }

.mb-send-btn svg { width: 18px; height: 18px; }

/* === Footer note === */
.mb-footer-note {
  text-align: center;
  font-size: 10.5px;
  color: var(--mb-grey-text);
  padding: 5px 10px 8px;
  background: var(--mb-white);
  flex-shrink: 0;
}

.mb-footer-note a { color: var(--mb-primary); text-decoration: none; }

/* === Mobile === */
@media (max-width: 480px) {
  #mauricebot-root {
    bottom: 16px;
    right: 16px;
  }

  .mb-window {
    width: calc(100vw - 32px);
    height: 80vh;
    right: 16px;
    bottom: 76px;
  }

  .mb-bubble-label {
    display: none;
  }

  #mauricebot-bubble {
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
    gap: 0;
  }
}

/* === Bouton ajout au panier === */
.mb-cart-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  background: #412a6a;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: background 0.2s, transform 0.15s;
  font-family: var(--mb-font);
}
.mb-cart-btn:hover   { background: #2d1a44; transform: translateY(-1px); }
.mb-cart-btn:disabled { background: #22c55e; cursor: default; transform: none; }

/* === Liens produits dans les bulles === */
.mb-product-link {
  display: inline-block;
  margin: 4px 0 2px;
  color: var(--mb-primary);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px solid var(--mb-primary);
  transition: opacity 0.2s;
}
.mb-product-link:hover { opacity: 0.75; }
