/**
 * Roberts Pest Control - Chat Widget Styles v5 (20260223c)
 * Theme-matched: black bg, #39FF14 primary, #50FF38 hover accent
 * Buttons: white icons, black borders
 */

/* Container */
#rpc-chat-widget {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 99999;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

/* ── CSS Isolation — prevent Elementor/theme/lightbox from overriding ── */
#rpc-chat-widget button,
#rpc-chat-widget [role="button"] {
  all: unset;
  box-sizing: border-box;
  cursor: pointer;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

#rpc-chat-widget * {
  opacity: 1;
  visibility: visible;
}


/* ── Chat Bubble ─────────────────────────────────────────── */
#rpc-chat-bubble {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: #39FF14;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(57, 255, 20, 0.45), 0 2px 8px rgba(0,0,0,0.3);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
  border: 2px solid #000000;
}

#rpc-chat-bubble svg {
  width: 45px;
  height: 45px;
}

#rpc-chat-bubble svg path {
  fill: #000000 !important;
  stroke: #000000;
  stroke-width: 0.5px;
}

#rpc-chat-bubble:hover {
  transform: scale(1.12);
  background: #50FF38;
  box-shadow: 0 6px 28px rgba(57, 255, 20, 0.6), 0 4px 12px rgba(0,0,0,0.4);
}

#rpc-chat-bubble.rpc-hidden {
  display: none;
}

#rpc-chat-bubble.rpc-pulse {
  animation: rpc-pulse-ring 2s ease-out 1;
}

@keyframes rpc-pulse-ring {
  0%   { box-shadow: 0 4px 20px rgba(57,255,20,0.35), 0 0 0 0 rgba(57,255,20,0.6); }
  50%  { box-shadow: 0 4px 20px rgba(57,255,20,0.35), 0 0 0 20px rgba(57,255,20,0); }
  100% { box-shadow: 0 4px 20px rgba(57,255,20,0.35), 0 0 0 0 rgba(57,255,20,0); }
}

#rpc-bubble-text {
  position: absolute;
  right: 124px;
  background: #39FF14;
  color: #000000;
  padding: 8px 16px;
  border-radius: 8px;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  animation: rpc-fade-in 0.5s ease-in-out 2s both;
  pointer-events: none;
  border: 2px solid #000000;
}

#rpc-bubble-text::after {
  content: '';
  position: absolute;
  right: -7px;
  top: 50%;
  transform: translateY(-50%);
  border-left: 7px solid #39FF14;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
}

@keyframes rpc-fade-in {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Proactive Teaser Popup ─────────────────────────────── */
#rpc-chat-teaser {
  position: absolute;
  bottom: 125px;
  right: 0;
  width: 280px;
  background: #121212;
  border: 1px solid #39FF14;
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5), 0 0 15px rgba(57, 255, 20, 0.15);
  animation: rpc-teaser-in 0.4s ease-out;
  cursor: pointer;
  color: #fdfdfd;
  font-size: 14px;
  line-height: 1.5;
  z-index: 1;
}

#rpc-chat-teaser::after {
  content: '';
  position: absolute;
  bottom: -8px;
  right: 40px;
  width: 14px;
  height: 14px;
  background: #121212;
  border-right: 1px solid #39FF14;
  border-bottom: 1px solid #39FF14;
  transform: rotate(45deg);
}

#rpc-chat-teaser strong {
  color: #39FF14;
  font-size: 15px;
}

#rpc-teaser-content {
  cursor: pointer;
}

#rpc-teaser-close {
  position: absolute;
  top: 6px;
  right: 10px;
  background: none;
  border: none;
  color: #666;
  font-size: 18px;
  cursor: pointer;
  padding: 2px 6px;
  line-height: 1;
  transition: color 0.2s;
}

#rpc-teaser-close:hover {
  color: #39FF14;
}

@keyframes rpc-teaser-in {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Chat Window ─────────────────────────────────────────── */
#rpc-chat-window {
  width: 420px;
  height: 620px;
  background: #000000;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(57, 255, 20, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: rpc-slide-up 0.3s ease-out;
}

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

/* ── Header ──────────────────────────────────────────────── */
#rpc-chat-header {
  background: #121212;
  color: #fdfdfd;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  border-bottom: 2px solid #39FF14;
}

#rpc-chat-header-info {
  display: flex;
  flex-direction: column;
}

#rpc-chat-logo {
  max-height: 36px;
  width: auto;
  display: block;
}

#rpc-chat-header-info strong {
  font-size: 16px;
  letter-spacing: 0.3px;
  color: #ffffff;
}

#rpc-chat-status {
  font-size: 12px;
  color: #39FF14;
  text-shadow: 0 0 2px #000000, 0 0 2px #000000;
}

#rpc-chat-status::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #39FF14;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
  box-shadow: 0 0 6px #39FF14;
}

#rpc-chat-close {
  background: none;
  border: none;
  color: #fdfdfd;
  font-size: 28px;
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
  opacity: 0.8;
  transition: opacity 0.2s, color 0.2s;
}

#rpc-chat-close:hover {
  opacity: 1;
  color: #39FF14;
}

/* ── Messages Area ───────────────────────────────────────── */
#rpc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #000000;
  -webkit-overflow-scrolling: touch;
}

#rpc-chat-messages::-webkit-scrollbar {
  width: 5px;
}

#rpc-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(57, 255, 20, 0.2);
  border-radius: 3px;
}

#rpc-chat-messages.rpc-drag-over {
  background: rgba(57, 255, 20, 0.05);
  outline: 2px dashed #39FF14;
  outline-offset: -4px;
}

/* ── Message Bubbles ─────────────────────────────────────── */
.rpc-message {
  display: flex;
  max-width: 85%;
}

.rpc-message-user {
  align-self: flex-end;
}

.rpc-message-assistant {
  align-self: flex-start;
}

.rpc-bubble {
  padding: 12px 16px;
  border-radius: 18px;
  word-wrap: break-word;
  overflow-wrap: break-word;
  font-size: 14px;
  line-height: 1.5;
}

.rpc-message-user .rpc-bubble {
  background: #39FF14;
  color: #000000;
  font-weight: 500;
  border: 2px solid #000000;
  border-bottom-right-radius: 4px;
}

.rpc-message-assistant .rpc-bubble {
  background: #1a1a1a;
  color: #ffffff;
  border-bottom-left-radius: 4px;
  border: 2px solid #000000;
  text-shadow: 0 0 1px rgba(0,0,0,0.3);
}

/* Image/video in messages */
.rpc-chat-image {
  max-width: 240px;
  max-height: 200px;
  border-radius: 10px;
  display: block;
  margin-bottom: 6px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.rpc-chat-image:hover {
  opacity: 0.85;
}

.rpc-chat-video {
  max-width: 260px;
  max-height: 200px;
  border-radius: 10px;
  display: block;
  margin-bottom: 6px;
  background: #000;
}

/* ── Typing Indicator ────────────────────────────────────── */
.rpc-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 14px 18px !important;
}

.rpc-typing span {
  width: 7px;
  height: 7px;
  background: #39FF14;
  border-radius: 50%;
  animation: rpc-bounce 1.2s infinite;
}

.rpc-typing span:nth-child(2) { animation-delay: 0.2s; }
.rpc-typing span:nth-child(3) { animation-delay: 0.4s; }

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

/* ── Quick Suggestions ───────────────────────────────────── */
#rpc-chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 18px 10px;
  flex-shrink: 0;
}

.rpc-suggestion {
  background: transparent;
  border: 2px solid #39FF14;
  color: #39FF14;
  padding: 6px 14px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
  text-shadow: 0 0 2px #000000, 0 0 2px #000000;
  box-shadow: 0 0 0 1px #000000;
}

.rpc-suggestion:hover {
  background: rgba(57, 255, 20, 0.12);
  border-color: #39FF14;
}

/* ── Lead / Appointment Form ─────────────────────────────── */
#rpc-lead-form {
  padding: 14px 18px;
  border-top: 1px solid #222;
  flex-shrink: 0;
  max-height: 340px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#rpc-lead-form-inner p {
  color: #fdfdfd;
  margin: 0 0 12px 0;
  font-size: 14px;
}

#rpc-lead-form input,
#rpc-lead-form textarea,
#rpc-lead-form select {
  width: 100%;
  padding: 10px 12px;
  margin-bottom: 8px;
  background: #121212;
  border: 1px solid #333;
  border-radius: 8px;
  color: #fdfdfd;
  font-size: 14px;
  font-family: inherit;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.2s;
}

#rpc-lead-form select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2339FF14' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}

#rpc-lead-form input[type="date"] {
  color-scheme: dark;
}

#rpc-lead-form input:focus,
#rpc-lead-form textarea:focus,
#rpc-lead-form select:focus {
  outline: none;
  border-color: #39FF14;
  box-shadow: 0 0 0 2px rgba(57, 255, 20, 0.1);
}

#rpc-lead-form input::placeholder,
#rpc-lead-form textarea::placeholder {
  color: #666;
}

#rpc-lead-submit {
  width: 100%;
  padding: 12px;
  background: #121212;
  color: #39FF14;
  border: 2px solid #39FF14;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 700;
  margin-top: 6px;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

#rpc-lead-submit:hover {
  background: rgba(57, 255, 20, 0.1);
  box-shadow: 0 0 16px rgba(57, 255, 20, 0.2);
}

#rpc-lead-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.rpc-btn-secondary {
  width: 100%;
  padding: 10px;
  background: transparent;
  color: #888;
  border: 1px solid #333;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  margin-top: 6px;
  transition: all 0.2s;
}

.rpc-btn-secondary:hover {
  color: #fdfdfd;
  border-color: #555;
}

/* Attachment items */
.rpc-attachment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  margin-bottom: 4px;
  background: #121212;
  border-radius: 6px;
}

.rpc-attachment-thumb {
  width: 36px;
  height: 36px;
  object-fit: cover;
  border-radius: 6px;
}

.rpc-attachment-name {
  flex: 1;
  font-size: 12px;
  color: #aaa;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rpc-attachment-remove {
  background: none;
  border: none;
  color: #666;
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
  line-height: 1;
}

.rpc-attachment-remove:hover {
  color: #f44;
}

/* ── Input Area ──────────────────────────────────────────── */
#rpc-chat-input-area {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-top: 1px solid #222;
  gap: 10px;
  flex-shrink: 0;
  background: #000000;
}

/* ATTACH BUTTON — white icon, black border */
#rpc-attach-btn {
  width: 46px;
  height: 46px;
  min-width: 46px;
  border-radius: 50%;
  background: #121212;
  border: 2px solid #000000;
  outline: 1px solid #444;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
}

#rpc-attach-btn svg {
  width: 22px;
  height: 22px;
  display: block;
}

#rpc-attach-btn svg path {
  fill: #ffffff !important;
}

#rpc-attach-btn:hover {
  outline-color: #39FF14;
  background: rgba(57, 255, 20, 0.08);
}

#rpc-attach-btn:hover svg path {
  fill: #39FF14;
}

/* TEXT INPUT */
#rpc-chat-input {
  flex: 1;
  padding: 10px 16px;
  background: #121212;
  border: 1px solid #333;
  border-radius: 24px;
  color: #fdfdfd;
  font-size: 15px;
  font-family: inherit;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
  transition: border-color 0.2s;
}

#rpc-chat-input:focus {
  outline: none;
  border-color: #39FF14;
  box-shadow: 0 0 0 2px rgba(57, 255, 20, 0.1);
}

#rpc-chat-input::placeholder {
  color: #666;
}

/* SEND BUTTON — white icon, black border, green glow */
#rpc-chat-send {
  width: 46px;
  height: 46px;
  min-width: 46px;
  border-radius: 50%;
  background: #50FF38;
  border: 2px solid #000000;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: 0 2px 12px rgba(158, 255, 0, 0.3);
}

#rpc-chat-send svg {
  width: 22px;
  height: 22px;
  display: block;
}

#rpc-chat-send svg path {
  fill: #ffffff !important;
  stroke: #000000;
  stroke-width: 1px;
}

#rpc-chat-send:hover {
  background: #39FF14;
  box-shadow: 0 4px 20px rgba(57, 255, 20, 0.5);
  transform: scale(1.08);
}

/* Upload preview */
#rpc-upload-preview {
  display: none;
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 480px) {
  #rpc-chat-widget {
    bottom: 0;
    right: 0;
    left: 0;
  }

  #rpc-chat-window {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    position: fixed;
    top: 0;
    left: 0;
  }

  #rpc-chat-bubble {
    bottom: 20px;
    right: 20px;
    position: fixed;
  }

  #rpc-bubble-text {
    display: none;
  }

  #rpc-chat-teaser {
    right: 10px;
    bottom: 135px;
    width: 250px;
    font-size: 13px;
  }

  #rpc-chat-input {
    font-size: 16px;
    padding: 12px 16px;
  }

  #rpc-lead-form input,
  #rpc-lead-form textarea,
  #rpc-lead-form select {
    font-size: 16px;
    padding: 12px 14px;
  }

  #rpc-attach-btn,
  #rpc-chat-send {
    width: 50px;
    height: 50px;
    min-width: 50px;
  }

  #rpc-attach-btn svg,
  #rpc-chat-send svg {
    width: 24px;
    height: 24px;
  }

  .rpc-suggestion {
    padding: 8px 16px;
    font-size: 14px;
  }

  .rpc-chat-image {
    max-width: 200px;
    max-height: 160px;
  }

  .rpc-chat-video {
    max-width: 220px;
  }
}

/* Tablet */
@media (min-width: 481px) and (max-width: 768px) {
  #rpc-chat-window {
    width: 400px;
    height: 560px;
  }
}

/* ── Accessibility ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #rpc-chat-window,
  #rpc-bubble-text,
  .rpc-typing span,
  #rpc-chat-bubble.rpc-pulse {
    animation: none;
  }

  #rpc-chat-bubble,
  #rpc-chat-send {
    transition: none;
  }
}

#rpc-chat-bubble:focus-visible,
#rpc-chat-close:focus-visible,
#rpc-chat-send:focus-visible,
#rpc-attach-btn:focus-visible,
.rpc-suggestion:focus-visible {
  outline: 2px solid #39FF14;
  outline-offset: 2px;
}
