/* ==========================================================================
   Dracul AI Conversational Widget Styles
   ========================================================================== */

.dracul-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: inherit;
}

.chat-launcher {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #0f0f13;
  color: #fff;
  border: 1px solid rgba(229, 9, 20, 0.5);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 15px rgba(229, 9, 20, 0.25);
  border-radius: 50px;
  padding: 10px 18px 10px 14px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  outline: none;
}

.chat-launcher:hover {
  background: #181820;
  border-color: #e50914;
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.8), 0 0 25px rgba(229, 9, 20, 0.45);
  transform: translateY(-2px);
}

.launcher-pulse {
  position: relative;
  display: inline-block;
  width: 10px;
  height: 10px;
  background: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 8px #22c55e;
}

.launcher-pulse::after {
  content: "";
  position: absolute;
  top: -3px;
  left: -3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(34, 197, 94, 0.5);
  animation: pulse-ring 2s infinite cubic-bezier(0.4, 0, 0.6, 1);
}

@keyframes pulse-ring {
  0% { transform: scale(0.6); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

.launcher-icon {
  display: flex;
  align-items: center;
  color: #e50914;
}

.launcher-label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

/* Chat Window */
.chat-window {
  position: absolute;
  bottom: 60px;
  right: 0;
  width: min(390px, calc(100vw - 32px));
  height: 540px;
  max-height: calc(100vh - 100px);
  background: rgba(13, 13, 17, 0.96);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(229, 9, 20, 0.35);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.8), 0 0 30px rgba(229, 9, 20, 0.2);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(20px) scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-window.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

/* Header */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: #16161d;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-avatar {
  position: relative;
  width: 36px;
  height: 36px;
  background: #000;
  border: 1px solid rgba(229, 9, 20, 0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}

.chat-avatar img {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

.status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: #22c55e;
  border: 2px solid #16161d;
  border-radius: 50%;
}

.chat-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.03em;
}

.chat-status-text {
  font-size: 11px;
  color: #a1a1aa;
}

.chat-close {
  background: transparent;
  border: none;
  color: #a1a1aa;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}

.chat-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

/* Chat Body / Messages */
.chat-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.chat-body::-webkit-scrollbar {
  width: 6px;
}

.chat-body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.25);
}

.chat-body::-webkit-scrollbar-thumb {
  background: rgba(229, 9, 20, 0.4);
  border-radius: 4px;
}

.chat-body::-webkit-scrollbar-thumb:hover {
  background: rgba(229, 9, 20, 0.7);
}

.chat-message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: msg-appear 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.chat-message.bot {
  align-self: flex-start;
}

.chat-message.user {
  align-self: flex-end;
}

.message-content {
  padding: 10px 14px;
  font-size: 13.5px;
  line-height: 1.5;
}

.chat-message.bot .message-content {
  background: #181820;
  color: #e4e4e7;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px 14px 14px 2px;
}

.chat-message.bot .message-content p {
  margin: 0 0 8px;
}

.chat-message.bot .message-content p:last-child {
  margin-bottom: 0;
}

.chat-message.user .message-content {
  background: rgba(229, 9, 20, 0.2);
  color: #fff;
  border: 1px solid rgba(229, 9, 20, 0.4);
  border-radius: 14px 14px 2px 14px;
}

/* Suggestions */
.chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  width: 100%;
  animation: msg-appear 0.3s ease forwards;
}

.suggestion-chip {
  background: #121217;
  border: 1px solid rgba(229, 9, 20, 0.3);
  color: #d4d4d8;
  padding: 8px 14px;
  font-size: 12.5px;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  box-sizing: border-box;
}

.suggestion-chip:hover {
  background: rgba(229, 9, 20, 0.15);
  border-color: #e50914;
  color: #fff;
  transform: translateY(-1px);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 14px;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: #e50914;
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

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

/* Input Area */
.chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: #121216;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.chat-input-area input {
  flex: 1;
  background: #1c1c24;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #fff;
  padding: 10px 14px;
  border-radius: 24px;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input-area input:focus {
  border-color: #e50914;
  box-shadow: 0 0 0 2px rgba(229, 9, 20, 0.2);
}

.chat-input-area button {
  background: #e50914;
  border: none;
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.15s;
}

.chat-input-area button:hover {
  background: #b80710;
  transform: scale(1.05);
}

.chat-input-area button:disabled {
  background: #3f3f46;
  cursor: not-allowed;
  transform: none;
}



/* Mobile Responsiveness for Dracul Chat */
body.nav-open .dracul-chat-widget,
body.nav-open #dracul-chat-widget {
  display: none !important;
}

body.chat-widget-active {
  overflow: hidden !important;
  touch-action: none;
}

@media (max-width: 640px) {
  .dracul-chat-widget {
    bottom: max(16px, env(safe-area-inset-bottom));
    right: max(16px, env(safe-area-inset-right));
  }

  .launcher-label {
    display: none;
  }

  .chat-launcher {
    width: 54px;
    height: 54px;
    padding: 0;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.7), 0 0 15px rgba(229, 9, 20, 0.4);
    touch-action: manipulation;
  }

  .launcher-pulse {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 9px;
    height: 9px;
  }

  /* When chat is open on mobile: immersive full-screen view */
  .dracul-chat-widget.is-chat-open {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    z-index: 100000;
  }

  .dracul-chat-widget.is-chat-open .chat-launcher {
    display: none;
  }

  .chat-window {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    background: #0d0d12;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
  }

  .chat-window.is-open {
    transform: translateY(0);
  }

  .chat-header {
    padding-top: max(14px, env(safe-area-inset-top));
    padding-left: 16px;
    padding-right: 16px;
    padding-bottom: 12px;
    background: #14141b;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
  }

  .chat-header-info {
    gap: 10px;
  }

  .chat-avatar {
    width: 38px;
    height: 38px;
  }

  .chat-avatar img {
    width: 24px;
    height: 24px;
  }

  .chat-header h3 {
    font-size: 16px;
  }

  .chat-status-text {
    font-size: 12px;
  }

  .chat-close {
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    padding: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e4e4e7;
    touch-action: manipulation;
  }

  .chat-close svg {
    width: 20px;
    height: 20px;
  }

  .chat-close:active {
    background: rgba(229, 9, 20, 0.3);
    color: #fff;
  }

  .chat-body {
    padding: 16px 14px 10px;
    gap: 12px;
    flex: 1;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .chat-message {
    max-width: 88%;
  }

  .message-content {
    padding: 12px 15px;
    font-size: 14.5px;
    line-height: 1.55;
  }

  /* Opções no chat de IA no mobile uma embaixo da outra */
  .chat-suggestions {
    display: flex !important;
    flex-direction: column !important;
    align-items: stretch !important;
    flex-wrap: nowrap !important;
    overflow-x: visible !important;
    padding: 6px 2px 10px !important;
    gap: 8px !important;
    scrollbar-width: none !important;
    flex-shrink: 0 !important;
    width: 100% !important;
    box-sizing: border-box !important;
  }

  .chat-suggestions::-webkit-scrollbar {
    display: none !important;
  }

  .suggestion-chip {
    flex-shrink: 0 !important;
    width: 100% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    text-align: left !important;
    font-size: 13.5px !important;
    font-weight: 500 !important;
    line-height: 1.4 !important;
    padding: 10px 16px !important;
    border-radius: 20px !important;
    white-space: normal !important;
    word-break: break-word !important;
    background: #171720 !important;
    border: 1px solid rgba(229, 9, 20, 0.4) !important;
    color: #f4f4f5 !important;
    touch-action: manipulation !important;
    box-sizing: border-box !important;
  }

  .suggestion-chip:active {
    background: rgba(229, 9, 20, 0.25) !important;
    border-color: #e50914 !important;
  }

  .chat-input-area {
    padding-top: 10px;
    padding-left: 12px;
    padding-right: 12px;
    padding-bottom: max(14px, env(safe-area-inset-bottom));
    background: #111116;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
  }

  .chat-input-area input {
    font-size: 16px !important; /* Crucial: stops iOS Safari auto-zoom on input focus */
    padding: 11px 16px;
    border-radius: 24px;
    height: 44px;
    box-sizing: border-box;
  }

  .chat-input-area button {
    width: 44px;
    height: 44px;
    min-height: 44px;
    flex-shrink: 0;
  }
}

/* High-specificity protection to prevent global button styles from bleeding into the chat widget */
#dracul-chat-widget .chat-launcher,
.dracul-chat-widget .chat-launcher {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
  background: #0f0f13 !important;
  color: #fff !important;
  border: 1px solid rgba(229, 9, 20, 0.5) !important;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 15px rgba(229, 9, 20, 0.25) !important;
  border-radius: 50px !important;
  padding: 10px 18px 10px 14px !important;
  min-height: auto !important;
  font-family: inherit !important;
  font-size: 14px !important;
  font-weight: 600 !important;
  line-height: 1.4 !important;
  text-decoration: none !important;
}

#dracul-chat-widget .chat-launcher:hover,
.dracul-chat-widget .chat-launcher:hover {
  background: #181820 !important;
  border-color: #e50914 !important;
  box-shadow: 0 6px 25px rgba(0, 0, 0, 0.8), 0 0 25px rgba(229, 9, 20, 0.45) !important;
  transform: translateY(-2px) !important;
  color: #fff !important;
}

#dracul-chat-widget .chat-close,
.dracul-chat-widget .chat-close {
  background: transparent !important;
  border: none !important;
  color: #a1a1aa !important;
  cursor: pointer !important;
  padding: 4px !important;
  border-radius: 6px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: auto !important;
  width: auto !important;
  box-shadow: none !important;
  font-size: inherit !important;
}

#dracul-chat-widget .chat-close:hover,
.dracul-chat-widget .chat-close:hover {
  color: #fff !important;
  background: rgba(255, 255, 255, 0.1) !important;
  border: none !important;
}

#dracul-chat-widget .suggestion-chip,
.dracul-chat-widget .suggestion-chip {
  background: #121217 !important;
  border: 1px solid rgba(229, 9, 20, 0.3) !important;
  color: #d4d4d8 !important;
  padding: 8px 14px !important;
  font-size: 12.5px !important;
  font-weight: 500 !important;
  font-family: inherit !important;
  line-height: 1.4 !important;
  border-radius: 20px !important;
  cursor: pointer !important;
  text-align: left !important;
  display: flex !important;
  align-items: center !important;
  justify-content: flex-start !important;
  width: 100% !important;
  min-height: auto !important;
  box-shadow: none !important;
  box-sizing: border-box !important;
}

#dracul-chat-widget .suggestion-chip:hover,
.dracul-chat-widget .suggestion-chip:hover {
  background: rgba(229, 9, 20, 0.15) !important;
  border-color: #e50914 !important;
  color: #fff !important;
  transform: translateY(-1px) !important;
  box-shadow: none !important;
}

#dracul-chat-widget .chat-input-area button,
.dracul-chat-widget .chat-input-area button {
  background: #e50914 !important;
  border: none !important;
  color: #fff !important;
  width: 38px !important;
  height: 38px !important;
  min-height: 38px !important;
  border-radius: 50% !important;
  cursor: pointer !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  box-shadow: none !important;
}

#dracul-chat-widget .chat-input-area button:hover,
.dracul-chat-widget .chat-input-area button:hover {
  background: #b80710 !important;
  transform: scale(1.05) !important;
  border: none !important;
}

#dracul-chat-widget .chat-input-area button:disabled,
.dracul-chat-widget .chat-input-area button:disabled {
  background: #3f3f46 !important;
  border: none !important;
  cursor: not-allowed !important;
  transform: none !important;
}

@media (max-width: 640px) {
  #dracul-chat-widget .chat-launcher,
  .dracul-chat-widget .chat-launcher {
    width: 54px !important;
    height: 54px !important;
    min-height: 54px !important;
    padding: 0 !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
  }

  #dracul-chat-widget .chat-input-area button,
  .dracul-chat-widget .chat-input-area button {
    width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
  }
}
