/* ============================================================
   LiveChat Widget  —  Professional floating support chat
   ============================================================ */

:root {
  --lc-accent:       #1a56db;
  --lc-accent-dark:  #1141b3;
  --lc-accent-light: #e8efff;
  --lc-surface:      #ffffff;
  --lc-bg:           #f7f8fc;
  --lc-border:       #e2e6f0;
  --lc-text:         #1c2333;
  --lc-text-muted:   #6b7a99;
  --lc-visitor-bg:   #1a56db;
  --lc-visitor-fg:   #ffffff;
  --lc-agent-bg:     #ffffff;
  --lc-agent-fg:     #1c2333;
  --lc-shadow:       0 8px 40px rgba(0,0,0,0.14), 0 2px 10px rgba(0,0,0,0.08);
  --lc-radius:       16px;
  --lc-z:            9999;
  --lc-font:         'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Toggle Button ── */
#lc-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: var(--lc-z);
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--lc-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(26,86,219,0.45);
  transition: transform 0.2s cubic-bezier(.34,1.56,.64,1),
              background 0.15s ease,
              box-shadow 0.15s ease;
  outline: none;
}
#lc-toggle:hover {
  background: var(--lc-accent-dark);
  box-shadow: 0 6px 24px rgba(26,86,219,0.55);
  transform: scale(1.06);
}
#lc-toggle:active { transform: scale(0.96); }

#lc-toggle svg { transition: opacity 0.15s, transform 0.2s; }
#lc-toggle.open .icon-chat    { opacity: 0; transform: scale(0.6) rotate(20deg); }
#lc-toggle.open .icon-close   { opacity: 1; transform: scale(1) rotate(0deg); }
#lc-toggle .icon-close        { opacity: 0; transform: scale(0.6) rotate(-20deg); position: absolute; }

/* Unread badge */
#lc-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: #e74c3c;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--lc-font);
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid #fff;
  display: none;
}

/* ── Widget Panel ── */
#lc-widget {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: var(--lc-z);
  width: 368px;
  max-height: 580px;
  display: flex;
  flex-direction: column;
  background: var(--lc-surface);
  border-radius: var(--lc-radius);
  box-shadow: var(--lc-shadow);
  border: 1px solid var(--lc-border);
  font-family: var(--lc-font);
  transform-origin: bottom right;
  transform: scale(0.88) translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(.34,1.3,.64,1),
              opacity 0.2s ease;
  overflow: hidden;
}
#lc-widget.visible {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ── */
#lc-header {
  background: linear-gradient(135deg, #1a3a6e 0%, #1a56db 100%);
  padding: 18px 20px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#lc-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#lc-header-info { flex: 1; min-width: 0; }
#lc-header-info h4 {
  margin: 0 0 2px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
#lc-header-info p {
  margin: 0;
  font-size: 12px;
  opacity: 0.78;
  display: flex;
  align-items: center;
  gap: 5px;
}
#lc-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #2ecc71;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(46,204,113,0.3);
}
#lc-status-dot.offline { background: #95a5b6; box-shadow: none; }

/* ── Pre-chat form (shown before first message) ── */
#lc-prechat {
  padding: 20px;
  border-bottom: 1px solid var(--lc-border);
  background: var(--lc-bg);
  flex-shrink: 0;
}
#lc-prechat p {
  margin: 0 0 14px;
  font-size: 13px;
  color: var(--lc-text-muted);
  line-height: 1.5;
}
#lc-prechat input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--lc-border);
  border-radius: 8px;
  font-size: 13px;
  font-family: var(--lc-font);
  color: var(--lc-text);
  background: #fff;
  box-sizing: border-box;
  margin-bottom: 8px;
  transition: border-color 0.15s;
  outline: none;
}
#lc-prechat input:focus { border-color: var(--lc-accent); }
#lc-prechat-submit {
  width: 100%;
  padding: 9px;
  background: var(--lc-accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--lc-font);
  cursor: pointer;
  transition: background 0.15s;
}
#lc-prechat-submit:hover { background: var(--lc-accent-dark); }

/* ── Messages ── */
#lc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: var(--lc-bg);
}
#lc-messages::-webkit-scrollbar { width: 4px; }
#lc-messages::-webkit-scrollbar-track { background: transparent; }
#lc-messages::-webkit-scrollbar-thumb { background: #d0d7e8; border-radius: 4px; }

.lc-msg-group { display: flex; flex-direction: column; gap: 4px; }
.lc-msg-group.visitor { align-items: flex-end; }
.lc-msg-group.agent   { align-items: flex-start; }

.lc-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
  animation: lc-pop 0.2s cubic-bezier(.34,1.56,.64,1) both;
}
.lc-msg-group.visitor .lc-bubble {
  background: var(--lc-visitor-bg);
  color: var(--lc-visitor-fg);
  border-bottom-right-radius: 4px;
}
.lc-msg-group.agent .lc-bubble {
  background: var(--lc-agent-bg);
  color: var(--lc-agent-fg);
  border: 1px solid var(--lc-border);
  border-bottom-left-radius: 4px;
}

.lc-sender-label {
  font-size: 11px;
  color: var(--lc-text-muted);
  padding: 0 4px;
  margin-bottom: 2px;
}
.lc-timestamp {
  font-size: 10px;
  color: var(--lc-text-muted);
  padding: 0 4px;
}

/* System message */
.lc-system {
  text-align: center;
  font-size: 12px;
  color: var(--lc-text-muted);
  padding: 4px 12px;
  background: rgba(0,0,0,0.04);
  border-radius: 20px;
  align-self: center;
  max-width: 80%;
}

/* Typing indicator */
#lc-typing {
  display: none;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--lc-agent-bg);
  border: 1px solid var(--lc-border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
}
.lc-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--lc-text-muted);
  animation: lc-typing 1.2s infinite;
}
.lc-dot:nth-child(2) { animation-delay: 0.2s; }
.lc-dot:nth-child(3) { animation-delay: 0.4s; }

/* ── Input area ── */
#lc-footer {
  padding: 12px 14px;
  border-top: 1px solid var(--lc-border);
  background: var(--lc-surface);
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-shrink: 0;
}
#lc-input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 14px;
  border: 1px solid var(--lc-border);
  border-radius: 20px;
  font-size: 14px;
  font-family: var(--lc-font);
  color: var(--lc-text);
  resize: none;
  outline: none;
  overflow-y: auto;
  line-height: 1.4;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
#lc-input:focus { border-color: var(--lc-accent); }
#lc-input::placeholder { color: var(--lc-text-muted); }

#lc-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--lc-accent);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.15s;
  outline: none;
}
#lc-send:hover  { background: var(--lc-accent-dark); }
#lc-send:active { transform: scale(0.9); }
#lc-send:disabled { background: #c5cfe6; cursor: default; }

/* Connection banner */
#lc-conn-banner {
  display: none;
  background: #fff3cd;
  color: #856404;
  font-size: 12px;
  padding: 6px 16px;
  text-align: center;
  border-bottom: 1px solid #ffc107;
  flex-shrink: 0;
}

/* ── Animations ── */
@keyframes lc-pop {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}
@keyframes lc-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

/* ── Mobile ── */
@media (max-width: 480px) {
  #lc-widget {
    bottom: 0;
    right: 0;
    width: 100vw;
    max-height: 100dvh;
    border-radius: var(--lc-radius) var(--lc-radius) 0 0;
  }
  #lc-toggle { bottom: 20px; right: 20px; }
}
@media (max-width: 521px) {
  #lc-toggle {
    bottom: 95px;
  }
}
