/* Основное окно чата */
.bot-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  transition: transform 0.35s ease, opacity 0.35s ease;
}

/* Окно чата — появляется при is-open */
.bot-widget__window {
  display: none;
  flex-direction: column;
  width: 320px;
  max-height: 440px;
  background: var(--color-bg-bot);
  border: 0.5px solid rgba(155,127,232,0.3);
  border-radius: 16px;
  overflow: hidden;
  box-shadow:
    0 20px 60px rgba(0,0,0,0.6),
    0 0 0 0.5px rgba(255,255,255,0.05) inset;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.bot-widget.is-open .bot-widget__window { display: flex; }

/* Заголовок */
.bot-widget__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 0.5px solid rgba(255,255,255,0.07);
  background: rgba(255,255,255,0.03);
  position: relative;
}

.bot-widget__avatar-sm {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--color-accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--color-text); flex-shrink: 0;
}

.bot-widget__header-info { display: flex; flex-direction: column; gap: 2px; }

.bot-widget__name {
  font-size: 13px; font-weight: 500; color: var(--color-text);
  font-family: var(--font-display); letter-spacing: 1px;
}

.bot-widget__status {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: rgba(74,222,128,0.8);
}

.bot-widget__dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--color-green);
  animation: dot-pulse 2s ease-in-out infinite;
}


/* Сообщения */
.bot-widget__messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 160px;
  max-height: 260px;
  scrollbar-width: thin;
  scrollbar-color: rgba(155,127,232,0.2) transparent;
}

.bot-message {
  max-width: 85%; padding: 8px 12px;
  border-radius: 4px 12px 12px 12px;
  font-size: 13px; line-height: 1.5;
  opacity: 0; transform: translateY(4px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.bot-message.is-visible { opacity: 1; transform: translateY(0); }

.bot-message--bot {
  background: rgba(91,45,142,0.2); border: 0.5px solid rgba(155,127,232,0.2);
  color: var(--color-text); align-self: flex-start;
}

.bot-message--user {
  background: var(--color-accent); color: var(--color-text);
  align-self: flex-end; border-radius: 12px 4px 12px 12px;
}

.bot-typing { display: flex; gap: 4px; padding: 10px 14px; align-self: flex-start; }

.bot-typing span {
  width: 5px; height: 5px; border-radius: 50%;
  background: rgba(155,127,232,0.6);
  animation: typing-dot 1.2s ease-in-out infinite;
}

.bot-typing span:nth-child(2) { animation-delay: 0.2s; }
.bot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing-dot {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* Инпут */
.bot-widget__input-wrap {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 0.5px solid rgba(255,255,255,0.07);
  background: rgba(255,255,255,0.02);
}

.bot-input {
  flex: 1; background: rgba(255,255,255,0.05);
  border: 0.5px solid var(--color-border); border-radius: 20px;
  padding: 8px 14px; font-size: 13px; color: var(--color-text);
  font-family: var(--font-body); outline: none; transition: border-color 0.2s ease;
}

.bot-input:focus { border-color: rgba(155,127,232,0.5); }
.bot-input::placeholder { color: var(--color-text-dim); }

.bot-send {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--color-accent); border: none; color: var(--color-text);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  transition: background 0.2s ease, transform 0.2s ease;
}

.bot-send:hover { background: #7B3DBE; transform: scale(1.05); }

/* Пузырь подсказка */
.bot-widget__bubble {
  background: #1A0A3A;
  border: 0.5px solid rgba(155,127,232,0.3);
  border-radius: 12px 12px 0 12px;
  padding: 10px 14px;
  font-size: 13px;
  color: rgba(232,228,240,0.8);
  max-width: 240px;
  line-height: 1.5;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

@media (max-width: 767px) {
  .bot-widget {
    position: fixed;
    bottom: 76px;
    right: 16px;
    z-index: 999;
    left: auto;
  }

  .bot-widget__window {
    position: fixed;
    bottom: 80px;
    right: 16px;
    left: 16px;
    width: auto;
    max-height: 55vh;
    border-radius: 14px;
    transform-origin: bottom right;
    transition: bottom 0.3s ease;
  }

  .bot-widget.is-open .bot-widget__window {
    display: flex;
    flex-direction: column;
  }

  .bot-widget__messages {
    max-height: calc(55vh - 110px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .bot-widget__input-wrap {
    flex-shrink: 0;
    position: relative;
    bottom: auto;
  }

  .bot-input {
    font-size: 16px;
  }

  .bot-widget.is-open .bot-widget__toggle {
    display: none;
  }
}

@supports (height: 100dvh) {
  @media (max-width: 767px) {
    .bot-widget__window {
      bottom: calc(env(safe-area-inset-bottom) + 80px);
    }
  }
}

.bot-widget__close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  border: none;
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
  z-index: 10;
}

.bot-widget.is-open .bot-widget__close {
  display: flex;
}

.bot-widget__close:hover {
  background: rgba(255,255,255,0.15);
}
