/* ===== BÄR CHATBOT ===== */

/* Floating Toggle Button */
.baer-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--gradient-primary);
  box-shadow: 0 6px 25px rgba(29, 158, 117, 0.4), 0 0 0 0 rgba(29, 158, 117, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  animation: baer-pulse 3s ease-in-out infinite;
}

.baer-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 30px rgba(29, 158, 117, 0.5), 0 0 0 8px rgba(29, 158, 117, 0.1);
}

.baer-toggle:active {
  transform: scale(0.96);
}

@keyframes baer-pulse {
  0%, 100% { box-shadow: 0 6px 25px rgba(29, 158, 117, 0.4), 0 0 0 0 rgba(29, 158, 117, 0.3); }
  50% { box-shadow: 0 6px 25px rgba(29, 158, 117, 0.4), 0 0 0 10px rgba(29, 158, 117, 0); }
}

.baer-toggle-icon {
  width: 28px;
  height: 28px;
  transition: transform 0.3s ease, opacity 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.baer-toggle-icon svg {
  width: 100%;
  height: 100%;
}

.baer-toggle.open .baer-toggle-icon--chat {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
  position: absolute;
}

.baer-toggle.open .baer-toggle-icon--close {
  opacity: 1;
  transform: rotate(0) scale(1);
}

.baer-toggle:not(.open) .baer-toggle-icon--close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
  position: absolute;
}

.baer-toggle:not(.open) .baer-toggle-icon--chat {
  opacity: 1;
  transform: rotate(0) scale(1);
}

/* Notification Badge */
.baer-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  background: #e74c3c;
  border-radius: 50%;
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  font-family: var(--font-body);
  animation: baer-badge-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes baer-badge-pop {
  0% { transform: scale(0); }
  100% { transform: scale(1); }
}

/* Chat Window */
.baer-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 9998;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 140px);
  border-radius: var(--radius-lg);
  background: #fff;
  box-shadow: 0 20px 60px rgba(21, 32, 24, 0.18), 0 0 0 1px rgba(29, 158, 117, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.baer-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* Header */
.baer-header {
  background: var(--gradient-primary);
  padding: 20px 22px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.baer-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}

.baer-avatar svg {
  width: 34px;
  height: 34px;
}

.baer-header-info {
  flex: 1;
}

.baer-header-name {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
  line-height: 1.2;
}

.baer-header-status {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  gap: 6px;
}

.baer-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ADE80;
  animation: baer-status-blink 2.5s ease-in-out infinite;
}

@keyframes baer-status-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.baer-header-close {
  background: rgba(255,255,255,0.15);
  border: none;
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.baer-header-close:hover {
  background: rgba(255,255,255,0.3);
}

.baer-header-close svg {
  width: 16px;
  height: 16px;
  stroke: #fff;
}

/* Messages Area */
.baer-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #FAFCFB;
  scroll-behavior: smooth;
}

.baer-messages::-webkit-scrollbar {
  width: 5px;
}

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

.baer-messages::-webkit-scrollbar-thumb {
  background: rgba(29, 158, 117, 0.2);
  border-radius: 10px;
}

/* Message Bubbles */
.baer-msg {
  display: flex;
  gap: 10px;
  max-width: 88%;
  animation: baer-msg-in 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes baer-msg-in {
  0% { opacity: 0; transform: translateY(12px); }
  100% { opacity: 1; transform: translateY(0); }
}

.baer-msg--bot {
  align-self: flex-start;
}

.baer-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.baer-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 2px;
  overflow: hidden;
}

.baer-msg-avatar svg {
  width: 26px;
  height: 26px;
}

.baer-msg--bot .baer-msg-avatar {
  background: linear-gradient(135deg, #0F5C43, #1D9E75);
}

.baer-msg-bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.55;
  font-family: var(--font-body);
}

.baer-msg--bot .baer-msg-bubble {
  background: #fff;
  color: var(--text-primary);
  border: 1px solid rgba(29, 158, 117, 0.1);
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(21, 32, 24, 0.04);
}

.baer-msg--user .baer-msg-bubble {
  background: var(--gradient-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 12px rgba(29, 158, 117, 0.25);
}

.baer-msg-bubble a {
  color: var(--primary);
  text-decoration: underline;
  font-weight: 600;
}

.baer-msg--user .baer-msg-bubble a {
  color: #C1F5E3;
}

.baer-msg-bubble strong {
  font-weight: 600;
}

/* Quick Reply Chips */
.baer-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
  animation: baer-msg-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.15s both;
}

.baer-chip {
  padding: 8px 16px;
  border-radius: 20px;
  border: 1.5px solid rgba(29, 158, 117, 0.25);
  background: rgba(29, 158, 117, 0.06);
  color: var(--primary-dark);
  font-size: 0.82rem;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.baer-chip:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(29, 158, 117, 0.25);
}

/* Typing Indicator */
.baer-typing {
  display: flex;
  align-items: center;
  gap: 10px;
  align-self: flex-start;
  padding: 0 4px;
}

.baer-typing-dots {
  display: flex;
  gap: 4px;
  padding: 12px 18px;
  background: #fff;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(29, 158, 117, 0.1);
  box-shadow: 0 2px 8px rgba(21, 32, 24, 0.04);
}

.baer-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.4;
  animation: baer-bounce 1.4s ease-in-out infinite;
}

.baer-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.baer-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes baer-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Input Area */
.baer-input-area {
  padding: 14px 16px;
  border-top: 1px solid rgba(29, 158, 117, 0.1);
  background: #fff;
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
}

.baer-input {
  flex: 1;
  border: 1.5px solid rgba(29, 158, 117, 0.15);
  border-radius: 14px;
  padding: 11px 16px;
  font-family: var(--font-body);
  font-size: 0.9rem;
  color: var(--text-primary);
  background: #FAFCFB;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  resize: none;
  min-height: 42px;
  max-height: 100px;
  line-height: 1.4;
}

.baer-input::placeholder {
  color: var(--text-muted);
}

.baer-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.1);
}

.baer-send {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: none;
  cursor: pointer;
  background: var(--gradient-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  flex-shrink: 0;
}

.baer-send:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(29, 158, 117, 0.3);
}

.baer-send:active {
  transform: scale(0.95);
}

.baer-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.baer-send svg {
  width: 18px;
  height: 18px;
  stroke: #fff;
  fill: none;
}

/* Powered by */
.baer-powered {
  text-align: center;
  padding: 6px 0 10px;
  font-size: 0.7rem;
  color: var(--text-muted);
  background: #fff;
  font-family: var(--font-body);
}

.baer-powered strong {
  color: var(--primary);
  font-weight: 600;
}

/* Mobile Responsive */
@media (max-width: 480px) {
  .baer-window {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100%;
    height: 100dvh;
    max-height: 100%;
    max-height: 100dvh;
    border-radius: 0;
    z-index: 10000;
  }

  .baer-toggle.open {
    display: none !important;
  }

  .baer-messages {
    padding: 15px 12px;
  }

  .baer-msg-bubble {
    max-width: 88%;
    font-size: 0.92rem;
    padding: 10px 14px;
  }

  .baer-chips {
    gap: 6px;
    margin-top: 8px;
  }

  .baer-chip {
    font-size: 0.8rem;
    padding: 6px 11px;
  }

  .baer-toggle {
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
  }

  .baer-toggle-icon {
    width: 26px;
    height: 26px;
  }

  .baer-header {
    padding: 14px 16px;
    border-radius: 0;
  }

  .baer-msg {
    max-width: 95%;
  }
}

/* Welcome animation */
.baer-welcome-appear {
  animation: baer-welcome 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes baer-welcome {
  0% { opacity: 0; transform: translateY(20px) scale(0.9); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
