/* Floating Button */
#wpai-chatbot-button {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 50px;
  height: 50px;
  /* border-radius: 50%; */
  border-radius: 12px;
  /* background: linear-gradient(135deg, #ff7a45, #ff5638); */
  background: white; /* disable gradient background */
  padding: 0;
  color: white;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 22px;
  cursor: pointer;
  z-index: 99999;
  box-shadow: 0 4px 10px rgba(255, 86, 56, 0.35);
  border: 1px solid rgba(255, 86, 56, 0.35);

  /* animation */
  animation: wpai-pulse 3s ease-in-out infinite;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

#wpai-chatbot-button:hover {
  animation: none;
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(255, 86, 56, 0.45);
}

#wpai-chatbot-button img {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* Chatbox Panel */
#wpai-chatbot-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  height: 650px;
  width: 400px;
  max-width: calc(100% - 48px);
  border-radius: 12px;
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.35);
  background: #fff;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  font-family: system-ui, sans-serif;

  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
  transition: all 0.35s ease;
}

#wpai-chatbot-panel.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* Header */
#wpai-chatbot-header {
  flex-shrink: 0;
  background: linear-gradient(135deg, #ff7a45, #ff5638);
  color: white;
  padding: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
  letter-spacing: 0.3px;
  z-index: 2;
}

.wpai-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.wpai-header-left img {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  object-fit: cover;
  background: white;
}

.wpai-header-info {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  line-height: 1.4;
}

.wpai-company-name {
  font-weight: 600;
  font-size: 15px;
}

.wpai-contact-item {
  cursor: pointer;
  opacity: 0.9;
  transition: opacity 0.2s;
}

.wpai-contact-item:hover {
  opacity: 1;
  text-decoration: underline;
}

#wpai-close-btn {
  background: transparent;
  border: none;
  color: white;
  font-size: 18px;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s;
}

#wpai-close-btn:hover {
  opacity: 1;
}

#wpai-chatbot-header button {
  background: transparent;
  border: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  opacity: 0.8;
  transition: opacity 0.2s;
}

#wpai-chatbot-header button:hover {
  opacity: 1;
}

#wpai-chatbot-chat {
  display: none;
  flex-direction: column;
  height: 100%;
  flex: 1;
  overflow: hidden; /* important */
}

/* Chat Area */
#wpai-chatbot-messages {
  flex: 1;
  display: flex;
  padding: 12px;
  overflow-y: auto;
  background: #f6f7f9;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: #ff5638 #f1f1f1;
}

.wpai-user-msg {
  background: #dcf8c6;
  align-self: flex-end;
  animation: fadeIn 0.3s ease;
}

.wpai-bot-msg {
  background: #fff;
  align-self: flex-start;
  animation: fadeIn 0.3s ease;
}

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

/* Input Area */
/* #wpai-chatbot-input-area {
  flex-shrink: 0;
  display: flex;
  padding: 10px;
  border-top: 1px solid #ddd;
  background: #fff;
  gap: 8px;
  align-items: flex-end;
  z-index: 2;
} */
#wpai-chatbot-input-area {
  display: none !important;
  flex-shrink: 0;
  display: flex;
  padding: 10px;
  border-top: 1px solid #eee;
  gap: 8px;
  align-items: center;
  background: #fff;
}

#wpai-chatbot-input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff; /* ✅ pure white input */
  font-size: 14px;
  resize: none; /* disable manual resize handle */
  outline: none;
  line-height: 1.4;
  min-height: 38px; /* default height */
  max-height: 100px; /* auto expand up to this */
  overflow-y: auto;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
  transition: border-color 0.2s, box-shadow 0.2s;
  height: 38px;
}

#wpai-chatbot-input:focus {
  border-color: #ff5638;
  box-shadow: 0 0 0 2px rgba(255, 86, 56, 0.2);
}

/* #wpai-chatbot-send {
  background: linear-gradient(135deg, #ff7a45, #ff5638);
  border: none;
  color: white;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 38px; // match input height 
  font-size: 18px;
  transition: all 0.25s ease;
} */

/* #wpai-chatbot-send:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(255, 86, 56, 0.4);
} */

#wpai-chatbot-send {
  background: #ff5638;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  transition: transform 0.2s ease;
  box-shadow: 0 4px 10px rgba(255, 86, 56, 0.3);
  border-radius: 12px;
}

#wpai-chatbot-send:hover {
  background: #ff734f;
  transform: scale(1.1);
  box-shadow: 0 6px 14px rgba(255, 86, 56, 0.45);
}

#wpai-chatbot-send img {
  width: 32px;
  height: 32px;
  /* filter: invert(42%) sepia(100%) saturate(600%) hue-rotate(-5deg); */
  filter: brightness(0) invert(1);
}

/* Chat bubbles */
#wpai-chatbot-messages div {
  font-size: 14px;
}

#wpai-chatbot-messages div.user {
  background: #ffe4dc;
  align-self: flex-end;
  color: #333;
}

#wpai-chatbot-messages div.bot {
  background: #fff;
  align-self: flex-start;
  color: #333;
}

/* .wpai-suggestion {
  background: linear-gradient(45deg, #ff5638, #ff7f50);
  color: white;
  border: none;
  border-radius: 20px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: transform 0.2s, opacity 0.2s;
} */

/* .wpai-suggestion:hover {
  transform: scale(1.05);
  color: white;
} */

/* suggestions (buttons) */
.wpai-suggestion {
  background: linear-gradient(45deg, #ff5638, #ff7f50);
  color: white;
  border: none;
  border-radius: 20px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  transition: transform 0.14s ease;
}
.wpai-suggestion:hover {
  transform: translateY(-2px);
  color: white;
}

/* Lead Form */
#wpai-chatbot-leadform input,
select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
#wpai-chatbot-leadform input:focus {
  border-color: #ff5638;
  box-shadow: 0 0 0 2px rgba(255, 86, 56, 0.2);
}

#wpai-start-chat {
  background: linear-gradient(135deg, #ff7a45, #ff5638);
  color: white;
  border: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
#wpai-start-chat:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 8px rgba(255, 86, 56, 0.4);
}

/* Stop animation when chat panel is active */
#wpai-chatbot-panel.active + #wpai-chatbot-button,
#wpai-chatbot-button.active {
  animation: none;
  transform: scale(1);
  box-shadow: none;
}

@keyframes wpai-glow {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(255, 86, 56, 0);
  }
  50% {
    box-shadow: 0 0 18px rgba(255, 86, 56, 0.6);
  }
}

@keyframes wpai-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

@keyframes wpai-pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(255, 86, 56, 0);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 0 24px rgba(255, 86, 56, 0.4);
  }
}

.wpai-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
}

.wpai-error {
  font-size: 12px;
  color: #ff5638;
  height: 14px;
  margin-left: 4px;
  font-weight: 500;
}

.wpai-messages {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  overflow-y: auto;
}

/* row */
.wpai-msg-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
/* bot on left, user on right */
.wpai-msg-row.bot-row {
  justify-content: flex-start;
}
.wpai-msg-row.user-row {
  justify-content: flex-end;
}

/* avatar wrap */
.wpai-avatar-wrap {
  width: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* avatar image */
.wpai-avatar {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  display: block;
  border: 1px solid rgba(0, 0, 0, 0.06);
}

/* user avatar (text circle) */
.wpai-avatar-user {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #f0f0f0;
  color: #333;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
}

/* bubble wrapper (bubble + meta timestamp) */
.wpai-bubble-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 76%;
}

/* bubble base */
.wpai-bubble {
  padding: 10px 12px;
  border-radius: 12px;
  line-height: 1.4;
  word-break: break-word;
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

/* bot bubble (brand color outline / accent) */
.bot-bubble {
  background: #fff;
  border-left: 2px solid #ff5638;
  color: #222;
}

/* user bubble (green-ish) */
.user-bubble {
  background: #ffece6; /* pale orange/peach to keep brand tone */
  color: #222;
  align-self: flex-end;
}

/* meta (timestamp) */
.wpai-meta {
  font-size: 11px;
  color: #888;
  align-self: flex-start;
}

/* ensure user meta aligns right */
.wpai-msg-row.user-row .wpai-meta {
  align-self: flex-end;
}

/* thinking dots */
.wpai-thinking-dots {
  display: inline-flex;
  gap: 4px;
  font-weight: 700;
  color: #ff5638;
  font-size: 18px;
  height: 22px;
  align-items: center;
}
.wpai-thinking-dots .dot {
  opacity: 0.2;
  animation: wpai-dot 1.2s infinite;
}
.wpai-thinking-dots .dot:nth-child(2) {
  animation-delay: 0.15s;
}
.wpai-thinking-dots .dot:nth-child(3) {
  animation-delay: 0.3s;
}

.wpai-subservice-item:hover {
  background: #f9fbff;
  border-color: #007bff;
}
.wpai-subservice-item input:checked + span {
  background: #007bff;
  color: white;
}

@keyframes wpai-dot {
  0% {
    opacity: 0.2;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-4px);
  }
  100% {
    opacity: 0.2;
    transform: translateY(0);
  }
}

/* message content small animation */
.wpai-bubble .wpai-msg-content {
  display: inline-block;
}

/* small adjustments to existing bubble look */
.user-bubble {
  border-radius: 14px;
}
.bot-bubble {
  border-radius: 12px;
}

.wpai-bot-suggestions {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}

/* small responsive tweak */
@media (max-width: 420px) {
  .wpai-bubble-wrap {
    max-width: 70%;
  }
  .wpai-avatar,
  .wpai-avatar-user {
    width: 34px;
    height: 34px;
  }
}

@media (max-width: 600px) {
  #wpai-chatbot-panel {
    width: 100% !important;
    height: 100% !important;
    bottom: 0 !important;
    right: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    max-height: none !important;
    max-width: none !important;
  }

  #wpai-chatbot-header {
    padding: 12px !important;
  }

  #wpai-chatbot-header .wpai-company-name {
    font-size: 16px !important;
  }

  #wpai-chatbot-header .wpai-contact-item {
    font-size: 12px !important;
  }

  #wpai-chatbot-input-area {
    padding: 8px !important;
    gap: 6px !important;
  }

  #wpai-chatbot-input {
    font-size: 14px !important;
    padding: 8px 10px !important;
  }

  #wpai-chatbot-send img {
    width: 20px !important;
    height: 20px !important;
  }

  #wpai-chatbot-messages {
    padding: 10px !important;
    font-size: 14px !important;
  }

  .wpai-bubble {
    font-size: 12px !important;
    padding: 8px 10px !important;
  }

  .wpai-avatar {
    width: 28px !important;
    height: 28px !important;
  }

  /* Floating button should be smaller on mobile */
  #wpai-chatbot-button img {
    width: 44px !important;
    height: 44px !important;
    border-radius: 10px !important;
  }
}
