/* Плавающая кнопка и окно чата с помощником «Рекламной сметы».
   Стили кладутся в «Дополнительные стили» WordPress (wp_update_custom_css):
   тема YOOtheme свой style.css не подключает, а KSES вырезает <style> из контента. */

.rs-chat-root {
  --rs-accent: #1e87f0;
  --rs-accent-dark: #0f6ecd;
  --rs-radius: 16px;
  --rs-bg: #fff;
  --rs-text: #22303f;
  --rs-muted: #6b7b8c;
  --rs-line: #e3e8ee;
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9998;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* --- кнопка --- */
.rs-chat-fab {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  padding: 0 22px 0 18px;
  border: 0;
  border-radius: 28px;
  background: linear-gradient(135deg, var(--rs-accent), var(--rs-accent-dark));
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 6px 22px rgba(30, 135, 240, .38);
  transition: transform .18s ease, box-shadow .18s ease;
}

.rs-chat-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(30, 135, 240, .45); }
.rs-chat-fab:active { transform: translateY(0); }
.rs-chat-fab svg { width: 24px; height: 24px; flex: none; }
.rs-chat-fab-text { white-space: nowrap; }

/* Пульсирующая точка-подсказка, пока диалог не открыт. */
.rs-chat-fab[data-nudge="1"]::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 10px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #ff4d4f;
  box-shadow: 0 0 0 0 rgba(255, 77, 79, .7);
  animation: rs-pulse 2s infinite;
}

@keyframes rs-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(255, 77, 79, .7); }
  70%  { box-shadow: 0 0 0 12px rgba(255, 77, 79, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 77, 79, 0); }
}

/* --- окно --- */
.rs-chat-win {
  position: absolute;
  right: 0;
  bottom: 72px;
  display: none;
  flex-direction: column;
  width: 384px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: var(--rs-bg);
  border-radius: var(--rs-radius);
  box-shadow: 0 18px 56px rgba(16, 32, 48, .26);
  overflow: hidden;
}

.rs-chat-root[data-open="1"] .rs-chat-win { display: flex; }
.rs-chat-root[data-open="1"] .rs-chat-fab-text { display: none; }
.rs-chat-root[data-open="1"] .rs-chat-fab { padding: 0 16px; }

/* --- шапка --- */
.rs-chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--rs-accent), var(--rs-accent-dark));
  color: #fff;
}

.rs-chat-head-ava {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, .22);
  font-size: 19px;
}

.rs-chat-head-txt { flex: 1; min-width: 0; }
.rs-chat-head-title { font-size: 15px; font-weight: 600; line-height: 1.25; }
.rs-chat-head-sub { font-size: 12px; opacity: .88; margin-top: 2px; }

/* Счётчик бесплатных вопросов: когда остаётся один, подзаголовок заметнее. */
.rs-chat-head-sub[data-low="1"] { opacity: 1; font-weight: 600; }
.rs-chat-head-sub[data-low="1"]::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 5px;
  border-radius: 50%;
  background: #ffd83d;
  vertical-align: middle;
}

.rs-chat-close {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 26px;
  line-height: 1;
  padding: 0 4px;
  cursor: pointer;
  opacity: .85;
}

.rs-chat-close:hover { opacity: 1; }

/* --- лента сообщений --- */
.rs-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f7f9fb;
  scroll-behavior: smooth;
}

.rs-msg { display: flex; margin-bottom: 12px; }
.rs-msg-bot { justify-content: flex-start; }
.rs-msg-user { justify-content: flex-end; }

.rs-msg-bubble {
  max-width: 84%;
  padding: 11px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.rs-msg-bot .rs-msg-bubble {
  background: #fff;
  color: var(--rs-text);
  border: 1px solid var(--rs-line);
  border-bottom-left-radius: 4px;
}

.rs-msg-user .rs-msg-bubble {
  background: var(--rs-accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.rs-msg-note { font-size: 12px; color: var(--rs-muted); margin-top: 6px; }

/* Ссылка внутри текста сообщения — например, на официальную документацию. */
.rs-inline-link {
  color: var(--rs-accent-dark);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.rs-inline-link:hover { color: var(--rs-accent); }

.rs-msg-links { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--rs-line); }
.rs-msg-links-title { font-size: 12px; color: var(--rs-muted); margin-bottom: 5px; }
.rs-msg-links a {
  display: block;
  font-size: 13px;
  color: var(--rs-accent-dark);
  text-decoration: none;
  margin-bottom: 3px;
}
.rs-msg-links a:hover { text-decoration: underline; }

/* Точки «печатает» */
.rs-typing { display: flex; gap: 4px; padding: 4px 2px; }
.rs-typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: #b9c4d0; animation: rs-blink 1.3s infinite;
}
.rs-typing i:nth-child(2) { animation-delay: .18s; }
.rs-typing i:nth-child(3) { animation-delay: .36s; }

@keyframes rs-blink {
  0%, 60%, 100% { opacity: .35; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-3px); }
}

/* Быстрые подсказки-вопросы */
.rs-chat-chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 4px; }
.rs-chip {
  border: 1px solid var(--rs-line);
  background: #fff;
  color: var(--rs-accent-dark);
  font-size: 13px;
  padding: 7px 12px;
  border-radius: 16px;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.rs-chip:hover { background: #eef6fe; border-color: var(--rs-accent); }

/* --- блок контактов и заявки --- */
.rs-contacts {
  margin-top: 12px;
  padding: 13px 14px;
  background: #fff;
  border: 1px solid var(--rs-line);
  border-radius: 12px;
}
.rs-contacts-title { font-size: 13px; font-weight: 600; color: var(--rs-text); margin-bottom: 7px; }
.rs-contacts a { color: var(--rs-accent-dark); text-decoration: none; font-size: 13px; }
.rs-contacts a:hover { text-decoration: underline; }
.rs-contacts-row { margin-bottom: 4px; font-size: 13px; }

.rs-lead-form { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--rs-line); display: flex; flex-direction: column; gap: 8px; }
.rs-lead-form-title { font-size: 14px; font-weight: 600; color: var(--rs-text); line-height: 1.35; }
.rs-lead-form-hint { font-size: 12px; color: var(--rs-muted); line-height: 1.4; margin-top: -4px; }
.rs-lead-form input,
.rs-lead-form textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  border: 1px solid var(--rs-line);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
  color: var(--rs-text);
  background: #fff;
}
.rs-lead-form input:focus,
.rs-lead-form textarea:focus { outline: none; border-color: var(--rs-accent); }
.rs-lead-form textarea { resize: vertical; min-height: 54px; }

.rs-lead-consent {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 12px;
  color: var(--rs-muted);
  line-height: 1.4;
  cursor: pointer;
}
.rs-lead-consent input { width: auto; margin-top: 2px; flex: none; }
.rs-lead-consent a { color: var(--rs-accent-dark); }

.rs-btn {
  border: 0;
  border-radius: 9px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: background .15s ease, opacity .15s ease;
}
.rs-btn-primary { background: var(--rs-accent); color: #fff; }
.rs-btn-primary:hover { background: var(--rs-accent-dark); }
.rs-btn-ghost { background: #eef2f6; color: var(--rs-text); }
.rs-btn-ghost:hover { background: #e3e9ef; }
.rs-btn:disabled { opacity: .55; cursor: default; }

.rs-note { font-size: 12px; color: var(--rs-muted); margin-top: 7px; line-height: 1.45; }

/* --- поле ввода --- */
.rs-chat-foot {
  border-top: 1px solid var(--rs-line);
  background: #fff;
  padding: 10px 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.rs-chat-input {
  flex: 1;
  border: 1px solid var(--rs-line);
  border-radius: 11px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  color: var(--rs-text);
  resize: none;
  max-height: 110px;
  min-height: 42px;
  box-sizing: border-box;
}
.rs-chat-input:focus { outline: none; border-color: var(--rs-accent); }

.rs-chat-send {
  flex: none;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 11px;
  background: var(--rs-accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease, opacity .15s ease;
}
.rs-chat-send:hover { background: var(--rs-accent-dark); }
.rs-chat-send:disabled { opacity: .45; cursor: default; }
.rs-chat-send svg { width: 19px; height: 19px; }

.rs-chat-foot-note {
  font-size: 11px;
  color: var(--rs-muted);
  text-align: center;
  padding: 0 12px 9px;
  background: #fff;
  margin: 0;
}
.rs-chat-foot-note a { color: var(--rs-muted); text-decoration: underline; }

/* --- блок платного сопровождения --- */
.rs-tariffs {
  margin-top: 12px;
  padding: 14px;
  background: linear-gradient(135deg, #f4f9ff, #eaf3fd);
  border: 1px solid #cfe3f8;
  border-radius: 12px;
}
.rs-tariffs-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--rs-text);
  margin-bottom: 6px;
}
.rs-tariffs-note {
  font-size: 13px;
  line-height: 1.45;
  color: var(--rs-muted);
  margin-bottom: 11px;
}
.rs-tariffs-btn {
  display: block;
  text-align: center;
  text-decoration: none;
  margin-bottom: 8px;
}
.rs-tariffs-link {
  display: block;
  font-size: 13px;
  color: var(--rs-accent-dark);
  text-decoration: none;
}
.rs-tariffs-link:hover { text-decoration: underline; }

/* Поле ввода, закрытое после исчерпания лимита */
.rs-chat-input:disabled {
  background: #f2f5f8;
  color: var(--rs-muted);
  cursor: not-allowed;
}

/* --- мобильный --- */
@media (max-width: 640px) {
  .rs-chat-root { right: 16px; bottom: 16px; }
  .rs-chat-win {
    position: fixed;
    inset: 0;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    border-radius: 0;
    bottom: 0;
  }
  .rs-chat-fab { height: 52px; padding: 0 18px; }
  .rs-chat-fab-text { display: none; }
  .rs-chat-root[data-open="1"] .rs-chat-fab { display: none; }
  .rs-msg-bubble { max-width: 90%; }
}
