/* On-site анонимный чат сексолог.online. Тянет токены оформления из :root
   лендинга (--rose, --bg, --text...). Кнопка «Начать прямо на сайте»
   инжектится скриптом под каждой группой кнопок Telegram/MAX. */

/* --- Инжектируемая кнопка под кнопками TG/MAX --- */
.sx-launch-wrap { display: flex; justify-content: center; margin-top: 14px; position: relative; z-index: 1; }
.sx-chat-launch {
  background: linear-gradient(135deg, var(--rose, #D4196A), var(--rose-light, #E8377F));
  color: #fff;
  border: none;
  cursor: pointer;
  font-family: 'Raleway', sans-serif;
  box-shadow: 0 6px 24px var(--rose-glow, rgba(212, 25, 106, .35));
}
/* Hover как у TG/MAX: подъём (от .btn) + усиленная тень-glow. */
.sx-chat-launch:hover { box-shadow: 0 12px 36px rgba(212, 25, 106, .5); }
@media (max-width: 600px) { .sx-chat-launch { width: 260px; justify-content: center; } }

/* --- Затемнение --- */
.sx-chat-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(3px);
  z-index: 99998; opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
.sx-chat-overlay.open { opacity: 1; pointer-events: auto; }

/* --- Почти полноэкранная панель --- */
.sx-chat {
  position: fixed; z-index: 99999;
  top: 2.5vh; bottom: 2.5vh; left: 50%;
  width: min(940px, 96vw); max-height: 95vh;
  transform: translateX(-50%) scale(.98);
  background: var(--bg, #0D0A0C);
  color: var(--text, #F0E8ED);
  border: 1px solid var(--bg-border, #2B1E26);
  border-radius: 18px; overflow: hidden;
  display: flex; flex-direction: column;
  font-family: 'Raleway', system-ui, sans-serif;
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s cubic-bezier(.16, 1, .3, 1);
}
.sx-chat.open { opacity: 1; pointer-events: auto; transform: translateX(-50%) scale(1); }
@media (max-width: 640px) {
  .sx-chat { top: 0; bottom: 0; left: 0; width: 100vw; max-height: 100vh; border: none; border-radius: 0; transform: scale(.98); }
  .sx-chat.open { transform: scale(1); }
}

.sx-chat-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--bg-border, #2B1E26);
  flex-shrink: 0;
}

/* Двухколоночная раскладка: постоянный сайдбар-меню + чат. */
.sx-row { display: flex; flex: 1; min-height: 0; }
.sx-side {
  width: 250px; flex-shrink: 0; overflow-y: auto;
  border-right: 1px solid var(--bg-border, #2B1E26);
  padding: 16px 14px; display: flex; flex-direction: column; gap: 8px;
}
.sx-side-cap { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted, #C0A8B6); margin: 8px 4px 2px; }
.sx-side-bal { background: var(--bg-card, #151013); border: 1px solid var(--bg-border, #2B1E26); border-radius: 14px; padding: 13px 15px; }
.sx-side-bal .n { font-family: 'Playfair Display', serif; font-size: 1.5rem; font-weight: 700; }
.sx-side-bal .s { font-size: .72rem; color: var(--text-muted, #C0A8B6); margin-top: 2px; }
.sx-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sx-menu-toggle { display: none; }   /* только на узких экранах */
@media (max-width: 860px) {
  .sx-side { display: none; }
  .sx-menu-toggle { display: inline-flex; }
}
.sx-chat-title { font-weight: 600; font-size: 1rem; }
.sx-chat-sub { font-size: .72rem; color: var(--text-muted, #C0A8B6); margin-top: 2px; }
.sx-chat-spacer { flex: 1; }
.sx-chat-iconbtn {
  background: transparent; border: none;
  color: var(--text-muted, #C0A8B6);
  cursor: pointer; padding: 7px; border-radius: 8px; line-height: 0;
}
.sx-chat-iconbtn:hover { color: var(--text, #F0E8ED); background: var(--bg-card, #151013); }

/* --- Лента --- */
.sx-chat-body { flex: 1; overflow-y: auto; padding: 22px 18px; display: flex; flex-direction: column; align-items: center; }
.sx-thread { width: 100%; max-width: 760px; display: flex; flex-direction: column; gap: 12px; }

.sx-msg { max-width: 88%; padding: 12px 15px; border-radius: 16px; line-height: 1.55; font-size: .95rem; white-space: pre-wrap; word-wrap: break-word; }
.sx-msg-user { align-self: flex-end; background: var(--rose, #D4196A); color: #fff; border-bottom-right-radius: 4px; }
.sx-msg-bot { align-self: flex-start; background: var(--bg-card, #151013); border: 1px solid var(--bg-border, #2B1E26); border-bottom-left-radius: 4px; }
.sx-msg-bot.typing { color: var(--text-muted, #C0A8B6); }
.sx-typing { display: inline-flex; gap: 5px; align-items: center; padding: 3px 2px; }
.sx-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-muted, #C0A8B6); display: inline-block; animation: sx-bounce 1.2s infinite ease-in-out both; }
.sx-typing i:nth-child(2) { animation-delay: .16s; }
.sx-typing i:nth-child(3) { animation-delay: .32s; }
@keyframes sx-bounce { 0%, 80%, 100% { transform: scale(.5); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }

.sx-sales {
  align-self: stretch;
  background: linear-gradient(135deg, rgba(212, 25, 106, .12), rgba(212, 25, 106, .04));
  border: 1px solid var(--rose-dim, rgba(212, 25, 106, .18));
  border-radius: 16px; padding: 15px; font-size: .92rem; line-height: 1.55;
}
.sx-sales-cta {
  display: inline-block; margin-top: 10px; padding: 10px 18px;
  background: var(--rose, #D4196A); color: #fff; border: none; border-radius: 40px;
  font-family: inherit; font-weight: 600; font-size: .85rem; cursor: pointer; text-decoration: none;
}

/* --- Поле ввода --- */
.sx-chat-foot { flex-shrink: 0; padding: 14px 18px; border-top: 1px solid var(--bg-border, #2B1E26); }
.sx-chat-inputrow { width: 100%; max-width: 760px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.sx-chat-input {
  flex: 1; resize: none; max-height: 140px;
  box-sizing: border-box; overflow-y: hidden;
  background: var(--bg-card, #151013);
  border: 1px solid var(--bg-border, #2B1E26);
  border-radius: 14px; color: var(--text, #F0E8ED);
  padding: 12px 15px; font-family: inherit; font-size: .95rem; line-height: 1.45;
}
.sx-chat-input:focus { outline: none; border-color: var(--rose, #D4196A); }
.sx-chat-send {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%;
  background: var(--rose, #D4196A); border: none; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.sx-chat-send:disabled { opacity: .45; cursor: default; }
.sx-chat-note { max-width: 760px; margin: 8px auto 0; font-size: .68rem; color: var(--text-muted, #C0A8B6); text-align: center; line-height: 1.4; }
.sx-chat-note a { color: var(--text-muted, #C0A8B6); }

/* --- Экраны меню (баланс/пакеты/диалоги/настройки) поверх панели --- */
.sx-screen {
  position: absolute; inset: 0; z-index: 3;
  background: var(--bg, #0D0A0C);
  display: none; flex-direction: column;
}
.sx-screen.show { display: flex; }
.sx-screen-body { flex: 1; overflow-y: auto; padding: 20px 18px; display: flex; flex-direction: column; align-items: center; }
.sx-screen-inner { width: 100%; max-width: 680px; display: flex; flex-direction: column; gap: 12px; }
.sx-screen-h { font-family: 'Playfair Display', serif; font-size: 1.25rem; margin: 2px 0 6px; }

.sx-card {
  background: var(--bg-card, #151013);
  border: 1px solid var(--bg-border, #2B1E26);
  border-radius: 14px; padding: 15px;
  display: flex; align-items: center; gap: 12px;
}
.sx-card .sx-grow { flex: 1; }
.sx-card-title { font-weight: 600; font-size: .95rem; }
.sx-card-sub { font-size: .8rem; color: var(--text-muted, #C0A8B6); margin-top: 3px; }
.sx-balance-big { font-size: 1.6rem; font-weight: 700; font-family: 'Playfair Display', serif; }

.sx-btn {
  padding: 10px 18px; border-radius: 40px; border: none; cursor: pointer;
  font-family: 'Raleway', sans-serif; font-weight: 600; font-size: .85rem;
  background: var(--rose, #D4196A); color: #fff; white-space: nowrap;
}
.sx-btn-ghost { background: transparent; border: 1px solid var(--bg-border, #2B1E26); color: var(--text, #F0E8ED); }
.sx-btn-danger { background: transparent; border: 1px solid rgba(212,25,106,.5); color: var(--rose-light, #E8377F); }
.sx-btn:disabled { opacity: .5; cursor: default; }

.sx-menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 15px; border-radius: 14px; cursor: pointer;
  background: var(--bg-card, #151013); border: 1px solid var(--bg-border, #2B1E26);
  color: var(--text, #F0E8ED); font-size: .95rem; text-align: left; width: 100%;
}
.sx-menu-item:hover { border-color: var(--rose, #D4196A); }
.sx-menu-item .sx-grow { flex: 1; }

.sx-conv {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-radius: 12px;
  background: var(--bg-card, #151013); border: 1px solid var(--bg-border, #2B1E26);
}
.sx-conv.active { border-color: var(--rose, #D4196A); }
.sx-conv-main { flex: 1; min-width: 0; cursor: pointer; }
.sx-conv-title { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sx-conv-sub { font-size: .72rem; color: var(--text-muted, #C0A8B6); margin-top: 2px; }
.sx-conv-del { background: transparent; border: none; color: var(--text-muted, #C0A8B6); cursor: pointer; padding: 6px; line-height: 0; }
.sx-conv-del:hover { color: var(--rose-light, #E8377F); }

.sx-seg { display: flex; gap: 8px; flex-wrap: wrap; }
.sx-seg button {
  padding: 9px 14px; border-radius: 40px; cursor: pointer; font-family: 'Raleway', sans-serif; font-size: .82rem;
  background: var(--bg-card, #151013); border: 1px solid var(--bg-border, #2B1E26); color: var(--text, #F0E8ED);
}
.sx-seg button.sel { background: var(--rose, #D4196A); border-color: var(--rose, #D4196A); color: #fff; }

.sx-input {
  width: 100%; background: var(--bg-card, #151013);
  border: 1px solid var(--bg-border, #2B1E26); border-radius: 12px;
  color: var(--text, #F0E8ED); padding: 11px 14px; font-family: inherit; font-size: .95rem;
}
.sx-input:focus { outline: none; border-color: var(--rose, #D4196A); }
.sx-codebox {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card, #151013); border: 1px dashed var(--rose-dim, rgba(212,25,106,.35));
  border-radius: 14px; padding: 14px;
}
.sx-code { flex: 1; font-family: 'Playfair Display', serif; font-size: 1.5rem; font-weight: 700; letter-spacing: .12em; }

.sx-screen-note { font-size: .8rem; color: var(--text-muted, #C0A8B6); line-height: 1.5; }
.sx-empty { color: var(--text-muted, #C0A8B6); font-size: .9rem; text-align: center; padding: 24px 0; }

/* --- Свёрнутый пузырь (восстановить чат) --- */
.sx-chat-bubble {
  position: fixed; right: 20px; bottom: 20px;
  width: 60px; height: 60px; border-radius: 50%;
  background: linear-gradient(135deg, var(--rose, #D4196A), var(--rose-light, #E8377F));
  color: #fff; border: none; cursor: pointer;
  box-shadow: 0 8px 28px var(--rose-glow, rgba(212, 25, 106, .35));
  z-index: 99997; display: none; align-items: center; justify-content: center;
}
.sx-chat-bubble.show { display: flex; }
