/* Блок поддержки (.help) – фиксирован относительно окна браузера */
.help {
  position: fixed !important;
  /* Принудительное fixed */
  bottom: 16px;
  /* Отступ снизу */
  right: 16px;
  /* Отступ справа */
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: flex-end;
  z-index: 1;
  /* Низкий z-index по умолчанию */
  width: fit-content;
  --chat-panel-bg: rgba(0, 0, 0, 0.62);
  --chat-panel-border: rgba(255, 255, 255, 0.14);
  --chat-fab-bg: rgba(0, 0, 0, 0.58);
  --chat-bot-bg: var(--black);
  --chat-bot-text: var(--white);
  --chat-user-bg: var(--green);
  --chat-user-text: var(--black);
  --chat-status-text: var(--white);
  --chat-input-bg: var(--grey);
  --chat-input-text: var(--white);
  --chat-input-placeholder: var(--white);
  --chat-input-border: var(--border);
}

html[data-theme="light"] .help {
  --chat-panel-bg: rgba(255, 255, 255, 0.78);
  --chat-panel-border: rgba(0, 0, 0, 0.14);
  --chat-fab-bg: rgba(255, 255, 255, 0.82);
}

/* Добавляем z-index только когда панель видима */
.help.visible {
  z-index: 99999;
  /* Поверх всего, только когда открыто */
  padding: 0;
}

/* Внутренние элементы панели поддержки */
.help__dialog {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  margin-bottom: 8px;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  pointer-events: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.35) transparent;
  padding: 8px 4px;
}

/* Стили для сообщений */
.msg {
  max-width: 80%;
  margin: 4px 0;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
}

.msg.user {
  align-self: flex-end;
  background: var(--chat-user-bg);
  color: var(--chat-user-text);
  border-radius: 12px 12px 0 12px;
  font-family: var(--secondary, Arial, sans-serif)
}

.msg.bot {
  align-self: flex-start;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--chat-bot-text);
  border-radius: 12px 12px 12px 0;
  font-family: var(--secondary, Arial, sans-serif)
}

.msg-time {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 4px;
}

.help__dialog::-webkit-scrollbar {
  width: 8px;
}

.help__dialog::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.36);
  border-radius: 12px;
}

.help__dialog::-webkit-scrollbar-track {
  background: transparent;
}

.help__panel {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 10px;
  align-items: flex-start;
  flex-shrink: 0;
  border: 1px solid var(--chat-panel-border);
  border-radius: 24px;
  margin-bottom: var(--md);
  -webkit-backdrop-filter: blur(25px);
  backdrop-filter: blur(25px);
  transform: translateY(200%);
  transition: transform 0.3s ease;
  padding: var(--md);

  height: 480px;
  width: 480px;
  background: var(--chat-panel-bg);
  overflow: hidden;
}

/* Панель показывается, когда добавлен класс .visible */
.help__panel.visible {
  transform: translateY(0);
}

/* Кнопка-чата (.help__circle) */
.help__circle {
  bottom: 0;
  right: 0;
  padding: var(--md);
  border-radius: 88px;
  border: 1px solid var(--chat-panel-border);
  -webkit-backdrop-filter: blur(25px);
  backdrop-filter: blur(25px);
  cursor: pointer;
  box-sizing: content-box;
  z-index: 9990;
  /* Оставляем высокий z-index для кнопки */
  background-color: var(--chat-fab-bg);
  background-image: none !important;
}

.help__circle--open {
  bottom: 0;
  right: 0;
  padding: var(--md);
  border-radius: 88px;
  border: 1px solid var(--chat-panel-border);
  -webkit-backdrop-filter: blur(25px);
  backdrop-filter: blur(25px);

  cursor: pointer;

  box-sizing: content-box;
  z-index: 9990;
  /* Оставляем высокий z-index для кнопки */
  background-color: var(--chat-fab-bg);
  background-image: none !important;
}

/* Остальные стили */
.help__message {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.help__message--receiver,
.help__message--sender {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.help__message--sender {
  align-items: flex-end;
  margin-bottom: 24px;
}

.bubble {
  display: flex;
  padding: var(--xs);
  width: fit-content;
}

.bubble--sender {
  display: flex;
  background-color: var(--green);
  padding: var(--xs);
  border-radius: 8px 8px 0 8px;
}

.bubble--receiver {
  display: flex;
  background-color: var(--white);
  padding: var(--xs);
  border-radius: 8px 8px 8px 0;
}

.ai {
  display: flex;
  flex-direction: row;
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--lg);
  align-items: center;
  margin-bottom: var(--lg);
  position: sticky;
  top: 0;
  background: rgba(0, 0, 0, 0.25);
  padding: 16px;
  flex-shrink: 0;
}

.ai__photo {
  background-image: url('/front/static/img/avatar.webp');
  width: 48px;
  height: 48px;
  background-position: center;
  border-radius: 100%;
  background-repeat: no-repeat;
  background-size: cover;
}

.ai__desc {
  display: flex;
  flex-direction: column;
}

.title--help {
  font-size: var(--sm);
  color: #ffffff;
}

.text--help {
  font-size: var(--md);
  color: #ffffff;
  font-weight: 600;
}

.text--time {
  font-size: var(--sm);
  color: #ffffff;
  filter: opacity(0.5);
}

.input--help {
  width: auto;
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  background: transparent !important;
  color: #4c4c4c !important;
  border: none !important;
  filter: none !important;
  box-shadow: none !important;
}

.input--help::placeholder {
  color: #959595 !important;
}

.input__button--help {
  width: fit-content;
  margin: 0;
  margin-left: var(--xs);
}

.row--help {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  width: 100%;
  position: relative;
  background: transparent;
  padding-top: 8px;
  z-index: 1;
  flex-shrink: 0;
}

.chat-text-form {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 52px;
}

.container-ia-chat {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: end;
  width: 100%;
}

.input-text {
  max-width: 100%;
  width: 100%;
  margin-left: 0;
  padding: 0.75rem 1rem;
  padding-left: 1rem;
  padding-right: 46px;
  border-radius: 50px;
  border: 1px solid var(--chat-input-border) !important;
  outline: none;
  background-color: var(--chat-input-bg) !important;
  color: var(--chat-input-text) !important;
  font-size: 14px;
  line-height: 18px;
  font-family: var(--secondary);
  font-weight: 500;
  transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.05);
  z-index: 2;
}

.input-text:focus {
  border-color: var(--green) !important;
  box-shadow: 0 0 0 4px rgba(178, 255, 0, 0.22) !important;
}

.input-text::selection {
  background-color: var(--green);
  color: var(--black);
}

.input-text:not(:placeholder-shown) {
  padding-left: 1rem;
}

.label-voice,
.label-text {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  transform: translateX(0) translateY(-50%) scale(1);
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  border: none;
  outline: none;
  cursor: pointer;
  transition: all 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.05);
  z-index: 3;
  border-radius: 999px;
  font-family: var(--secondary);
}

.label-voice {
  color: var(--chat-input-text);
  background: transparent;
}

.label-voice:hover,
.label-voice:focus-visible {
  color: var(--chat-input-text);
  background: var(--chat-input-bg);
}

.icon-mask {
  display: block;
  width: 20px;
  height: 20px;
  background-color: currentColor;
  -webkit-mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
}

.icon-mic {
  -webkit-mask-image: url('/front/static/img/icons/mic-2-ai-fill.svg');
  mask-image: url('/front/static/img/icons/mic-2-ai-fill.svg');
}

.icon-send {
  width: 19px;
  height: 19px;
  -webkit-mask-image: url('/front/static/img/icons/send-ins-fill.svg');
  mask-image: url('/front/static/img/icons/send-ins-fill.svg');
}

.voice-toggle-btn.listening {
  color: var(--black);
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(178, 255, 0, 0.38);
  animation: voicePulse 1.1s infinite;
}

.voice-toggle-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.label-text {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-50%) scale(0.25);
  color: var(--black);
  background: var(--green);
  border: 1px solid var(--green);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.label-text:hover,
.label-text:focus-visible {
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.22);
}

.label-text:active {
  scale: 0.94;
}

.input-text:not(:placeholder-shown)~.label-text {
  transform: translateX(0) translateY(-50%) scale(1);
  opacity: 1;
  visibility: visible;
  pointer-events: all;
}

.input-text:not(:placeholder-shown)~.label-voice {
  transform: translateX(0) translateY(-50%) scale(0.25);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.voice-status {
  display: block;
  width: 100%;
  font-size: 12px;
  line-height: 1.3;
  color: var(--chat-status-text);
  margin-top: 2px;
  min-height: 18px;
  font-family: var(--secondary);
  filter: var(--opacity__50);
}

.voice-status.error {
  color: var(--red);
  filter: var(--opacity__100);
}

@keyframes voicePulse {
  0% {
    box-shadow: 0 0 0 0 rgba(178, 255, 0, 0.38);
  }

  70% {
    box-shadow: 0 0 0 12px rgba(178, 255, 0, 0);
  }

  100% {
    box-shadow: 0 0 0 0 rgba(178, 255, 0, 0);
  }
}

/* Мобильные стили */
@media (max-width: 768px) {
  .help__panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    flex-shrink: 0;
    border: none;
    border-radius: 0;
    /* Убираем скругления для полноэкранности */
    margin-bottom: 0;
    -webkit-backdrop-filter: blur(25px);
    backdrop-filter: blur(25px);
    transform: translateY(100%);
    transition: transform 0.3s ease;
    padding: var(--md);
    margin-right: 0;
    width: 100%;
    /* Полная ширина */
    height: 100vh;
    height: 100svh;
    /* Полная высота */
    background: var(--chat-panel-bg);

  }

  .help__dialog {
    flex-grow: 1;
    max-height: none;
  }

  .help {
    position: fixed !important;
    bottom: 0;
    right: 0;
    display: flex;
    flex-direction: row;
    align-items: center;
    width: var(--fill);
    gap: 12px;
    padding: var(--lg);


  }

  .help__circle {
    bottom: 0;
    right: 0;
    padding: var(--md);
    border-radius: 88px;
    border: 1px solid var(--chat-panel-border);
    -webkit-backdrop-filter: blur(25px);
    backdrop-filter: blur(25px);

    cursor: pointer;

    box-sizing: content-box;
    z-index: 9990;
    background-image: none !important;
  }


  .help__circle--open {
    display: none;
  }

  .chat-text-form {
    min-height: 48px;
  }

  .input-text {
    font-size: 14px;
    padding-left: 1rem;
    padding-right: 44px;
  }

  .voice-status {
    width: 100%;
    margin-top: 4px;
    font-size: 11.5px;
  }
}

/* Убираем псевдоэлементы у крестика закрытия, так как есть SVG иконка */
.chat__close::before,
.chat__close::after {
  display: none !important;
}