/* ============================================================
   Looper Chat — External Shell CSS
   Gère uniquement le positionnement et la visibilité des
   éléments Light DOM : #chat-box, #chat-bubble, #chatClose
   Le style interne (bulles, input, drawer citations…)
   est entièrement dans le Shadow DOM.
   ============================================================ */

/* ── Base chat-box ────────────────────────────────────────── */
#chat-box {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  display: none; /* Contrôlé par body.chat-open */
  flex-direction: column;
  background: #fff;
  overflow: hidden;
  z-index: 9999;
  font-family: "Lato", "Helvetica Neue", Arial, sans-serif;
  border-radius: 0;
  box-shadow: none;
}

#chat-box looper-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* ── Bubble ───────────────────────────────────────────────── */
#chat-bubble {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--lc-primary, #ca161a);
  color: white;
  font-size: 1.4rem;
  display: none; /* Contrôlé par body.has-mini */
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  z-index: 9999;
  transition: background 0.15s, transform 0.15s;
  user-select: none;
}
#chat-bubble:hover {
  background: var(--lc-primary-dark, #a81215);
  transform: scale(1.05);
}
#chat-bubble:has(img):hover {
  background: transparent !important;
}

/* ── Close button ─────────────────────────────────────────── */
#chatClose {
  display: none; /* Contrôlé par body.chat-open */
  position: absolute;
  top: 15px;
  right: 15px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  font-size: 16px;
  color: #666;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  transition: all 0.2s ease;
  z-index: 10000;
}
#chatClose:hover { background: #f5f5f5; color: #333; }

/* ── Visibility classes ───────────────────────────────────── */
.hidden { display: none !important; }
body.chat-open.has-mini { overflow: hidden; }

/* ── Maxi ─────────────────────────────────────────────────── */
body.has-maxi #chat-bubble { display: none; }
body.chat-open.has-maxi #chat-box.mode-maxi { display: flex; }

@media (min-width: 768px) {
  #chat-box.mode-maxi {
    inset: 0;
    margin: auto;
    width: min(90vw, 900px);
    height: 90dvh;
    border-radius: 12px;
  }
}

/* ── Mini ─────────────────────────────────────────────────── */
body.has-mini:not(.chat-open) #chat-bubble { display: flex; }
body.chat-open.has-mini #chat-box.mode-mini { display: flex; }
body.chat-open.has-mini #chatClose { display: flex; }

@media (min-width: 768px) {
  #chat-box.mode-mini {
    inset: auto;
    bottom: 5rem;
    right: 1.5rem;
    left: auto;
    top: auto;
    width: 420px;
    height: min(80dvh, 720px);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.16);
    border: 1px solid #e2e8f0;
  }
}
@media (min-width: 1024px) {
  #chat-box.mode-mini {
    width: 460px;
    height: min(85dvh, 800px);
  }
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 600px) {
  #chat-box.mode-mini { width: calc(100vw - 2rem); right: 1rem; }
}