/* ===================================================================
   LEO — chat UI (shared by the floating widget and the full page)
   Brand: orange #E8722A, navy #1B2A4A, near-black surfaces.
   Fonts: Syne (labels) + DM Sans (chat) — load on the host page.
   =================================================================== */

:root {
  --leo-orange: #E8722A;
  --leo-orange-d: #cf5f1c;
  --leo-bg: #0c0c0c;
  --leo-surface: #141414;
  --leo-leo-bubble: #161616;
  --leo-user-bubble: #232323;
  --leo-border: rgba(255, 255, 255, 0.08);
  --leo-text: #f2efea;
  --leo-muted: rgba(242, 239, 234, 0.46);
  --leo-hint: rgba(242, 239, 234, 0.30);
}

/* ---------- Core chat shell ---------- */
.leo-chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  background: var(--leo-bg);
  color: var(--leo-text);
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

.leo-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; scroll-behavior: smooth; }
.leo-scroll::-webkit-scrollbar { width: 3px; }
.leo-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 2px; }

.leo-feed {
  display: flex; flex-direction: column; gap: 13px;
  padding: 24px 22px 12px;
  max-width: 680px; margin: 0 auto; width: 100%;
}

.leo-msg {
  max-width: 84%;
  padding: 12px 16px;
  font-size: 15px; line-height: 1.6;
  white-space: pre-wrap;
  animation: leo-rise .26s ease both;
}
@keyframes leo-rise { from { opacity: 0; transform: translateY(9px); } to { opacity: 1; transform: translateY(0); } }

.leo-leo {
  background: var(--leo-leo-bubble);
  border: 1px solid var(--leo-border);
  border-left: 2px solid var(--leo-orange);
  border-radius: 3px 13px 13px 13px;
  align-self: flex-start;
}
.leo-user {
  background: var(--leo-user-bubble);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 13px 3px 13px 13px;
  align-self: flex-end;
}

.leo-typing {
  display: flex; gap: 5px; align-items: center;
  padding: 13px 16px; width: fit-content; align-self: flex-start;
  background: var(--leo-leo-bubble); border: 1px solid var(--leo-border);
  border-left: 2px solid var(--leo-orange); border-radius: 3px 13px 13px 13px;
  animation: leo-rise .2s ease;
}
.leo-typing span { width: 5px; height: 5px; border-radius: 50%; background: var(--leo-muted); animation: leo-blink 1.3s ease-in-out infinite; }
.leo-typing span:nth-child(2) { animation-delay: .18s; }
.leo-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes leo-blink { 0%,80%,100% { opacity: .25; transform: scale(.8); } 40% { opacity: 1; transform: scale(1); } }

/* ---------- Lead complete card ---------- */
.leo-complete { align-self: center; display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 10px 0; animation: leo-rise .4s ease; }
.leo-check { width: 44px; height: 44px; border-radius: 50%; border: 1.5px solid var(--leo-orange); background: rgba(232,114,42,.12); display: flex; align-items: center; justify-content: center; color: var(--leo-orange); }
.leo-check svg { width: 18px; height: 18px; }
.leo-complete-label { font-size: 12.5px; letter-spacing: .04em; color: var(--leo-muted); text-transform: uppercase; text-align: center; }

/* ---------- Input zone ---------- */
.leo-input-zone { flex-shrink: 0; padding: 8px 22px 20px; }
.leo-input-inner { max-width: 680px; margin: 0 auto; }
.leo-hint { font-size: 12px; color: var(--leo-hint); font-style: italic; margin-bottom: 7px; min-height: 0; padding-left: 2px; }
.leo-hint:empty { margin-bottom: 0; }

.leo-qr { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.leo-qr:empty { margin-bottom: 0; }
.leo-qr-btn {
  padding: 8px 15px; border-radius: 999px;
  border: 1px solid rgba(255,255,255,.12); background: transparent; color: var(--leo-text);
  font-family: inherit; font-size: 13px; cursor: pointer; white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
}
.leo-qr-btn:hover { border-color: var(--leo-orange); color: var(--leo-orange); }

.leo-input-row { display: flex; gap: 10px; align-items: center; }
.leo-text-input {
  flex: 1; background: var(--leo-surface); border: 1px solid var(--leo-border);
  border-radius: 11px; padding: 13px 16px; color: var(--leo-text);
  font-family: inherit; font-size: 15px; outline: none; transition: border-color .18s;
}
.leo-text-input::placeholder { color: var(--leo-muted); }
.leo-text-input:focus { border-color: rgba(232,114,42,.4); }
.leo-text-input:disabled { opacity: .45; cursor: not-allowed; }

.leo-send {
  width: 46px; height: 46px; border-radius: 11px; flex-shrink: 0;
  background: var(--leo-orange); border: none; cursor: pointer; color: #000;
  display: flex; align-items: center; justify-content: center; transition: background .18s, opacity .18s;
}
.leo-send:hover { background: var(--leo-orange-d); }
.leo-send:disabled { opacity: .4; cursor: not-allowed; }
.leo-send svg { width: 17px; height: 17px; }

/* ===================================================================
   FLOATING WIDGET
   =================================================================== */
.leo-widget { position: fixed; right: 22px; bottom: 22px; z-index: 1000; font-family: 'DM Sans', sans-serif; }

/* Rounded-square icon launcher */
.leo-launcher {
  position: relative;
  width: 60px; height: 60px; border-radius: 18px; border: none; cursor: pointer;
  background: var(--leo-orange); color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 12px 30px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.06) inset;
  transition: transform .18s ease, background .18s, box-shadow .18s;
}
.leo-launcher:hover { background: var(--leo-orange-d); transform: translateY(-2px); }
.leo-launcher svg { width: 26px; height: 26px; }
.leo-launcher-badge {
  position: absolute; top: 11px; right: 11px;
  width: 9px; height: 9px; border-radius: 50%;
  background: #fff; box-shadow: 0 0 0 2px var(--leo-orange);
  animation: leo-pulse 2.2s ease-in-out infinite;
}
@keyframes leo-pulse { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.7); } }
.leo-open .leo-launcher { display: none; }

.leo-panel {
  position: absolute; right: 0; bottom: 0;
  width: 400px; height: 620px; max-height: calc(100vh - 44px);
  display: none;            /* hidden by default — shown only via .leo-open */
  flex-direction: column; overflow: hidden;
  background: var(--leo-bg); border: 1px solid var(--leo-border);
  border-radius: 18px; box-shadow: 0 24px 70px rgba(0,0,0,.55);
}
.leo-widget.leo-open .leo-panel { display: flex; animation: leo-pop .22s ease both; }
@keyframes leo-pop { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

.leo-panel-head {
  flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--leo-border); background: #101010;
}
.leo-panel-id { display: flex; align-items: center; gap: 8px; font-family: 'Syne', sans-serif; font-weight: 700; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; }
.leo-pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--leo-orange); animation: leo-pulse 2.2s ease-in-out infinite; }
.leo-panel-close {
  background: none; border: none; color: var(--leo-muted);
  font-size: 28px; line-height: 1; cursor: pointer;
  width: 38px; height: 38px; border-radius: 9px; margin: -6px -8px -6px 0;
  display: flex; align-items: center; justify-content: center;
  transition: color .15s, background .15s;
}
.leo-panel-close:hover { color: var(--leo-text); background: rgba(255,255,255,.06); }
.leo-panel-body { flex: 1; min-height: 0; display: flex; }
.leo-panel-body .leo-chat { width: 100%; }
.leo-panel-body .leo-feed,
.leo-panel-body .leo-input-inner { max-width: none; }
.leo-panel-body .leo-feed { padding: 20px 16px 10px; }
.leo-panel-body .leo-input-zone { padding: 8px 16px 16px; }

@media (max-width: 640px) {
  .leo-widget { right: 16px; bottom: 16px; }
  .leo-widget.leo-open .leo-panel { position: fixed; inset: 0; width: auto; height: auto; max-height: none; border-radius: 0; }
}

/* ===================================================================
   FULL-PAGE MOUNT (leo.html) — host sets the page height
   =================================================================== */
.leo-page-mount { flex: 1; min-height: 0; display: flex; }
.leo-page-mount .leo-chat { width: 100%; }
