/* =========================================
   NILA AI – FINAL PREMIUM COMPACT UI
   Fonts: Lora (headings), Inter (body)
========================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500&family=Lora:wght@500;600&display=swap');

:root {
  --primary: #2F2B36;
  --secondary: #5A2D82;
  --accent: #7B4EA3;

  --bg: #F5F1FA;
  --bg-soft: #F9F7FD;
  --bg-highlight: #EFE8F6;

  --text: #2F2B36;
  --muted: #6A6478;
  --white: #ffffff;
}

/* ---------- Floating Root ---------- */
#nila-ai-floating-root {
  position: fixed;
  bottom: 22px;
  right: 22px;
  z-index: 999999;
  font-family: 'Inter', system-ui, sans-serif;
}

/* ---------- Launcher ---------- */
.nila-ai-launcher {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(123,78,163,.45);
  transition: transform .25s, box-shadow .25s;
}
.nila-ai-launcher img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}
.nila-ai-launcher:hover {
  transform: scale(1.06);
  box-shadow: 0 0 24px rgba(123,78,163,.9);
}

/* ---------- Popup ---------- */
.nila-ai-popup {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 360px;
  height: 560px;
  background: var(--white);
  border-radius: 22px;
  box-shadow: 0 26px 64px rgba(47,43,54,.32);
  overflow: hidden;
  display: flex;
}

/* ---------- Widget ---------- */
.nila-ai-widget {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

/* ---------- Header ---------- */
.nila-ai-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--bg-highlight);
}

.nila-ai-avatar {
  width: 40px;
  height: 40px;
  position: relative;
}
.nila-ai-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid var(--accent);
}
.nila-ai-avatar .dot {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 9px;
  height: 9px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid var(--bg-soft);
}

.nila-ai-title strong {
  font-family: 'Lora', serif;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.nila-ai-title small {
  font-size: 11px;
  color: var(--muted);
}

.nila-ai-new {
  margin-left: auto;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 15px;
  transition: transform .2s, box-shadow .2s;
}
.nila-ai-new:hover {
  transform: rotate(90deg) scale(1.05);
  box-shadow: 0 0 16px rgba(123,78,163,.8);
}

/* ---------- Body ---------- */
.nila-ai-body {
  flex: 1;
  padding: 16px;
  background: var(--bg);
  overflow-y: auto;
}

/* ---------- Welcome ---------- */
.nila-ai-welcome {
  text-align: center;
  margin-bottom: 16px;
}
.nila-ai-welcome h4 {
  font-family: 'Lora', serif;
  font-size: 28px;
  font-weight: 500;
  margin-bottom: 4px;
}
.nila-ai-welcome p {
  font-size: 15px;
  color: var(--muted);
}

/* ---------- Presets ---------- */
.nila-ai-presets {
  display: grid;
  gap: 10px;
}
.nila-ai-presets button {
  background: var(--white);
  border: 1px solid var(--bg-highlight);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
}
.nila-ai-presets button:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 18px rgba(123,78,163,.32);
}

/* ---------- Messages ---------- */
.nila-ai-msg {
  max-width: 82%;
  margin-bottom: 10px;
  font-size: 14px;
  line-height: 1.45;
}
.nila-ai-msg.user {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  padding: 10px 13px;
  border-radius: 16px 16px 4px 16px;
}
.nila-ai-msg.ai {
  background: var(--white);
  padding: 12px 14px;
  border-radius: 16px 16px 16px 4px;
  box-shadow: 0 6px 18px rgba(47,43,54,.08);
}

/* ---------- AI Actions (COMPACT FIX) ---------- */
.nila-ai-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.nila-ai-actions button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  font-size: 11px;
  border-radius: 999px;
  border: 1px solid var(--bg-highlight);
  background: var(--bg-soft);
  cursor: pointer;
  line-height: 1;
  transition: transform .15s, box-shadow .15s;
}
.nila-ai-actions svg {
  width: 13px;
  height: 13px;
}
.nila-ai-actions button:hover {
  transform: scale(1.04);
  box-shadow: 0 0 12px rgba(123,78,163,.35);
}

/* ---------- Typing ---------- */
.nila-ai-typing {
  font-size: 12.5px;
  color: var(--muted);
  font-style: italic;
  margin: 6px 0;
}

/* ---------- Input Row (PERFECTLY ALIGNED) ---------- */
.nila-ai-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  background: var(--bg-highlight);
}

.nila-ai-input input {
  flex: 1;
  height: 42px;
  border-radius: 999px;
  border: none;
  padding: 0 14px;
  font-size: 14px;
  outline: none;
}

.nila-ai-input button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
}
.nila-ai-input button svg {
  width: 17px;
  height: 17px;
}
.nila-ai-input button:hover {
  transform: scale(1.08);
  box-shadow: 0 0 16px rgba(123,78,163,.85);
}

/* ---------- Mic Pulse ---------- */
.nila-ai-mic-btn.listening {
  animation: micPulse 1.4s infinite;
}
@keyframes micPulse {
  0% { box-shadow: 0 0 0 5px rgba(123,78,163,.35); }
  50% { box-shadow: 0 0 0 10px rgba(123,78,163,.15); }
  100% { box-shadow: 0 0 0 5px rgba(123,78,163,.35); }
}
/* =====================================
   AI MESSAGE – SIMPLE & STABLE FIX
===================================== */

/* AI message row */
.nila-ai-msg.ai {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

/* Avatar */
.nila-ai-msg.ai .nila-ai-msg-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  margin-top: 6px;
}

.nila-ai-msg.ai .nila-ai-msg-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

/* Right column */
.nila-ai-msg.ai .nila-ai-msg-body {
  display: flex;
  flex-direction: column;
  max-width: 78%;
}

/* Bubble */
.nila-ai-msg.ai .nila-ai-msg-content {
  background: var(--white);
  padding: 12px 14px;
  border-radius: 16px 16px 16px 6px;
  box-shadow: 0 6px 18px rgba(47,43,54,.08);
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

/* Buttons ALWAYS below */
.nila-ai-msg.ai .nila-ai-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* Action buttons */
.nila-ai-actions button {
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 999px;
}

/* ================================
   CHAT WIDTH & BACKGROUND FIX
================================ */

/* Allow messages to use full row */
.nila-ai-msg {
  max-width: 100% !important;
}

/* AI message layout */
.nila-ai-msg.ai {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

/* Avatar */
.nila-ai-msg.ai .nila-ai-msg-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  margin-top: 6px;
}

/* Message column (bubble + actions) */
.nila-ai-msg.ai .nila-ai-msg-body {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
}

/* Bubble – wide, clean */
.nila-ai-msg.ai .nila-ai-msg-content {
  width: fit-content;
  max-width: 100%;
  background: #ffffff;
  padding: 14px 16px;
  border-radius: 16px 16px 16px 6px;
  box-shadow: 0 6px 16px rgba(0,0,0,.08);
  line-height: 1.5;
}

/* Actions BELOW bubble */
.nila-ai-msg.ai .nila-ai-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* User messages stay compact */
.nila-ai-msg.user {
  max-width: 75%;
  margin-left: auto;
}

/* =====================================
   FINAL CHAT MESSAGE FIX (AUTHORITATIVE)
   Paste at END of CSS
===================================== */

/* RESET conflicting widths */
.nila-ai-msg {
  max-width: 100% !important;
  background: transparent !important;
  padding: 0 !important;
  box-shadow: none !important;
}

/* ===== AI MESSAGE ROW ===== */
.nila-ai-msg.ai {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}

/* Avatar */
.nila-ai-msg.ai .nila-ai-msg-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  margin-top: 6px;
}

.nila-ai-msg.ai .nila-ai-msg-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

/* Message column */
.nila-ai-msg.ai .nila-ai-msg-body {
  display: flex;
  flex-direction: column;
  max-width: calc(100% - 42px);
}

/* ===== SINGLE CLEAN BUBBLE ===== */
.nila-ai-msg.ai .nila-ai-msg-content {
  background: #ffffff;
  padding: 14px 16px;
  border-radius: 16px 16px 16px 6px;
  box-shadow: 0 6px 16px rgba(0,0,0,.08);
  font-size: 14px;
  line-height: 1.55;
  max-width: 100%;
  width: fit-content;
}

/* Typography cleanup */
.nila-ai-msg.ai .nila-ai-msg-content h3,
.nila-ai-msg.ai .nila-ai-msg-content h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

.nila-ai-msg.ai .nila-ai-msg-content p {
  margin: 0 0 8px;
}

.nila-ai-msg.ai .nila-ai-msg-content p:last-child {
  margin-bottom: 0;
}

/* ===== ACTION BUTTONS BELOW ONLY ===== */
.nila-ai-msg.ai .nila-ai-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

/* Buttons */
.nila-ai-actions button {
  background: var(--bg-soft);
  border: 1px solid var(--bg-highlight);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.nila-ai-actions svg {
  width: 13px;
  height: 13px;
}

/* ===== USER MESSAGE (UNCHANGED, CLEAN) ===== */
.nila-ai-msg.user {
  max-width: 75%;
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  padding: 10px 13px;
  border-radius: 16px 16px 4px 16px;
}

/* =================================================
   FINAL CHAT LAYOUT – CLEAN, STABLE, CHAT-LIKE
   (Paste at END – overrides all previous conflicts)
================================================= */

/* ---------- RESET WRAPPER ---------- */
.nila-ai-msg {
  max-width: 100% !important;
  background: transparent !important;
  padding: 0 !important;
  box-shadow: none !important;
  margin-bottom: 14px;
}

/* ================= AI MESSAGE ================= */

.nila-ai-msg.ai {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

/* Avatar */
.nila-ai-msg.ai .nila-ai-msg-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  margin-top: 6px;
}

.nila-ai-msg.ai .nila-ai-msg-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
}

/* Column */
.nila-ai-msg.ai .nila-ai-msg-body {
  display: flex;
  flex-direction: column;
  max-width: calc(100% - 42px);
}

/* AI Bubble */
.nila-ai-msg.ai .nila-ai-msg-content {
  background: #ffffff;
  padding: 14px 16px;
  border-radius: 16px 16px 16px 6px;
  box-shadow: 0 6px 16px rgba(0,0,0,.08);
  font-size: 14px;
  line-height: 1.55;
  max-width: 100%;
  width: fit-content;
}

/* Typography cleanup */
.nila-ai-msg.ai .nila-ai-msg-content h3,
.nila-ai-msg.ai .nila-ai-msg-content h4 {
  margin: 0 0 6px;
  font-size: 15px;
}

.nila-ai-msg.ai .nila-ai-msg-content p {
  margin: 0 0 8px;
}

.nila-ai-msg.ai .nila-ai-msg-content p:last-child {
  margin-bottom: 0;
}

/* Action buttons BELOW bubble */
.nila-ai-msg.ai .nila-ai-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.nila-ai-actions button {
  background: var(--bg-soft);
  border: 1px solid var(--bg-highlight);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

/* ================= USER MESSAGE ================= */

.nila-ai-msg.user {
  display: flex;
  justify-content: flex-end;
}

/* User Bubble (RESTORED & CLEAN) */
.nila-ai-msg.user .nila-ai-msg-content {
  background: var(--accent);
  color: #ffffff;
  padding: 10px 14px;
  border-radius: 16px 16px 4px 16px;
  font-size: 14px;
  line-height: 1.45;
  max-width: 75%;
  box-shadow: 0 4px 14px rgba(0,0,0,.12);
}

/* =====================================
   SHORTCODE WIDGET – SAME AS FLOATING
   HEIGHT LOCK + SCROLL (NO JS)
===================================== */

/* Shortcode root */
.nila-ai-embedded-root {
  width: 100%;
  max-width: 420px;              /* optional – nice article fit */
  margin: 0 auto;
}

/* Force same height as floating widget */
.nila-ai-embedded-root .nila-ai-widget {
  height: 560px;                 /* EXACT SAME as floating */
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-radius: 22px;
  box-shadow: 0 18px 48px rgba(47,43,54,.18);
  overflow: hidden;
}

/* Header stays fixed */
.nila-ai-embedded-root .nila-ai-header {
  flex-shrink: 0;
}

/* Input stays fixed */
.nila-ai-embedded-root .nila-ai-input {
  flex-shrink: 0;
}

/* Chat area scrolls */
.nila-ai-embedded-root .nila-ai-body {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
}
/* =====================================
   AVATAR FIX – HEADER + MESSAGES
===================================== */

/* Header avatar – force perfect circle */
.nila-ai-avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;          /* CRITICAL */
}

.nila-ai-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;         /* CRITICAL */
  border-radius: 50%;
  display: block;
}

/* Message avatar (safety lock) */
.nila-ai-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.nila-ai-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

/* =====================================
   SHORTCODE WIDGET – HEIGHT + SCROLL
===================================== */

.nila-ai-embedded-root {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
}

.nila-ai-embedded-root .nila-ai-widget {
  height: 560px;                 /* SAME AS FLOATING */
  display: flex;
  flex-direction: column;
  background: var(--white);
  border-radius: 22px;
  box-shadow: 0 18px 48px rgba(47,43,54,.18);
  overflow: hidden;
}

/* Header fixed */
.nila-ai-embedded-root .nila-ai-header {
  flex-shrink: 0;
}

/* Input fixed */
.nila-ai-embedded-root .nila-ai-input {
  flex-shrink: 0;
}

/* BODY scrolls */
.nila-ai-embedded-root .nila-ai-body {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
}
/* =====================================
   FLOATING LAUNCHER – PERFECT CIRCLE FIX
===================================== */

.nila-ai-launcher {
  width: 56px;
  height: 56px;
  min-width: 56px;
  min-height: 56px;
  border-radius: 50% !important;
  padding: 0;
  overflow: hidden;               /* CRITICAL */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Avatar image inside launcher */
.nila-ai-launcher img {
  width: 100%;
  height: 100%;
  object-fit: cover;              /* prevents oval distortion */
  border-radius: 50% !important;
  display: block;
}

/* Optional: clean outer ring (premium look) */
.nila-ai-launcher::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(123,78,163,0.35);
  pointer-events: none;
}
/* =====================================
   INPUT FIELD – TRUE ROUND FIX
===================================== */

/* Input row container */
.nila-ai-input {
  border-radius: 999px !important;
  padding: 10px 12px;
}

/* Text input */
.nila-ai-input input {
  height: 44px;
  border-radius: 999px !important; /* FULL PILL */
  padding: 0 18px;
  background: #ffffff;
  border: none;
  outline: none;
}

/* Remove any clipping */
.nila-ai-input,
.nila-ai-input * {
  box-sizing: border-box;
}
/* =====================================
   TRUE PILL INPUT (TEXT FIELD ONLY)
===================================== */

/* Reset wrapper influence */
.nila-ai-input {
  background: transparent;
}

/* REAL text input */
.nila-ai-input input {
  height: 44px;
  border-radius: 9999px !important; /* hard pill */
  padding: 0 20px !important;
  background: #ffffff !important;
  border: 1px solid #e6e1ef !important;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.02);
}

/* Prevent flex squeeze */
.nila-ai-input input {
  flex: 1 1 auto;
  min-width: 0;
}