/* Chat widget — @alex Jul 2026. z-index above cookie banner */
.app-chatLauncher {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3.5rem;
  height: 3.5rem;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #047857;
  color: #fff;
  box-shadow: 0 8px 24px rgba(4, 120, 87, 0.35);
  cursor: pointer;
  transition: transform 0.25s ease, box-shadow 0.25s ease, background 0.2s ease;
}

.app-chatLauncher:hover {
  background: #065f46;
  transform: scale(1.05);
}

.app-chatLauncher svg {
  width: 1.5rem;
  height: 1.5rem;
}

.app-chatLauncher.is-open {
  background: #065f46;
}

.app-chatPanel {
  position: fixed;
  right: 1.25rem;
  bottom: 5.5rem;
  z-index: 401;
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 2rem));
  max-height: min(520px, calc(100vh - 7rem));
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.18);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(0.98);
  transition: opacity 0.28s ease, transform 0.28s ease, visibility 0.28s;
  overflow: hidden;
}

.app-chatPanel.is-open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.app-chatPanel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  background: #047857;
  color: #fff;
}

.app-chatPanel__title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
}

.app-chatPanel__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  font-size: 1.125rem;
  line-height: 1;
}

.app-chatPanel__messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: #f8fafc;
}

.app-chatMsg {
  max-width: 88%;
  padding: 0.625rem 0.875rem;
  font-size: 0.875rem;
  line-height: 1.5;
  border-radius: 12px;
  word-wrap: break-word;
}

.app-chatMsg--bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e2e8f0;
  color: #1e293b;
  border-bottom-left-radius: 4px;
}

.app-chatMsg--user {
  align-self: flex-end;
  background: #047857;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.app-chatMsg a {
  color: #047857;
  font-weight: 600;
  text-decoration: underline;
}

.app-chatMsg--user a {
  color: #ecfdf5;
}

.app-chatMsg__links {
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.app-chatMsg__links li {
  margin-bottom: 0.35rem;
}

.app-chatTyping {
  align-self: flex-start;
  display: none;
  gap: 4px;
  padding: 0.75rem 1rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}

.app-chatTyping.is-visible {
  display: flex;
}

.app-chatTyping span {
  width: 7px;
  height: 7px;
  background: #94a3b8;
  border-radius: 50%;
  animation: chatTypingBounce 1.2s infinite ease-in-out;
}

.app-chatTyping span:nth-child(2) { animation-delay: 0.15s; }
.app-chatTyping span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatTypingBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40% { transform: translateY(-5px); opacity: 1; }
}

.app-chatPanel__form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}

.app-chatPanel__input {
  flex: 1;
  padding: 0.625rem 0.75rem;
  font-family: inherit;
  font-size: 0.875rem;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.app-chatPanel__input:focus {
  outline: 2px solid #059669;
  outline-offset: 1px;
  border-color: #059669;
}

.app-chatPanel__send {
  padding: 0.625rem 0.875rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  background: #047857;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.app-chatPanel__send:hover {
  background: #065f46;
}

.app-chatPanel__send:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

body.has-chat-open {
  /* mobile full-screen handled below */
}

body.has-cookie-banner .app-chatLauncher {
  bottom: 5.25rem;
}

body.has-cookie-banner .app-chatPanel {
  bottom: 9.25rem;
}

@media (max-width: 640px) {
  .app-chatPanel {
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    height: calc(100% - 4.5rem);
    border-radius: 16px 16px 0 0;
    transform: translateY(100%);
  }

  .app-chatPanel.is-open {
    transform: translateY(0);
  }

  .app-chatLauncher {
    right: 1rem;
    bottom: 1rem;
  }

  body.has-chat-open.has-cookie-banner .app-chatLauncher {
    bottom: 5.5rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-chatPanel,
  .app-chatLauncher,
  .app-chatTyping span {
    transition: none;
    animation: none;
  }
}
