/* Lidia chat widget. Collapsed = one small pill in the bottom-right corner.
   Uses the theme tokens with fallbacks so it renders the same on every template. */

.rl-lidia {
  --lidia-ink: var(--rl-ink-900, #10141a);
  --lidia-muted: var(--rl-ink-500, #5b6572);
  --lidia-line: var(--rl-ink-200, #d9dee5);
  --lidia-paper: var(--rl-paper, #ffffff);
  --lidia-page: var(--rl-ink-050, #f4f6f8);
  --lidia-accent: var(--rl-blue-700, #1240b5);
  --lidia-accent-ink: #ffffff;
  --lidia-radius: 16px;
  --lidia-shadow: var(--shadow-lg, 0 12px 32px rgba(16, 20, 26, 0.18));
  --lidia-font: var(--rl-font-body, "IBM Plex Sans", system-ui, sans-serif);
  --lidia-safe-b: env(safe-area-inset-bottom, 0px);
  --lidia-safe-r: env(safe-area-inset-right, 0px);
  position: fixed;
  right: calc(16px + var(--lidia-safe-r));
  bottom: calc(16px + var(--lidia-safe-b));
  z-index: 2147483000;
  font-family: var(--lidia-font);
  font-size: 15px;
  line-height: 1.45;
  color: var(--lidia-ink);
  pointer-events: none; /* only the pill and the panel take clicks; the page underneath stays usable */
}
.rl-lidia * { box-sizing: border-box; }
.rl-lidia button { font: inherit; }

/* ---- dock: the launcher, plus the walkthrough action when merged on phones ---- */
.rl-lidia__dock { display: inline-flex; align-items: stretch; pointer-events: auto; }
.rl-lidia[data-state="open"] .rl-lidia__dock { display: none; }
.rl-lidia__walk { display: none; }
.rl-lidia--merged .rl-lidia__dock { background: var(--lidia-accent); border-radius: 999px; box-shadow: var(--lidia-shadow); }
.rl-lidia--merged .rl-lidia__launcher { box-shadow: none; border-radius: 999px 0 0 999px; width: auto; padding: 0 12px 0 6px; }
.rl-lidia--merged .rl-lidia__launcher:hover, .rl-lidia--merged .rl-lidia__launcher:focus-visible { transform: none; }
.rl-lidia--merged .rl-lidia__launcher-text { display: inline; }
.rl-lidia--merged .rl-lidia__walk {
  display: inline-flex; align-items: center;
  padding: 0 16px 0 12px; border-left: 1px solid rgba(255,255,255,.4); border-radius: 0 999px 999px 0;
  color: var(--lidia-accent-ink); text-decoration: none; font-weight: 600; font-size: 14px; white-space: nowrap;
}
.rl-lidia--merged .rl-lidia__walk:active { background: rgba(255,255,255,.14); }
body.rl-lidia-merged .pdp-mobile-cta { display: none !important; }

/* ---- launcher pill ---- */
.rl-lidia__launcher {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 48px;
  padding: 0 18px 0 6px;
  border: 0;
  border-radius: 999px;
  background: var(--lidia-accent);
  color: var(--lidia-accent-ink);
  box-shadow: var(--lidia-shadow);
  cursor: pointer;
  font-weight: 600;
  transition: transform .15s ease, box-shadow .15s ease;
}
.rl-lidia__launcher:hover, .rl-lidia__launcher:focus-visible { transform: translateY(-1px); outline: none; box-shadow: 0 14px 36px rgba(16,20,26,.24); }
.rl-lidia__launcher:focus-visible { box-shadow: 0 0 0 3px var(--lidia-paper), 0 0 0 6px var(--lidia-accent); }
.rl-lidia[data-state="open"] .rl-lidia__launcher { display: none; }
.rl-lidia__avatar {
  display: inline-grid; place-items: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--lidia-paper); color: var(--lidia-accent);
  font-weight: 700; font-size: 16px; flex: 0 0 auto;
}

/* ---- panel ---- */
.rl-lidia__panel {
  pointer-events: auto;
  display: flex; flex-direction: column;
  width: min(380px, calc(100vw - 32px));
  height: min(600px, calc(100vh - 32px - var(--lidia-safe-b)));
  height: min(600px, calc(100dvh - 32px - var(--lidia-safe-b)));
  background: var(--lidia-paper);
  border-radius: var(--lidia-radius);
  box-shadow: var(--lidia-shadow);
  overflow: hidden;
  transform-origin: bottom right;
  animation: rl-lidia-in .18s ease-out;
}
.rl-lidia__panel[hidden] { display: none; }
@keyframes rl-lidia-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .rl-lidia__panel { animation: none; } .rl-lidia__launcher { transition: none; } }

.rl-lidia__head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 12px 12px 14px;
  background: var(--lidia-accent); color: var(--lidia-accent-ink);
}
.rl-lidia__head-text { flex: 1 1 auto; min-width: 0; }
.rl-lidia__title { font-weight: 700; font-size: 15px; }
.rl-lidia__subtitle { font-size: 12px; opacity: .85; }
.rl-lidia__end {
  border: 1px solid rgba(255,255,255,.55); background: transparent; color: inherit;
  border-radius: 999px; padding: 4px 10px; font-size: 12px; cursor: pointer;
}
.rl-lidia__close {
  border: 0; background: transparent; color: inherit; cursor: pointer;
  width: 36px; height: 36px; border-radius: 50%; font-size: 16px; line-height: 1;
}
.rl-lidia__close:hover, .rl-lidia__end:hover { background: rgba(255,255,255,.14); }

.rl-lidia__disclosure {
  margin: 0; padding: 8px 14px;
  font-size: 11.5px; color: var(--lidia-muted);
  background: var(--lidia-page); border-bottom: 1px solid var(--lidia-line);
}
.rl-lidia__disclosure a { color: inherit; }

.rl-lidia__who { margin: 0; padding: 6px 14px; font-size: 11.5px; color: var(--lidia-muted); border-bottom: 1px solid var(--lidia-line); }
.rl-lidia__who[hidden] { display: none; }
.rl-lidia__who a { color: inherit; }

/* ---- gate ---- */
.rl-lidia__gate { padding: 16px 14px; overflow: auto; flex: 1 1 auto; }
.rl-lidia__gate[hidden] { display: none; }
.rl-lidia__gate-intro { margin: 0 0 12px; font-weight: 600; }
.rl-lidia__field { display: block; margin-bottom: 10px; }
.rl-lidia__field span { display: block; font-size: 12px; color: var(--lidia-muted); margin-bottom: 4px; }
.rl-lidia__field input, .rl-lidia__composer textarea {
  width: 100%; font: inherit; font-size: 16px; /* 16px stops iOS zooming into the field */
  color: var(--lidia-ink); background: var(--lidia-paper);
  border: 1px solid var(--lidia-line); border-radius: 10px; padding: 10px 12px;
}
.rl-lidia__field input:focus, .rl-lidia__composer textarea:focus { outline: 2px solid var(--lidia-accent); outline-offset: 1px; border-color: transparent; }
.rl-lidia__hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.rl-lidia__submit {
  width: 100%; margin-top: 6px; padding: 12px; border: 0; border-radius: 10px;
  background: var(--lidia-accent); color: var(--lidia-accent-ink); font-weight: 600; cursor: pointer;
}
.rl-lidia__submit[disabled], .rl-lidia__send[disabled] { opacity: .6; cursor: default; }
.rl-lidia__error { margin: 8px 14px; font-size: 13px; color: #b3261e; }
.rl-lidia__error[hidden] { display: none; }

/* ---- thread ---- */
.rl-lidia__thread { flex: 1 1 auto; overflow-y: auto; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; overscroll-behavior: contain; }
.rl-lidia__thread[hidden] { display: none; }
.rl-lidia__msg { max-width: 88%; padding: 9px 12px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.rl-lidia__msg--lidia { align-self: flex-start; background: var(--lidia-page); border-bottom-left-radius: 4px; }
.rl-lidia__msg--visitor { align-self: flex-end; background: var(--lidia-accent); color: var(--lidia-accent-ink); border-bottom-right-radius: 4px; }
.rl-lidia__msg--system { align-self: center; font-size: 12px; color: var(--lidia-muted); background: transparent; }
.rl-lidia__msg a { color: inherit; text-decoration: underline; }
.rl-lidia__typing { align-self: flex-start; padding: 9px 12px; border-radius: 14px; background: var(--lidia-page); color: var(--lidia-muted); font-size: 13px; }
.rl-lidia__typing::after { content: "…"; animation: rl-lidia-dots 1.2s steps(3, end) infinite; }
@keyframes rl-lidia-dots { 0% { clip-path: inset(0 100% 0 0); } 100% { clip-path: inset(0 0 0 0); } }

/* ---- composer ---- */
.rl-lidia__composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px calc(10px + var(--lidia-safe-b)); border-top: 1px solid var(--lidia-line); background: var(--lidia-paper); }
.rl-lidia__composer[hidden] { display: none; }
.rl-lidia__composer textarea { resize: none; max-height: 120px; line-height: 1.35; }
.rl-lidia__send { flex: 0 0 auto; width: 42px; height: 42px; border: 0; border-radius: 50%; background: var(--lidia-accent); color: var(--lidia-accent-ink); cursor: pointer; font-size: 16px; }

/* ---- small screens: icon-only pill, bottom sheet panel ---- */
@media (max-width: 640px) {
  .rl-lidia { right: calc(12px + var(--lidia-safe-r)); bottom: calc(12px + var(--lidia-safe-b)); }
  .rl-lidia:not(.rl-lidia--merged) .rl-lidia__launcher { padding: 0 6px; width: 48px; justify-content: center; }
  .rl-lidia:not(.rl-lidia--merged) .rl-lidia__launcher-text { display: none; }
  .rl-lidia--merged .rl-lidia__launcher-text, .rl-lidia--merged .rl-lidia__walk { font-size: 13px; }
  .rl-lidia[data-state="open"] { right: 0; bottom: 0; left: 0; }
  .rl-lidia__panel {
    width: 100vw; max-width: none;
    height: 88vh; height: 88dvh;
    border-radius: var(--lidia-radius) var(--lidia-radius) 0 0;
    transform-origin: bottom center;
  }
}
@media (max-height: 520px) and (orientation: landscape) {
  .rl-lidia__panel { height: calc(100dvh - 16px); }
  .rl-lidia__disclosure { display: none; }
}
