/* ===== LOUDBABY CHAT WIDGET ===== */
:root {
  --lb-primary: #2d3436;
  --lb-accent: #5cc2df;
  --lb-bg: #ffffff;
  --lb-bg-chat: #f8f9fa;
  --lb-text: #2d3436;
  --lb-text-light: #636e72;
  --lb-border: #e0e0e0;
  --lb-user-bubble: #2d3436;
  --lb-ai-bubble: #ffffff;
  --lb-shadow: 0 8px 32px rgba(0,0,0,0.15);
  --lb-radius: 16px;
  --lb-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Floating trigger button */
.lb-trigger {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--lb-primary);
  border: none;
  cursor: pointer;
  box-shadow: var(--lb-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, background 0.2s;
  z-index: 99998;
}
.lb-trigger:hover {
  transform: scale(1.08);
  background: linear-gradient(to right, #1a1a2e 0%, var(--lb-primary) 30%, var(--lb-accent) 100%);
}
.lb-trigger svg {
  width: 28px;
  height: 28px;
  fill: white;
}
.lb-trigger.active .lb-icon-chat { display: none; }
.lb-trigger.active .lb-trigger-gif { display: none; }
.lb-trigger:not(.active) .lb-icon-close { display: none; }

/* Custom trigger icon (GIF/image) */
.lb-trigger-custom {
  background: transparent;
  box-shadow: none;
  padding: 0;
  overflow: hidden;
}
.lb-trigger-custom:hover {
  background: transparent;
  transform: scale(1.12);
}
.lb-trigger-custom .lb-trigger-gif {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}
.lb-trigger-custom.active {
  background: var(--lb-primary);
  box-shadow: var(--lb-shadow);
}
.lb-trigger-custom.active:hover {
  background: linear-gradient(to right, #1a1a2e 0%, var(--lb-primary) 30%, var(--lb-accent) 100%);
}

/* Chat panel */
.lb-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 560px;
  max-height: calc(100vh - 140px);
  background: var(--lb-bg);
  border-radius: var(--lb-radius);
  box-shadow: var(--lb-shadow);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  font-family: var(--lb-font);
  animation: lb-slide-up 0.25s ease-out;
}
.lb-panel.open { display: flex; }

@keyframes lb-slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Header */
.lb-header {
  background: linear-gradient(to right, #1a1a2e 0%, var(--lb-primary) 30%, var(--lb-accent) 100%);
  color: white;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.lb-header-logo {
  display: flex;
  align-items: center;
}
.lb-header-logo img,
.lb-header-logo svg {
  height: 24px;
  width: auto;
}

/* Mute/unmute buttons */
.lb-mute-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, opacity 0.2s;
  color: white;
  opacity: 0.7;
}
.lb-mute-btn:hover {
  opacity: 1;
  background: rgba(255,255,255,0.15);
}
.lb-mute-btn.muted {
  opacity: 1;
  color: #e74c3c;
}
.lb-mute-input {
  color: var(--lb-text-light);
  opacity: 1;
}
.lb-mute-input:hover {
  background: var(--lb-bg-chat);
}
.lb-mute-input.muted {
  color: #e74c3c;
}

/* Messages area */
.lb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: var(--lb-bg-chat);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.lb-messages::-webkit-scrollbar { width: 4px; }
.lb-messages::-webkit-scrollbar-track { background: transparent; }
.lb-messages::-webkit-scrollbar-thumb { background: var(--lb-border); border-radius: 4px; }

/* Message bubbles */
.lb-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
}
.lb-msg.ai {
  align-self: flex-start;
  background: var(--lb-ai-bubble);
  color: var(--lb-text);
  border: 1px solid var(--lb-border);
  border-bottom-left-radius: 4px;
}
.lb-msg.user {
  align-self: flex-end;
  background: var(--lb-user-bubble);
  color: white;
  border-bottom-right-radius: 4px;
}

/* Typing indicator */
.lb-typing {
  align-self: flex-start;
  display: none;
  gap: 4px;
  padding: 12px 16px;
  background: var(--lb-ai-bubble);
  border: 1px solid var(--lb-border);
  border-radius: 12px;
  border-bottom-left-radius: 4px;
}
.lb-typing.show { display: flex; }
.lb-typing span {
  width: 6px;
  height: 6px;
  background: var(--lb-text-light);
  border-radius: 50%;
  animation: lb-bounce 1.2s infinite;
}
.lb-typing span:nth-child(2) { animation-delay: 0.2s; }
.lb-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes lb-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* Welcome state */
.lb-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 32px 24px;
  gap: 16px;
}
.lb-welcome h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--lb-text);
}
.lb-welcome p {
  font-size: 14px;
  color: var(--lb-text-light);
  line-height: 1.5;
}

/* Voice call button */
.lb-call-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  max-width: 240px;
  padding: 14px 24px;
  background: var(--lb-primary);
  color: white;
  border: none;
  border-radius: 40px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  font-family: var(--lb-font);
}
.lb-call-btn:hover { background: var(--lb-accent); }
.lb-call-btn:active { transform: scale(0.97); }
.lb-call-btn.active-call { background: #e74c3c; }
.lb-call-btn.active-call:hover { background: #c0392b; }
.lb-call-btn svg { width: 18px; height: 18px; fill: currentColor; }

/* Or divider */
.lb-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 240px;
  color: var(--lb-text-light);
  font-size: 12px;
}
.lb-divider::before,
.lb-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--lb-border);
}

/* Input area */
.lb-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--lb-border);
  background: white;
  flex-shrink: 0;
}
.lb-input {
  flex: 1;
  border: 1px solid var(--lb-border);
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: var(--lb-font);
  outline: none;
  transition: border-color 0.2s;
  color: var(--lb-text);
}
.lb-input:focus { border-color: var(--lb-accent); }
.lb-input::placeholder { color: #b2bec3; }

.lb-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--lb-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}
.lb-send-btn:hover { background: var(--lb-accent); }
.lb-send-btn:disabled { opacity: 0.4; cursor: default; }
.lb-send-btn:disabled:hover { background: var(--lb-primary); }
.lb-send-btn svg { width: 16px; height: 16px; fill: white; }

/* Voice active state */
.lb-voice-indicator {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 16px;
  background: linear-gradient(to right, #1a1a2e 0%, var(--lb-primary) 30%, var(--lb-accent) 100%);
  color: white;
  font-size: 13px;
}
.lb-voice-indicator.show { display: flex; }
.lb-voice-bars {
  display: flex;
  gap: 2px;
  align-items: center;
  height: 16px;
}
.lb-voice-bars span {
  width: 3px;
  background: var(--lb-accent);
  border-radius: 2px;
  animation: lb-bar 0.8s ease-in-out infinite;
}
.lb-voice-bars span:nth-child(1) { height: 6px; animation-delay: 0s; }
.lb-voice-bars span:nth-child(2) { height: 12px; animation-delay: 0.15s; }
.lb-voice-bars span:nth-child(3) { height: 8px; animation-delay: 0.3s; }
.lb-voice-bars span:nth-child(4) { height: 14px; animation-delay: 0.45s; }
.lb-voice-bars span:nth-child(5) { height: 6px; animation-delay: 0.6s; }

@keyframes lb-bar {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(1.8); }
}

/* Close button in header (mobile) */
.lb-close-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, opacity 0.2s;
  color: white;
  opacity: 0.7;
  margin-left: 8px;
}
.lb-close-btn:hover {
  opacity: 1;
  background: rgba(255,255,255,0.15);
}

/* Responsive - mobile panel */
@media (max-width: 480px) {
  .lb-panel {
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    border-radius: 0;
    z-index: 999999 !important;
    position: fixed !important;
    animation: lb-fade-in 0.2s ease-out;
  }
  .lb-trigger { bottom: 16px; right: 16px; z-index: 999998 !important; }
  .lb-close-btn { display: flex; }
  .lb-header {
    padding: 12px 16px;
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    min-height: 48px;
  }
  .lb-messages {
    padding: 12px;
    flex: 1;
    min-height: 0;
  }
  .lb-input-area {
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
}

@keyframes lb-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
