/* Relies on the theme's :root custom properties (main.css) — fallbacks included so this
   plugin still renders sensibly if loaded without that stylesheet. */

/* ============ Floating badge ============ */
.mec-ia-badge {
  position: fixed; right: 28px; bottom: 28px; z-index: 300;
  height: 58px; border-radius: 999px; padding: 0 22px 0 8px;
  background: linear-gradient(135deg, var(--vert-foret, #1B5E20), var(--bleu-fleuve, #1565C0));
  border: 2px solid var(--dore, #B8935A);
  color: #fff; cursor: pointer;
  display: flex; align-items: center; gap: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  transition: transform .2s;
}
.mec-ia-badge:hover { transform: translateY(-3px) scale(1.03); }
.mec-ia-badge-hidden { display: none; }
.mec-ia-badge-icon-wrap {
  position: relative; width: 42px; height: 42px; border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.mec-ia-badge-icon { position: relative; z-index: 1; font-size: 22px; }
.mec-ia-badge-label {
  font-family: 'Montserrat', sans-serif; font-weight: 800; font-size: 15px; letter-spacing: .02em;
}
.mec-ia-badge-pulse {
  position: absolute; inset: -5px; border-radius: 50%;
  border: 2px solid var(--dore-clair, #D4B483);
  animation: mec-ia-pulse 2.4s ease-out infinite;
}
@keyframes mec-ia-pulse {
  0% { transform: scale(0.85); opacity: .8; }
  100% { transform: scale(1.3); opacity: 0; }
}

/* ============ Drawer ============ */
.mec-ia-drawer {
  position: fixed; top: 0; right: 0; height: 100vh; height: 100dvh; width: 400px; max-width: 92vw;
  background: #fff; z-index: 299;
  box-shadow: -20px 0 60px rgba(0,0,0,0.25);
  display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform .35s ease;
}
.mec-ia-drawer.open { transform: translateX(0); }

.mec-ia-drawer-head {
  background: var(--vert-foret, #1B5E20); color: #fff;
  padding: 20px 22px; display: flex; align-items: center; justify-content: space-between;
}
.mec-ia-drawer-head-id { display: flex; align-items: center; gap: 12px; }
.mec-ia-drawer-avatar {
  width: 40px; height: 40px; border-radius: 50%; background: rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0;
}
.mec-ia-drawer-title { font-family: 'Montserrat', sans-serif; font-weight: 800; font-size: 16px; }
.mec-ia-drawer-sub { font-size: 12px; color: rgba(255,255,255,0.75); margin-top: 2px; }
.mec-ia-close { background: none; border: none; color: #fff; font-size: 26px; cursor: pointer; line-height: 1; }

/* overflow-x: hidden as a hard backstop — nothing inside (a long filename, an
   unbroken URL…) should ever be able to force the drawer itself to scroll sideways. */
.mec-ia-messages { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.mec-ia-msg { max-width: 88%; padding: 12px 15px; border-radius: 12px; font-size: 14px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.mec-ia-msg-bot { background: var(--beige, #F4EFE3); color: #1C2620; align-self: flex-start; border-bottom-left-radius: 3px; }
.mec-ia-msg-user { background: var(--vert-foret, #1B5E20); color: #fff; align-self: flex-end; border-bottom-right-radius: 3px; }
.mec-ia-msg-error { background: #FDECEC; color: #9A2323; }

.mec-ia-sources { align-self: flex-start; max-width: 88%; display: flex; flex-direction: column; gap: 6px; margin-top: -4px; }
.mec-ia-sources-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-soft, #5B6B60); font-weight: 700; }
/* A source title comes straight from a document/attachment filename — often long and
   with no spaces to break on naturally — so it needs an explicit permission to wrap. */
.mec-ia-source-link { display: block; font-size: 12.5px; color: var(--bleu-fleuve, #1565C0); text-decoration: underline; overflow-wrap: anywhere; }

.mec-ia-tools { padding: 0 20px 10px; }
.mec-ia-simplify-btn {
  width: 100%; background: var(--beige, #F4EFE3); border: 1px solid var(--beige-fonce, #E8DFC8);
  border-radius: 8px; padding: 10px 12px; font-size: 13px; font-weight: 600; color: var(--vert-foret, #1B5E20);
  cursor: pointer; transition: background .2s;
}
.mec-ia-simplify-btn:hover { background: var(--beige-fonce, #E8DFC8); }

.mec-ia-form { display: flex; gap: 8px; padding: 16px 20px; border-top: 1px solid #eee; }
.mec-ia-form input {
  /* 16px minimum — below that, iOS Safari auto-zooms the whole page on focus, which is
     what made the drawer look shifted/zoomed and hard to type into on mobile. */
  flex: 1; border: 1px solid #ddd; border-radius: 8px; padding: 11px 14px; font-size: 16px; font-family: inherit;
}
.mec-ia-form input:focus { outline: 2px solid var(--dore, #B8935A); outline-offset: 1px; }
.mec-ia-form button {
  width: 42px; height: 42px; border-radius: 8px; border: none; background: var(--dore, #B8935A);
  color: #1a1400; font-size: 16px; cursor: pointer; flex-shrink: 0;
}
.mec-ia-form button:hover { background: var(--dore-clair, #D4B483); }

.mec-ia-disclaimer { font-size: 10.5px; color: var(--text-soft, #5B6B60); text-align: center; padding: 0 16px 14px; line-height: 1.4; }

/* ============ HeroIA (homepage search) ============ */
.mec-hero-ia { position: relative; z-index: 2; max-width: 640px; margin-top: 36px; }
.mec-hero-ia-label {
  font-family: 'Montserrat', sans-serif; font-weight: 700; font-size: 13px; letter-spacing: .03em;
  color: var(--dore-clair, #D4B483); margin-bottom: 10px; display: flex; align-items: center; gap: 8px;
}
.mec-hero-ia-form {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.35);
  backdrop-filter: blur(10px); border-radius: 999px; padding: 8px 8px 8px 20px;
}
.mec-hero-ia-icon { color: var(--dore-clair, #D4B483); font-size: 16px; }
.mec-hero-ia-form input {
  /* 16px minimum — same iOS auto-zoom-on-focus issue as the drawer's input. */
  flex: 1; background: none; border: none; color: #fff; font-size: 16px; font-family: inherit; padding: 10px 0;
}
.mec-hero-ia-form input::placeholder { color: rgba(255,255,255,0.65); }
.mec-hero-ia-form input:focus { outline: none; }
.mec-hero-ia-form button {
  background: var(--dore, #B8935A); color: #1a1400; border: none; border-radius: 999px;
  padding: 11px 22px; font-family: 'Montserrat', sans-serif; font-weight: 700; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.mec-hero-ia-form button:hover { background: var(--dore-clair, #D4B483); }

.mec-hero-ia-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.mec-hero-ia-chip {
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.25); color: rgba(255,255,255,0.9);
  border-radius: 999px; padding: 8px 16px; font-size: 12.5px; cursor: pointer; transition: all .2s;
}
.mec-hero-ia-chip:hover { background: rgba(255,255,255,0.18); border-color: var(--dore-clair, #D4B483); }

.mec-hero-ia-answer {
  position: absolute; top: calc(100% + 14px); left: 0; right: 0;
  background: #fff; border-radius: 12px; padding: 22px 24px; box-shadow: 0 30px 60px rgba(0,0,0,0.3);
  color: #1C2620; max-width: 100%; overflow-x: hidden; box-sizing: border-box;
}
.mec-hero-ia-answer-close { position: absolute; top: 10px; right: 14px; background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-soft, #5B6B60); }
.mec-hero-ia-answer-body { font-size: 14.5px; line-height: 1.65; padding-right: 20px; white-space: pre-wrap; overflow-wrap: anywhere; }
.mec-hero-ia-answer-sources { margin-top: 14px; display: flex; flex-direction: column; gap: 6px; }
.mec-hero-ia-answer-sources .mec-ia-sources-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-soft, #5B6B60); font-weight: 700; }
.mec-hero-ia-answer-sources .mec-ia-source-link { font-size: 12.5px; color: var(--bleu-fleuve, #1565C0); text-decoration: underline; display: block; overflow-wrap: anywhere; }

.mec-ia-loading { display: inline-flex; align-items: center; gap: 5px; padding: 4px 0; }
.mec-ia-loading span {
  width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: .35;
  animation: mec-ia-bounce 1.1s infinite ease-in-out;
}
.mec-ia-loading span:nth-child(2) { animation-delay: .15s; }
.mec-ia-loading span:nth-child(3) { animation-delay: .3s; }
@keyframes mec-ia-bounce {
  0%, 80%, 100% { opacity: .35; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

@media (max-width: 760px) {
  /* `inset: 0` (not `width: 100vw`) — if anything on the page ever overflows
     horizontally, `100vw` is measured against that wider layout viewport rather than
     what's actually visible, so a "full width" panel ends up covering only part of the
     screen exactly like the desktop-style drawer looked here. Pinning all four edges
     is immune to that regardless of the cause, and matches a full-screen mobile chat
     sheet (à la Cdiscount) rather than a scaled-down desktop side panel. */
  .mec-ia-drawer { inset: 0; width: auto; max-width: none; border-radius: 0; }
  .mec-ia-badge { right: 12px; bottom: 12px; height: 50px; padding: 0 16px 0 6px; gap: 8px; }
  .mec-ia-badge-icon-wrap { width: 36px; height: 36px; }
  .mec-ia-badge-icon { font-size: 18px; }
  .mec-ia-badge-label { font-size: 13px; }
  .mec-hero-ia-form { flex-wrap: wrap; border-radius: 16px; padding: 14px; }
  .mec-hero-ia-form input { width: 100%; }
  .mec-hero-ia-form button { width: 100%; }
}
