/* ─────────────────────────────────────────────────────────────────────────────
   NKR Portfolio — Chat Widget
   Self-contained styles (scoped under .nkr-chat*) so the widget looks consistent
   on both the portfolio (index.html) and blog pages regardless of page CSS.
   ───────────────────────────────────────────────────────────────────────────── */

.nkr-chat,
.nkr-chat * {
  box-sizing: border-box;
}

.nkr-chat {
  --nkrc-paper: #f5f1ea;
  --nkrc-card: #fffdf9;
  --nkrc-ink: #29292c;
  --nkrc-muted: #66635f;
  --nkrc-line: rgba(41, 41, 44, 0.12);
  --nkrc-blue: #4285f4;
  --nkrc-green: #34a853;
  --nkrc-red: #ea4335;
  --nkrc-yellow: #fbbc05;
  --nkrc-radius: 18px;
  --nkrc-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --nkrc-display: "Outfit", var(--nkrc-font);

  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 9000;
  font-family: var(--nkrc-font);
}

/* ── Launcher bubble ─────────────────────────────────────────────────────── */
.nkr-chat-launcher {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--nkrc-ink);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 32px rgba(41, 41, 44, 0.28);
  transition: transform 0.18s ease, opacity 0.18s ease;
}
.nkr-chat-launcher:hover {
  transform: scale(1.06);
}
.nkr-chat-launcher svg {
  width: 26px;
  height: 26px;
}
.nkr-chat-launcher .nkrc-dot {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--nkrc-green);
  border: 2px solid var(--nkrc-ink);
}

/* ── Panel ───────────────────────────────────────────────────────────────── */
.nkr-chat-panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 120px));
  background: var(--nkrc-paper);
  border: 1px solid var(--nkrc-line);
  border-radius: var(--nkrc-radius);
  box-shadow: 0 24px 70px rgba(41, 41, 44, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px) scale(0.97);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.nkr-chat.open .nkr-chat-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.nkr-chat.open .nkr-chat-launcher {
  opacity: 0;
  pointer-events: none;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
.nkr-chat-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.95rem 1.1rem;
  background: var(--nkrc-card);
  border-bottom: 1px solid var(--nkrc-line);
}
.nkr-chat-dots {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.nkr-chat-dots span {
  display: block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.nkr-chat-dots span:nth-child(1) { background: var(--nkrc-blue); }
.nkr-chat-dots span:nth-child(2) { background: var(--nkrc-red); }
.nkr-chat-dots span:nth-child(3) { background: var(--nkrc-green); }
.nkr-chat-dots span:nth-child(4) { background: var(--nkrc-yellow); }
.nkr-chat-titles {
  flex: 1;
  min-width: 0;
}
.nkr-chat-title {
  font-family: var(--nkrc-display);
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--nkrc-ink);
  line-height: 1.2;
}
.nkr-chat-status {
  font-size: 0.72rem;
  color: var(--nkrc-muted);
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.nkr-chat-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--nkrc-green);
}
.nkr-chat-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--nkrc-muted);
  padding: 4px;
  border-radius: 8px;
  display: flex;
  transition: background 0.15s ease, color 0.15s ease;
}
.nkr-chat-close:hover {
  background: rgba(41, 41, 44, 0.06);
  color: var(--nkrc-ink);
}

/* ── Messages ────────────────────────────────────────────────────────────── */
.nkr-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  scroll-behavior: smooth;
}
.nkr-chat-msg {
  max-width: 86%;
  padding: 0.7rem 0.95rem;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.nkr-chat-msg.bot {
  align-self: flex-start;
  background: var(--nkrc-card);
  border: 1px solid var(--nkrc-line);
  color: var(--nkrc-ink);
  border-bottom-left-radius: 4px;
}
.nkr-chat-msg.user {
  align-self: flex-end;
  background: var(--nkrc-ink);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.nkr-chat-msg a {
  color: var(--nkrc-blue);
}
.nkr-chat-msg.user a {
  color: #cfe0ff;
}

/* typing indicator */
.nkr-chat-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.nkr-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--nkrc-muted);
  opacity: 0.5;
  animation: nkrc-blink 1.2s infinite ease-in-out;
}
.nkr-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.nkr-chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes nkrc-blink {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* suggested prompts */
.nkr-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1.1rem 0.6rem;
}
.nkr-chat-suggestion {
  font-size: 0.76rem;
  font-weight: 500;
  color: var(--nkrc-muted);
  background: var(--nkrc-card);
  border: 1px solid var(--nkrc-line);
  padding: 0.4rem 0.8rem;
  border-radius: 100px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.nkr-chat-suggestion:hover {
  color: var(--nkrc-ink);
  border-color: rgba(41, 41, 44, 0.28);
}

/* ── Composer ────────────────────────────────────────────────────────────── */
.nkr-chat-composer {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
  padding: 0.75rem;
  border-top: 1px solid var(--nkrc-line);
  background: var(--nkrc-card);
}
.nkr-chat-input {
  flex: 1;
  resize: none;
  border: 1px solid var(--nkrc-line);
  border-radius: 12px;
  padding: 0.6rem 0.8rem;
  font-family: var(--nkrc-font);
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--nkrc-ink);
  background: var(--nkrc-paper);
  outline: none;
  max-height: 110px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.nkr-chat-input:focus {
  border-color: rgba(66, 133, 244, 0.5);
  box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.12);
}
.nkr-chat-send {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--nkrc-ink);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease, transform 0.12s ease;
}
.nkr-chat-send:hover:not(:disabled) {
  transform: scale(0.95);
}
.nkr-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.nkr-chat-send svg {
  width: 18px;
  height: 18px;
}

.nkr-chat-footer {
  text-align: center;
  font-size: 0.66rem;
  color: var(--nkrc-muted);
  padding: 0 0.75rem 0.6rem;
  background: var(--nkrc-card);
}

@media (prefers-reduced-motion: reduce) {
  .nkr-chat-panel,
  .nkr-chat-launcher,
  .nkr-chat-typing span {
    transition: none;
    animation: none;
  }
}
