/* ==========================================================================
   Custom AI Chatbot Widget Styles - Alphi Gabriel Portfolio
   ========================================================================== */

:root {
  --chat-navy: #003a6c;
  --chat-navy-dark: #002647;
  --chat-teal: #0d9488;
  --chat-teal-hover: #0f766e;
  --chat-bg: #ffffff;
  --chat-bg-subtle: #f8fafc;
  --chat-border: rgba(0, 58, 108, 0.12);
  --chat-text: #1e293b;
  --chat-text-muted: #64748b;
  --chat-user-msg-bg: #003a6c;
  --chat-user-msg-text: #ffffff;
  --chat-bot-msg-bg: #f1f5f9;
  --chat-bot-msg-text: #0f172a;
  --chat-radius: 16px;
  --chat-shadow: 0 12px 36px rgba(0, 38, 71, 0.18), 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Launcher Floating Button */
.chat-launcher-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-navy) 0%, #004d8c 100%);
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 6px 20px rgba(0, 58, 108, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9990;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  outline: none;
}

.chat-launcher-btn:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 10px 28px rgba(13, 148, 136, 0.45);
  border-color: var(--chat-teal);
}

.chat-launcher-btn svg {
  width: 26px;
  height: 26px;
  transition: transform 0.3s ease;
}

.chat-launcher-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background-color: var(--chat-teal);
  border: 2px solid #ffffff;
  border-radius: 50%;
  animation: pulseBadge 2.5s infinite;
}

@keyframes pulseBadge {
  0% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(13, 148, 136, 0.6); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(13, 148, 136, 0); }
  100% { transform: scale(0.9); box-shadow: 0 0 0 0 rgba(13, 148, 136, 0); }
}

/* Tooltip on Launcher */
.chat-launcher-tooltip {
  position: fixed;
  bottom: 32px;
  right: 90px;
  background: var(--chat-navy-dark);
  color: #ffffff;
  padding: 8px 14px;
  border-radius: 20px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0,0,0,0.15);
  pointer-events: none;
  opacity: 0;
  transform: translateX(10px);
  transition: all 0.3s ease;
  z-index: 9989;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-launcher-btn:hover + .chat-launcher-tooltip,
.chat-launcher-tooltip.show-initially {
  opacity: 1;
  transform: translateX(0);
}

/* Chat Container Window */
.chat-widget-container {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background-color: var(--chat-bg);
  border-radius: var(--chat-radius);
  box-shadow: var(--chat-shadow);
  border: 1px solid var(--chat-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9995;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: 'Josefin Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

.chat-widget-container.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Header */
.chat-header {
  background: linear-gradient(135deg, var(--chat-navy) 0%, var(--chat-navy-dark) 100%);
  color: #ffffff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

.chat-header-details h4 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.05rem;
  font-weight: 600;
  margin: 0;
  color: #ffffff;
  line-height: 1.2;
}

.chat-header-status {
  font-size: 0.75rem;
  color: #99f6e4;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.status-live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--chat-teal);
  display: inline-block;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-action-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.8);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.chat-action-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

/* Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background-color: var(--chat-bg-subtle);
  scroll-behavior: smooth;
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

.chat-message-row {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: messageSlideIn 0.25s ease-out forwards;
}

@keyframes messageSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.chat-message-row.user {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-message-row.bot {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.5;
  word-break: break-word;
}

.chat-message-row.user .chat-bubble {
  background: var(--chat-user-msg-bg);
  color: var(--chat-user-msg-text);
  border-bottom-right-radius: 4px;
}

.chat-message-row.bot .chat-bubble {
  background: var(--chat-bot-msg-bg);
  color: var(--chat-bot-msg-text);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-bottom-left-radius: 4px;
}

.chat-bubble p {
  margin: 0 0 6px 0;
}
.chat-bubble p:last-child {
  margin-bottom: 0;
}

.chat-bubble ul, .chat-bubble ol {
  margin: 6px 0 6px 18px;
  padding: 0;
}

.chat-bubble li {
  margin-bottom: 3px;
}

.chat-bubble a {
  color: var(--chat-teal);
  text-decoration: underline;
  font-weight: 500;
}

.chat-bubble strong {
  font-weight: 600;
}

.chat-bubble code {
  font-family: 'JetBrains Mono', monospace;
  background: rgba(0, 0, 0, 0.08);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.85em;
}

.chat-time {
  font-size: 0.7rem;
  color: var(--chat-text-muted);
  margin-top: 3px;
  padding: 0 4px;
}

/* Typing Indicator */
.chat-typing-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--chat-bot-msg-bg);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--chat-text-muted);
  border-radius: 50%;
  animation: typingBounce 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 typingBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* Suggested Chips */
.chat-suggestions {
  padding: 8px 12px;
  background: #ffffff;
  border-top: 1px solid var(--chat-border);
  display: flex;
  gap: 6px;
  overflow-x: auto;
  white-space: nowrap;
  scrollbar-width: none;
}

.chat-suggestions::-webkit-scrollbar {
  display: none;
}

.suggestion-chip {
  background: #e0f2fe;
  color: var(--chat-navy);
  border: 1px solid #bae6fd;
  border-radius: 20px;
  padding: 5px 11px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.suggestion-chip:hover {
  background: var(--chat-teal);
  color: #ffffff;
  border-color: var(--chat-teal);
}

/* Input Area */
.chat-input-area {
  padding: 10px 14px;
  background: #ffffff;
  border-top: 1px solid var(--chat-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-input-field {
  flex: 1;
  border: 1px solid rgba(0, 58, 108, 0.2);
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  background: var(--chat-bg-subtle);
  color: var(--chat-text);
  resize: none;
  max-height: 90px;
  line-height: 1.4;
  transition: border-color 0.2s ease;
}

.chat-input-field:focus {
  border-color: var(--chat-teal);
  background: #ffffff;
}

.chat-send-btn {
  background: var(--chat-teal);
  color: #ffffff;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.chat-send-btn:hover {
  background: var(--chat-teal-hover);
  transform: scale(1.05);
}

.chat-send-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  transform: none;
}

/* Footer Disclaimer */
.chat-footer-disclaimer {
  padding: 4px 10px 6px;
  text-align: center;
  font-size: 0.68rem;
  color: var(--chat-text-muted);
  background: #ffffff;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  .chat-widget-container {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  
  .chat-launcher-btn {
    bottom: 16px;
    right: 16px;
  }
}
