/* ===== Чат-віджет ===== */

/* Кнопка відкриття */
.chatbot-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e07a5f, #c65d42);
  border: none;
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 28px rgba(224, 122, 95, 0.45);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  color: white;
  font-size: 26px;
}

.chatbot-toggle:hover {
  transform: scale(1.1) translateY(-2px);
  box-shadow: 0 8px 36px rgba(224, 122, 95, 0.55);
}

.chatbot-toggle:active {
  transform: scale(0.95);
}

/* Пульсуюче кільце */
.chatbot-toggle::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(224, 122, 95, 0.3);
  animation: chatbot-pulse 2s ease-in-out infinite;
}

@keyframes chatbot-pulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.12); opacity: 0; }
}

.chatbot-toggle.open {
  background: #0c1b33;
  box-shadow: 0 4px 20px rgba(12, 27, 51, 0.3);
}

.chatbot-toggle.open::before {
  display: none;
}

/* Вікно чату */
.chatbot-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 380px;
  max-height: 600px;
  height: min(600px, calc(100vh - 140px));
  background: #ffffff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.04);
  z-index: 9998;
  display: none;
  flex-direction: column;
  overflow: hidden;
  animation: chatbot-slideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  transform-origin: bottom right;
}

.chatbot-window.open {
  display: flex;
}

@keyframes chatbot-slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Хедер */
.chatbot-header {
  background: linear-gradient(135deg, #0c1b33, #162b52);
  color: white;
  padding: 18px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  user-select: none;
}

.chatbot-header-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #e07a5f, #f09b81);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.chatbot-header-info {
  flex: 1;
  min-width: 0;
}

.chatbot-header-title {
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.3px;
}

.chatbot-header-status {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 1px;
}

.chatbot-header-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  animation: chatbot-dotPulse 1.5s ease-in-out infinite;
}

@keyframes chatbot-dotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.chatbot-header-close {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
  line-height: 1;
}

.chatbot-header-close:hover {
  color: white;
}

/* Повідомлення */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8f4f0;
  scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 3px;
}

/* Окреме повідомлення */
.chatbot-msg {
  max-width: 85%;
  padding: 10px 16px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
  animation: chatbot-msgIn 0.3s ease;
}

@keyframes chatbot-msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chatbot-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #e07a5f, #c65d42);
  color: white;
  border-bottom-right-radius: 4px;
}

.chatbot-msg.bot {
  align-self: flex-start;
  background: white;
  color: #1a1a2e;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  border-bottom-left-radius: 4px;
}

.chatbot-msg.bot a {
  color: #e07a5f;
  font-weight: 600;
  text-decoration: underline;
  word-break: break-word;
}

.chatbot-msg.bot a:hover {
  color: #c95f45;
}

.chatbot-msg.bot .chatbot-msg-voice-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(224, 122, 95, 0.1);
  color: #e07a5f;
  font-size: 0.75rem;
  font-weight: 600;
  border: none;
  cursor: pointer;
  transition: background 0.2s;
}

.chatbot-msg.bot .chatbot-msg-voice-btn:hover {
  background: rgba(224, 122, 95, 0.2);
}

.chatbot-msg.bot .chatbot-msg-voice-btn.playing {
  background: rgba(224, 122, 95, 0.25);
  animation: chatbot-btnPulse 0.8s ease-in-out infinite;
}

@keyframes chatbot-btnPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Індикатор друку */
.chatbot-typing {
  display: none;
  align-self: flex-start;
  background: white;
  padding: 12px 18px;
  border-radius: 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  gap: 4px;
}

.chatbot-typing.active {
  display: flex;
}

.chatbot-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9ca3af;
  animation: chatbot-typingDot 1.2s ease-in-out infinite;
}

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

@keyframes chatbot-typingDot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Привітання */
.chatbot-welcome {
  text-align: center;
  padding: 20px 10px;
  color: #6b7280;
  font-size: 0.85rem;
  line-height: 1.6;
}

.chatbot-welcome-icon {
  font-size: 36px;
  margin-bottom: 10px;
}

.chatbot-welcome-title {
  font-weight: 700;
  font-size: 1rem;
  color: #0c1b33;
  margin-bottom: 6px;
}

/* Швидкі кнопки */
.chatbot-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 20px 12px;
  background: #f8f4f0;
}

.chatbot-suggestions button {
  padding: 8px 14px;
  border-radius: 50px;
  border: 1px solid rgba(12, 27, 51, 0.15);
  background: white;
  color: #0c1b33;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  white-space: nowrap;
}

.chatbot-suggestions button:hover {
  background: #0c1b33;
  color: white;
  border-color: #0c1b33;
}

/* Поле вводу */
.chatbot-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px 14px;
  background: white;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.chatbot-input {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 50px;
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
  line-height: 1.4;
  max-height: 80px;
  background: #f8f4f0;
}

.chatbot-input:focus {
  border-color: #e07a5f;
  background: white;
}

.chatbot-btn {
  width: 42px;
  height: 42px;
  min-width: 42px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chatbot-btn-send {
  background: linear-gradient(135deg, #e07a5f, #c65d42);
  color: white;
  box-shadow: 0 3px 12px rgba(224, 122, 95, 0.35);
}

.chatbot-btn-send:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(224, 122, 95, 0.45);
}

.chatbot-btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.chatbot-btn-mic {
  background: #f8f4f0;
  color: #0c1b33;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.chatbot-btn-mic:hover {
  background: #efe8e0;
}

.chatbot-btn-mic.recording {
  background: #e07a5f;
  color: white;
  animation: chatbot-recording 1s ease-in-out infinite;
}

@keyframes chatbot-recording {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224, 122, 95, 0.5); }
  50% { box-shadow: 0 0 0 10px rgba(224, 122, 95, 0); }
}

/* Адаптивність */
@media (max-width: 500px) {
  .chatbot-window {
    right: 12px;
    left: 12px;
    bottom: 90px;
    width: auto;
    max-height: calc(100vh - 120px);
    height: auto;
  }

  .chatbot-toggle {
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    font-size: 22px;
  }
}
