/* =========================================================================
   PrintWell — плавающий AI-чат виджет
   Бренд: синий #2B2BB5, оранжевый #E87E18 (акцент), золото #e8c547 (акцент),
   тёмная тема окна #141414. Самодостаточный модуль, не зависит от Tailwind.
   ========================================================================= */

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

.pw-chat {
  font-family: 'Unbounded', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* ===== Плавающая круглая кнопка (FAB) ===== */
.pw-chat__fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 45;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  background: #2b2bb5;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(43, 43, 181, 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  animation: pw-chat-pulse 2.4s ease-in-out infinite;
}

.pw-chat__fab:hover {
  background: #2424a0;
  transform: translateY(-2px);
}

.pw-chat__fab:focus-visible {
  outline: 3px solid #e8c547;
  outline-offset: 2px;
}

.pw-chat__fab svg {
  width: 28px;
  height: 28px;
  display: block;
}

/* Лёгкая пульсация */
@keyframes pw-chat-pulse {
  0% {
    box-shadow: 0 8px 24px rgba(43, 43, 181, 0.45), 0 0 0 0 rgba(43, 43, 181, 0.45);
  }
  70% {
    box-shadow: 0 8px 24px rgba(43, 43, 181, 0.45), 0 0 0 16px rgba(43, 43, 181, 0);
  }
  100% {
    box-shadow: 0 8px 24px rgba(43, 43, 181, 0.45), 0 0 0 0 rgba(43, 43, 181, 0);
  }
}

/* Когда чат открыт — прячем FAB */
.pw-chat.pw-chat--open .pw-chat__fab {
  display: none;
}

/* ===== Окно чата ===== */
.pw-chat__panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 46;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 48px);
  display: none;
  flex-direction: column;
  background: #141414;
  color: #f2f2f2;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.pw-chat.pw-chat--open .pw-chat__panel {
  display: flex;
  animation: pw-chat-in 0.22s ease both;
}

@keyframes pw-chat-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ===== Шапка окна ===== */
.pw-chat__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #2b2bb5 0%, #1d1d7d 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.pw-chat__avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.pw-chat__avatar svg {
  width: 18px;
  height: 18px;
}

.pw-chat__heading {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  flex: 1 1 auto;
  min-width: 0;
}

.pw-chat__title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #ffffff;
}

.pw-chat__status {
  font-size: 0.7rem;
  font-weight: 300;
  color: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  gap: 5px;
}

.pw-chat__status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e8c547;
  display: inline-block;
}

.pw-chat__close {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease;
}

.pw-chat__close:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* ===== Тело: лента сообщений ===== */
.pw-chat__body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pw-chat__messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pw-chat__msg {
  max-width: 85%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.85rem;
  font-weight: 300;
  line-height: 1.45;
  word-wrap: break-word;
}

.pw-chat__msg--bot {
  align-self: flex-start;
  background: #232323;
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #f2f2f2;
  border-bottom-left-radius: 4px;
}

.pw-chat__msg--user {
  align-self: flex-end;
  background: #2b2bb5;
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

/* ===== Быстрые кнопки ===== */
.pw-chat__quick {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}

.pw-chat__quick-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 13px;
  border-radius: 12px;
  background: #1e1e1e;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f2f2f2;
  font-size: 0.82rem;
  font-weight: 400;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.pw-chat__quick-btn:hover {
  background: #262663;
  border-color: #2b2bb5;
  transform: translateX(2px);
}

.pw-chat__quick-btn svg {
  width: 17px;
  height: 17px;
  flex: 0 0 auto;
  color: #e87e18;
}

/* ===== Строка ввода ===== */
.pw-chat__inputbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: #181818;
}

.pw-chat__input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: #0f0f0f;
  color: #f2f2f2;
  font-size: 0.85rem;
  font-family: inherit;
  outline: none;
}

.pw-chat__input::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.pw-chat__input:focus {
  border-color: #2b2bb5;
}

.pw-chat__send {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 10px;
  background: #2b2bb5;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.pw-chat__send:hover {
  background: #2424a0;
}

.pw-chat__send svg {
  width: 18px;
  height: 18px;
}

/* ===== Мобильная адаптация: окно на весь экран ===== */
@media (max-width: 768px) {
  .pw-chat__panel {
    right: 0;
    bottom: 0;
    top: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }

  .pw-chat__fab {
    right: 18px;
    bottom: 18px;
  }
}

/* ===== Доступность: отключаем анимации ===== */
@media (prefers-reduced-motion: reduce) {
  .pw-chat__fab {
    animation: none;
    transition: none;
  }
  .pw-chat.pw-chat--open .pw-chat__panel {
    animation: none;
  }
  .pw-chat__quick-btn,
  .pw-chat__fab:hover,
  .pw-chat__quick-btn:hover {
    transition: none;
    transform: none;
  }
}
