/* Саниране БГ — чат widget (v2).
   Самостоятелен, не зависи от styles.css на сайта, но ползва същите цветове.
   Всички класове са с префикс sbg-chat-, за да не се бият с нищо. */

.sbg-chat,
.sbg-chat * {
  box-sizing: border-box;
}

.sbg-chat {
  /* огледало на :root от /styles.css */
  --sbg-ink-900: #0B1D2E;
  --sbg-ink-800: #102842;
  --sbg-ink-700: #173757;
  --sbg-lime: #A8E63A;
  --sbg-lime-400: #BDEE5C;
  --sbg-cyan: #62D7FF;
  --sbg-mist-200: #C8D6E2;
  --sbg-mist-400: #6E8AA3;
  --sbg-grey: #E9EDF2;
  --sbg-grey-text: #16283b;
  --sbg-danger: #FF6B6B;
  --sbg-border: rgba(168, 230, 58, 0.18);
  --sbg-hairline: rgba(255, 255, 255, 0.08);
  --sbg-font-display: 'Phenomena', 'Oswald', system-ui, sans-serif;
  --sbg-font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  font-family: var(--sbg-font-body);
  font-size: 15px;
  line-height: 1.45;
}

/* ---------- Балонче ---------- */

.sbg-chat__launcher {
  position: fixed;
  right: 24px;
  bottom: calc(24px + var(--sbg-lift, 0px));
  z-index: 2147483000; /* над бисквитки, модали, всичко */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 60px;
  padding: 0 22px 0 18px;
  border: none;
  border-radius: 999px;
  background: var(--sbg-lime);
  color: var(--sbg-ink-900);
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 0 24px rgba(168, 230, 58, 0.18);
  transition: transform 160ms cubic-bezier(0.2, 0.8, 0.2, 1), filter 160ms ease;
}
.sbg-chat__launcher:hover { transform: scale(1.06); filter: brightness(1.06); }
.sbg-chat__launcher:active { transform: scale(0.97); }
.sbg-chat__launcher:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(168, 230, 58, 0.45); }
.sbg-chat__launcher svg { width: 26px; height: 26px; display: block; flex: none; }
.sbg-chat__launcher .sbg-chat__icon-close { display: none; }
.sbg-chat.is-open .sbg-chat__launcher .sbg-chat__icon-open { display: none; }
.sbg-chat.is-open .sbg-chat__launcher .sbg-chat__icon-close { display: block; }

.sbg-chat__launcher-label {
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.01em;
  line-height: 1;
  white-space: nowrap;
}
/* Отворен чат → балончето се свива до кръгче с X */
.sbg-chat.is-open .sbg-chat__launcher { width: 60px; padding: 0; }
.sbg-chat.is-open .sbg-chat__launcher-label { display: none; }

/* Докато модалът на бюлетина е отворен, чатът се скрива, за да не се застъпват */
.sbg-chat--floating.is-eclipsed .sbg-chat__launcher,
.sbg-chat--floating.is-eclipsed .sbg-chat__panel { display: none !important; }

.sbg-chat__dot {
  position: absolute;
  top: 2px;
  right: 2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--sbg-danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
}
.sbg-chat__dot[hidden] { display: none; }

/* ---------- Плаващ панел ---------- */

.sbg-chat--floating .sbg-chat__panel {
  position: fixed;
  right: 24px;
  bottom: calc(96px + var(--sbg-lift, 0px));
  z-index: 2147483000;
  display: none;
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 130px - var(--sbg-lift, 0px));
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}
.sbg-chat--floating.is-open .sbg-chat__panel {
  display: flex;
  animation: sbg-chat-in 200ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes sbg-chat-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.sbg-chat__panel {
  display: flex;
  flex-direction: column;
  background: var(--sbg-ink-900);
  border: 1px solid var(--sbg-border);
  border-radius: 16px;
  overflow: hidden;
  color: #fff;
}

/* ---------- Вграден (inline) панел ---------- */

.sbg-chat--inline { display: block; width: 100%; }
.sbg-chat__panel--inline {
  position: relative;
  width: 100%;
  height: 560px;
  max-height: 80vh;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
@media (max-width: 640px) {
  .sbg-chat__panel--inline { height: 520px; max-height: 78vh; }
}

/* ---------- Хедър ---------- */

.sbg-chat__header {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  background: var(--sbg-ink-800);
  border-bottom: 1px solid var(--sbg-hairline);
}
.sbg-chat__title {
  margin: 0;
  font-family: var(--sbg-font-display);
  font-size: 21px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: #fff;
}
.sbg-chat__subtitle { margin: 2px 0 0; font-size: 12.5px; color: var(--sbg-mist-200); }

.sbg-chat__close {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--sbg-mist-200);
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}
.sbg-chat__close:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.sbg-chat__close svg { width: 16px; height: 16px; display: block; }

.sbg-chat__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---------- Форма ---------- */

.sbg-chat__form { padding: 18px; overflow-y: auto; }
.sbg-chat__intro { margin: 0 0 16px; font-size: 13.5px; color: var(--sbg-mist-200); }

.sbg-chat__field { display: block; margin-bottom: 13px; }
.sbg-chat__label { display: block; margin-bottom: 5px; font-size: 12.5px; color: var(--sbg-mist-200); }
.sbg-chat__req { color: var(--sbg-lime); }

.sbg-chat input[type="text"],
.sbg-chat input[type="tel"],
.sbg-chat textarea {
  width: 100%;
  padding: 10px 12px;
  background: var(--sbg-ink-800);
  border: 1px solid var(--sbg-border);
  border-radius: 8px;
  color: #fff;
  font-family: inherit;
  font-size: 14.5px;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.sbg-chat input::placeholder,
.sbg-chat textarea::placeholder { color: var(--sbg-mist-400); }
.sbg-chat input:focus,
.sbg-chat textarea:focus {
  border-color: var(--sbg-lime);
  box-shadow: 0 0 0 3px rgba(168, 230, 58, 0.28);
}
.sbg-chat textarea { resize: none; }

.sbg-chat__btn {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 8px;
  background: var(--sbg-lime);
  color: var(--sbg-ink-900);
  font-family: var(--sbg-font-display);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  cursor: pointer;
  transition: filter 120ms ease, opacity 120ms ease;
}
.sbg-chat__btn:hover:not(:disabled) { filter: brightness(1.07); }
.sbg-chat__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--sbg-ink-700);
  color: var(--sbg-mist-400);
}

.sbg-chat__error {
  margin: 0 0 12px;
  color: var(--sbg-danger);
  font-size: 12.5px;
}
.sbg-chat__error[hidden] { display: none; }

.sbg-chat__privacy {
  margin: 12px 0 0;
  font-size: 11.5px;
  color: var(--sbg-mist-400);
  text-align: center;
}

/* ---------- Съобщения ---------- */

.sbg-chat__thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.sbg-chat__msg { display: flex; flex-direction: column; max-width: 80%; }
/* Клиентът вдясно, зелен. */
.sbg-chat__msg--client { align-self: flex-end; align-items: flex-end; }
/* Екипът вляво, сив. */
.sbg-chat__msg--agent { align-self: flex-start; align-items: flex-start; }

.sbg-chat__bubble {
  padding: 9px 12px;
  border-radius: 12px;
  font-size: 14.5px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.sbg-chat__msg--client .sbg-chat__bubble {
  background: var(--sbg-lime);
  color: var(--sbg-ink-900);
  border-bottom-right-radius: 4px;
}
.sbg-chat__msg--agent .sbg-chat__bubble {
  background: var(--sbg-grey);
  color: var(--sbg-grey-text);
  border-bottom-left-radius: 4px;
}
.sbg-chat__msg-label { margin: 3px 2px 0; font-size: 11px; color: var(--sbg-mist-400); }
.sbg-chat__msg--agent .sbg-chat__msg-label { color: var(--sbg-cyan); }

.sbg-chat__system {
  align-self: center;
  padding: 5px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--sbg-mist-200);
  font-size: 11.5px;
  text-align: center;
}

/* ---------- Композер ---------- */

.sbg-chat__composer {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  background: var(--sbg-ink-800);
  border-top: 1px solid var(--sbg-hairline);
}
.sbg-chat__composer textarea { max-height: 110px; line-height: 1.4; }
.sbg-chat__send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  background: var(--sbg-lime);
  color: var(--sbg-ink-900);
  cursor: pointer;
  transition: filter 120ms ease;
}
.sbg-chat__send:hover { filter: brightness(1.07); }
.sbg-chat__send:disabled { opacity: 0.55; cursor: not-allowed; }
.sbg-chat__send svg { width: 19px; height: 19px; display: block; }

.sbg-chat__hidden { display: none !important; }

/* ---------- Мобилен: панелът заема почти целия екран ---------- */

@media (max-width: 640px) {
  .sbg-chat__launcher { right: 16px; bottom: calc(16px + var(--sbg-lift, 0px)); height: 54px; padding: 0 19px 0 15px; gap: 8px; }
  .sbg-chat__launcher svg { width: 24px; height: 24px; }
  .sbg-chat__launcher-label { font-size: 15px; }
  .sbg-chat.is-open .sbg-chat__launcher { width: 54px; padding: 0; }
  .sbg-chat--floating .sbg-chat__panel {
    right: 8px;
    left: 8px;
    bottom: calc(82px + var(--sbg-lift, 0px));
    top: 8px;
    width: auto;
    height: auto;
    max-height: none;
    border-radius: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sbg-chat__launcher,
  .sbg-chat--floating.is-open .sbg-chat__panel { transition: none; animation: none; }
}
