/* Pop-up Mimi — assistante IA publique de la marketplace. Couleurs MimiMSN
   (orange #f25c05). Responsive mobile irréprochable : 100dvh, safe-area-inset,
   seule la zone messages défile, input jamais coupé, fermeture toujours visible. */
.mimi {
  --mimi-brand: var(--brand, #f25c05);
  --mimi-brand-dark: var(--brand-dark, #d14f04);
  --mimi-brand-soft: var(--brand-soft, #fff1e8);
  --mimi-ink: #1f2933;
  --mimi-line: #efe7df;
  font-family: "Plus Jakarta Sans", system-ui, sans-serif;
}

/* ── Bouton flottant ── */
.mimi-fab {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 1200;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 54px;
  padding: 0 20px 0 16px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--mimi-brand), var(--mimi-brand-dark));
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(242, 92, 5, .42);
  transition: transform .15s ease, box-shadow .15s ease;
}
.mimi-fab:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(242, 92, 5, .5); }
.mimi-fab:active { transform: translateY(0); }
.mimi-fab-ico { flex-shrink: 0; }
.mimi[data-state="open"] .mimi-fab { display: none; }

/* ── Panneau ── */
.mimi-panel {
  position: fixed;
  z-index: 1201;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  width: 384px;
  max-width: calc(100vw - 36px);
  height: min(640px, 82vh);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--mimi-line);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(16, 42, 67, .28);
  animation: mimi-pop .18s ease;
}
@keyframes mimi-pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

/* ── En-tête (toujours visible) ── */
.mimi-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 12px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  background: linear-gradient(135deg, var(--mimi-brand), var(--mimi-brand-dark));
  color: #fff;
}
.mimi-head-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.mimi-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, .2); color: #fff; flex-shrink: 0;
}
.mimi-head-txt { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.mimi-head-txt strong { font-size: 15px; }
.mimi-head-txt small { font-size: 11.5px; opacity: .9; }
.mimi-close {
  flex-shrink: 0;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: none; border-radius: 10px;
  background: rgba(255, 255, 255, .16); color: #fff; cursor: pointer;
  transition: background .15s ease;
}
.mimi-close:hover { background: rgba(255, 255, 255, .3); }

/* ── Zone messages : SEULE partie qui défile ── */
.mimi-msgs {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: 14px;
  background: #faf8f5;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mimi-row { display: flex; }
.mimi-row.user { justify-content: flex-end; }
.mimi-bubble {
  max-width: 86%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.mimi-row.bot .mimi-bubble { background: #fff; color: var(--mimi-ink); border: 1px solid var(--mimi-line); border-bottom-left-radius: 4px; }
.mimi-row.user .mimi-bubble { background: var(--mimi-brand); color: #fff; border-bottom-right-radius: 4px; }
.mimi-bubble a { color: var(--mimi-brand-dark); font-weight: 600; }
.mimi-row.user .mimi-bubble a { color: #fff; text-decoration: underline; }

/* ── Cartes produit dans le fil ── */
.mimi-cards { display: flex; flex-direction: column; gap: 8px; margin-top: 2px; }
.mimi-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; background: #fff;
  border: 1px solid var(--mimi-line); border-radius: 13px;
  text-decoration: none; color: var(--mimi-ink);
  transition: border-color .15s ease, box-shadow .15s ease, transform .1s ease;
}
.mimi-card:hover { border-color: var(--mimi-brand); box-shadow: 0 6px 16px rgba(242, 92, 5, .14); transform: translateY(-1px); }
.mimi-card-img { width: 52px; height: 52px; flex-shrink: 0; border-radius: 9px; background: #fff; border: 1px solid var(--mimi-line); object-fit: contain; padding: 3px; }
.mimi-card-body { flex: 1 1 auto; min-width: 0; }
.mimi-card-name { font-size: 13px; font-weight: 600; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mimi-card-meta { font-size: 11.5px; color: #829ab1; margin-top: 2px; }
.mimi-card-price { font-size: 13.5px; font-weight: 800; color: var(--mimi-brand-dark); margin-top: 1px; }
.mimi-card-go {
  flex-shrink: 0; align-self: center;
  font-size: 12px; font-weight: 700; color: var(--mimi-brand-dark);
  background: var(--mimi-brand-soft); border-radius: 8px; padding: 6px 10px;
}

/* ── Indicateur de saisie ── */
.mimi-typing { display: inline-flex; gap: 4px; padding: 11px 13px; }
.mimi-typing span { width: 7px; height: 7px; border-radius: 50%; background: #bcccdc; animation: mimi-bounce 1s infinite; }
.mimi-typing span:nth-child(2) { animation-delay: .15s; }
.mimi-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes mimi-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .6; } 30% { transform: translateY(-5px); opacity: 1; } }

/* ── Suggestions rapides ── */
.mimi-suggest { flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 12px 0; }
.mimi-chip {
  border: 1px solid var(--mimi-line); background: #fff; color: var(--mimi-ink);
  font: inherit; font-size: 12px; font-weight: 600;
  padding: 6px 11px; border-radius: 999px; cursor: pointer; transition: all .12s ease;
}
.mimi-chip:hover { border-color: var(--mimi-brand); color: var(--mimi-brand-dark); background: var(--mimi-brand-soft); }
.mimi-suggest.hide { display: none; }

/* ── Saisie (jamais coupée, safe-area en bas) ── */
.mimi-input {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--mimi-line);
  background: #fff;
}
.mimi-input input {
  flex: 1 1 auto; min-width: 0;
  height: 42px; padding: 0 14px;
  border: 1px solid var(--mimi-line); border-radius: 999px;
  font: inherit; font-size: 14px; color: var(--mimi-ink);
  background: #faf8f5;
}
.mimi-input input:focus { outline: none; border-color: var(--mimi-brand); background: #fff; }
.mimi-send {
  flex-shrink: 0;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border: none; border-radius: 50%;
  background: var(--mimi-brand); color: #fff; cursor: pointer;
  transition: background .15s ease, transform .1s ease;
}
.mimi-send:hover { background: var(--mimi-brand-dark); }
.mimi-send:disabled { opacity: .5; cursor: default; }

/* ── Mobile : plein écran, 100dvh, safe-areas ── */
@media (max-width: 560px) {
  .mimi-panel {
    right: 0; left: 0; bottom: 0; top: 0;
    width: 100%; max-width: 100%;
    height: 100dvh;
    border: none; border-radius: 0;
  }
  .mimi-fab { right: 14px; bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }
}

/* Empêche le scroll du fond quand le panneau est ouvert sur mobile */
body.mimi-lock { overflow: hidden; }
@media (min-width: 561px) { body.mimi-lock { overflow: auto; } }
