/* ══════════════════════════════════════════════════════════════════
   LEXI WIDGET v0.1.0 — standalone styles
   LC navy front-door utility. Quiet, trustworthy, accessible.
   Scoped under .lexi-root so it never collides with the host page.
   ══════════════════════════════════════════════════════════════════ */

.lexi-root {
  --lexi-navy: #1B3A6B;
  --lexi-navy-700: #15315c;
  --lexi-ink: #1c2430;
  --lexi-muted: #5b6675;
  --lexi-line: #e4e8ee;
  --lexi-bg: #ffffff;
  --lexi-user: #1B3A6B;
  --lexi-bot: #f4f6f9;
  --lexi-accent: #2f80ed;
  --lexi-radius: 14px;
  --lexi-shadow: 0 12px 40px rgba(20, 40, 80, 0.18);
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--lexi-ink);
}

/* Launcher */
.lexi-launcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--lexi-navy);
  color: #fff;
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--lexi-shadow);
  transition: transform 120ms ease, background 120ms ease;
}
.lexi-launcher:hover { background: var(--lexi-navy-700); transform: translateY(-1px); }
.lexi-launcher:focus-visible { outline: 3px solid var(--lexi-accent); outline-offset: 2px; }
.lexi-root.lexi-is-open .lexi-launcher { display: none; }
.lexi-launcher-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: #58d68d; box-shadow: 0 0 0 3px rgba(88, 214, 141, 0.25);
}

/* Panel — hidden by default. Shown only when root carries .lexi-is-open.
   Driving visibility from a class (not the hidden attribute) avoids the
   specificity collision where display:flex silently overrode [hidden]. */
.lexi-panel {
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 40px);
  background: var(--lexi-bg);
  border: 1px solid var(--lexi-line);
  border-radius: var(--lexi-radius);
  box-shadow: var(--lexi-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.lexi-root.lexi-is-open .lexi-panel { display: flex; }

.lexi-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  background: var(--lexi-navy);
  color: #fff;
}
.lexi-title { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; }
.lexi-title-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: rgba(255,255,255,0.16);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px;
}
.lexi-sub { font-weight: 500; font-size: 12px; opacity: 0.8; margin-left: 2px; }
.lexi-close {
  background: transparent; border: 0; color: #fff;
  font-size: 24px; line-height: 1; cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.lexi-close:hover { background: rgba(255,255,255,0.12); }
.lexi-close:focus-visible { outline: 2px solid #fff; }

/* Messages */
.lexi-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #fbfcfe;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lexi-row { display: flex; }
.lexi-row-user { justify-content: flex-end; }
.lexi-row-bot { justify-content: flex-start; }
.lexi-bubble {
  max-width: 84%;
  padding: 10px 13px;
  border-radius: 13px;
  word-wrap: break-word;
}
.lexi-bubble-user { background: var(--lexi-user); color: #fff; border-bottom-right-radius: 4px; }
.lexi-bubble-bot { background: var(--lexi-bot); color: var(--lexi-ink); border-bottom-left-radius: 4px; }
.lexi-p { margin: 0 0 8px; }
.lexi-p:last-child { margin-bottom: 0; }

/* Quick reply chips */
.lexi-quick { display: flex; flex-wrap: wrap; gap: 7px; margin: 2px 0 4px; }
.lexi-chip {
  background: #fff; color: var(--lexi-navy);
  border: 1px solid var(--lexi-line);
  border-radius: 999px; padding: 7px 13px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: border-color 100ms ease, background 100ms ease;
}
.lexi-chip:hover { border-color: var(--lexi-navy); background: #f3f6fb; }
.lexi-chip:focus-visible { outline: 2px solid var(--lexi-accent); }

/* Provider cards */
.lexi-cards { display: flex; flex-direction: column; gap: 9px; margin: 2px 0; }
.lexi-card {
  border: 1px solid var(--lexi-line); border-radius: 12px; padding: 12px 13px; background: #fff;
}
.lexi-card-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lexi-card-name { font-weight: 700; font-size: 15px; }
.lexi-badge {
  font-size: 11px; font-weight: 700; color: #137a4b;
  background: #e6f6ed; border-radius: 999px; padding: 3px 8px;
}
.lexi-card-meta { color: var(--lexi-muted); font-size: 13px; margin: 4px 0 10px; }
.lexi-card-acts { display: flex; flex-wrap: wrap; gap: 7px; }
.lexi-card-btn {
  border: 1px solid var(--lexi-navy); color: var(--lexi-navy); background: #fff;
  border-radius: 8px; padding: 7px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.lexi-card-btn:first-child { background: var(--lexi-navy); color: #fff; }
.lexi-card-btn:hover { filter: brightness(0.97); }
.lexi-card-btn:focus-visible { outline: 2px solid var(--lexi-accent); }

/* Citations */
.lexi-cites { display: flex; flex-direction: column; gap: 4px; margin: 2px 0; }
.lexi-cite {
  font-size: 12px; color: var(--lexi-muted); text-decoration: none;
  border-left: 3px solid var(--lexi-line); padding-left: 9px;
}
a.lexi-cite:hover { color: var(--lexi-navy); border-left-color: var(--lexi-navy); text-decoration: underline; }

/* Handoff */
.lexi-handoff {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: #fff; border: 1px dashed var(--lexi-line); border-radius: 12px; padding: 11px 13px; margin: 2px 0;
}
.lexi-handoff-text { font-size: 13.5px; color: var(--lexi-muted); }
.lexi-handoff-btn {
  background: var(--lexi-navy); color: #fff; text-decoration: none;
  border-radius: 8px; padding: 7px 13px; font-size: 13px; font-weight: 600; white-space: nowrap;
}

/* Composer */
.lexi-composer {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 11px 12px; border-top: 1px solid var(--lexi-line); background: #fff;
}
.lexi-input {
  flex: 1; resize: none; border: 1px solid var(--lexi-line); border-radius: 11px;
  padding: 10px 12px; font: inherit; font-size: 14.5px; max-height: 120px; outline: none;
}
.lexi-input:focus { border-color: var(--lexi-navy); }
.lexi-send {
  width: 40px; height: 40px; flex: 0 0 40px; border: 0; border-radius: 10px;
  background: var(--lexi-navy); color: #fff; font-size: 19px; cursor: pointer;
}
.lexi-send:hover { background: var(--lexi-navy-700); }
.lexi-send:focus-visible { outline: 2px solid var(--lexi-accent); }

/* Footer disclaimer */
.lexi-foot { padding: 8px 14px 12px; font-size: 11.5px; color: var(--lexi-muted); background: #fff; }

/* Thinking dots */
.lexi-dots { display: inline-flex; gap: 4px; padding: 2px 0; }
.lexi-dots i { width: 7px; height: 7px; border-radius: 50%; background: #b8c1cf; animation: lexiBounce 1.1s infinite; }
.lexi-dots i:nth-child(2) { animation-delay: 0.15s; }
.lexi-dots i:nth-child(3) { animation-delay: 0.30s; }
@keyframes lexiBounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .lexi-launcher, .lexi-dots i { transition: none; animation: none; }
}

/* Mobile: full-bleed sheet. Below 600px the panel fills the viewport.
   inset:0 escapes the launcher's bottom-right anchoring (fixed = viewport).
   100dvh handles iOS Safari's URL-bar height shift; 100vh is the fallback.
   Safe-area insets keep the header and footer clear of notch / home bar. */
@media (max-width: 600px) {
  .lexi-panel {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    max-height: none;
    border: 0;
    border-radius: 0;
  }
  .lexi-header { padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  .lexi-foot   { padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }
  .lexi-close  { font-size: 30px; padding: 8px 12px; }   /* bigger touch target */
  .lexi-launcher { right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); }
}
