
/* =============================================
   NEXUS FLOATING WIDGET — JFKAISLAY.COM
   ============================================= */

:root {
  --nx-blue: #00AAFF;
  --nx-blue-deep: #0066EE;
  --nx-blue-glow: rgba(0, 170, 255, 0.6);
  --nx-blue-glow-intense: rgba(0, 170, 255, 0.85);
  --nx-chrome: linear-gradient(145deg, #2a2a2a 0%, #0a0a0a 50%, #1a1a1a 100%);
  --nx-bg: #ffffff;
  --nx-surface: #f5f5f5;
  --nx-border: rgba(0,0,0,0.1);
  --nx-text: #111111;
  --nx-text-dim: #666;
  --nx-radius: 22%;
}

/* =============================================
   FLOATING BUTTON
   ============================================= */

.nexus-chat-btn {
  position: fixed;
  z-index: 99999;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: var(--nx-radius);
  background: var(--nx-chrome);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  outline: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s ease;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.5),
    0 0 35px var(--nx-blue-glow),
    0 0 70px rgba(0, 170, 255, 0.25),
    0 0 110px rgba(0, 170, 255, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  animation: nxPulse 2.5s ease-in-out infinite;
}

@keyframes nxPulse {
  0%, 100% {
    box-shadow:
      0 4px 20px rgba(0, 0, 0, 0.5),
      0 0 30px var(--nx-blue-glow),
      0 0 65px rgba(0, 170, 255, 0.2),
      0 0 100px rgba(0, 170, 255, 0.06),
      inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }
  50% {
    box-shadow:
      0 4px 20px rgba(0, 0, 0, 0.5),
      0 0 45px var(--nx-blue-glow-intense),
      0 0 90px rgba(0, 170, 255, 0.4),
      0 0 140px rgba(0, 170, 255, 0.12),
      inset 0 1px 0 rgba(255, 255, 255, 0.12);
  }
}

.nexus-chat-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0) 100%);
  border-radius: var(--nx-radius) var(--nx-radius) 0 0;
  pointer-events: none;
}

.nexus-chat-btn:hover {
  transform: scale(1.08);
  animation: none;
  box-shadow:
    0 6px 28px rgba(0, 0, 0, 0.5),
    0 0 55px var(--nx-blue-glow-intense),
    0 0 110px rgba(0, 170, 255, 0.5),
    0 0 160px rgba(0, 170, 255, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.nexus-chat-btn:active {
  transform: scale(0.95);
  animation: none;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.5),
    0 0 15px rgba(0, 170, 255, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.nexus-btn-icon {
  width: 28px;
  height: 28px;
  position: relative;
  z-index: 1;
  filter:
    drop-shadow(0 0 6px rgba(0, 170, 255, 0.9))
    drop-shadow(0 0 14px rgba(0, 140, 255, 0.6));
}

/* =============================================
   GREETING BUBBLE
   ============================================= */

.nexus-greeting {
  position: fixed;
  z-index: 99998;
  background: var(--nx-bg);
  color: var(--nx-text);
  padding: 10px 14px;
  border-radius: 12px 12px 4px 12px;
  max-width: 260px;
  font-family: Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.4;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--nx-border);
  cursor: pointer;
  opacity: 0;
  will-change: opacity, transform;
  transform: translateY(8px) translateZ(0);
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}
.nexus-greeting.visible { opacity: 1; transform: translateY(0) translateZ(0); pointer-events: auto; }
.nexus-greeting-close { position: absolute; top: 4px; right: 8px; background: none; border: none; color: #999; font-size: 16px; cursor: pointer; padding: 0; line-height: 1; -webkit-tap-highlight-color: transparent; }
.nexus-greeting-close:hover { color: #333; }

/* =============================================
   CHAT WINDOW — BASE
   ============================================= */

.nexus-chat-window {
  position: fixed;
  z-index: 100000;
  background: var(--nx-bg);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: Helvetica, Arial, sans-serif;
  overscroll-behavior: contain;
}
.nexus-chat-window.open { display: flex; }

/* =============================================
   HEADER
   ============================================= */

.nexus-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--nx-border);
  background: var(--nx-bg);
}
.nexus-header-left { display: flex; align-items: center; gap: 10px; }
.nexus-header-avatar { width: 32px; height: 32px; border-radius: 8px; object-fit: cover; background: var(--nx-surface); }
.nexus-header-info { display: flex; flex-direction: column; }
.nexus-header-name { font-size: 14px; font-weight: 600; color: #111; letter-spacing: 0.5px; }
.nexus-header-status { display: flex; align-items: center; gap: 5px; font-size: 11px; color: #16a34a; letter-spacing: 0.5px; }
.nexus-status-dot { width: 6px; height: 6px; border-radius: 50%; background: #16a34a; animation: nxDotPulse 2s ease-in-out infinite; }

@keyframes nxDotPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px #16a34a; }
  50% { opacity: 0.4; box-shadow: 0 0 10px #16a34a; }
}

.nexus-close-btn { background: none; border: none; color: #999; cursor: pointer; padding: 4px; font-size: 20px; line-height: 1; -webkit-tap-highlight-color: transparent; transition: color 0.15s; }
.nexus-close-btn:hover { color: #333; }

/* =============================================
   MESSAGES AREA
   ============================================= */

.nexus-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
}
.nexus-messages::-webkit-scrollbar { width: 3px; }
.nexus-messages::-webkit-scrollbar-track { background: transparent; }
.nexus-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.12); border-radius: 3px; }

/* =============================================
   MESSAGE BUBBLES
   ============================================= */

.nx-msg {
  max-width: 85%;
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
  animation: nxMsgIn 0.2s ease-out;
  flex-shrink: 0;
}

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

.nx-msg-user { align-self: flex-end; background: rgba(0, 170, 255, 0.1); color: #111; border-radius: 16px 16px 4px 16px; }
.nx-msg-assistant { align-self: flex-start; background: transparent; color: #111; font-weight: 450; border-radius: 16px 16px 16px 4px; }
.nx-msg a { color: var(--nx-blue-deep); text-decoration: none; border-bottom: 1px solid rgba(0, 102, 238, 0.3); }
.nx-msg a:hover { color: #0088dd; border-bottom-color: #0088dd; }

/* =============================================
   TYPING INDICATOR
   ============================================= */

.nx-typing { align-self: flex-start; padding: 10px 14px; display: none; gap: 5px; align-items: center; flex-shrink: 0; }
.nx-typing.active { display: flex; }
.nx-typing-dot { width: 6px; height: 6px; background: #ccc; border-radius: 50%; animation: nxBounce 1.2s infinite; }
.nx-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.nx-typing-dot:nth-child(3) { animation-delay: 0.4s; }

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

/* =============================================
   TTS BUTTON
   ============================================= */

.nexus-tts-btn { background: none; border: none; cursor: pointer; padding: 4px 0; margin-top: 4px; opacity: 0.4; transition: opacity 0.2s; display: block; -webkit-tap-highlight-color: transparent; line-height: 1; }
.nexus-tts-btn:hover { opacity: 1; }
.nexus-tts-btn.playing { opacity: 1; }
.nexus-tts-btn.loading { opacity: 0.6; animation: nxTtsPulse 1s infinite; }
.nexus-tts-btn svg { width: 16px; height: 16px; fill: var(--nx-blue-deep); }

@keyframes nxTtsPulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 0.8; } }

/* =============================================
   INPUT FOOTER
   ============================================= */

.nexus-footer {
  flex: 0 0 auto;
  padding: 12px 16px;
  border-top: 1px solid var(--nx-border);
  background: var(--nx-bg);
}

.nexus-input-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  background: var(--nx-surface);
  border: 2px solid #ddd;
  border-radius: 12px;
  padding: 6px 6px 6px 14px;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.nexus-input-row:focus-within { border-color: var(--nx-blue); }

.nexus-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: #111;
  font-family: Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  resize: none;
  max-height: 100px;
  min-height: 20px;
  padding: 4px 0;
  caret-color: var(--nx-blue);
  -webkit-appearance: none;
}
.nexus-input::placeholder { color: #999; }

.nexus-mic-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: #999;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nexus-mic-btn:hover { color: var(--nx-blue); }
.nexus-mic-btn.recording { color: #ff4444; animation: nxMicPulse 1s infinite; }
.nexus-mic-btn svg { width: 18px; height: 18px; fill: currentColor; }

@keyframes nxMicPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

.nexus-send-btn {
  background: transparent;
  border: 2px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  min-width: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nexus-send-btn svg { width: 16px; height: 16px; fill: #999; transition: fill 0.15s; }
.nexus-send-btn:hover { background: #111; border-color: #111; }
.nexus-send-btn:hover svg { fill: #fff; }

.nexus-powered { text-align: center; padding: 6px 0 2px; font-size: 10px; color: #999; letter-spacing: 0.3px; }
.nexus-powered a { color: #999; text-decoration: none; }
.nexus-powered a:hover { color: var(--nx-blue); }


/* =============================================
   DESKTOP (≥1024px)
   ============================================= */

@media (min-width: 1024px) {
  .nexus-chat-btn { bottom: 24px; right: 24px; }
  .nexus-greeting { bottom: 90px; right: 24px; }
  .nexus-chat-window {
    bottom: 90px;
    right: 24px;
    width: 400px;
    height: 560px;
    border-radius: 16px;
    border: 1px solid var(--nx-border);
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.15);
  }
}


/* =============================================
   TABLET (768px – 1023px)
   ============================================= */

@media (min-width: 768px) and (max-width: 1023px) {
  .nexus-chat-btn { bottom: 20px; right: 20px; width: 52px; height: 52px; }
  .nexus-greeting { bottom: 82px; right: 20px; }
  .nexus-chat-window {
    bottom: 82px;
    right: 20px;
    width: 380px;
    height: 500px;
    border-radius: 16px;
    border: 1px solid var(--nx-border);
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.15);
  }
  .nexus-mic-btn { width: 34px; height: 34px; min-width: 34px; }
  .nexus-send-btn { width: 34px; height: 34px; min-width: 34px; }
}


/* =============================================
   MOBILE (≤767px)
   button at bottom:76px clears Chrome's
   ~56-70px bottom toolbar
   chat at 93dvh leaves room for browser chrome
   ============================================= */

@media (max-width: 767px) {
  .nexus-chat-btn {
    bottom: 76px;
    right: 16px;
    width: 50px;
    height: 50px;
  }
  .nexus-chat-btn::before { border-radius: var(--nx-radius) var(--nx-radius) 0 0; }

  .nexus-greeting { bottom: 140px; right: 16px; max-width: 220px; }

  .nexus-chat-window {
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 93vh;
    height: 93dvh;
    border-radius: 16px 16px 0 0;
    border: none;
    box-shadow: 0 -4px 30px rgba(0, 0, 0, 0.15);
  }

  .nexus-messages { padding: 14px; gap: 8px; }
  .nx-msg { max-width: 90%; font-size: 15px; }

  .nexus-footer { padding: 10px 12px; }

  .nexus-input-row {
    gap: 4px;
    padding: 5px 5px 5px 12px;
    border-radius: 10px;
  }

  .nexus-input {
    font-size: 16px;
    padding: 6px 0;
    min-height: 22px;
  }

  .nexus-mic-btn { width: 38px; height: 38px; min-width: 38px; }
  .nexus-mic-btn svg { width: 20px; height: 20px; }

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


/* =============================================
   SMALL MOBILE (≤374px — iPhone SE)
   ============================================= */

@media (max-width: 374px) {
  .nexus-chat-btn { bottom: 76px; right: 12px; width: 46px; height: 46px; }
  .nexus-greeting { bottom: 136px; right: 12px; max-width: 200px; }

  .nexus-footer { padding: 8px 10px; }

  .nexus-input-row {
    gap: 3px;
    padding: 4px 4px 4px 10px;
  }

  .nexus-input { font-size: 16px; padding: 5px 0; }

  .nexus-mic-btn { width: 34px; height: 34px; min-width: 34px; }
  .nexus-mic-btn svg { width: 18px; height: 18px; }

  .nexus-send-btn { width: 34px; height: 34px; min-width: 34px; }
  .nexus-send-btn svg { width: 16px; height: 16px; }
}


/* =============================================
   SAFE AREA — iPhone notch + home indicator
   ============================================= */

@supports (padding-bottom: env(safe-area-inset-bottom)) {
  @media (max-width: 767px) {
    .nexus-footer {
      padding-bottom: calc(10px + env(safe-area-inset-bottom));
    }
    .nexus-chat-btn {
      bottom: calc(76px + env(safe-area-inset-bottom));
    }
    .nexus-greeting {
      bottom: calc(140px + env(safe-area-inset-bottom));
    }
  }
}
