/* ── Launcher ── */
:root {
  --lc-launcher-size: 58px;
  --lc-launcher-bottom: 22px;
  --lc-panel-gap: 14px;
}

.live-chat-launcher {
  position: fixed;
  right: 22px;
  bottom: var(--lc-launcher-bottom);
  z-index: 998;
  width: var(--lc-launcher-size);
  height: var(--lc-launcher-size);
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, var(--primary), var(--primary-d));
  color: #fff;
  font-size: 1.4rem;
  box-shadow: 0 12px 32px rgba(192, 57, 43, 0.38);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.live-chat-launcher:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 16px 36px rgba(192, 57, 43, 0.45);
}

.live-chat-launcher[aria-expanded="true"] {
  transform: scale(0.96);
}

.live-chat-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: #16a34a;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ── Panel shell ── */
.live-chat-panel {
  position: fixed;
  right: 22px;
  bottom: calc(var(--lc-launcher-bottom) + var(--lc-launcher-size) + var(--lc-panel-gap));
  z-index: 998;
  width: min(380px, calc(100vw - 24px));
  height: 560px;
  max-height: calc(100vh - var(--lc-launcher-bottom) - var(--lc-launcher-size) - var(--lc-panel-gap) - 24px);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(16, 24, 40, 0.2), 0 0 0 1px rgba(16, 24, 40, 0.06);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: inherit;
}

.live-chat-panel.open {
  display: flex;
  animation: liveChatSlideUp 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes liveChatSlideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Header ── */
.live-chat-head {
  background: linear-gradient(135deg, #1a2744 0%, #243b6b 100%);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.live-chat-head-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.live-chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.live-chat-head strong {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.live-chat-head span {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.76rem;
  color: #b8c5d9;
  margin-top: 2px;
}

.live-chat-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.25);
  flex-shrink: 0;
}

.live-chat-panel.is-closed .live-chat-dot {
  background: #94a3b8;
  box-shadow: none;
}

.live-chat-dot-wait {
  background: #fbbf24;
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.28);
  animation: liveChatDotPulse 1.4s ease-in-out infinite;
}

@keyframes liveChatDotPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.live-chat-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.live-chat-wa {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #25d366;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.15s ease, transform 0.15s ease;
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.35);
}

.live-chat-wa:hover {
  background: #1da851;
  color: #fff;
  transform: translateY(-1px);
}

.live-chat-close {
  appearance: none;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  flex-shrink: 0;
}

.live-chat-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ── Body & views ── */
.live-chat-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.live-chat-welcome {
  flex: 1;
  overflow-y: auto;
  padding: 28px 22px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.live-chat-panel.is-chatting .live-chat-welcome {
  display: none;
}

.live-chat-conversation {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.live-chat-conversation[hidden] {
  display: none !important;
}

.live-chat-panel.is-chatting .live-chat-conversation {
  display: flex;
}

.live-chat-waiting {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 14px 16px;
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-bottom: 1px solid #fde68a;
  flex-shrink: 0;
}

.live-chat-waiting[hidden] {
  display: none !important;
}

.live-chat-waiting-pulse {
  display: flex;
  align-items: center;
  gap: 5px;
  padding-top: 6px;
  flex-shrink: 0;
}

.live-chat-waiting-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #d97706;
  animation: liveChatWaitBounce 1.2s ease-in-out infinite;
}

.live-chat-waiting-dot:nth-child(2) { animation-delay: 0.15s; }
.live-chat-waiting-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes liveChatWaitBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.live-chat-waiting-text {
  min-width: 0;
}

.live-chat-waiting-text strong {
  display: block;
  font-size: 0.88rem;
  color: #92400e;
  margin-bottom: 4px;
}

.live-chat-waiting-text p {
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: #b45309;
}

.live-chat-waiting-estimate {
  display: block;
  margin-top: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #a16207;
}

.live-chat-welcome-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(145deg, #fdf0ef, #fce8e6);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  margin-bottom: 16px;
}

.live-chat-welcome h3 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  color: #1a2744;
  font-weight: 700;
}

.live-chat-welcome > p {
  margin: 0 0 24px;
  font-size: 0.86rem;
  line-height: 1.55;
  color: #64748b;
  max-width: 280px;
}

/* ── Start form ── */
.live-chat-start {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.live-chat-start label {
  font-size: 0.78rem;
  font-weight: 600;
  color: #344054;
  margin-top: 4px;
}

.live-chat-optional {
  font-weight: 500;
  color: #98a2b3;
}

.live-chat-start input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 12px;
  font-family: inherit;
  font-size: 0.9rem;
  background: #f8fafc;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.live-chat-start input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.12);
}

.live-chat-start-btn {
  margin-top: 8px;
  width: 100%;
  border: none;
  background: linear-gradient(145deg, var(--primary), var(--primary-d));
  color: #fff;
  border-radius: 12px;
  padding: 13px 16px;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 6px 18px rgba(192, 57, 43, 0.28);
}

.live-chat-start-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 22px rgba(192, 57, 43, 0.34);
}

/* ── Messages ── */
.live-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  background: #f1f5f9;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scroll-behavior: smooth;
}

.live-chat-messages::-webkit-scrollbar {
  width: 5px;
}

.live-chat-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 999px;
}

.live-chat-day-divider {
  align-self: center;
  font-size: 0.7rem;
  font-weight: 600;
  color: #94a3b8;
  background: #e8edf3;
  padding: 4px 12px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.live-chat-msg {
  display: flex;
  gap: 8px;
  max-width: 92%;
  animation: liveChatMsgIn 0.22s ease;
}

@keyframes liveChatMsgIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.live-chat-msg.visitor {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.live-chat-msg.admin,
.live-chat-msg.system {
  align-self: flex-start;
}

.live-chat-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  margin-top: 2px;
}

.live-chat-msg.admin .live-chat-msg-avatar,
.live-chat-msg.system .live-chat-msg-avatar {
  background: #1a2744;
  color: #fff;
}

.live-chat-msg.visitor .live-chat-msg-avatar {
  background: var(--primary);
  color: #fff;
}

.live-chat-msg-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.live-chat-msg.visitor .live-chat-msg-content {
  align-items: flex-end;
}

.live-chat-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.5;
  word-break: break-word;
}

.live-chat-msg.visitor .live-chat-bubble {
  background: linear-gradient(145deg, var(--primary), var(--primary-d));
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: 0 4px 12px rgba(192, 57, 43, 0.22);
}

.live-chat-msg.admin .live-chat-bubble {
  background: #fff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 5px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.live-chat-msg.system .live-chat-bubble {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  font-size: 0.82rem;
}

.live-chat-meta {
  font-size: 0.72rem;
  color: #94a3b8;
  padding: 0 4px;
}

.live-chat-msg.visitor .live-chat-meta {
  text-align: right;
}

/* ── Compose ── */
.live-chat-compose {
  flex-shrink: 0;
  padding: 12px 14px 10px;
  border-top: 1px solid #e8edf3;
  background: #fff;
}

.live-chat-compose-inner {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #f8fafc;
  border: 1.5px solid #e2e8f0;
  border-radius: 16px;
  padding: 6px 6px 6px 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.live-chat-compose-inner:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(192, 57, 43, 0.1);
  background: #fff;
}

.live-chat-compose textarea {
  flex: 1;
  resize: none;
  border: none;
  background: transparent;
  padding: 8px 0;
  font-family: inherit;
  font-size: 0.88rem;
  line-height: 1.45;
  max-height: 120px;
  min-height: 24px;
}

.live-chat-compose textarea:focus {
  outline: none;
}

.live-chat-send {
  width: 40px;
  height: 40px;
  border: none;
  background: linear-gradient(145deg, var(--primary), var(--primary-d));
  color: #fff;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.live-chat-send:hover {
  transform: scale(1.05);
}

.live-chat-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.live-chat-compose-hint {
  margin: 6px 4px 0;
  font-size: 0.68rem;
  color: #b0bac9;
  text-align: center;
}

.live-chat-panel.is-closed .live-chat-compose {
  display: none;
}

.live-chat-ended-banner {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 18px;
  border-radius: 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  font-size: 0.82rem;
  line-height: 1.45;
  text-align: left;
}

.live-chat-ended-banner[hidden] {
  display: none !important;
}

.live-chat-ended-banner i {
  margin-top: 2px;
  flex-shrink: 0;
}

.live-chat-closed-actions {
  flex-shrink: 0;
  padding: 16px;
  text-align: center;
  background: #f8fafc;
  border-top: 1px solid #e8edf3;
}

.live-chat-closed-actions[hidden] {
  display: none !important;
}

.live-chat-closed-actions p {
  margin: 0 0 12px;
  font-size: 0.84rem;
  color: #64748b;
}

.live-chat-new-btn {
  width: 100%;
  border: none;
  background: linear-gradient(145deg, var(--primary), var(--primary-d));
  color: #fff;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 6px 18px rgba(192, 57, 43, 0.28);
}

.live-chat-new-btn:hover {
  transform: translateY(-1px);
}

/* ── Error ── */
.live-chat-error {
  margin: 0;
  padding: 10px 16px;
  background: #fef2f2;
  color: #b42318;
  font-size: 0.8rem;
  border-bottom: 1px solid #fecaca;
  flex-shrink: 0;
}

.live-chat-error[hidden] {
  display: none !important;
}

.live-chat-backdrop {
  display: none;
}

.live-chat-sheet-handle {
  display: none;
}

/* ── Mobile base (desktop uses floating card) ── */
@media (max-width: 768px) {
  .live-chat-compose-hint {
    display: none;
  }
}
