/* ── Live Chat Widget ── */
:root {
  --lc-accent:  #6C63FF;
  --lc-accent2: #574fd6;
  --lc-radius:  18px;
  --lc-shadow:  0 8px 40px rgba(0,0,0,.18);
}

/* Launcher button */
#lc-launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 99992;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--lc-accent);
  border: none;
  cursor: pointer;
  box-shadow: var(--lc-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: bottom .35s cubic-bezier(.4,0,.2,1),
              right  .35s cubic-bezier(.4,0,.2,1),
              transform .2s, background .2s;
  outline: none;
}
#lc-launcher:hover { background: var(--lc-accent2); transform: scale(1.08); }
#lc-launcher svg { width: 26px; height: 26px; fill: #fff; transition: opacity .2s; }
#lc-launcher .lc-ico-open  { display: block; }
#lc-launcher .lc-ico-close { display: none; }
#lc-launcher.lc-open .lc-ico-open  { display: none; }
#lc-launcher.lc-open .lc-ico-close { display: block; }

/* When chat is open on mobile — move launcher to top-right */
@media (max-width: 600px) {
  #lc-launcher.lc-open {
    bottom: calc(100vh - 46px);
    right: 14px;
    width: 36px;
    height: 36px;
    box-shadow: none;
    background: rgba(255,255,255,.22);
    transform: none !important;
  }
  #lc-launcher.lc-open svg {
    width: 18px;
    height: 18px;
  }
  #lc-launcher.lc-open:hover {
    background: rgba(255,255,255,.35);
  }
}

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

/* Chat window */
#lc-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 99989;
  width: 360px;
  max-width: calc(100vw - 36px);
  max-height: 540px;
  background: #fff;
  border-radius: var(--lc-radius);
  box-shadow: var(--lc-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0) translateY(10px);
  opacity: 0;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), opacity .2s;
  pointer-events: none;
}
#lc-window.lc-visible {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Header */
#lc-header {
  background: var(--lc-accent);
  color: #fff;
  padding: 16px 18px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  position: relative;
}
#lc-header-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
#lc-header-info { flex: 1; min-width: 0; padding-right: 8px; }
#lc-header-title {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#lc-header-status {
  font-size: 11px;
  opacity: .8;
  margin-top: 1px;
  display: flex; align-items: center; gap: 5px;
}
.lc-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #2ecc71;
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(46,204,113,.4);
  animation: lc-pulse 2s infinite;
}
@keyframes lc-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(46,204,113,.5); }
  70%  { box-shadow: 0 0 0 6px rgba(46,204,113,0); }
  100% { box-shadow: 0 0 0 0 rgba(46,204,113,0); }
}

/* Name form */
#lc-name-form {
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  justify-content: center;
}
#lc-name-form p { margin: 0; font-size: 14px; color: #555; text-align: center; }
#lc-name-input {
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  outline: none;
  transition: border-color .2s;
  font-family: inherit;
}
#lc-name-input:focus { border-color: var(--lc-accent); }
#lc-name-btn {
  background: var(--lc-accent);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 11px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
  font-family: inherit;
}
#lc-name-btn:hover { background: var(--lc-accent2); }

/* Messages */
#lc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: smooth;
}
#lc-messages::-webkit-scrollbar { width: 4px; }
#lc-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

.lc-msg {
  max-width: 78%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
  animation: lc-fadein .2s ease;
}
@keyframes lc-fadein { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:none; } }
.lc-msg.visitor {
  background: var(--lc-accent);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.lc-msg.operator {
  background: #f1f0f5;
  color: #222;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.lc-msg-time {
  font-size: 10px;
  opacity: .55;
  margin-top: 4px;
  text-align: right;
}
.lc-msg.operator .lc-msg-time { text-align: left; }

/* Typing indicator */
#lc-typing {
  align-self: flex-start;
  display: none;
  gap: 4px;
  padding: 10px 14px;
  background: #f1f0f5;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
#lc-typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #aaa;
  display: inline-block;
  animation: lc-bounce .9s infinite;
}
#lc-typing span:nth-child(2) { animation-delay: .15s; }
#lc-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes lc-bounce {
  0%,80%,100% { transform: translateY(0); }
  40%         { transform: translateY(-6px); }
}

/* Closed banner */
#lc-closed-banner {
  display: none;
  background: #fff3cd;
  color: #856404;
  font-size: 12px;
  text-align: center;
  padding: 6px 10px;
  flex-shrink: 0;
}

/* Input area */
#lc-footer {
  border-top: 1px solid #f0f0f0;
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: #fff;
}
#lc-text {
  flex: 1;
  border: 1.5px solid #e0e0e0;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13.5px;
  resize: none;
  min-height: 36px;
  max-height: 100px;
  outline: none;
  font-family: inherit;
  line-height: 1.45;
  transition: border-color .2s;
}
#lc-text:focus { border-color: var(--lc-accent); }
#lc-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--lc-accent);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .2s, transform .1s;
}
#lc-send:hover { background: var(--lc-accent2); }
#lc-send:active { transform: scale(.92); }
#lc-send svg { width: 18px; height: 18px; fill: #fff; }

/* Mobile — full screen */
@media (max-width: 600px) {
  #lc-window {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    max-width: 100%;
    max-height: 100%;
    height: 100%;
    border-radius: 0;
  }
  /* launcher position handled by lc-open state above */
  #lc-messages {
    flex: 1;
    max-height: none;
  }
  #lc-footer {
    padding-bottom: max(14px, env(safe-area-inset-bottom));
  }
  /* Fix zoom on input focus — must be at least 16px */
  #lc-text, #lc-name-input {
    font-size: 16px !important;
  }
}

/* Close button — hidden, launcher takes its role */
#lc-mobile-close { display: none; }
