/* ============================================================
   AI Sales Rep — live chat demo widget
   pereiradigital.ca/ai-sales-rep/ only.

   Reuses the site's existing design tokens (site/assets/css/style.css
   :root block) rather than introducing a second palette — this is meant
   to read as a feature of the page, not a bolted-on third-party widget.
   Loaded after style.css, so var(--ink)/var(--accent)/etc. resolve.
   ============================================================ */

.aidemo {
  --aidemo-radius-panel: 14px;
  --aidemo-radius-bubble: 13px;
  --aidemo-radius-input: 9px;
  --aidemo-glass: rgba(255, 255, 255, 0.06);
  --aidemo-glass-border: rgba(255, 255, 255, 0.15);
  --aidemo-body: #B9BECF;
  font-family: var(--sans);
}

.aidemo-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 14px 28px -10px rgba(193, 101, 47, 0.55);
  transition: transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.aidemo-launcher:hover { background: var(--accent-light); transform: translateY(-2px); box-shadow: 0 18px 34px -10px rgba(193, 101, 47, 0.6); }
.aidemo-launcher:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 3px; }

.aidemo-launcher-icon { position: relative; width: 24px; height: 24px; }
.aidemo-launcher-icon svg { position: absolute; inset: 0; transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease); }
.aidemo-launcher-icon .aidemo-icon-chat { opacity: 1; transform: scale(1) rotate(0deg); }
.aidemo-launcher-icon .aidemo-icon-close { opacity: 0; transform: scale(0.6) rotate(-45deg); }
.aidemo.is-open .aidemo-launcher-icon .aidemo-icon-chat { opacity: 0; transform: scale(0.6) rotate(45deg); }
.aidemo.is-open .aidemo-launcher-icon .aidemo-icon-close { opacity: 1; transform: scale(1) rotate(0deg); }

.aidemo-live-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--accent-light);
  border: 2px solid var(--bg);
  animation: aidemoPulse 2.6s ease-in-out infinite;
}
.aidemo.is-open .aidemo-live-dot { display: none; }
@keyframes aidemoPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(224, 138, 79, 0.5); }
  50% { box-shadow: 0 0 0 6px rgba(224, 138, 79, 0); }
}

.aidemo-panel {
  position: fixed;
  right: 24px;
  bottom: 96px;
  z-index: 91;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: min(70vh, 560px);
  max-height: calc(100vh - 132px);
  background: var(--ink);
  border-radius: var(--aidemo-radius-panel);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 30px 70px -18px rgba(0, 0, 0, 0.55);
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  opacity: 0;
  transform: translateY(14px) scale(0.97);
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.aidemo.is-open .aidemo-panel { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

.aidemo-header {
  position: relative;
  flex-shrink: 0;
  padding: 20px 50px 18px 22px;
  overflow: hidden;
}
.aidemo-header::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 100% -20%, rgba(193, 101, 47, 0.28), transparent 60%);
  pointer-events: none;
}
.aidemo-eyebrow {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2.4px;
  text-transform: uppercase;
  color: var(--accent-light);
  margin-bottom: 8px;
}
.aidemo-eyebrow-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-light); animation: aidemoPulse 2.6s ease-in-out infinite; flex-shrink: 0; }
.aidemo-title { position: relative; font-family: var(--serif); font-weight: 600; font-size: 19px; color: var(--bg); line-height: 1.3; }
.aidemo-accent-rule { position: relative; width: 38px; height: 2px; background: var(--accent-light); margin-top: 12px; }

.aidemo-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: #D9DCE6;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.aidemo-close:hover { background: rgba(255, 255, 255, 0.14); color: #fff; }
.aidemo-close:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 2px; }

.aidemo-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
.aidemo-messages::-webkit-scrollbar { width: 6px; }
.aidemo-messages::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 6px; }

.aidemo-msg {
  max-width: 86%;
  padding: 11px 14px;
  border-radius: var(--aidemo-radius-bubble);
  font-size: 14.5px;
  line-height: 1.55;
}
.aidemo-msg p { color: inherit; font-size: inherit; margin: 0; }
.aidemo-msg p + p,
.aidemo-msg ul + p,
.aidemo-msg p + ul { margin-top: 8px; }
.aidemo-msg strong { color: #fff; font-weight: 700; }
.aidemo-msg ul { margin: 0; padding: 0; }
.aidemo-msg li { position: relative; padding-left: 15px; }
.aidemo-msg li + li { margin-top: 5px; }
.aidemo-msg li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent-light);
}

.aidemo-msg-assistant {
  align-self: flex-start;
  background: var(--aidemo-glass);
  border: 1px solid var(--aidemo-glass-border);
  border-bottom-left-radius: 4px;
  color: var(--aidemo-body);
}
.aidemo-msg-assistant em { color: #E9DFD0; font-style: italic; font-family: var(--serif); }

.aidemo-msg-user {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.aidemo-msg-error {
  align-self: flex-start;
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.25);
  color: #B9BECF;
  font-style: italic;
}

.aidemo-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 5px;
  padding: 14px 16px;
  border-radius: var(--aidemo-radius-bubble);
  border-bottom-left-radius: 4px;
  background: var(--aidemo-glass);
  border: 1px solid var(--aidemo-glass-border);
}
.aidemo-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent-light); animation: aidemoBounce 1.1s ease-in-out infinite; }
.aidemo-typing span:nth-child(2) { animation-delay: 0.15s; }
.aidemo-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes aidemoBounce {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.aidemo-capped {
  align-self: stretch;
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--aidemo-body);
}
.aidemo-capped p { margin: 0 0 12px; color: inherit; }
.aidemo-capped-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 13.5px;
  padding: 11px 20px;
  border-radius: var(--radius-btn);
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.aidemo-capped-cta:hover { background: var(--accent-light); transform: translateY(-1px); }
.aidemo-capped-cta:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 2px; }

.aidemo-composer {
  flex-shrink: 0;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}
.aidemo-input {
  flex: 1;
  resize: none;
  max-height: 92px;
  padding: 11px 14px;
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.4;
  color: var(--bg);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--aidemo-radius-input);
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.aidemo-input::placeholder { color: #7C8296; }
.aidemo-input:focus { outline: none; border-color: var(--accent-light); background: rgba(255, 255, 255, 0.08); }
.aidemo-input:disabled { opacity: 0.5; cursor: not-allowed; }

.aidemo-send {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}
.aidemo-send:hover:not(:disabled) { background: var(--accent-light); transform: translateY(-1px); }
.aidemo-send:focus-visible { outline: 2px solid var(--accent-light); outline-offset: 2px; }
.aidemo-send:disabled { opacity: 0.4; cursor: not-allowed; }

/* Tablet: slightly narrower panel, tighter offsets */
@media (max-width: 900px) {
  .aidemo-panel { width: 340px; bottom: 88px; }
  .aidemo-launcher { right: 20px; bottom: 20px; }
}

/* Mobile: full-width bottom sheet, matches the site's own 640px breakpoint */
@media (max-width: 640px) {
  .aidemo-launcher { right: 16px; bottom: 16px; width: 54px; height: 54px; }
  .aidemo-panel {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: min(80vh, 620px);
    max-height: 85vh;
    border-radius: 18px 18px 0 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }
  .aidemo.is-open .aidemo-panel { transform: translateY(0); }
  .aidemo-panel:not(.is-open) { transform: translateY(14px); }
}

@media (prefers-reduced-motion: reduce) {
  .aidemo-launcher,
  .aidemo-panel,
  .aidemo-launcher-icon svg,
  .aidemo-send,
  .aidemo-close,
  .aidemo-capped-cta {
    transition: none;
  }
  .aidemo-live-dot,
  .aidemo-eyebrow-dot,
  .aidemo-typing span {
    animation: none;
  }
}
