/* Native live chat widget — client area, bottom-right */
/* Hidden until at least one agent is "available" */
.syn-lcw--ai .syn-lcw__prechat {
  display: none !important;
}

.syn-lcw--ai.syn-lcw.is-open .syn-lcw__chat {
  display: flex;
}

.syn-lcw--offline .syn-lcw__launcher-wrap {
  display: none;
}

.syn-lcw__connecting {
  flex: 0 0 auto;
  margin: 0;
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  color: #0f766e;
  background: rgba(45, 212, 191, 0.12);
  border-bottom: 1px solid var(--syn-lcw-border);
}

.syn-lcw__connecting.syn-lcw__connecting--joined {
  color: #e2e8f0;
  background: rgba(45, 212, 191, 0.18);
  font-weight: 500;
}

.syn-lcw__textarea--pre {
  min-height: 5.75rem;
}

.syn-lcw__textarea--rating {
  min-height: 4rem;
  max-height: 10rem;
}

.syn-lcw {
  --syn-lcw-accent: #2dd4bf;
  --syn-lcw-accent-dim: #115e59;
  --syn-lcw-bg: #0f172a;
  --syn-lcw-border: #334155;
  --syn-lcw-text: #e2e8f0;
  --syn-lcw-muted: #94a3b8;
  position: fixed;
  z-index: 99990;
  bottom: 1.25rem;
  right: 1.25rem;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
}

.syn-lcw__launcher {
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(145deg, var(--syn-lcw-accent), var(--syn-lcw-accent-dim));
  color: #042f2e;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.syn-lcw__launcher:hover {
  transform: scale(1.05);
  box-shadow: 0 10px 32px rgba(45, 212, 191, 0.25);
}

.syn-lcw__launcher:focus-visible {
  outline: 2px solid var(--syn-lcw-accent);
  outline-offset: 3px;
}

.syn-lcw__launcher svg {
  width: 1.65rem;
  height: 1.65rem;
}

.syn-lcw__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 1.1rem;
  height: 1.1rem;
  padding: 0 4px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.1rem;
  text-align: center;
  border: 2px solid var(--syn-lcw-bg);
  display: none;
}

.syn-lcw__launcher-wrap {
  position: relative;
}

.syn-lcw__launcher-wrap.has-unread .syn-lcw__badge {
  display: block;
}

.syn-lcw__panel {
  position: absolute;
  bottom: calc(3.5rem + 0.75rem);
  right: 0;
  width: min(100vw - 2rem, 420px);
  height: min(92vh, 620px);
  max-height: min(92vh, 620px);
  display: flex;
  flex-direction: column;
  background: var(--syn-lcw-bg);
  color: var(--syn-lcw-text);
  border: 1px solid var(--syn-lcw-border);
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.syn-lcw.is-open .syn-lcw__panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.syn-lcw__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid var(--syn-lcw-border);
}

.syn-lcw__head h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.syn-lcw__head-sub {
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: var(--syn-lcw-muted);
  font-weight: 400;
}

.syn-lcw__status-pill {
  display: inline-block;
  margin-top: 0.35rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  border-radius: 999px;
  line-height: 1.3;
}

.syn-lcw__status-pill--ai {
  background: rgba(56, 189, 248, 0.18);
  color: #7dd3fc;
}

.syn-lcw__status-pill--agent {
  background: rgba(74, 222, 128, 0.18);
  color: #86efac;
}

.syn-lcw__status-pill--escalated {
  background: rgba(251, 191, 36, 0.2);
  color: #fcd34d;
}

.syn-lcw__connecting--ai {
  background: rgba(56, 189, 248, 0.08);
  border-color: rgba(56, 189, 248, 0.25);
  color: #bae6fd;
}

.syn-lcw__head-btn {
  background: transparent;
  border: none;
  color: var(--syn-lcw-muted);
  cursor: pointer;
  padding: 0.35rem;
  border-radius: 8px;
  line-height: 1;
}

.syn-lcw__head-btn:hover {
  color: var(--syn-lcw-text);
  background: rgba(148, 163, 184, 0.12);
}

.syn-lcw__head-actions {
  position: relative;
  flex-shrink: 0;
}

.syn-lcw__menu {
  position: relative;
}

.syn-lcw__menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin: 4px 0 0;
  padding: 6px 0;
  min-width: 180px;
  list-style: none;
  background: #1e293b;
  border: 1px solid var(--syn-lcw-border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  z-index: 10;
}

.syn-lcw__menu-dropdown[hidden] {
  display: none !important;
}

.syn-lcw__menu-item {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0.55rem 1rem;
  border: none;
  background: transparent;
  color: var(--syn-lcw-text);
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
}

.syn-lcw__menu-item:hover {
  background: rgba(148, 163, 184, 0.12);
}

.syn-lcw__body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.syn-lcw__prechat {
  flex: 1;
  min-height: 0;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  overflow-y: auto;
}

/* Stack label directly above its control; spacing between groups comes from .syn-lcw__prechat gap */
.syn-lcw__field {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin: 0;
}

.syn-lcw__prechat[hidden],
.syn-lcw__chat[hidden] {
  display: none !important;
}

.syn-lcw__label {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--syn-lcw-muted);
  line-height: 1.25;
}

.syn-lcw__select {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--syn-lcw-border);
  background: #080a0d;
  color: var(--syn-lcw-text);
  font: inherit;
}

.syn-lcw__input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--syn-lcw-border);
  background: #080a0d;
  color: var(--syn-lcw-text);
  font: inherit;
}

.syn-lcw__hint-inline {
  font-weight: 400;
  opacity: 0.85;
}

.syn-lcw__btn-primary {
  width: 100%;
  padding: 0.65rem 1rem;
  border: none;
  border-radius: 10px;
  background: var(--syn-lcw-accent-dim);
  color: #ecfeff;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--syn-lcw-accent);
}

.syn-lcw__btn-primary:hover {
  filter: brightness(1.08);
}

.syn-lcw__btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.syn-lcw__btn-secondary {
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.55rem 1rem;
  border-radius: 10px;
  background: transparent;
  color: var(--syn-lcw-muted);
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--syn-lcw-border);
}

.syn-lcw__btn-secondary:hover {
  color: var(--syn-lcw-text);
  border-color: var(--syn-lcw-muted);
}

.syn-lcw__rating {
  flex: 1;
  min-height: 0;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  overflow-y: auto;
}

.syn-lcw__rating[hidden] {
  display: none !important;
}

.syn-lcw__rating-title {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--syn-lcw-text);
}

.syn-lcw__stars {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.syn-lcw__star {
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(148, 163, 184, 0.12);
  color: var(--syn-lcw-muted);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  transition: color 0.12s ease, background 0.12s ease, transform 0.12s ease;
}

.syn-lcw__star:hover,
.syn-lcw__star:focus-visible {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
  outline: none;
}

.syn-lcw__star.is-active {
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.18);
  transform: scale(1.05);
}

.syn-lcw__hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--syn-lcw-muted);
}

.syn-lcw__err {
  margin: 0;
  font-size: 0.8rem;
  color: #f87171;
}

.syn-lcw__chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.syn-lcw__thread {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  -webkit-overflow-scrolling: touch;
}

.syn-lcw__msg {
  max-width: 90%;
  padding: 0.5rem 0.75rem;
  border-radius: 12px;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.syn-lcw__msg--client {
  align-self: flex-end;
  background: rgba(45, 212, 191, 0.15);
  border: 1px solid rgba(45, 212, 191, 0.35);
}

.syn-lcw__msg--staff {
  align-self: flex-start;
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid rgba(148, 163, 184, 0.25);
}

.syn-lcw__msg--assistant {
  align-self: flex-start;
  background: rgba(45, 212, 191, 0.08);
  border: 1px solid rgba(45, 212, 191, 0.35);
}

.syn-lcw__typing {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.55rem 0.85rem;
  margin: 0.25rem 0;
  border-radius: 12px;
  background: rgba(148, 163, 184, 0.12);
  border: 1px solid rgba(148, 163, 184, 0.22);
  color: var(--syn-lcw-muted);
  font-size: 0.82rem;
}

.syn-lcw__typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}

.syn-lcw__typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--syn-lcw-accent);
  opacity: 0.35;
  animation: syn-lcw-typing-bounce 1.2s ease-in-out infinite;
}

.syn-lcw__typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.syn-lcw__typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes syn-lcw-typing-bounce {
  0%,
  80%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.syn-lcw__msg-meta {
  margin-top: 0.25rem;
  font-size: 0.68rem;
  opacity: 0.75;
}

.syn-lcw__compose {
  flex-shrink: 0;
  padding: 0.65rem 1rem 1rem;
  border-top: 1px solid var(--syn-lcw-border);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.syn-lcw__textarea {
  width: 100%;
  min-height: 3.25rem;
  max-height: 8rem;
  resize: vertical;
  padding: 0.5rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--syn-lcw-border);
  background: #080a0d;
  color: var(--syn-lcw-text);
  font: inherit;
}

.syn-lcw__send-row {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 480px) {
  .syn-lcw {
    bottom: 1rem;
    right: 1rem;
  }

  .syn-lcw__panel {
    width: calc(100vw - 2rem);
    height: min(92vh, 620px);
    max-height: min(92vh, 620px);
  }
}
