/* Live Chat visitor widget */
.cms-lc { position: relative; z-index: 1080; font-family: inherit; }
.cms-lc-launcher {
  position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 1081;
  width: 3.5rem; height: 3.5rem; border: 0; border-radius: 999px;
  background: #0d6e6e; color: #fff; box-shadow: 0 8px 24px rgba(13,110,110,.35);
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.35rem;
  cursor: pointer; transition: transform .15s ease, background .15s ease;
}
.cms-lc-launcher:hover { background: #0a5757; transform: scale(1.05); }
.cms-lc-launcher--offline {
  background: #9ca3af;
  color: #fff;
  box-shadow: 0 8px 24px rgba(107, 114, 128, 0.35);
}
.cms-lc-launcher--offline:hover { background: #6b7280; }
.cms-lc-header--offline { background: #6b7280; }
.cms-lc-btn--offline { background: #6b7280; }
.cms-lc-btn--offline:hover { background: #4b5563; }
.cms-lc--offline .cms-lc-panel {
  border: 1px solid #d1d5db;
}
.cms-lc-offline-banner {
  margin: 0 0 .75rem;
  padding: .7rem .75rem;
  border-radius: 10px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  color: #374151;
}
.cms-lc-offline-pill {
  display: inline-flex;
  align-items: center;
  margin-bottom: .35rem;
  padding: .15rem .55rem;
  border-radius: 999px;
  background: #e5e7eb;
  color: #374151;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.cms-lc-offline-notice {
  font-size: .84rem;
  line-height: 1.4;
  color: #4b5563;
}
.cms-lc-offline-reply {
  margin: -.35rem 0 .85rem;
  font-size: .84rem;
  color: #6b7280;
}
.cms-lc-success {
  margin-top: .65rem; padding: .65rem .75rem; border-radius: 8px;
  background: #ecfdf5; color: #065f46; font-size: .88rem; line-height: 1.4;
}
.cms-lc-badge {
  position: absolute; top: -2px; right: -2px; min-width: 1.15rem; height: 1.15rem;
  padding: 0 .3rem; border-radius: 999px; background: #dc3545; color: #fff;
  font-size: .7rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center;
}
.cms-lc-panel {
  position: fixed; right: 1.25rem; bottom: 5.75rem; z-index: 1082;
  width: min(380px, calc(100vw - 1.5rem));
  max-height: min(560px, calc(100vh - 7rem));
  max-height: min(560px, calc(100dvh - 7rem));
  background: #fff; border-radius: 14px; overflow: hidden;
  box-shadow: 0 16px 48px rgba(15,23,42,.22); display: flex; flex-direction: column;
  animation: cmsLcIn .2s ease;
}
/* Active conversation needs a stable chat pane height */
.cms-lc-panel:has([data-lc-chat]:not([hidden])) {
  height: min(520px, calc(100vh - 7rem));
  height: min(520px, calc(100dvh - 7rem));
  max-height: min(520px, calc(100vh - 7rem));
  max-height: min(520px, calc(100dvh - 7rem));
}
@keyframes cmsLcIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.cms-lc-header {
  display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem;
  padding: .7rem .85rem; background: #0d6e6e; color: #fff; flex-shrink: 0;
}
.cms-lc-header strong { font-size: .95rem; line-height: 1.25; }
.cms-lc-status { font-size: .72rem; opacity: .9; margin-top: .1rem; }
.cms-lc-header-actions { display: flex; gap: .25rem; }
.cms-lc-icon-btn {
  border: 0; background: rgba(255,255,255,.12); color: #fff; width: 1.85rem; height: 1.85rem;
  border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.cms-lc-icon-btn:hover { background: rgba(255,255,255,.22); }
.cms-lc-body { flex: 1; min-height: 0; overflow: auto; padding: .85rem; background: #f8fafc; }

/* --- Pre-chat: compact form, pinned Start button --- */
.cms-lc-prechat {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}
.cms-lc-prechat-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
}
.cms-lc-prechat-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: .75rem .85rem .35rem;
  overscroll-behavior: contain;
}
.cms-lc-prechat-footer {
  flex: 0 0 auto;
  padding: .55rem .85rem .75rem;
  background: #f8fafc;
  border-top: 1px solid #e8eef3;
  box-shadow: 0 -6px 12px rgba(248, 250, 252, .9);
}
.cms-lc-intro {
  font-size: .8125rem;
  line-height: 1.4;
  color: #475569;
  margin: 0 0 .65rem;
}
.cms-lc-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .45rem .55rem;
}
.cms-lc-field { margin-bottom: 0; min-width: 0; }
.cms-lc-field--message { grid-column: 1 / -1; }
.cms-lc-field label {
  display: block;
  font-size: .7rem;
  font-weight: 600;
  margin-bottom: .15rem;
  color: #334155;
  line-height: 1.25;
}
.cms-lc-field input,
.cms-lc-field textarea {
  width: 100%;
  border: 1px solid #d0d7de;
  border-radius: 8px;
  padding: .4rem .55rem;
  font: inherit;
  font-size: .875rem;
  line-height: 1.3;
  background: #fff;
}
.cms-lc-field textarea {
  min-height: 3.25rem;
  max-height: 5.5rem;
  resize: vertical;
}
.cms-lc-check {
  display: flex; align-items: flex-start; gap: .45rem; font-size: .78rem; font-weight: 500; color: #334155; cursor: pointer;
  margin: 0;
}
.cms-lc-check input {
  width: auto; margin-top: .12rem; flex-shrink: 0;
}
.cms-lc-remember {
  margin: .55rem 0 0;
}
.cms-lc-error {
  color: #dc3545;
  font-size: .7rem;
  line-height: 1.25;
  margin-top: .15rem;
  min-height: 0;
}
.cms-lc-error:empty { display: none; }
.cms-lc-alert {
  background: #fee2e2; color: #991b1b; border-radius: 8px; padding: .45rem .6rem; font-size: .78rem; margin: .5rem 0 0;
}
.cms-lc-btn {
  width: 100%; border: 0; border-radius: 8px; padding: .6rem 1rem; background: #0d6e6e; color: #fff;
  font-weight: 600; cursor: pointer; font-size: .9rem;
}
.cms-lc-btn:disabled { opacity: .65; cursor: not-allowed; }

/* Active chat pane */
.cms-lc-chat { display: flex; flex-direction: column; padding: 0; }
.cms-lc-messages { flex: 1; overflow: auto; padding: .85rem; display: flex; flex-direction: column; gap: .55rem; }
.cms-lc-msg { max-width: 85%; padding: .55rem .7rem; border-radius: 12px; font-size: .875rem; line-height: 1.4; word-break: break-word; }
.cms-lc-msg--visitor { align-self: flex-end; background: #0d6e6e; color: #fff; border-bottom-right-radius: 4px; }
.cms-lc-msg--admin, .cms-lc-msg--system { align-self: flex-start; background: #fff; border: 1px solid #e2e8f0; border-bottom-left-radius: 4px; }
.cms-lc-msg--system { color: #475569; font-style: italic; }
.cms-lc-msg time { display: block; font-size: .65rem; opacity: .75; margin-top: .25rem; }
.cms-lc-composer {
  display: flex; align-items: flex-end; gap: .4rem; padding: .65rem; border-top: 1px solid #e2e8f0; background: #fff;
}
.cms-lc-composer textarea {
  flex: 1; border: 1px solid #d0d7de; border-radius: 10px; padding: .5rem .65rem; resize: none; font: inherit; min-height: 2.5rem;
}
.cms-lc-send { width: auto; padding: .55rem .7rem; border-radius: 10px; }
.cms-lc-attach { display: inline-flex; align-items: center; justify-content: center; width: 2.75rem; height: 2.75rem; color: #475569; cursor: pointer; }
.cms-lc-launcher:focus-visible,
.cms-lc-icon-btn:focus-visible,
.cms-lc-btn:focus-visible,
.cms-lc-attach:focus-within,
.cms-lc-field input:focus-visible,
.cms-lc-field textarea:focus-visible {
  outline: 2px solid #0d6e6e;
  outline-offset: 2px;
}

/* Go To Top sits above the chat launcher when Live Chat is present */
body:has(#cmsLiveChat) .back-to-top {
  right: 1.25rem;
  bottom: 5.5rem;
  z-index: 1075;
}

@media (max-width: 575.98px) {
  .cms-lc-panel {
    right: .5rem;
    left: .5rem;
    width: auto;
    bottom: 5.25rem;
    max-height: min(72vh, calc(100vh - 6.5rem));
    max-height: min(72dvh, calc(100dvh - 6.5rem));
  }
  .cms-lc-panel:has([data-lc-chat]:not([hidden])) {
    height: min(72vh, calc(100vh - 6.5rem));
    height: min(72dvh, calc(100dvh - 6.5rem));
    max-height: min(72vh, calc(100vh - 6.5rem));
    max-height: min(72dvh, calc(100dvh - 6.5rem));
  }
  .cms-lc-fields { grid-template-columns: 1fr; gap: .4rem; }
  .cms-lc-launcher { right: .85rem; bottom: .85rem; }
  body:has(#cmsLiveChat) .back-to-top {
    right: .85rem;
    bottom: 5rem;
  }
}

@media (max-width: 380px) {
  .cms-lc-prechat-scroll { padding: .65rem .7rem .3rem; }
  .cms-lc-prechat-footer { padding: .45rem .7rem .65rem; }
  .cms-lc-intro { font-size: .78rem; margin-bottom: .5rem; }
}

/* Short viewports (laptops / landscape phones): keep Start Chat visible */
@media (max-height: 700px) {
  .cms-lc-panel {
    bottom: 5.25rem;
    max-height: calc(100vh - 6.25rem);
    max-height: calc(100dvh - 6.25rem);
  }
  .cms-lc-panel:has([data-lc-chat]:not([hidden])) {
    height: calc(100vh - 6.25rem);
    height: calc(100dvh - 6.25rem);
    max-height: calc(100vh - 6.25rem);
    max-height: calc(100dvh - 6.25rem);
  }
  .cms-lc-header { padding: .55rem .75rem; }
  .cms-lc-intro { margin-bottom: .45rem; }
  .cms-lc-fields { gap: .35rem .5rem; }
  .cms-lc-field textarea { min-height: 2.75rem; max-height: 4.25rem; }
}

@media (max-height: 560px) {
  .cms-lc-fields { grid-template-columns: 1fr 1fr; }
  .cms-lc-panel {
    bottom: 4.75rem;
    max-height: calc(100vh - 5.5rem);
    max-height: calc(100dvh - 5.5rem);
  }
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  .cms-lc-panel { animation: none; }
  .cms-lc-launcher { transition: none; }
}

/* Admin conversation */
.lc-admin-messages { max-height: 420px; overflow: auto; display: flex; flex-direction: column; gap: .65rem; padding: .25rem; }
.lc-admin-msg { padding: .65rem .8rem; border-radius: 10px; background: #f8fafc; border: 1px solid #e2e8f0; }
.lc-admin-msg--admin { background: #e8f5f5; border-color: #b7dede; }
.lc-admin-msg--visitor { background: #fff; }
.lc-admin-msg--system { color: #64748b; font-style: italic; }
.lc-admin-msg-meta { display: flex; justify-content: space-between; gap: 1rem; font-size: .75rem; margin-bottom: .25rem; }
.lc-admin-msg-body { font-size: .9rem; }
