/* Basyra AI Popup — gold/amber detective theme */

:root {
  --bn-ease: cubic-bezier(.22, .61, .36, 1);
  --bn-dur: 200ms;
}

/* ── FAB (mascot image trigger) ── */
.ai-fab {
  position: fixed;
  bottom: 28px;
  right: 22px;
  z-index: 2147483001;
  width: 104px;
  cursor: pointer;
  border: none;
  background: transparent;
  padding: 0;
  filter: drop-shadow(0 8px 20px rgba(0,0,0,0.32));
  transition: transform 200ms ease-out, filter 200ms ease;
}
.ai-fab:hover {
  transform: scale(1.06);
  filter: drop-shadow(0 10px 24px rgba(0,0,0,0.38)) drop-shadow(0 0 20px rgba(226,173,88,0.28));
}
.ai-fab:active { transform: scale(0.95); }
.ai-fab img {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
}

/* ── Aura (ambient glow behind popup) ── */
.ai-aura {
  position: fixed;
  bottom: 88px;
  right: 14px;
  z-index: 2147482999;
  width: 430px;
  height: 640px;
  pointer-events: none;
  opacity: 0;
  border-radius: 40px;
  filter: blur(48px);
  transition: opacity 420ms cubic-bezier(.22, .61, .36, 1);
  background:
    radial-gradient(210px 210px at 74% 18%, rgba(240,190,96,.55), transparent 66%),
    radial-gradient(200px 200px at 24% 60%, rgba(176,86,38,.42), transparent 66%),
    radial-gradient(190px 190px at 86% 90%, rgba(247,205,120,.34), transparent 66%);
}
.ai-aura.show { opacity: 0.8; }

/* ── Main Popup Panel ── */
.ai-popup {
  position: fixed;
  bottom: 190px;
  right: 22px;
  z-index: 2147483006;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  isolation: isolate;
  width: 394px;
  height: min(582px, 76vh);
  max-width: calc(100vw - 32px);
  border-radius: 28px;
  font-family: 'Manrope', sans-serif;
  color: #fff;
  color-scheme: dark;
  background: linear-gradient(160deg, rgba(22,28,40,.44), rgba(10,14,22,.55) 52%, rgba(5,8,13,.63));
  -webkit-backdrop-filter: blur(34px) saturate(128%) brightness(.74) contrast(1.05);
  backdrop-filter: blur(34px) saturate(128%) brightness(.74) contrast(1.05);
  box-shadow:
    inset 0 1px 0 rgba(255,240,214,.14),
    inset 0 0 0 1px rgba(255,240,214,.04),
    inset 0 -80px 100px -50px rgba(0,0,0,.72),
    0 26px 70px rgba(0,0,0,.6),
    0 10px 28px rgba(0,0,0,.45),
    0 0 60px rgba(226,173,88,.14);
  transform-origin: calc(100% - 52px) 100%;
  opacity: 0;
  transform: translateY(14px) scale(.94);
  pointer-events: none;
  transition: opacity 200ms var(--bn-ease), transform 340ms cubic-bezier(.22,.61,.36,1);
}
.ai-popup.open, .ai-popup[data-open="true"] {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* Specular highlight */
.ai-popup::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(120% 80% at 14% -6%, rgba(206,220,246,.09), rgba(206,220,246,.03) 40%, transparent 56%),
    linear-gradient(180deg, rgba(206,220,246,.03), transparent 18%);
}

/* Border gradient */
.ai-popup::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 4;
  padding: 1px;
  background: linear-gradient(150deg, rgba(214,226,248,.30), rgba(214,226,248,.05) 32%, rgba(255,240,214,0) 58%, rgba(255,240,214,.12));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

/* ── Noise overlay ── */
.ai-noise {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  border-radius: inherit;
  opacity: .14;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 200px 200px;
}

/* ── Content z-index (above noise/pseudo layers) ── */
.ai-hd, .ai-body, .ai-foot { position: relative; z-index: 1; }

/* ── Header ── */
.ai-hd {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 14px;
  border-bottom: 1px solid rgba(255,240,214,.09);
}

/* Mascot avatar (38px box) */
.ai-hd .orb-sm {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  flex-shrink: 0;
  overflow: hidden;
  background: radial-gradient(120% 120% at 30% 25%, #f4d288, #d5983f 60%, #8a5620);
  box-shadow: 0 4px 14px rgba(226,173,88,.5), inset 0 1px 1px rgba(255,244,210,.5);
}
.ai-hd .orb-sm img {
  width: 150%;
  height: 150%;
  object-fit: cover;
  object-position: 52% 8%;
  transform: translate(-9px, -1px);
  display: block;
}

/* Header text */
.htxt { flex: 1; min-width: 0; line-height: 1.3; }
.htxt .t { font-size: 14.5px; font-weight: 650; letter-spacing: -0.01em; color: #f6efe1; }
.htxt .s {
  font-size: 11.5px;
  color: rgba(255,246,232,.55);
  margin-top: 1px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.htxt .s .live {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4bd07a;
  display: inline-block;
  animation: bnLive 2s infinite;
}

/* Close button */
.ai-x {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  background: rgba(255,245,220,.08);
  color: rgba(255,246,232,.7);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--bn-dur) var(--bn-ease), color var(--bn-dur) var(--bn-ease);
  padding: 0;
  font-family: inherit;
}
.ai-x:hover { background: rgba(226,173,88,.22); color: #f4ecdd; }

/* ── Body / Messages ── */
.ai-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  scrollbar-width: thin;
}
.ai-body::-webkit-scrollbar { width: 8px; }
.ai-body::-webkit-scrollbar-thumb {
  background: rgba(255,240,214,.16);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: content-box;
}

/* Welcome card */
.ai-welcome .wt {
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.3;
  color: #f6efe1;
}
.ai-welcome .wt .grad {
  background: linear-gradient(90deg, #f2d494, #e0a24e);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.ai-welcome .ws {
  font-size: 12.5px;
  color: rgba(255,246,232,.6);
  margin-top: 6px;
  line-height: 1.55;
}

/* Quick chips */
.ai-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(255,245,220,.07), rgba(255,245,220,.02));
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255,240,214,.13);
  color: rgba(255,246,232,.94);
  box-shadow: inset 0 1px 0 rgba(255,245,220,.14), 0 2px 8px rgba(0,0,0,.28);
  border-radius: 14px;
  padding: 11px 14px;
  font-size: 12.5px;
  font-weight: 560;
  letter-spacing: -0.01em;
  text-align: left;
  overflow: hidden;
  transition: background var(--bn-dur) var(--bn-ease), border-color var(--bn-dur) var(--bn-ease), transform var(--bn-dur) var(--bn-ease), box-shadow var(--bn-dur) var(--bn-ease);
  font-family: inherit;
}
.ai-chip:hover {
  transform: translateY(-1.5px);
  border-color: rgba(226,173,88,.5);
  background: linear-gradient(180deg, rgba(255,245,220,.12), rgba(255,245,220,.04));
  box-shadow: inset 0 1px 0 rgba(255,245,220,.2), 0 6px 18px rgba(0,0,0,.34);
}
.ai-chip:active { transform: translateY(0) scale(.98); }
.ai-chip svg { width: 15px; height: 15px; color: #e9c079; flex-shrink: 0; }

/* Message bubbles */
.ai-msg {
  display: flex;
  justify-content: flex-start;
  animation: bnMsgIn .2s ease;
}
.ai-msg.user { justify-content: flex-end; }
.ai-msg .bubble {
  max-width: 84%;
  padding: 10px 13px;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
}
.ai-msg.ai .bubble {
  border-radius: 15px 15px 15px 5px;
  background: linear-gradient(180deg, rgba(255,245,220,.13), rgba(255,245,220,.055));
  border: 1px solid rgba(255,240,214,.12);
  box-shadow: inset 0 1px 0 rgba(255,245,220,.16);
  color: rgba(255,246,232,.95);
}
.ai-msg.user .bubble {
  border-radius: 15px 15px 5px 15px;
  background: linear-gradient(180deg, #f0c675, #d5983f);
  border: 1px solid rgba(255,236,190,.4);
  box-shadow: 0 4px 14px rgba(226,173,88,.4);
  color: #241705;
}

/* Typing indicator */
.ai-typing {
  display: inline-flex;
  gap: 4px;
  padding: 13px 14px;
  border-radius: 15px 15px 15px 5px;
  background: linear-gradient(180deg, rgba(255,245,220,.13), rgba(255,245,220,.055));
  border: 1px solid rgba(255,240,214,.12);
}
.ai-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255,246,232,.6);
  animation: bnDot 1.2s infinite;
}
.ai-typing span:nth-child(2) { animation-delay: .2s; }
.ai-typing span:nth-child(3) { animation-delay: .4s; }

/* ── Footer / Input ── */
.ai-foot {
  padding: 12px;
  border-top: 1px solid rgba(255,240,214,.09);
}
.ai-inputbar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(180deg, rgba(255,245,220,.07), rgba(255,245,220,.02));
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,240,214,.12);
  box-shadow: inset 0 1px 0 rgba(255,245,220,.14);
  border-radius: 22px;
  padding: 7px 7px 7px 16px;
  transition: border-color var(--bn-dur) var(--bn-ease), box-shadow var(--bn-dur) var(--bn-ease);
}
.ai-inputbar:focus-within {
  border-color: rgba(226,173,88,.65);
  box-shadow: inset 0 1px 0 rgba(255,245,220,.25), 0 0 0 3px rgba(226,173,88,.16);
}
.ai-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: #f6efe1;
  font-size: 13.5px;
  font-family: 'Manrope', sans-serif;
  padding: 0;
  margin: 0;
  line-height: 40px;
  height: 40px;
  resize: none;
  overflow: hidden;
}
.ai-input::placeholder { color: rgba(255,246,232,.45); }

/* Send button (40px gold circle + magnifying glass) */
.ai-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  background: linear-gradient(180deg, #f0c675, #d5983f 55%, #9a6522);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255,244,210,.45), 0 4px 14px rgba(226,173,88,.5);
  transition: transform .15s ease, box-shadow .15s ease;
  padding: 0;
  font-family: inherit;
}
.ai-send:hover {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 13px 26px rgba(190,145,60,.5), inset 0 1px 0 rgba(255,240,200,.5);
}
.ai-send:active { transform: translateY(0) scale(.96); }
.ai-send:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; transform: none; }
.ai-send svg { width: 19px; height: 19px; }

/* Stop button */
.ai-stop {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  background: rgba(255,245,220,.12);
  color: rgba(255,246,232,.8);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255,245,220,.18);
  transition: background var(--bn-dur) var(--bn-ease), transform var(--bn-dur) var(--bn-ease);
  padding: 0;
  font-family: inherit;
}
.ai-stop:hover { background: rgba(255,245,220,.2); transform: scale(1.06); }
.ai-stop:active { transform: scale(0.96); }
.ai-stop svg { width: 14px; height: 14px; }

/* Disclaimer */
.ai-disclaimer {
  text-align: center;
  font-size: 10.5px;
  color: rgba(255,246,232,.4);
  margin-top: 8px;
}

/* ── Action buttons ── */
.ai-actions{display:flex;gap:10px;margin-top:12px;}
.ai-cta{flex:1;display:inline-flex;align-items:center;justify-content:center;gap:8px;height:48px;
  border-radius:22px;corner-shape:squircle;
  font-family:'Manrope',sans-serif;font-weight:700;font-size:14px;letter-spacing:.2px;
  text-decoration:none;cursor:pointer;transition:transform .16s ease,filter .16s ease;}
.ai-cta:hover{transform:translateY(-1px);filter:brightness(1.04);}
.ai-cta:active{transform:scale(.97);}
.ai-cta svg{width:18px;height:18px;display:block;}
.ai-cta-tg{background:linear-gradient(180deg,#e8bf6e,#c99a4e);color:#241a0c;box-shadow:0 6px 16px rgba(201,154,78,.32);}
.ai-cta-call{background:transparent;color:#e6c48a;border:1px solid rgba(210,170,90,.5);}
.ai-foot:has(.ai-input:not(:placeholder-shown)) .ai-actions{display:none;}

/* Powered-by credit badge */
.ai-powered {
  display: flex;
  justify-content: center;
  margin: 4px 0 10px;
}
.ai-powered a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  text-decoration: none;
  transition: color 0.18s ease;
}
.ai-powered a:hover {
  color: rgba(255, 255, 255, 0.8);
}
.ai-powered a span {
  color: #fff;
  font-weight: 700;
}
.ai-powered a .ai-powered-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #e6a84f;
  flex: none;
}

/* ── Idle speech bubble ── */
.mascot-bubble {
  position: fixed;
  right: 22px;
  bottom: 164px;
  z-index: 2147483002;
  max-width: 240px;
  cursor: pointer;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,.05);
  border-radius: 22px;
  color: #1c1c1e;
  font-family: 'Manrope', sans-serif;
  font-weight: 600;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-line;
  box-shadow: 0 14px 34px rgba(0,0,0,.24), 0 3px 10px rgba(0,0,0,.12);
  padding: 13px 18px;
  animation: bnPop .3s cubic-bezier(.22,.61,.36,1);
}
.mascot-bubble__tail {
  position: absolute;
  bottom: -10px;
  right: 46px;
  width: 0; height: 0;
  border-left: 11px solid transparent;
  border-right: 11px solid transparent;
  border-top: 12px solid #ffffff;
  filter: drop-shadow(0 5px 3px rgba(0,0,0,.10));
}

/* ── Error box ── */
.ai-error {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(239,68,68,.12);
  border: 1px solid rgba(239,68,68,.35);
  color: #fecaca;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.5;
  margin: 0 0 12px;
}
.ai-error svg { width: 16px; height: 16px; flex-shrink: 0; color: #f87171; }

/* ── Markdown inside bubbles ── */
.ai-msg .bubble p { margin: 0 0 8px; }
.ai-msg .bubble p:last-child { margin-bottom: 0; }
.ai-msg .bubble strong { font-weight: 700; color: #f5e7cf; }
.ai-msg .bubble em { font-style: italic; }
.ai-msg .bubble h4 { margin: 12px 0 6px; font-size: 15px; font-weight: 800; color: #f5e7cf; line-height: 1.3; }
.ai-msg .bubble h4:first-child { margin-top: 0; }
.ai-msg .bubble h5 { margin: 10px 0 4px; font-size: 13.5px; font-weight: 700; color: #e6c48a; }
.ai-msg .bubble h6 { margin: 8px 0 4px; font-size: 12px; font-weight: 700; color: rgba(230,196,138,.9); text-transform: uppercase; letter-spacing: 1px; }
.ai-msg .bubble code {
  background: rgba(255,255,255,.14);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.ai-msg .bubble ul, .ai-msg .bubble ol { margin: 0 0 8px; padding-left: 18px; }
.ai-msg .bubble ul:last-child, .ai-msg .bubble ol:last-child { margin-bottom: 0; }
.ai-msg .bubble li { margin: 2px 0; }
.ai-form-cta {
  display: block;
  margin: 14px 0 2px;
  padding: 10px 20px;
  background: linear-gradient(135deg, #c99645, #a07730);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  text-align: center;
  text-decoration: none;
  border-radius: 10px;
  letter-spacing: 0.3px;
  transition: transform .15s ease, box-shadow .15s ease;
  box-shadow: 0 2px 8px rgba(160,119,48,.35);
}
.ai-form-cta:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(160,119,48,.45);
}

/* ── Animations ── */
@keyframes bnPop {
  from { opacity: 0; transform: translateY(14px) scale(.94); }
  to { opacity: 1; transform: none; }
}
@keyframes bnMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
@keyframes bnLive {
  0%   { box-shadow: 0 0 0 0 rgba(75,208,122,.5); }
  70%  { box-shadow: 0 0 0 6px rgba(75,208,122,0); }
  100% { box-shadow: 0 0 0 0 rgba(75,208,122,0); }
}
@keyframes bnDot {
  0%, 80%, 100% { transform: translateY(0); opacity: .45; }
  40%            { transform: translateY(-5px); opacity: 1; }
}

/* ── Mobile ── */
@media (max-width: 640px) {
  .ai-popup {
    right: 0; bottom: 0; left: 0; top: 0;
    width: 100vw; height: 100vh;
    max-width: 100vw; max-height: 100vh;
    border-radius: 0;
    transform-origin: calc(100% - 52px) calc(100% - 52px);
  }
  .ai-aura { display: none; }
  .ai-input { font-size: 16px; }
}

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
  .ai-popup { transition: opacity 120ms linear !important; }
  .ai-aura { transition: none !important; }
}
