:root {
  --bg-light: #ffffff;
  --primary-gray: #f5f5f5;
  --secondary-gray: #e8e8e8;
  --text-heading: #1a1a1a;
  --text-body: #666666;
  --chat-bg: rgba(255, 255, 255, 0.98);
  --message-sent-bg: rgba(230, 230, 230, 0.9);
  --message-received-bg: rgba(252, 252, 252, 0.98);
  --border-color: rgba(0, 0, 0, 0.1);
}

/* Overlay escuro quando o chat está aberto */
.chat-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 200010;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.chat-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* Wrapper do chat (contém header + container) */
.chat-wrapper {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 100%;
  max-width: 400px;
  z-index: 200015;
  opacity: 0;
  visibility: hidden;
  transform: scale(0);
  transform-origin: bottom right;
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              visibility 0.3s ease,
              transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(10px);
  font-family: "DM Sans", sans-serif;
}

.chat-wrapper.active {
  opacity: 1;
  visibility: visible;
  transform: scale(1);
}

/* Container do chat */
.chat-container {
  height: auto;
  background-color: var(--chat-bg);
  display: flex;
  flex-direction: column;
  font-family: "DM Sans", sans-serif;
}

/* Header do chat */
.chat-header {
  background: #3e85ed;
  padding: 20px 30px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  flex-shrink: 0;
}

.chat-title {
  color: #ffffff;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.chat-status {
  display: none;
}

.chat-close {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, opacity 0.2s ease;
  line-height: 1;
  opacity: 1;
  flex-shrink: 0;
  margin-right: -8px;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.chat-close:hover {
  transform: scale(1.1);
  opacity: 1;
}

/* Mensagens do chat */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 30px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #ffffff;
}

.message {
  max-width: 75%;
  padding: 12px 16px;
  border-radius: 12px;
  clear: both;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-sent {
  background-color: var(--message-sent-bg);
  color: #1a1a1a;
  align-self: flex-end;
  margin-left: auto;
  border-bottom-right-radius: 4px;
  border: none;
}

.message-received {
  background-color: rgba(252, 252, 252, 0.98) !important;
  color: #666666;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border: 1px solid #ececec;
}

/* Input do chat */
.chat-input {
  display: flex;
  padding: 16px 30px;
  background: #f8f8f8;
  border-top: 1px solid #e0e0e0;
  gap: 10px;
  flex-shrink: 0;
}

.message-input {
  flex-grow: 1;
  background-color: #ffffff;
  border: 1px solid #e8e8e8;
  color: #1a1a1a;
  padding: 12px 16px;
  border-radius: 24px;
  font-family: "DM Sans", sans-serif;
  font-size: 14px;
  transition: all 0.2s ease;
  outline: none;
}

.message-input::placeholder {
  color: #999999;
  opacity: 0.8;
}

.message-input:focus {
  background-color: #ffffff;
  box-shadow: none;
}

.send-btn {
  background: #ffffff;
  color: #1a1a1a;
  border: 1px solid #e8e8e8;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.send-btn:hover {
  background: #f8f8f8;
  transform: scale(1.08);
}

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

.send-btn svg {
  width: 18px;
  height: 18px;
}

/* Scrollbar customizada */
.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: #f5f5f5;
  border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #d0d0d0;
  border-radius: 3px;
  transition: background 0.2s ease;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #b8b8b8;
}

/* Indicador de digitação */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  background-color: var(--message-received-bg);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
  max-width: 60px;
  align-self: flex-start;
  border: none;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  background-color: #999999;
  border-radius: 50%;
  animation: typing 1.4s ease-in-out infinite;
}

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

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

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

/* Formulário de contato no chat */
.contact-form-container {
  flex: 1;
  padding: 20px 30px;
  background: #ffffff;
  overflow-y: auto;
  display: none;
  flex-direction: column;
  justify-content: center;
}

.chat-contact-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.chat-form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-form-group input {
  font-family: "DM Sans", sans-serif;
  padding: 12px 0;
  border: none;
  border-bottom: 1px solid #e8e8e8;
  font-size: 16px;
  background: transparent;
  color: #1a1a1a;
  outline: none;
  transition: border-color 0.2s ease;
}

.chat-form-group input:focus {
  border-bottom-color: #1a1a1a;
}

/* Remove fundo azul do autocomplete do browser */
.chat-form-group input:-webkit-autofill,
.chat-form-group input:-webkit-autofill:hover,
.chat-form-group input:-webkit-autofill:focus,
.chat-form-group input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 1000px #ffffff inset !important;
  -webkit-text-fill-color: #1a1a1a !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  caret-color: #1a1a1a !important;
}

.chat-form-group label {
  font-family: "DM Sans", sans-serif;
  font-size: 10px;
  color: #666666;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.chat-form-footer {
  display: flex;
  justify-content: flex-end;
  padding-bottom: 20px;
}

.chat-form-submit {
  font-family: "DM Sans", sans-serif;
  padding: 10px 24px;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
  background: transparent;
  color: #1a1a1a;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-form-submit:hover {
  background: #e8e8e8;
  color: #1a1a1a;
}

/* Botão de fechar no footer do formulário (mobile) */
.chat-form-close {
  display: none;
  font-family: "DM Sans", sans-serif;
  padding: 10px 24px;
  border: 1px solid #e8e8e8;
  border-radius: 4px;
  background: transparent;
  color: #1a1a1a;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  transition: all 0.2s ease;
}

.chat-form-close:hover {
  background: #e8e8e8;
  color: #1a1a1a;
}

/* Multi-select para soluções de interesse */
.chat-form-multiselect {
  position: relative;
}

.chat-form-multiselect-btn {
  font-family: "DM Sans", sans-serif;
  width: 100%;
  padding: 12px 0;
  border: none;
  border-bottom: 1px solid #e8e8e8;
  font-size: 16px;
  background: transparent;
  color: #1a1a1a;
  outline: none;
  cursor: pointer;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: border-color 0.2s ease;
}

.chat-form-multiselect-btn:focus,
.chat-form-multiselect-btn.active {
  border-bottom-color: #1a1a1a;
}

.chat-form-multiselect-btn .placeholder {
  color: #999999;
}

.chat-form-multiselect-btn .selected-text {
  color: #1a1a1a;
}

.chat-form-multiselect-btn svg {
  width: 14px;
  height: 14px;
  color: #999999;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.chat-form-multiselect-btn.active svg {
  transform: rotate(180deg);
}

.chat-form-multiselect-dropdown {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: #ffffff;
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  margin-bottom: 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
}

.chat-form-multiselect-dropdown.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.chat-form-multiselect-option {
  display: flex;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.15s ease;
  gap: 10px;
}

.chat-form-multiselect-option:hover {
  background: #f8f8f8;
}

.chat-form-multiselect-option input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #3e85ed;
  cursor: pointer;
  flex-shrink: 0;
}

.chat-form-multiselect-option span {
  font-family: "DM Sans", sans-serif;
  font-size: 14px;
  color: #1a1a1a;
}

/* Tooltip para chamar atenção ao chat */
.chat-tooltip {
  position: fixed;
  bottom: 110px;
  right: 35px;
  background-color: rgba(0, 0, 0, 0.9);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 8px;
  font-family: "DM Sans", sans-serif;
  font-size: 14px;
  font-weight: 300;
  white-space: nowrap;
  z-index: 200005;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.chat-tooltip.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.chat-tooltip::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 20px;
  width: 12px;
  height: 12px;
  background-color: rgba(0, 0, 0, 0.9);
  transform: rotate(45deg);
}

/* Esconde tooltip em resoluções não-desktop */
@media (max-aspect-ratio: 16/10) {
  .chat-tooltip {
    display: none !important;
  }
}

/* Responsive Design */
@media (max-width: 480px) {
  .chat-wrapper {
    width: 100%;
    max-width: none;
    border-radius: 0;
    bottom: 0;
    right: 0;
  }

  .chat-container {
    height: 100dvh;
    min-height: 100dvh;
  }

  .chat-messages {
    padding: 16px;
  }

  .chat-tooltip {
    bottom: 90px;
    right: 20px;
    font-size: 13px;
    padding: 10px 16px;
  }

  /* Mobile: footer do formulário com gap e botão de fechar visível */
  .chat-form-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
  }

  .chat-form-close {
    display: inline-block;
  }

  /* Mobile: centralizar formulário verticalmente */
  .contact-form-container {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    min-height: 0;
  }

  .chat-contact-form {
    width: 100%;
  }
}
