/* ===== Chat Widget ===== */
#chat-widget {
  font-family: 'Space Grotesk', sans-serif;
}

/* Botão flutuante — fixo no canto inferior direito */
@keyframes toggle-enter {
  from { opacity: 0; transform: scale(0.4) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes ring-pulse {
  0%   { box-shadow: 0 4px 20px var(--orange-glow), 0 0 0 0 var(--orange-glow); }
  70%  { box-shadow: 0 4px 20px var(--orange-glow), 0 0 0 10px transparent; }
  100% { box-shadow: 0 4px 20px var(--orange-glow), 0 0 0 0 transparent; }
}
@keyframes bubble-appear {
  from { opacity: 0; transform: scale(0.8) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

#chat-toggle {
  position: fixed;
  bottom: 52px;
  right: clamp(16px, 2vw, 32px);
  z-index: 10000;
  width: clamp(52px, 5vmin, 66px);
  height: clamp(52px, 5vmin, 66px);
  border-radius: 50%;
  background: var(--orange);
  border: 2px solid rgba(255,255,255,0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px var(--orange-glow);
  color: #fff;
  animation: toggle-enter 0.5s cubic-bezier(0.34,1.56,0.64,1) 4s both, ring-pulse 2s ease-out 4.6s infinite;
  transition: opacity 0.3s ease;
}

#chat-toggle:hover, #chat-toggle.hovered {
  filter: brightness(1.2) !important;
  transform: scale(1.12) !important;
  box-shadow: 0 0 0 4px var(--orange), 0 8px 32px var(--orange-glow) !important;
  animation-play-state: paused !important;
}
#chat-toggle svg { width: 26px; height: 26px; fill: #fff; }

#chat-toggle.no-bounce { animation: none; box-shadow: 0 4px 20px var(--orange-glow); }

/* Speech bubble */
#owl-speech-bubble {
  position: fixed;
  bottom: 122px;
  right: 20px;
  z-index: 9999;
  background: #1e1e24;
  border: 1.5px solid var(--orange);
  color: #e8e8ef;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.72rem;
  font-weight: 500;
  line-height: 1.45;
  padding: 8px 12px;
  border-radius: 10px;
  max-width: 170px;
  text-align: left;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  animation: bubble-appear 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
#owl-speech-bubble:hover {
  transform: scale(1.06);
  border-color: var(--orange);
  box-shadow: 0 6px 24px var(--orange-glow);
}
#owl-speech-bubble::before {
  content: '';
  position: absolute;
  bottom: -10px;
  right: 21px;
  border-width: 10px 10px 0 0;
  border-style: solid;
  border-color: var(--orange) transparent transparent transparent;
}
#owl-speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 22px;
  border-width: 8px 8px 0 0;
  border-style: solid;
  border-color: #1e1e24 transparent transparent transparent;
}
#owl-speech-bubble.highlighted {
  transform: scale(1.05);
  border-color: var(--orange);
  box-shadow: 0 6px 24px var(--orange-glow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#owl-speech-bubble.hide {
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

/* Side Panel */
#chat-panel {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 65px;
  right: 0;
  width: 380px;
  height: calc(100vh - 65px);
  background: #1a1a1a;
  border-left: 1px solid #2a2a2a;
  border-top: 1px solid #2a2a2a;
  box-shadow: -8px 0 32px rgba(0,0,0,0.5);
  z-index: 9999;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

#chat-panel.open {
  opacity: 1;
  pointer-events: all;
}

/* Resize handle */
#chat-resize-handle {
  position: absolute;
  left: 0;
  top: 0;
  width: 5px;
  height: 100%;
  cursor: col-resize;
  z-index: 10;
  transition: background 0.15s;
}
#chat-resize-handle:hover,
#chat-resize-handle.dragging { background: var(--orange-glow); }

/* Header */
#chat-header {
  padding: 10px 14px;
  background: #111;
  border-bottom: 1px solid #2a2a2a;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--orange);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  flex-shrink: 0;
  white-space: nowrap;
  min-height: 0;
}

#chat-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

#chat-counter {
  font-size: 0.72rem;
  color: #555;
  font-weight: 500;
  letter-spacing: 0;
}

#chat-close {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  padding: 2px 4px;
  transition: color 0.2s;
}
#chat-close:hover { color: #fff; }

#chat-built-with {
  text-align: center;
  padding: 6px 0 8px;
  background: #0d0d0d;
  border-top: 1px solid #1e1e1e;
}

#chat-built-btn {
  background: none;
  border: none;
  color: #555;
  font-size: 0.72rem;
  cursor: pointer;
  transition: color 0.2s;
  letter-spacing: 0.01em;
}
#chat-built-btn:hover { color: var(--orange); }

#chat-info-btn {
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 2px 4px;
  transition: color 0.2s;
}
#chat-info-btn:hover { color: var(--orange); }

#chat-info-modal {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

#chat-info-content {
  background: #1a1a1a;
  border: 1px solid #333;
  border-radius: 12px;
  padding: 22px 24px;
  max-width: 360px;
  position: relative;
  color: #ccc;
  font-size: 0.83rem;
  line-height: 1.55;
}

#chat-info-content h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  color: #fff;
}

#chat-info-content ul {
  margin: 8px 0;
  padding-left: 1.1rem;
}

#chat-info-content li {
  margin-bottom: 5px;
}

#chat-info-content strong {
  color: var(--orange);
}

#chat-info-close {
  position: absolute;
  top: 10px;
  right: 12px;
  background: none;
  border: none;
  color: #888;
  cursor: pointer;
  font-size: 1rem;
  transition: color 0.2s;
}
#chat-info-close:hover { color: #fff; }

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

/* Área de mensagens */
#chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: #333 transparent;
  opacity: 0;
  transition: opacity 0.45s ease;
}

#chat-messages.visible {
  opacity: 1;
}

#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-thumb { background: #333; border-radius: 2px; }

/* Mensagens */
#chat-messages.visible .chat-msg {
  animation: msg-appear 0.3s ease both;
}

.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.5;
  color: #e0e0e0;
  word-wrap: break-word;
}

.chat-msg.user {
  align-self: flex-end;
  background: #2a2a2a;
  border-bottom-right-radius: 4px;
}

.chat-msg.assistant {
  align-self: flex-start;
  background: #1e1e1e;
  border: 1px solid #2a2a2a;
  border-bottom-left-radius: 4px;
}

/* Indicador de "a escrever" */
.chat-msg.typing {
  align-self: flex-start;
  background: #1e1e1e;
  border: 1px solid #2a2a2a;
  border-bottom-left-radius: 4px;
  padding: 12px 14px;
}

.typing-dots { display: flex; gap: 4px; align-items: center; }

.typing-dots span {
  width: 6px; height: 6px;
  background: var(--orange);
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite;
}

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

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

/* Input */
#chat-input-area {
  padding: 12px 12px 20px;
  border-top: 1px solid #2a2a2a;
  display: flex;
  gap: 8px;
  background: #111;
  flex-shrink: 0;
}

#chat-input {
  flex: 1;
  background: #1e1e1e;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 10px 14px;
  color: #e0e0e0;
  font-size: 0.875rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
#chat-input:focus { border-color: var(--orange); }
#chat-input::placeholder { color: #555; }

#chat-send {
  width: 40px; height: 40px;
  background: var(--orange);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: filter 0.2s, transform 0.1s;
  flex-shrink: 0;
}
#chat-send:hover { filter: brightness(1.1); }
#chat-send:active { transform: scale(0.95); }
#chat-send svg { width: 18px; height: 18px; fill: #fff; }
#chat-send:disabled { background: #333; cursor: not-allowed; }

/* Formulário de contacto inline */
.chat-contact-form {
  max-width: 100% !important;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-sizing: border-box;
}

.cf-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cf-title { margin: 0 0 4px; font-size: 0.85rem; color: #aaa; }

.cf-cancel {
  background: none; border: none; color: #666;
  cursor: pointer; font-size: 0.9rem; line-height: 1;
  padding: 2px 4px; transition: color 0.2s; flex-shrink: 0;
}
.cf-cancel:hover { color: #fff; }

.cf-subtitle {
  font-size: 0.78rem;
  color: #7a8a99;
  margin: 0 0 0.75rem;
  line-height: 1.5;
}

.cf-input {
  width: 100%;
  background: #111;
  border: 1px solid #333;
  border-radius: 6px;
  padding: 8px 10px;
  color: #e0e0e0;
  font-size: 0.82rem;
  font-family: inherit;
  outline: none;
  box-sizing: border-box;
  transition: border-color 0.2s;
}
.cf-input:focus { border-color: var(--orange); }
.cf-input::placeholder { color: #555; }
.cf-textarea { resize: vertical; min-height: 64px; }

.cf-submit {
  background: var(--orange); color: #fff; border: none;
  border-radius: 6px; padding: 9px 14px;
  font-size: 0.82rem; font-family: inherit; font-weight: 600;
  cursor: pointer; transition: filter 0.2s; align-self: flex-end;
}
.cf-submit:hover { filter: brightness(1.1); }
.cf-submit:disabled { background: #444; cursor: not-allowed; }

.cf-error { margin: 0; font-size: 0.78rem; color: var(--orange); }

.cf-success { margin: 0; font-size: 0.85rem; color: #6fcf97; }

/* Listas nas mensagens do assistente */
.chat-msg.assistant ul {
  margin: 0.4rem 0 0.2rem 1rem;
  padding: 0;
  list-style: disc;
}
.chat-msg.assistant li {
  margin: 0.1rem 0;
  padding: 0;
  line-height: 1.5;
}

.chat-action-link {
  display: inline-block;
  margin-top: 0.35rem;
  padding-top: 0.35rem;
  border-top: 1px solid #2a2a2a;
  width: 100%;
  color: var(--orange);
  font-weight: 600;
  font-size: 0.82rem;
  text-decoration: none;
  border: 1px solid var(--orange-glow);
  border-radius: 6px;
  padding: 0.2rem 0.6rem;
  transition: background 0.15s;
}
.chat-action-link:hover { background: var(--orange-glow2); }

/* Mobile — full screen */
@media (max-width: 600px) {
  #chat-panel { width: 100vw !important; }
  #chat-resize-handle { display: none; }
}
