/* ============================================================
   NexCore AI Chat Widget — styles
   Matches the platform's dark theme (#0a0b1c base, #6ee7f3 accent)
   ============================================================ */

/* ── Floating trigger button ────────────────────────────────── */
#nexai-trigger {
  position: fixed;
  bottom: 18px;
  right: 18px;
  z-index: 9998;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(8, 10, 22, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: 0 4px 24px rgba(2, 6, 23, 0.55);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
}

#nexai-trigger:hover {
  transform: scale(1.05);
  box-shadow: 0 0px 20px rgba(110, 231, 243, 0.45);
  border-color: rgba(110, 231, 243, 0.7);
}

 #nexai-trigger:hover svg {
  stroke: #6ee7f3;
 }



#nexai-trigger:active {
  transform: scale(0.98);
}

#nexai-trigger svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: #9aa3b2;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.2s;
}

/* Pulse ring when AI is available */


@keyframes nexai-pulse {
  0%, 100% { opacity: 0.5; transform: scale(1);    }
  50%       { opacity: 0;   transform: scale(1.22); }
}

/* Unread badge */
#nexai-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #9aa3b2;
  border: 2px solid #0a0b1c;
  display: none;
}

#nexai-badge:hover{
  background: #6ee7f3;
}

#nexai-badge.visible {
  display: block;
}

/* ── Chat panel (the popup window) ─────────────────────────── */
#nexai-panel {
  position: fixed;
  bottom: 94px;
  right: 28px;
  z-index: 9001;
  width: 360px;
  max-height: 560px;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(10, 11, 28, 0.96);
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(110, 231, 243, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  overflow: hidden;

  /* Hidden by default */
  opacity: 0;
  transform: translateY(12px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.2, 0.9, 0.3, 1),
              transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1);
}

#nexai-panel::before {
  content: '';
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--ncc-primary), transparent);
  opacity: 0.45;
  border-radius: var(--ncc-radius) var(--ncc-radius) 0 0;
  pointer-events: none;
}

#nexai-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Panel header ───────────────────────────────────────────── */
#nexai-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid rgba(110, 231, 243, 0.08);
  flex-shrink: 0;
  user-select: none;
}

#nexai-header .nexai-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6ee7f3, #3ac5c0);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 16px;
  color: #031017;
}

#nexai-header .nexai-title {
  flex: 1;
}

#nexai-header .nexai-title h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  color: #eaf6fb;
  letter-spacing: 0.3px;
}

#nexai-header .nexai-title span {
  font-size: 11px;
  color: #6ee7f3;
  opacity: 0.8;
}

.nexai-usage-pill {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 20px;
  background: rgba(110, 231, 243, 0.08);
  border: 1px solid rgba(110, 231, 243, 0.15);
  color: #6ee7f3;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.nexai-usage-pill.depleted {
  background: rgba(255, 100, 100, 0.08);
  border-color: rgba(255, 100, 100, 0.2);
  color: #ff7878;
}

#nexai-close {
  background: transparent;
  border: none;
  color: rgba(154, 163, 178, 0.7);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  line-height: 1;
  font-size: 18px;
  transition: color 0.2s, background 0.2s;
  flex-shrink: 0;
}

#nexai-close:hover {
  color: #eaf6fb;
  background: rgba(255, 255, 255, 0.05);
}

/* ── Messages area ─────────────────────────────────────────── */
#nexai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(110, 231, 243, 0.2) transparent;
}

#nexai-messages::-webkit-scrollbar {
  width: 4px;
}
#nexai-messages::-webkit-scrollbar-thumb {
  background: rgba(110, 231, 243, 0.2);
  border-radius: 4px;
}

/* ── Message bubble ─────────────────────────────────────────── */
.nexai-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: nexai-msg-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}

@keyframes nexai-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0);   }
}

.nexai-msg.user {
  align-self: flex-end;
  align-items: flex-end;
}

.nexai-msg.ai {
  align-self: flex-start;
  align-items: flex-start;
}

.nexai-bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.nexai-msg.user .nexai-bubble {
  background: linear-gradient(135deg, rgba(110, 231, 243, 0.18), rgba(58, 197, 192, 0.12));
  border: 1px solid rgba(110, 231, 243, 0.2);
  color: #eaf6fb;
  border-bottom-right-radius: 4px;
}

.nexai-msg.ai .nexai-bubble {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #c8d6e5;
  border-bottom-left-radius: 4px;
}

.nexai-msg-time {
  font-size: 10px;
  color: rgba(154, 163, 178, 0.5);
  margin-top: 3px;
  padding: 0 2px;
}

/* ── Typing indicator ──────────────────────────────────────── */
.nexai-typing {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 2px;
}

.nexai-typing-dots {
  display: flex;
  gap: 4px;
}

.nexai-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6ee7f3;
  opacity: 0.4;
  animation: nexai-dot 1.2s ease-in-out infinite;
}

.nexai-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.nexai-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes nexai-dot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8);   }
  40%            { opacity: 1;   transform: scale(1.15);  }
}

.nexai-typing-label {
  font-size: 11.5px;
  color: #6ee7f3;
  opacity: 0.8;
  font-style: italic;
}

/* ── Quick suggestions ─────────────────────────────────────── */
#nexai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 10px;
}

.nexai-suggestion {
  font-size: 11.5px;
  padding: 5px 10px;
  border-radius: 20px;
  border: 1px solid rgba(110, 231, 243, 0.2);
  background: rgba(110, 231, 243, 0.05);
  color: #6ee7f3;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.nexai-suggestion:hover {
  background: rgba(110, 231, 243, 0.12);
  border-color: rgba(110, 231, 243, 0.4);
  transform: translateY(-1px);
}

.nexai-suggestion:active {
  transform: scale(0.97);
}

/* ── Input area ────────────────────────────────────────────── */
#nexai-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 14px 14px;
  border-top: 1px solid rgba(110, 231, 243, 0.06);
  flex-shrink: 0;
}

#nexai-input {
  flex: 1;
  resize: none;
  font-family: Inter, sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  max-height: 90px;
  min-height: 40px;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid rgba(110, 231, 243, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: #eaf6fb;
  outline: none;
  overflow-y: auto;
  scrollbar-width: thin;
  box-sizing: border-box;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition: border-color 0.2s, box-shadow 0.2s;
  /* Reset inherited global input styles */
  width: 100%;
  max-width: 100%;
  margin: 0;
  transform: none;
  box-shadow: none;
}

#nexai-input:focus {
  border-color: rgba(110, 231, 243, 0.45);
  box-shadow: 0 0 0 3px rgba(110, 231, 243, 0.07);
  transform: none;
  font-size: 13.5px;
}

#nexai-input::placeholder {
  color: rgba(154, 163, 178, 0.5);
}

#nexai-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

#nexai-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

#nexai-send svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: #031017;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Sources footer ─────────────────────────────────────────── */
.nexai-sources {
  margin-top: 5px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.nexai-source-tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  background: rgba(110, 231, 243, 0.07);
  border: 1px solid rgba(110, 231, 243, 0.12);
  color: rgba(110, 231, 243, 0.7);
}

/* ── Error / empty state ────────────────────────────────────── */
.nexai-error-bubble {
  background: rgba(255, 100, 100, 0.08) !important;
  border-color: rgba(255, 100, 100, 0.2) !important;
  color: #ffaaaa !important;
}

.nexai-welcome {
  text-align: center;
  padding: 16px 8px;
  color: rgba(154, 163, 178, 0.7);
  font-size: 13px;
  user-select: none;
}

.nexai-welcome .nexai-welcome-icon {
  font-size: 28px;
  margin-bottom: 8px;
  display: block;
}

/* ── Character counter ──────────────────────────────────────── */
#nexai-char-counter {
  font-size: 10px;
  color: rgba(154, 163, 178, 0.4);
  text-align: right;
  padding: 0 16px 4px;
  flex-shrink: 0;
  min-height: 16px;
  transition: color 0.2s;
}

#nexai-char-counter.warn {
  color: #ffb347;
}

#nexai-char-counter.limit {
  color: #ff7878;
}

/* ── Auth CTA (shown when not signed in) ────────────────────── */
#nexai-auth-cta {
  padding: 0 14px 14px;
  flex-shrink: 0;
}

.nexai-signin-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: linear-gradient(135deg, rgba(110, 231, 243, 0.12), rgba(110, 231, 243, 0.06));
  border: 1px solid rgba(110, 231, 243, 0.3);
  border-radius: 10px;
  color: #6ee7f3;
  font-size: 13.5px;
  font-weight: 600;
  font-family: Inter, sans-serif;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.nexai-signin-btn:hover {
  background: linear-gradient(135deg, rgba(110, 231, 243, 0.2), rgba(110, 231, 243, 0.1));
  border-color: rgba(110, 231, 243, 0.55);
  transform: translateY(-1px);
}

.nexai-signin-btn:active {
  transform: translateY(0);
}

/* ── Retry button ───────────────────────────────────────────── */
.nexai-retry-btn {
  font-size: 11px;
  margin-top: 5px;
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid rgba(255, 100, 100, 0.3);
  background: rgba(255, 100, 100, 0.06);
  color: #ffaaaa;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  -webkit-tap-highlight-color: transparent;
  outline: none;
}

.nexai-retry-btn:hover {
  background: rgba(255, 100, 100, 0.14);
  border-color: rgba(255, 100, 100, 0.5);
}

/* ── Support bubble & button (shown on API quota exhaustion) ─────────── */
.nexai-support-bubble {
  background: rgba(255, 180, 0, 0.05) !important;
  border-color: rgba(255, 180, 0, 0.18) !important;
  color: #f0d8a0 !important;
}

.nexai-support-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 8px 16px;
  border-radius: 20px;
  background: #0070ba;
  color: #fff;
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.3px;
  transition: background 0.2s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.nexai-support-btn:hover {
  background: #005ea6;
  transform: translateY(-1px);
}

.nexai-support-btn:active {
  transform: scale(0.97);
}

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #nexai-trigger::after,
  .nexai-typing-dots span,
  .nexai-msg {
    animation: none;
  }
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 420px) {
  #nexai-panel {
    width: calc(100vw - 24px);
    right: 12px;
    bottom: 84px;
    max-height: 70vh;
    border-radius: 14px;
  }

  #nexai-trigger {
    right: 16px;
    bottom: 20px;
  }
}
