/* ===========================================================================
   MP Chatbot — самописная копия виджета Pipedrive LeadBooster
   Дизайн снят с живого виджета modernipravnik.cz + playbookSettings:
   headerColor #7a1e2c (бордовый), mainColor #77675b, botName ModerniPravnik.cz
   Без зависимостей. Встраивается одним <script> + этим CSS.
   =========================================================================== */

.mpc, .mpc * { box-sizing: border-box; }

.mpc {
  --mpc-header: #7a1e2c;      /* бордовый — шапка/акцент */
  --mpc-accent: #7a1e2c;
  --mpc-main:   #77675b;      /* вторичный (аватар-фон и т.п.) */
  --mpc-bg:     #ffffff;
  --mpc-bot-bubble: #f1f1f1;
  --mpc-user-bubble: #7a1e2c;
  --mpc-user-text: #ffffff;
  --mpc-text:   #2b2b2b;
  --mpc-muted:  #8a8a8a;
  --mpc-border: #e4e4e4;
  --mpc-radius: 16px;
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--mpc-text);
}

/* ---- Кнопка-лаунчер (коричневый скруглённый квадрат + иконка чата) ---- */
.mpc-launcher {
  width: 60px; height: 60px;
  border-radius: 18px;
  border: none;
  background: var(--mpc-main);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
  display: flex; align-items: center; justify-content: center;
  padding: 0;
  transition: transform .15s ease, background .15s ease;
}
.mpc-launcher:hover { transform: scale(1.06); }
.mpc-launcher svg { width: 30px; height: 30px; }

/* ---- Окно чата ---- */
.mpc-window {
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 620px;
  max-height: calc(100vh - 100px);
  background: var(--mpc-bg);
  border-radius: var(--mpc-radius);
  box-shadow: 0 12px 48px rgba(0,0,0,.28);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.mpc.is-open .mpc-window { display: flex; }
.mpc.is-open .mpc-launcher { display: none; }

/* Шапка */
.mpc-header {
  background: var(--mpc-header);
  color: #fff;
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  flex: 0 0 auto;
}
.mpc-header img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--mpc-main); }
.mpc-header h1 { margin: 0; font-size: 18px; font-weight: 700; flex: 1; color: #fff !important; font-family: inherit; line-height: 1.2; }
.mpc-close {
  background: transparent; border: none; color: #fff; cursor: pointer;
  font-size: 22px; line-height: 1; padding: 4px; opacity: .9;
}
.mpc-close:hover { opacity: 1; }

/* Лента сообщений */
.mpc-body {
  flex: 1; overflow-y: auto;
  padding: 16px 14px;
  background: #fafafa;
  display: flex; flex-direction: column; gap: 10px;
}
.mpc-day { text-align: center; font-size: 12px; color: var(--mpc-muted); margin: 4px 0; }

.mpc-row { display: flex; align-items: flex-end; gap: 8px; max-width: 100%; }
.mpc-row.bot  { justify-content: flex-start; }
.mpc-row.user { justify-content: flex-end; }
.mpc-row .mpc-ava { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: 0 0 auto; background: var(--mpc-main); }
.mpc-row.user .mpc-ava { display: none; }

.mpc-bubble {
  padding: 10px 13px;
  border-radius: 16px;
  max-width: 78%;
  word-wrap: break-word;
  white-space: normal;
}
.mpc-row.bot  .mpc-bubble { background: var(--mpc-bot-bubble); border-bottom-left-radius: 4px; }
.mpc-row.user .mpc-bubble { background: var(--mpc-user-bubble); color: var(--mpc-user-text); border-bottom-right-radius: 4px; }
.mpc-bubble a { color: inherit; text-decoration: underline; }
.mpc-row.bot .mpc-bubble a { color: var(--mpc-accent); }

/* Индикатор «печатает» */
.mpc-typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.mpc-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: #b5b5b5;
  animation: mpc-blink 1.2s infinite both;
}
.mpc-typing span:nth-child(2) { animation-delay: .2s; }
.mpc-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes mpc-blink { 0%,80%,100% { opacity:.3 } 40% { opacity:1 } }

/* Кнопки-варианты */
.mpc-options { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 4px auto; align-items: flex-end; }
.mpc-option {
  background: #fff;
  border: 1.5px solid var(--mpc-accent);
  color: var(--mpc-accent);
  border-radius: 20px;
  padding: 9px 16px;
  cursor: pointer;
  font-size: 14.5px;
  text-align: right;
  max-width: 90%;
  transition: background .12s ease, color .12s ease;
}
.mpc-option:hover { background: var(--mpc-accent); color: #fff; }

/* Поле ввода */
.mpc-input {
  flex: 0 0 auto;
  border-top: 1px solid var(--mpc-border);
  padding: 10px 12px;
  display: none;
  gap: 8px; align-items: center;
  background: #fff;
}
.mpc-input.is-active { display: flex; }
.mpc-input input {
  flex: 1; border: none; outline: none; font-size: 15px; padding: 8px 6px; background: transparent;
}
.mpc-send {
  border: none; background: var(--mpc-accent); color: #fff;
  width: 38px; height: 38px; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
}
.mpc-send:disabled { background: #ccc; cursor: default; }
.mpc-send svg { width: 18px; height: 18px; }

/* Футер (без брендинга Pipedrive) */
.mpc-footer { text-align: center; font-size: 11px; color: var(--mpc-muted); padding: 6px; background:#fff; flex:0 0 auto; }

@media (max-width: 480px) {
  .mpc { right: 0; bottom: 0; left: 0; }
  .mpc-window { width: 100vw; height: 100vh; max-height: 100vh; border-radius: 0; }
  .mpc-launcher { right: 16px; }
  .mpc.is-open { right: 0; bottom: 0; }
}
