/* Миглиор — своя запись (YClients) + AI-ассистент. Заменяют Kontaktium/Onicon и мёртвую
   Megagroup-форму. Палитра подобрана под тёмно-зелёный фон и шалфейно-зелёные кнопки сайта. */
:root {
  --mg-bg: #14170f;
  --mg-panel: #1c211a;
  --mg-panel-2: #232a1f;
  --mg-accent: #9ab588;
  --mg-accent-dark: #7f9a6d;
  --mg-text: #f3f1e7;
  --mg-text-dim: #c7c9bd;
  --mg-border: rgba(255, 255, 255, 0.12);
  --mg-radius: 14px;
  --mg-font: "Open Sans", Arial, Helvetica, sans-serif;
}

/* Мёртвая форма Megagroup (без бэкенда) — прячем везде, где бы она ни лежала в разметке. */
form[data-s3-anketa-id] { display: none !important; }

#mg-widgets * { box-sizing: border-box; font-family: var(--mg-font); }

#mg-widgets { position: fixed; z-index: 999999; }

.mg-fab-stack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  z-index: 999999;
}

.mg-fab {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease;
}
.mg-fab:hover { transform: scale(1.06); }
.mg-fab:active { transform: scale(0.96); }

.mg-fab-chat { background: var(--mg-accent); color: #14170f; }
.mg-fab-book { background: var(--mg-panel); color: var(--mg-accent); border: 1px solid var(--mg-border); }

.mg-fab svg { width: 26px; height: 26px; }

/* ---------- Модалка записи ---------- */

.mg-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 7, 4, 0.72);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999998;
  padding: 16px;
}
.mg-overlay.mg-open { display: flex; }

.mg-modal {
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--mg-panel);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius);
  color: var(--mg-text);
  padding: 22px;
  position: relative;
}

.mg-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--mg-text-dim);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.mg-close:hover { color: var(--mg-text); }

.mg-title { font-size: 19px; margin: 0 0 4px; color: var(--mg-text); font-weight: 600; }
.mg-subtitle { font-size: 13px; color: var(--mg-text-dim); margin: 0 0 18px; }

.mg-step { display: none; }
.mg-step.mg-active { display: block; }

.mg-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }

.mg-option {
  text-align: left;
  background: var(--mg-panel-2);
  border: 1px solid var(--mg-border);
  color: var(--mg-text);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.mg-option:hover { border-color: var(--mg-accent); }
.mg-option small { color: var(--mg-text-dim); font-weight: 400; white-space: nowrap; }

.mg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.mg-chip {
  background: var(--mg-panel-2);
  border: 1px solid var(--mg-border);
  color: var(--mg-text);
  border-radius: 8px;
  padding: 9px 6px;
  cursor: pointer;
  font-size: 13px;
  text-align: center;
}
.mg-chip:hover { border-color: var(--mg-accent); }

.mg-back {
  background: none;
  border: none;
  color: var(--mg-accent);
  cursor: pointer;
  font-size: 13px;
  padding: 0 0 14px;
}

.mg-field { margin-bottom: 12px; }
.mg-field label { display: block; font-size: 12px; color: var(--mg-text-dim); margin-bottom: 5px; }
.mg-field input {
  width: 100%;
  background: var(--mg-panel-2);
  border: 1px solid var(--mg-border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--mg-text);
  font-size: 14px;
}
.mg-field input:focus { outline: none; border-color: var(--mg-accent); }

.mg-summary {
  background: var(--mg-panel-2);
  border: 1px solid var(--mg-border);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--mg-text-dim);
  margin-bottom: 14px;
  line-height: 1.5;
}
.mg-summary b { color: var(--mg-text); }

.mg-btn-primary {
  width: 100%;
  background: var(--mg-accent);
  border: none;
  color: #14170f;
  font-weight: 600;
  border-radius: 10px;
  padding: 13px;
  font-size: 14px;
  cursor: pointer;
}
.mg-btn-primary:hover { background: var(--mg-accent-dark); }
.mg-btn-primary:disabled { opacity: 0.6; cursor: default; }

.mg-empty { color: var(--mg-text-dim); font-size: 13px; padding: 8px 0; }
.mg-error { color: #e39a9a; font-size: 13px; margin-top: 10px; }
.mg-success { text-align: center; padding: 10px 0; }
.mg-success .mg-check {
  width: 52px; height: 52px; border-radius: 50%; background: var(--mg-accent);
  display: flex; align-items: center; justify-content: center; margin: 0 auto 14px; color: #14170f; font-size: 26px;
}

/* ---------- Чат-ассистент ---------- */

.mg-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 90px;
  width: 350px;
  max-width: calc(100vw - 32px);
  height: 480px;
  max-height: 70vh;
  background: var(--mg-panel);
  border: 1px solid var(--mg-border);
  border-radius: var(--mg-radius);
  display: none;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  z-index: 999999;
}
.mg-chat-panel.mg-open { display: flex; }

.mg-chat-head {
  background: var(--mg-panel-2);
  padding: 14px 16px;
  border-bottom: 1px solid var(--mg-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.mg-chat-head div b { color: var(--mg-text); font-size: 14px; display: block; }
.mg-chat-head div span { color: var(--mg-accent); font-size: 12px; }

.mg-chat-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }

.mg-msg { max-width: 84%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.45; white-space: pre-wrap; }
.mg-msg-bot { background: var(--mg-panel-2); color: var(--mg-text); align-self: flex-start; border-bottom-left-radius: 3px; }
.mg-msg-user { background: var(--mg-accent); color: #14170f; align-self: flex-end; border-bottom-right-radius: 3px; }
.mg-msg-typing { background: var(--mg-panel-2); color: var(--mg-text-dim); align-self: flex-start; font-style: italic; }

.mg-chat-input {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--mg-border);
}
.mg-chat-input input {
  flex: 1;
  background: var(--mg-panel-2);
  border: 1px solid var(--mg-border);
  border-radius: 20px;
  padding: 10px 14px;
  color: var(--mg-text);
  font-size: 13.5px;
}
.mg-chat-input input:focus { outline: none; border-color: var(--mg-accent); }
.mg-chat-input button {
  background: var(--mg-accent);
  border: none;
  border-radius: 50%;
  width: 38px;
  height: 38px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #14170f;
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .mg-chat-panel { right: 12px; left: 12px; width: auto; bottom: 84px; }
  .mg-fab-stack { right: 12px; bottom: 12px; }
}
