/* ==========================================================================
   NIDHEESH KRISHNA — AI ASSISTANT CHATBOT
   Native Floating Component System
   Light Glassmorphic Executive Aesthetic · Bottom-Left Viewport Anchor
   ========================================================================== */

/* --------------------------------------------------------------------------
   Tap Highlight & Focus Cleanup
   -------------------------------------------------------------------------- */
.nk-chatbot-panel,
.nk-chatbot-panel *,
.nk-quick-btn,
.nk-chip-btn,
.nk-input-send {
  -webkit-tap-highlight-color: transparent !important;
  -webkit-touch-callout: none;
  outline: none;
}

/* --------------------------------------------------------------------------
   1. Floating Launcher Button (Fixed Bottom-Left)
   -------------------------------------------------------------------------- */
.nk-chatbot-launcher {
  display: none !important;
}

.nk-chatbot-launcher:active {
  transform: translateY(0) scale(0.98);
}

.nk-launcher-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(13, 148, 136, 0.12);
  color: var(--primary, #0f766e);
  font-size: 0.9rem;
  flex-shrink: 0;
  transition: transform 0.3s ease, background 0.3s ease;
}

.nk-chatbot-launcher:hover .nk-launcher-icon {
  background: var(--primary-container, #0d9488);
  color: #ffffff;
  transform: rotate(15deg);
}

.nk-launcher-text {
  white-space: nowrap;
}

.nk-launcher-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.8);
  animation: nkPulseBreath 2.4s infinite ease-in-out;
  flex-shrink: 0;
}

@keyframes nkPulseBreath {
  0%, 100% {
    transform: scale(1);
    opacity: 0.85;
    box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
  }
  50% {
    transform: scale(1.25);
    opacity: 1;
    box-shadow: 0 0 12px rgba(34, 197, 94, 1);
  }
}

.nk-chatbot-launcher.is-active {
  border-color: var(--primary, #1d4ed8);
  background: #ffffff;
}

/* --------------------------------------------------------------------------
   2. Floating Chatbot Window Panel
   -------------------------------------------------------------------------- */
.nk-chatbot-panel {
  position: fixed;
  top: calc(var(--header-height, 72px) + 10px);
  right: clamp(1rem, 3.5vw, 2.5rem);
  left: auto !important;
  bottom: auto;
  width: 380px;
  max-width: calc(100vw - 24px);
  height: min(580px, calc(100vh - var(--header-height, 72px) - 24px));
  z-index: 99985;
  background: rgba(255, 255, 255, 0.99);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid rgba(13, 148, 136, 0.28);
  border-radius: var(--radius-xl, 16px);
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.16), 0 0 25px rgba(13, 148, 136, 0.12);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: contain !important;
  opacity: 0;
  transform: translateY(-10px) scale(0.95);
  transform-origin: top right;
  pointer-events: none;
  visibility: hidden;
  transition: 
    opacity 0.32s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.32s cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0.32s ease;
  box-sizing: border-box;
}

@media (max-width: 640px) {
  .nk-chatbot-panel {
    top: calc(var(--header-height, 72px) + 6px);
    left: auto !important;
    right: 12px !important;
    width: min(380px, calc(100vw - 24px));
    height: min(540px, calc(100vh - var(--header-height, 72px) - 20px));
  }
}

.nk-chatbot-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
}

/* --------------------------------------------------------------------------
   3. Chatbot Header
   -------------------------------------------------------------------------- */
.nk-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.95rem 1.15rem;
  background: rgba(248, 250, 252, 0.96);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  flex-shrink: 0;
  gap: 0.75rem;
}

.nk-header-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.nk-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.15) 0%, rgba(241, 245, 249, 0.9) 100%);
  border: 1.5px solid rgba(37, 99, 235, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary, #1d4ed8);
  font-family: var(--font-body, sans-serif);
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.nk-header-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.nk-header-title {
  font-family: var(--font-body, sans-serif);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-main, #0f172a);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nk-header-status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono, monospace);
  font-size: 0.6875rem;
  color: var(--text-dim, #64748b);
}

.nk-header-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
}

.nk-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.nk-header-page-badge {
  font-family: var(--font-mono, monospace);
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--primary, #1d4ed8);
  background: rgba(37, 99, 235, 0.1);
  border: 1px solid rgba(37, 99, 235, 0.25);
  border-radius: var(--radius-full, 9999px);
  padding: 0.2rem 0.55rem;
  white-space: nowrap;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nk-header-close-btn {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 50%;
  color: var(--text-muted, #64748b);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.nk-header-close-btn svg {
  display: block;
  margin: auto;
  pointer-events: none;
}

.nk-header-close-btn:hover {
  background: var(--surface-low, #f1f5f9);
  color: var(--text-main, #0f172a);
  border-color: rgba(15, 23, 42, 0.25);
  transform: rotate(90deg);
}

/* --------------------------------------------------------------------------
   4. Direct Contact Top Utility Strip
   -------------------------------------------------------------------------- */
.nk-chat-quick-contact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(241, 245, 249, 0.8);
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
  flex-shrink: 0;
}

.nk-quick-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-sm, 4px);
  border: 1px solid rgba(15, 23, 42, 0.1);
  text-decoration: none;
  color: var(--text-secondary, #334155);
  background: #ffffff;
  transition: all 0.2s ease;
  font-weight: 600;
  flex: 1;
  justify-content: center;
  white-space: nowrap;
}

.nk-quick-btn:hover {
  border-color: var(--primary-container, #2563eb);
  color: var(--primary, #1d4ed8);
  background: rgba(37, 99, 235, 0.08);
}

.nk-quick-btn.whatsapp-quick:hover {
  border-color: #22c55e;
  background: rgba(34, 197, 94, 0.1);
  color: #15803d;
}

/* --------------------------------------------------------------------------
   5. Chat Messages Scroll Container
   -------------------------------------------------------------------------- */
.nk-chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto !important;
  overflow-x: hidden !important;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  overscroll-behavior: contain !important;
  -webkit-overflow-scrolling: touch !important;
  touch-action: pan-y !important;
  scrollbar-width: thin;
  scrollbar-color: rgba(37, 99, 235, 0.35) rgba(15, 23, 42, 0.05);
}

.nk-chat-messages::-webkit-scrollbar {
  width: 6px;
}
.nk-chat-messages::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.04);
  border-radius: 6px;
}
.nk-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(37, 99, 235, 0.35);
  border-radius: 6px;
}
.nk-chat-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(37, 99, 235, 0.6);
}

/* Welcome Card */
.nk-welcome-card {
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: var(--radius-lg, 12px);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  animation: nkFadeSlideIn 0.35s ease forwards;
}

.nk-welcome-title {
  font-family: var(--font-body, sans-serif);
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-main, #0f172a);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.nk-welcome-desc {
  font-size: 0.8125rem;
  line-height: 1.55;
  color: var(--text-muted, #64748b);
}

/* Suggested Action Chips */
.nk-chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  margin-top: 0.35rem;
}

.nk-suggestion-chip {
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.1);
  border-radius: var(--radius-sm, 4px);
  padding: 0.45rem 0.75rem;
  text-align: left;
  font-family: var(--font-body, sans-serif);
  font-size: 0.78rem;
  color: var(--text-secondary, #334155);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nk-suggestion-chip:hover {
  background: rgba(37, 99, 235, 0.06);
  border-color: var(--primary-container, #2563eb);
  color: var(--primary, #1d4ed8);
  transform: translateX(3px);
}

.nk-suggestion-chip::after {
  content: '→';
  color: var(--primary, #1d4ed8);
  font-size: 0.75rem;
  transition: transform 0.2s ease;
}

.nk-suggestion-chip:hover::after {
  transform: translateX(2px);
}

/* Message Rows & Bubbles */
.nk-message-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  animation: nkFadeSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

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

.nk-message-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #f1f5f9;
  border: 1px solid rgba(37, 99, 235, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--primary, #1d4ed8);
  flex-shrink: 0;
  margin-top: 2px;
}

.nk-message-bubble {
  max-width: 84%;
  padding: 0.75rem 0.95rem;
  font-family: var(--font-body, sans-serif);
  font-size: 0.84rem;
  line-height: 1.55;
  box-sizing: border-box;
  word-break: break-word;
}

.nk-message-row.user-row .nk-message-bubble {
  background: #1d4ed8;
  border: 1px solid #1e40af;
  border-radius: 14px 14px 2px 14px;
  color: #ffffff;
}

.nk-message-row.assistant-row .nk-message-bubble {
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px 14px 14px 2px;
  color: var(--text-main, #0f172a);
}

/* Warning Message Styling */
.nk-message-row.assistant-row.warning-row .nk-message-bubble {
  background: rgba(239, 68, 68, 0.08) !important;
  border: 1px solid rgba(239, 68, 68, 0.35) !important;
  color: #991b1b !important;
  box-shadow: 0 4px 18px rgba(239, 68, 68, 0.08) !important;
}

.nk-message-row.assistant-row.warning-row .nk-message-bubble strong {
  color: #b91c1c !important;
}

.nk-message-row.assistant-row.warning-row .nk-message-avatar {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
  color: #b91c1c !important;
}

.nk-message-bubble p {
  margin: 0 0 0.5rem 0;
}
.nk-message-bubble p:last-child {
  margin-bottom: 0;
}

.nk-message-bubble ul, .nk-message-bubble ol {
  margin: 0.4rem 0 0.5rem 1.25rem;
  padding: 0;
}

.nk-message-bubble li {
  margin-bottom: 0.3rem;
  color: var(--text-secondary, #334155);
}

.nk-message-bubble strong {
  color: #0f172a;
  font-weight: 600;
}

.nk-message-row.user-row .nk-message-bubble strong {
  color: #ffffff;
}

/* In-Message Call to Action Buttons */
.nk-message-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.65rem;
  padding-top: 0.5rem;
  border-top: 1px solid rgba(15, 23, 42, 0.08);
}

.nk-msg-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: var(--radius-sm, 4px);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s ease;
}

.nk-msg-btn-primary {
  background: var(--primary-container, #0d9488);
  color: #ffffff;
  border: 1px solid var(--primary-container, #0d9488);
}

.nk-msg-btn-primary:hover {
  background: var(--primary-hover, #0f766e);
  box-shadow: 0 0 10px rgba(13, 148, 136, 0.3);
}

.nk-msg-btn-secondary {
  background: #ffffff;
  color: var(--text-main, #0f172a);
  border: 1px solid rgba(15, 23, 42, 0.12);
}

.nk-msg-btn-secondary:hover {
  background: #f1f5f9;
  border-color: rgba(15, 23, 42, 0.25);
}

.nk-msg-btn-whatsapp {
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.nk-msg-btn-whatsapp:hover {
  background: #22c55e;
  color: #ffffff;
}

/* Typing / Thinking Indicator */
.nk-typing-indicator {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.6rem 0.85rem;
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px 14px 14px 2px;
  width: fit-content;
}

.nk-typing-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary, #1d4ed8);
  animation: nkTypingBounce 1.4s infinite ease-in-out;
}

.nk-typing-dot:nth-child(1) { animation-delay: 0s; }
.nk-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.nk-typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

.nk-typing-text {
  font-family: var(--font-mono, monospace);
  font-size: 0.7rem;
  color: var(--text-dim, #64748b);
  margin-left: 0.3rem;
}

/* --------------------------------------------------------------------------
   6. Chatbot Input Footer
   -------------------------------------------------------------------------- */
.nk-chat-footer {
  padding: 0.75rem 1rem 0.85rem;
  background: rgba(248, 250, 252, 0.98);
  border-top: 1px solid rgba(15, 23, 42, 0.08);
  flex-shrink: 0;
}

.nk-chat-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #ffffff;
  border: 1px solid rgba(15, 23, 42, 0.15);
  border-radius: var(--radius-md, 8px);
  padding: 0.35rem 0.5rem 0.35rem 0.85rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.nk-chat-form:focus-within {
  border-color: var(--primary-container, #0d9488);
  box-shadow: 0 0 0 2px rgba(13, 148, 136, 0.18);
}

.nk-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text-main, #0f172a);
  font-family: var(--font-body, sans-serif);
  font-size: 16px; /* Prevents auto-zoom on iOS Safari */
  line-height: 1.4;
  min-height: 24px;
}

.nk-chat-input::placeholder {
  color: var(--text-dim, #94a3b8);
  font-size: 0.84rem;
}

.nk-chat-send-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm, 4px);
  background: var(--primary-container, #0d9488);
  border: none;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.nk-chat-send-btn:hover {
  background: var(--primary-hover, #0f766e);
  transform: scale(1.05);
}

.nk-chat-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.nk-chat-disclaimer {
  display: block;
  text-align: center;
  font-family: var(--font-mono, monospace);
  font-size: 0.63rem;
  color: var(--text-dim, #94a3b8);
  margin-top: 0.45rem;
}

/* --------------------------------------------------------------------------
   7. Responsive Adaptations (Mobile & Safe Areas)
   -------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .nk-chatbot-launcher {
    bottom: max(16px, env(safe-area-inset-bottom, 16px));
    left: max(16px, env(safe-area-inset-left, 16px));
    padding: 0.6rem 0.95rem 0.6rem 0.85rem;
    font-size: 0.75rem;
  }

  .nk-chatbot-panel {
    top: calc(var(--header-height, 72px) + 6px);
    right: 12px !important;
    left: auto !important;
    bottom: auto;
    width: min(380px, calc(100vw - 24px));
    height: min(540px, calc(100vh - var(--header-height, 72px) - 20px));
  }

  .nk-header-page-badge {
    display: none;
  }
}

/* Very small screens (Smartwatches & Compact Foldables 240px - 320px) */
@media (max-width: 320px) {
  .nk-chatbot-launcher {
    bottom: 12px;
    left: 8px;
    padding: 0.5rem 0.75rem;
    font-size: 0.7rem;
  }

  .nk-launcher-text {
    display: none;
  }

  .nk-chatbot-panel {
    top: calc(var(--header-height, 72px) + 4px);
    right: 6px !important;
    left: auto !important;
    bottom: auto;
    width: calc(100vw - 12px);
    height: calc(100vh - var(--header-height, 72px) - 12px);
    border-radius: var(--radius-md, 8px);
  }

  .nk-chat-header {
    padding: 0.75rem 0.85rem;
  }

  .nk-chat-messages {
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .nk-chat-quick-contact {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Keyboard open state on mobile */
body.nk-chat-keyboard-open .nk-chatbot-panel {
  position: fixed;
  top: 10px;
  bottom: auto;
  height: calc(var(--visual-viewport-height, 100vh) - 20px);
}

/* Reduced Motion Override */
@media (prefers-reduced-motion: reduce) {
  .nk-chatbot-launcher,
  .nk-chatbot-panel,
  .nk-message-row,
  .nk-welcome-card {
    transition: none !important;
    animation: none !important;
  }
  .nk-launcher-pulse-dot {
    animation: none !important;
  }
}
