/* ==============================
   AI Chatbot – CSS V1
   Adapted to mgpt-* structure
   ============================== */

#mgpt-chatbot {
  width: 100%;
  margin: 40px auto;
  max-width: 900px;
}

.mgpt-chatbot-inner {

  --border-radius: 14px;
  --border-width: 2px;
  --border-color: var(--mgpt-border-color, #ff6a00);
  --spacing: 12px;

  --bg-user: var(--mgpt-user-bg, #6c5ce7);
  --bg-bot: var(--mgpt-bot-bg, #f4f6ff);

  font-family: inherit;
  color: inherit;

  border: var(--border-width) solid var(--border-color);
  border-radius: var(--border-radius);

  background: #ffffff;

  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);

  width: 100%;
  box-sizing: border-box;

  display: flex;
  flex-direction: column;
}

/* Message area */
#mgpt-chat-messages {
  padding: var(--spacing);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Messages injected by JS */
.mgpt-message {
  display: flex;
}

/* User message */
.mgpt-message.user {
  justify-content: flex-end;
}

/* Bot message */
.mgpt-message.bot {
  justify-content: flex-start;
}

.mgpt-message.bot,
.mgpt-message.user {
  line-height: 1.6;
}

/* Bubble */
.mgpt-bubble {
  padding: 12px 16px;
  border-radius: var(--border-radius);
  max-width: 75%;
  font-size: 0.95em;
  line-height: 1.6;
}

.mgpt-message.user .mgpt-bubble {
  background: var(--bg-user);
}

.mgpt-message.bot .mgpt-bubble {
  background: var(--bg-bot);
}

/* Form */
#mgpt-chat-form {
  display: flex;
  gap: 8px;
  padding: var(--spacing);
  border-top: 1px solid #ffffff;
}

#mgpt-chat-input {
  flex: 1;
  font-family: inherit;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--mgpt-input-bg-color, #ffffff);
  border: 1px solid #c0c0c0; /* gris argenté */
}

#mgpt-chat-input:focus {
  outline: none;
  border-color: #a8a8a8;
  box-shadow: 0 0 0 2px rgba(192,192,192,0.2);
}

#mgpt-chat-form button {
  font-family: inherit;
  padding: 0;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: none;
  background: var(--mgpt-button-bg, #38bdf8);
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

#mgpt-chat-form button::before {
  content: "";
  width: 18px;
  height: 18px;
  background: white;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M2 21l21-9L2 3v7l15 2-15 2z'/%3E%3C/svg%3E") no-repeat center;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M2 21l21-9L2 3v7l15 2-15 2z'/%3E%3C/svg%3E") no-repeat center;
  mask-size: contain;
  -webkit-mask-size: contain;
}

#mgpt-chat-form button:hover {
  background: var(--mgpt-button-hover-color, #0ea5e9);
  transform: scale(1.05);
}

/* ==============================
   Floating Bubble Mode
============================== */

#mgpt-floating-wrapper {
  position: fixed;
  bottom: 20px;
  z-index: 999999;
  pointer-events: auto;
}

#mgpt-floating-bubble {
  pointer-events: auto;
}

.mgpt-position-right {
  right: 20px;
}

.mgpt-position-left {
  left: 20px;
}

/* Bulle ronde */
#mgpt-floating-bubble {
  width: 90px;
  height: 90px;
  background: var(--mgpt-bubble-color, #ff6a00);
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(0,0,0,0.25);
  font-size: 28px;
}

/* Fenêtre cachée par défaut */
#mgpt-floating-chat {
  width: 350px;
  margin-bottom: 10px;
}

.mgpt-hidden {
  display: none;
}

/* =========================
   True Progressive Height System
========================= */

.mgpt-chatbot-inner {
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

#mgpt-chat-messages {
  flex: 1;
  overflow-y: auto;
}

/* =========================
   Close Button
========================= */

#mgpt-close-chat {
  width: 42px;
  height: 42px;
  margin: 12px auto 16px auto;
  border-radius: 50%;
  border: none;
  background: var(--mgpt-bubble-color, #ff6a00);
  color: #ffffff;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

#mgpt-close-chat:hover {
  transform: scale(1.08);
  opacity: 0.9;
}

.mgpt-timer {
  font-size: 12px;
  opacity: 0.7;
  font-style: italic;
}