/* LiveChat WP - Widget Styles */
#lcwp-widget-root * {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Launcher bubble */
#lcwp-launcher {
  position: fixed;
  bottom: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--lcwp-color, #1a7f64);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  z-index: 99999;
  transition: transform 0.2s, box-shadow 0.2s;
}
#lcwp-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0,0,0,0.28);
}
#lcwp-launcher.lcwp-right { right: 24px; }
#lcwp-launcher.lcwp-left  { left: 24px; }
#lcwp-launcher svg { transition: transform 0.3s; }
#lcwp-launcher.open svg { transform: rotate(45deg); }

#lcwp-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e74c3c;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
#lcwp-unread-badge.visible { display: flex; }

/* Chat window */
#lcwp-window {
  position: fixed;
  bottom: 96px;
  width: 360px;
  height: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  z-index: 99998;
  overflow: hidden;
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s;
}
#lcwp-window.lcwp-right { right: 24px; }
#lcwp-window.lcwp-left  { left: 24px; }
#lcwp-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Header */
#lcwp-header {
  padding: 16px 18px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.lcwp-agent-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  flex-shrink: 0;
  overflow: hidden;
}
.lcwp-agent-avatar img { width: 100%; height: 100%; object-fit: cover; }
.lcwp-header-text { flex: 1; }
.lcwp-header-text h4 { margin: 0; font-size: 15px; font-weight: 600; }
.lcwp-header-text p  { margin: 2px 0 0; font-size: 12px; opacity: 0.85; display: flex; align-items: center; gap: 5px; }
.lcwp-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #4ade80;
  display: inline-block;
}
.lcwp-status-dot.offline { background: #fbbf24; }

#lcwp-close-btn {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.8); padding: 4px; border-radius: 4px;
  line-height: 1;
}
#lcwp-close-btn:hover { color: #fff; background: rgba(255,255,255,0.15); }

/* Pre-chat form */
#lcwp-prechat {
  flex: 1;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}
#lcwp-prechat h5 {
  margin: 0 0 4px;
  font-size: 15px;
  color: #1a1a1a;
}
#lcwp-prechat p { margin: 0 0 12px; color: #666; font-size: 13px; line-height: 1.5; }
.lcwp-form-field { display: flex; flex-direction: column; gap: 5px; }
.lcwp-form-field label { font-size: 12px; font-weight: 600; color: #444; }
.lcwp-form-field input,
.lcwp-form-field textarea {
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}
.lcwp-form-field input:focus,
.lcwp-form-field textarea:focus { border-color: var(--lcwp-color, #1a7f64); }

.lcwp-start-btn {
  margin-top: 4px;
  padding: 11px;
  background: var(--lcwp-color, #1a7f64);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.lcwp-start-btn:hover { opacity: 0.88; }
.lcwp-start-btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* Messages */
#lcwp-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8f9fa;
}
#lcwp-messages::-webkit-scrollbar { width: 4px; }
#lcwp-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

.lcwp-msg-row { display: flex; gap: 8px; max-width: 85%; }
.lcwp-msg-row.visitor { align-self: flex-end; flex-direction: row-reverse; }
.lcwp-msg-row.agent { align-self: flex-start; }

.lcwp-msg-bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}
.lcwp-msg-row.agent .lcwp-msg-bubble {
  background: #fff;
  color: #1a1a1a;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.lcwp-msg-row.visitor .lcwp-msg-bubble {
  background: var(--lcwp-color, #1a7f64);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.lcwp-msg-time {
  font-size: 10px;
  color: #aaa;
  margin-top: 3px;
  text-align: right;
}
.lcwp-msg-row.agent .lcwp-msg-time { text-align: left; }

.lcwp-msg-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: #e5e7eb;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; color: #666;
  flex-shrink: 0; align-self: flex-end; overflow: hidden;
}
.lcwp-msg-avatar img { width: 100%; height: 100%; object-fit: cover; }

.lcwp-typing-indicator {
  display: flex; align-items: center; gap: 4px;
  padding: 9px 13px;
  background: #fff;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  align-self: flex-start;
}
.lcwp-typing-dot {
  width: 6px; height: 6px;
  background: #aaa; border-radius: 50%;
  animation: lcwp-bounce 1.2s infinite;
}
.lcwp-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.lcwp-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes lcwp-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-5px); }
}

/* Chat closed banner */
.lcwp-chat-closed {
  text-align: center;
  padding: 12px;
  background: #f1f5f9;
  border-radius: 8px;
  font-size: 12px;
  color: #666;
  margin: 8px 0;
}

/* Input area */
#lcwp-input-area {
  padding: 12px 14px;
  border-top: 1px solid #eee;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: #fff;
  flex-shrink: 0;
}
#lcwp-message-input {
  flex: 1;
  border: 1px solid #e0e0e0;
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 14px;
  outline: none;
  resize: none;
  max-height: 100px;
  font-family: inherit;
  line-height: 1.4;
  transition: border-color 0.2s;
}
#lcwp-message-input:focus { border-color: var(--lcwp-color, #1a7f64); }
#lcwp-send-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--lcwp-color, #1a7f64);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s;
}
#lcwp-send-btn:hover { opacity: 0.85; }
#lcwp-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Powered by */
.lcwp-powered {
  text-align: center;
  padding: 6px;
  font-size: 10px;
  color: #ccc;
  border-top: 1px solid #f0f0f0;
  background: #fff;
}

/* End chat */
#lcwp-end-chat-wrap {
  padding: 8px 14px 0;
  text-align: right;
}
#lcwp-end-chat {
  background: none; border: none; cursor: pointer;
  font-size: 11px; color: #aaa; text-decoration: underline;
}
#lcwp-end-chat:hover { color: #666; }

/* Mobile */
@media (max-width: 420px) {
  #lcwp-window {
    width: 100vw;
    height: 100vh;
    bottom: 0;
    right: 0 !important;
    left: 0 !important;
    border-radius: 0;
  }
}
