/* ═══════════════════════════════════════════════════════════════════════════
   GAURAV BHARGAVA - CHATBOT STYLES
   Matches site aesthetic: Navy (#0D3B66), Sky Blue (#57B9FF), Cream (#FBFAF8)
   ═══════════════════════════════════════════════════════════════════════════ */

.chatbot-container {
  position: fixed;
  bottom: 32px;
  right: 32px;
  z-index: 9999;
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Toggle Button ──────────────────────────────────────────────────────── */
.chatbot-toggle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #0D3B66;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 24px rgba(13, 59, 102, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
}

.chatbot-toggle:hover {
  transform: scale(1.1);
  background: #1A5276;
  box-shadow: 0 8px 32px rgba(13, 59, 102, 0.4);
}

.chatbot-toggle svg {
  width: 28px;
  height: 28px;
  color: white;
  transition: all 0.3s;
}

.chatbot-toggle .chat-icon {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

.chatbot-toggle .close-icon {
  position: absolute;
  opacity: 0;
  transform: scale(0) rotate(90deg);
}

.chatbot-toggle.active .chat-icon {
  opacity: 0;
  transform: scale(0) rotate(-90deg);
}

.chatbot-toggle.active .close-icon {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* ── Chat Window ────────────────────────────────────────────────────────── */
.chatbot-window {
  position: absolute;
  bottom: 80px;
  right: 0;
  width: 380px;
  max-width: calc(100vw - 64px);
  height: 600px;
  max-height: calc(100vh - 140px);
  background: white;
  border-radius: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.15);
  display: none;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.chatbot-container.open .chatbot-window {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.chatbot-header {
  background: linear-gradient(135deg, #0D3B66 0%, #1A5276 100%);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.chatbot-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #57B9FF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
  color: #0D3B66;
  flex-shrink: 0;
}

/* ── Branded Header Avatar ─────────────────────────────────────────────── */
.chatbot-avatar-photo {
  overflow: hidden;
  background: #57B9FF;
  border: 2px solid rgba(255, 255, 255, 0.35);
}

.chatbot-avatar-photo img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center top;
}

.chatbot-title {
  font-weight: 600;
  font-size: 16px;
  color: white;
  margin-bottom: 2px;
}

.chatbot-status {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.7);
}

/* ── Messages Area ──────────────────────────────────────────────────────── */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #FBFAF8;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chatbot-messages::-webkit-scrollbar {
  width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: #DDE3E9;
  border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
  background: #C5CBD1;
}

/* ── Message Bubbles ────────────────────────────────────────────────────── */
.chat-message {
  display: flex;
  animation: messageSlide 0.3s ease-out;
}

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

.message-content {
  padding: 12px 16px;
  border-radius: 12px;
  max-width: 85%;
  line-height: 1.5;
  font-size: 14px;
}

.user-message {
  justify-content: flex-end;
}

.user-message .message-content {
  background: #0D3B66;
  color: white;
  border-bottom-right-radius: 4px;
}

.bot-message {
  justify-content: flex-start;
}

.bot-message .message-content {
  background: white;
  color: #1A2A3A;
  border: 1px solid #DDE3E9;
  border-bottom-left-radius: 4px;
}

/* ── Suggestions ────────────────────────────────────────────────────────── */
.chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: messageSlide 0.3s ease-out 0.2s both;
}

.suggestion-btn {
  background: white;
  border: 1.5px solid #57B9FF;
  color: #0D3B66;
  padding: 10px 16px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  font-family: inherit;
}

.suggestion-btn:hover {
  background: #57B9FF;
  color: white;
  transform: translateX(4px);
  box-shadow: 0 2px 8px rgba(87, 185, 255, 0.3);
}

.suggestion-btn:active {
  transform: translateX(4px) scale(0.98);
}

/* ── Input Area ─────────────────────────────────────────────────────────── */
.chatbot-input-area {
  padding: 16px;
  background: white;
  border-top: 1px solid #DDE3E9;
  display: flex;
  gap: 8px;
  align-items: center;
}

.chatbot-input {
  flex: 1;
  padding: 12px 16px;
  border: 1.5px solid #DDE3E9;
  border-radius: 24px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s;
  background: #FBFAF8;
}

.chatbot-input:focus {
  border-color: #57B9FF;
  background: white;
  box-shadow: 0 0 0 3px rgba(87, 185, 255, 0.1);
}

.chatbot-input::placeholder {
  color: #9CA3AF;
}

.chatbot-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #57B9FF;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.chatbot-send:hover {
  background: #3DAAFF;
  transform: scale(1.05);
}

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

.chatbot-send svg {
  width: 20px;
  height: 20px;
  color: white;
}

/* ── Mobile Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .chatbot-container {
    bottom: 20px;
    right: 20px;
    left: 20px;
  }

  .chatbot-toggle {
    width: 56px;
    height: 56px;
    margin-left: auto;
  }

  .chatbot-toggle svg {
    width: 24px;
    height: 24px;
  }

  .chatbot-window {
    width: 100%;
    max-width: 100%;
    height: calc(100vh - 100px);
    bottom: 72px;
    right: 0;
    left: 0;
  }

  .chatbot-header {
    padding: 16px;
  }

  .chatbot-messages {
    padding: 16px;
  }

  .message-content {
    max-width: 90%;
    font-size: 14px;
  }
}

/* ── Accessibility ──────────────────────────────────────────────────────── */
.chatbot-toggle:focus-visible,
.chatbot-send:focus-visible,
.suggestion-btn:focus-visible {
  outline: 3px solid #57B9FF;
  outline-offset: 2px;
}

.chatbot-input:focus-visible {
  outline: none;
}

/* ── Dark Mode Support (if site adds dark mode) ────────────────────────── */
@media (prefers-color-scheme: dark) {
  body.dark-mode .chatbot-window {
    background: #1A2A3A;
  }

  body.dark-mode .chatbot-messages {
    background: #0F1A24;
  }

  body.dark-mode .bot-message .message-content {
    background: #1A2A3A;
    border-color: #2A3A4A;
    color: #E5E7EB;
  }

  body.dark-mode .chatbot-input-area {
    background: #1A2A3A;
    border-top-color: #2A3A4A;
  }

  body.dark-mode .chatbot-input {
    background: #0F1A24;
    border-color: #2A3A4A;
    color: #E5E7EB;
  }

  body.dark-mode .suggestion-btn {
    background: #1A2A3A;
    border-color: #57B9FF;
    color: #57B9FF;
  }

  body.dark-mode .suggestion-btn:hover {
    background: #57B9FF;
    color: #0D3B66;
  }
}

/* ===== GB mobile Navigator fix: class-driven + media fallback ===== */
.chatbot-title {
  overflow: visible;
  text-overflow: clip;
}

@media (max-width: 820px), (hover: none) and (pointer: coarse) {
  .chatbot-container {
    left: auto !important;
    right: 12px !important;
    bottom: max(12px, env(safe-area-inset-bottom)) !important;
    width: auto !important;
    height: auto !important;
    max-width: none !important;
    max-height: none !important;
  }
}

.chatbot-container.gb-chatbot-mobile,
.gb-chatbot-mobile-viewport .chatbot-container {
  left: auto !important;
  right: 12px !important;
  bottom: max(12px, env(safe-area-inset-bottom)) !important;
  width: auto !important;
  height: auto !important;
  max-width: none !important;
  max-height: none !important;
  z-index: 9999 !important;
}

.chatbot-container.gb-chatbot-mobile .chatbot-toggle,
.gb-chatbot-mobile-viewport .chatbot-toggle {
  width: 46px !important;
  height: 46px !important;
  min-width: 46px !important;
  min-height: 46px !important;
  margin-left: auto !important;
  box-shadow: 0 8px 24px rgba(13,59,102,.24) !important;
}

.chatbot-container.gb-chatbot-mobile .chatbot-toggle svg,
.gb-chatbot-mobile-viewport .chatbot-toggle svg {
  width: 20px !important;
  height: 20px !important;
}

.chatbot-container.gb-chatbot-mobile .chatbot-window,
.gb-chatbot-mobile-viewport .chatbot-window {
  position: fixed !important;
  right: 10px !important;
  left: auto !important;
  bottom: calc(62px + env(safe-area-inset-bottom)) !important;
  top: auto !important;
  width: min(318px, calc(100vw - 20px)) !important;
  max-width: calc(100vw - 20px) !important;
  height: min(390px, calc(100dvh - 132px)) !important;
  max-height: calc(100dvh - 132px) !important;
  min-height: 0 !important;
  border-radius: 15px !important;
  overflow: hidden !important;
  transform-origin: bottom right !important;
}

.chatbot-container.gb-chatbot-mobile .chatbot-header,
.gb-chatbot-mobile-viewport .chatbot-header {
  padding: 9px 11px !important;
  gap: 8px !important;
  min-height: 60px !important;
  max-height: 66px !important;
}

.chatbot-container.gb-chatbot-mobile .chatbot-avatar,
.gb-chatbot-mobile-viewport .chatbot-avatar {
  width: 31px !important;
  height: 31px !important;
  min-width: 31px !important;
  font-size: 11px !important;
}

.chatbot-container.gb-chatbot-mobile .chatbot-online-dot,
.gb-chatbot-mobile-viewport .chatbot-online-dot {
  width: 9px !important;
  height: 9px !important;
  border-width: 1.5px !important;
}

.chatbot-container.gb-chatbot-mobile .chatbot-title,
.gb-chatbot-mobile-viewport .chatbot-title {
  font-size: 12.5px !important;
  line-height: 1.15 !important;
  margin: 0 0 1px !important;
  white-space: nowrap !important;
}

.chatbot-container.gb-chatbot-mobile .chatbot-status,
.gb-chatbot-mobile-viewport .chatbot-status {
  font-size: 9.8px !important;
  line-height: 1.25 !important;
  max-width: 236px !important;
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
}

.chatbot-container.gb-chatbot-mobile .chatbot-messages,
.gb-chatbot-mobile-viewport .chatbot-messages {
  padding: 9px !important;
  gap: 7px !important;
  overflow-y: auto !important;
}

.chatbot-container.gb-chatbot-mobile .message-content,
.gb-chatbot-mobile-viewport .message-content {
  max-width: 92% !important;
  font-size: 11.5px !important;
  line-height: 1.38 !important;
  padding: 7px 9px !important;
  border-radius: 11px !important;
}

.chatbot-container.gb-chatbot-mobile .chat-suggestions,
.gb-chatbot-mobile-viewport .chat-suggestions {
  gap: 5px !important;
  margin-top: 5px !important;
}

.chatbot-container.gb-chatbot-mobile .suggestion-btn,
.gb-chatbot-mobile-viewport .suggestion-btn {
  font-size: 10.7px !important;
  line-height: 1.25 !important;
  padding: 6px 8px !important;
  border-radius: 13px !important;
}

.chatbot-container.gb-chatbot-mobile .chatbot-input-area,
.gb-chatbot-mobile-viewport .chatbot-input-area {
  padding: 7px !important;
  gap: 5px !important;
}

.chatbot-container.gb-chatbot-mobile .chatbot-input,
.gb-chatbot-mobile-viewport .chatbot-input {
  min-height: 34px !important;
  padding: 7px 9px !important;
  font-size: 12px !important;
  border-radius: 17px !important;
}

.chatbot-container.gb-chatbot-mobile .chatbot-input::placeholder,
.gb-chatbot-mobile-viewport .chatbot-input::placeholder {
  font-size: 12px !important;
}

.chatbot-container.gb-chatbot-mobile .chatbot-send,
.gb-chatbot-mobile-viewport .chatbot-send {
  width: 34px !important;
  height: 34px !important;
  min-width: 34px !important;
  min-height: 34px !important;
}

.chatbot-container.gb-chatbot-mobile .chatbot-send svg,
.gb-chatbot-mobile-viewport .chatbot-send svg {
  width: 16px !important;
  height: 16px !important;
}

@media (max-width: 380px) {
  .chatbot-container.gb-chatbot-mobile .chatbot-window,
  .gb-chatbot-mobile-viewport .chatbot-window {
    right: 8px !important;
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    height: min(372px, calc(100dvh - 126px)) !important;
    max-height: calc(100dvh - 126px) !important;
  }

  .chatbot-container.gb-chatbot-mobile .chatbot-status,
  .gb-chatbot-mobile-viewport .chatbot-status {
    max-width: 205px !important;
  }
}
