:root {
  --lc-primary: #2563eb;
  --lc-primary-dark: #1d4ed8;
  --lc-btn-color: #2563eb;
  --lc-bg: #ffffff;
  --lc-text: #1f2937;
  --lc-muted: #6b7280;
  --lc-border: #e5e7eb;
  --lc-visitor-bg: #f3f4f6;
  --lc-visitor-text: #1f2937;
  --lc-operator-bg: #2563eb;
  --lc-operator-text: #ffffff;
  --lc-shadow: 0 8px 32px rgba(0,0,0,.18);
  --lc-radius: 16px;
}

/* Button hidden until theme is applied */
#lc-root:not(.lc-ready) .lc-btn { opacity: 0; pointer-events: none; }
#lc-root.lc-ready .lc-btn { transition: opacity .15s; }

/* Position: bottom-right (default) */
#lc-root .lc-btn    { bottom:var(--lc-oy,24px); top:auto; right:var(--lc-ox,24px); left:auto; }
#lc-root .lc-window { bottom:24px; top:auto; right:24px; left:auto; }

/* bottom-left */
#lc-root.lc-pos-bottom-left .lc-btn    { left:var(--lc-ox,24px); right:auto; }

/* top-right */
#lc-root.lc-pos-top-right .lc-btn    { top:var(--lc-oy,24px); bottom:auto; }

/* top-left */
#lc-root.lc-pos-top-left .lc-btn    { top:var(--lc-oy,24px); bottom:auto; left:var(--lc-ox,24px); right:auto; }

.lc-btn {
  position: fixed;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--lc-btn-color, var(--lc-primary));
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(37,99,235,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s, background .2s;
  z-index: 999998;
}
.lc-btn:hover { background: var(--lc-primary-dark); transform: scale(1.08); }
.lc-btn.offline { background: #9ca3af; box-shadow: 0 4px 16px rgba(0,0,0,.15); }
.lc-btn.offline:hover { background: #6b7280; }
.lc-btn svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.lc-badge {
  position: absolute;
  top: -4px; right: -4px;
  background: #ef4444;
  color: #fff;
  border-radius: 50%;
  width: 20px; height: 20px;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  display: none;
}
.lc-badge.visible { display: flex; }

/* Trigger mode: hide the floating FAB */
.lc-has-trigger .lc-btn { display: none !important; }

/* Badge injected into a custom trigger element */
.lc-trigger-badge {
  display: none;
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  padding: 0 4px;
  pointer-events: none;
  z-index: 1;
}
.lc-trigger-badge.visible { display: block; }

.lc-window {
  position: fixed;
  width: 350px;
  height: 500px;
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
  min-width: 280px;
  min-height: 360px;
  background: var(--lc-bg);
  border-radius: var(--lc-radius);
  box-shadow: var(--lc-shadow);
  display: flex;
  flex-direction: column;
  z-index: 999999;
  overflow: hidden;
  transform: scale(.95) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition: transform .2s ease, opacity .2s ease;
}
.lc-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

.lc-header {
  background: var(--lc-primary);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.lc-header-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex;
  align-items: center;
  justify-content: center;
}
.lc-header-avatar svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.lc-header-info { flex: 1; }
.lc-header-title { font-weight: 600; font-size: 15px; }
.lc-header-sub { font-size: 12px; opacity: .8; }
.lc-close-btn { background: none; border: none; color: #fff; cursor: pointer; opacity: .8; padding: 4px; border-radius: 6px; }
.lc-close-btn:hover { opacity: 1; background: rgba(255,255,255,.15); }
.lc-close-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.5; stroke-linecap: round; }

.lc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}
.lc-messages::-webkit-scrollbar { width: 4px; }
.lc-messages::-webkit-scrollbar-thumb { background: var(--lc-border); border-radius: 2px; }

.lc-msg {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}
.lc-msg.visitor {
  align-self: flex-end;
  background: var(--lc-operator-bg);
  color: var(--lc-operator-text);
  border-bottom-right-radius: 4px;
}
.lc-msg.operator {
  align-self: flex-start;
  background: var(--lc-visitor-bg);
  color: var(--lc-visitor-text, var(--lc-text));
  border-bottom-left-radius: 4px;
}
.lc-msg-time {
  font-size: 11px;
  opacity: .55;
  margin-top: 3px;
}
.lc-msg.visitor .lc-msg-time { text-align: right; }
.lc-msg.operator .lc-msg-time { text-align: left; }

.lc-date-sep {
  text-align: center;
  font-size: 11px;
  color: var(--lc-muted);
  margin: 6px 0;
}

.lc-notice {
  text-align: center;
  font-size: 12px;
  color: var(--lc-muted);
  font-style: italic;
  padding: 2px 0;
  margin: 4px 0;
}
.lc-notice-error {
  color: #ef4444;
  font-style: normal;
  font-weight: 500;
}

.lc-typing {
  font-size: 13px;
  color: var(--lc-muted);
  padding: 0 14px 6px;
  min-height: 22px;
}

.lc-status-bar {
  background: #fef3c7;
  color: #92400e;
  font-size: 13px;
  padding: 8px 14px;
  text-align: center;
  display: none;
}
.lc-status-bar.visible { display: block; }

.lc-start-form {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lc-start-form input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--lc-border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  box-sizing: border-box;
  transition: border-color .15s;
  color: #1e293b;
  background: #fff;
  color-scheme: light;
}
.lc-start-form input:focus { border-color: var(--lc-primary); }

.lc-footer {
  position: relative;
  border-top: 1px solid var(--lc-border);
  padding: 10px 12px;
  display: flex;
  gap: 6px;
  align-items: flex-end;
  flex-shrink: 0;
}
.lc-attach-btn {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--lc-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color .15s;
  padding: 0;
}
.lc-attach-btn:hover { color: var(--lc-primary); }
.lc-attach-btn svg { width: 18px; height: 18px; }
.lc-input {
  flex: 1;
  border: 1px solid var(--lc-border);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 14px;
  resize: none;
  outline: none;
  max-height: 100px;
  overflow-y: auto;
  line-height: 1.4;
  font-family: inherit;
  transition: border-color .15s;
  box-sizing: border-box;
  color: #1e293b;
  background: #fff;
  color-scheme: light;
}
.lc-input:focus { border-color: var(--lc-primary); }
.lc-char-count {
  position: absolute;
  bottom: 6px;
  right: 52px;
  font-size: 10px;
  color: var(--lc-muted);
  pointer-events: none;
  line-height: 1;
}
.lc-char-count-warn { color: #ef4444; }
.lc-send-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--lc-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
}
.lc-send-btn:hover { background: var(--lc-primary-dark); }
.lc-send-btn svg { width: 16px; height: 16px; fill: none; stroke: #fff; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }

.lc-closed-notice {
  text-align: center;
  padding: 12px 16px;
  color: var(--lc-muted);
  font-size: 13px;
  border-top: 1px solid var(--lc-border);
}
.lc-new-chat-btn {
  display: block;
  margin: 8px auto 0;
  padding: 7px 18px;
  background: var(--lc-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.lc-new-chat-btn:hover { background: var(--lc-primary-dark); }

/* ── File messages ──────────────────────────────────────────────── */
.lc-file-img img {
  max-width: 200px;
  max-height: 200px;
  border-radius: 8px;
  cursor: pointer;
  display: block;
  object-fit: cover;
}
.lc-file-video video {
  max-width: 220px;
  border-radius: 8px;
  display: block;
}
.lc-file-doc {
  display: flex;
  align-items: center;
  gap: 7px;
}
.lc-file-doc svg {
  width: 20px; height: 20px;
  flex-shrink: 0;
  stroke-width: 1.5;
}
.lc-file-doc a {
  color: inherit;
  font-size: 13px;
  text-decoration: underline;
  text-underline-offset: 2px;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lc-file-size {
  font-size: 11px;
  opacity: .6;
  white-space: nowrap;
}

/* ── Pending upload ─────────────────────────────────────────────── */
.lc-pending-upload {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
}
.lc-progress-ring-wrap {
  position: relative;
  width: 44px; height: 44px;
  flex-shrink: 0;
}
.lc-progress-ring {
  width: 44px; height: 44px;
  transform: rotate(-90deg);
  display: block;
}
.lc-progress-bg {
  fill: none;
  stroke: rgba(255,255,255,.25);
  stroke-width: 4;
}
.lc-progress-bar {
  fill: none;
  stroke: #fff;
  stroke-width: 4;
  stroke-linecap: round;
  transition: stroke-dashoffset .2s ease;
}
.lc-cancel-upload {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: none;
  border: none;
  color: #fff;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  width: 22px; height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.lc-upload-name {
  font-size: 12px;
  opacity: .85;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Image modal ────────────────────────────────────────────────── */
.lc-img-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.85);
  z-index: 9999999;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.lc-img-modal img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  object-fit: contain;
  cursor: default;
  pointer-events: none;
}
.lc-img-modal-close {
  position: absolute;
  top: 16px; right: 16px;
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 36px; height: 36px;
  border-radius: 50%;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lc-img-modal-close:hover { background: rgba(255,255,255,.25); }

.lc-cant-connect {
  background: #fee2e2;
  color: #b91c1c;
  font-size: 13px;
  text-align: center;
  padding: 8px 14px;
  border-top: 1px solid #fecaca;
  flex-shrink: 0;
}

.lc-resize-handle {
  position: absolute;
  top: 0;
  left: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  z-index: 10;
}
.lc-resize-handle::before {
  content: '';
  position: absolute;
  top: 4px;
  left: 4px;
  width: 10px;
  height: 10px;
  border-top: 2px solid rgba(255,255,255,.5);
  border-left: 2px solid rgba(255,255,255,.5);
  border-radius: 2px 0 0 0;
}

@media (max-width: 400px) {
  .lc-window { width: calc(100vw - 16px); right: 8px; bottom: 80px; }
}
