/* ==============================
   R A F A Y   C H A T   W I D G E T (v2.4)
   Sleek • Modern • Professional — Final Build
   Author: Rafay | Updated: Nov 2025
============================== */

:root {
  --rafay-accent: #b57b3d; /* Header/brand color */
  --rafay-bg: #ffffff;
  --rafay-text: #1e1e1e;
  --rafay-width: 360px;
  --rafay-button: var(--rafay-accent);
}

/* Reset & Button Normalization */
button,
input,
select,
textarea {
  -webkit-appearance: none !important;
  appearance: none !important;
  outline: none !important;
  box-shadow: none !important;
  border-radius: 0;
  font-family: inherit;
  background: none;
}
button:focus,
button:active,
button:focus-visible {
  outline: none !important;
  box-shadow: none !important;
}

/* ---------------- HEADER ---------------- */
.rafay_final_header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--rafay-accent);
  color: #fff;
}

.rafay_final_header_logo {
  height: 38px;
  width: auto;
  border-radius: 6px;
  object-fit: contain;
}

.rafay_final_header_title {
  font-weight: 600;
  font-size: 15px;
  color: #fff;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* --- Close Button --- */
.rafay_final_close {
  margin-left: auto;
  background: transparent;
  border: none;
  color: #fff;
  font-size: 18px;
  padding: 4px 8px;
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.25s ease;
}
.rafay_final_close:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ---------------- WIDGET ICON ---------------- */
.rafay_final_toggle,
.rafay_final_widget_avatar {
  position: fixed;
  bottom: 18px;
  right: 18px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  border: none;
  background: var(--rafay-accent);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 99999;
}
.rafay_final_toggle:hover,
.rafay_final_widget_avatar:hover {
  transform: scale(1.08);
}

/* Hide avatar when chat is open */
.rafay_final_container.rafay_open ~ .rafay_final_widget_avatar {
  opacity: 0;
  visibility: hidden;
  transform: scale(0.9);
  pointer-events: none;
}

/* ---------------- CONTAINER ---------------- */
.rafay_final_container {
  position: fixed;
  bottom: 86px;
  right: 18px;
  width: var(--rafay-width);
  max-width: calc(100% - 40px);
  background: var(--rafay-bg);
  color: var(--rafay-text);
  border-radius: 14px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.18);
  transform: translateY(16px);
  opacity: 0;
  transition: all 0.35s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  visibility: hidden;
  z-index: 99998;
}
.rafay_final_container.rafay_open {
  transform: translateY(0);
  opacity: 1;
  visibility: visible;
}

/* ---------------- MESSAGES ---------------- */
.rafay_final_body {
  padding: 12px;
}
.rafay_final_messages {
  height: 420px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* Chat Bubbles */
.rafay_final_msg {
  clear: both;
  padding: 10px 14px;
  margin: 8px 0;
  border-radius: 18px;
  max-width: 82%;
  display: inline-block;
  font-size: 14px;
  line-height: 1.4;
}
.rafay_final_msg.bot {
  background: #f4f4f4;
  color: #111;
  float: left;
  border-radius: 14px 14px 14px 4px;
}
.rafay_final_msg.user {
  background: var(--rafay-accent);
  color: #fff;
  float: right;
  border-radius: 14px 14px 4px 14px;
}

/* ---------------- BOT OPTION BUTTONS ---------------- */
.rafay_final_msg.bot_select {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
  justify-content: flex-start;
}

.rafay_final_msg.bot_select button {
  background: #ffffff !important;
  border: 1px solid rgba(0, 0, 0, 0.15) !important;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: #1c1c1c !important;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.04);
}

/* Focus/Active override */
.rafay_final_msg.bot_select button:focus,
.rafay_final_msg.bot_select button:active {
  background: #f7f7f7 !important;
  border-color: rgba(0, 0, 0, 0.25) !important;
  color: #000 !important;
  outline: none !important;
  box-shadow: none !important;
}

/* Hover */
.rafay_final_msg.bot_select button:hover {
  background: rgba(0, 0, 0, 0.06) !important;
  border-color: rgba(0, 0, 0, 0.25) !important;
  color: #000 !important;
  transform: translateY(-1px);
}

/* Selected */
.rafay_final_msg.bot_select button.selected {
  background: var(--rafay-accent) !important;
  color: #fff !important;
  border-color: var(--rafay-accent) !important;
  box-shadow: 0 2px 6px rgba(181, 123, 61, 0.25) !important;
}

/* ---------------- INPUT AREA ---------------- */
.rafay_final_input {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  background: #fff;
}
#rafay_final_input {
  flex: 1;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #ddd;
  font-size: 14px;
  transition: border-color 0.2s ease;
}
#rafay_final_input:focus {
  border-color: var(--rafay-accent);
  outline: none;
}
#rafay_final_send {
  background: var(--rafay-accent);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.25s ease;
}
#rafay_final_send:hover {
  background: #9c652d;
}

/* ---------------- COUNTRY DROPDOWN ---------------- */
.rafay-country-dropdown {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid #ddd;
  font-size: 14px;
  background: #fff;
  color: #333;
  appearance: none;
  cursor: pointer;
  margin-top: 8px;
  transition: border-color 0.2s ease;
}
.rafay-country-dropdown:focus {
  border-color: var(--rafay-accent);
}

/* ---------------- AVATAR LABEL ---------------- */
.rafay_final_avatar_label {
  position: fixed;
  bottom: 90px;
  right: 90px;
  background: var(--rafay-accent);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
  opacity: 0;
  animation: labelFadeIn 0.8s ease 1s forwards;
  z-index: 99997;
}
@keyframes labelFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------- ANIMATIONS ---------------- */
@keyframes rafayFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.rafay_anim_fade_in { animation: rafayFadeIn 0.35s ease forwards; }

@keyframes rafaySlideIn {
  from { transform: translateY(25px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.rafay_anim_slide_in { animation: rafaySlideIn 0.4s ease forwards; }

/* ---------------- RESPONSIVE ---------------- */
@media (max-width: 600px) {
  .rafay_final_container {
    width: calc(100% - 24px);
    left: 12px;
    right: 12px;
    bottom: 16px;
  }
  .rafay_final_messages {
    height: 60vh;
  }
  .rafay_final_avatar_label {
    display: none;
  }
}
/* ======= HARD OVERRIDE FIX FOR BLUE BACKGROUND (Bootstrap/Theme Conflicts) ======= */
.rafay_final_msg.bot_select button,
.rafay_final_msg.bot_select button:hover,
.rafay_final_msg.bot_select button:focus,
.rafay_final_msg.bot_select button:active {
  background: #fff !important;
  border: 1px solid rgba(0, 0, 0, 0.15) !important;
  color: #111 !important;
  border-radius: 22px !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04) !important;
  text-transform: none !important;
  font-weight: 500 !important;
  transition: all 0.25s ease !important;
}

/* Hover effect: soft gray tint */
.rafay_final_msg.bot_select button:hover {
  background: rgba(0,0,0,0.06) !important;
  color: #000 !important;
  transform: translateY(-1px);
}

/* Selected state (clicked option) */
.rafay_final_msg.bot_select button.selected {
  background: var(--rafay-accent) !important;
  color: #fff !important;
  border-color: var(--rafay-accent) !important;
  box-shadow: 0 2px 6px rgba(181, 123, 61, 0.25) !important;
}
/* ===== Service button final override ===== */
.rafay_option_btn,
.rafay_final_msg.bot_select button {
  background: #ffffff !important;
  border: 1px solid rgba(0,0,0,0.12) !important;
  color: #111 !important;
  border-radius: 20px !important;
  padding: 10px 16px !important;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04) !important;
  text-transform: none !important;
  font-weight: 500 !important;
  transition: all 0.22s ease !important;
  display: inline-block;
  width: auto;
}

/* ensure buttons have spacing and wrap nicely */
.rafay_final_msg.bot_select {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: 10px !important;
  align-items: stretch;
}
.rafay_final_msg.bot_select .rafay_option_btn {
  flex: 1 1 48%;
  min-width: 150px;
}

/* hover: soft dark tint */
.rafay_option_btn:hover,
.rafay_final_msg.bot_select button:hover {
  background: rgba(0,0,0,0.06) !important;
  color: #000 !important;
  transform: translateY(-2px) !important;
  border-color: rgba(0,0,0,0.18) !important;
}

/* selected state */
.rafay_option_btn.selected,
.rafay_final_msg.bot_select button.selected {
  background: var(--rafay-accent) !important;
  color: #fff !important;
  border-color: var(--rafay-accent) !important;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12) !important;
}

/* remove default browser focus ring */
.rafay_option_btn:focus,
.rafay_final_msg.bot_select button:focus {
  outline: none !important;
  box-shadow: none !important;
}

/* Fix Chatbox Close Button Hover */
.rafay_chat_close_btn,
.rafay_chat_close_btn:hover,
.rafay_chat_close_btn:focus {
    background-color: transparent !important;
    border: none !important;
    color: #ffffff !important;
    transition: none !important;
}

.rafay_chat_close_btn svg,
.rafay_chat_close_btn i {
    color: #ffffff !important;
}

.rafay_chat_close_btn:hover svg,
.rafay_chat_close_btn:hover i {
    color: #ffffff !important;
    background: none !important;
    box-shadow: none !important;
}
/* Close button styling */
#rafay_final_chat_close {
  background-color: #015bbb; /* existing color, optional */
  border: none;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

/* Fix hover color (remove blue highlight) */
#rafay_final_chat_close:hover,
#rafay_final_chat_close:focus,
#rafay_final_chat_close:active {
  background-color: #b37730 !important; /* same as header color or your theme */
  outline: none !important;
  box-shadow: none !important;
}

/* If it's an <a> link inside button */
#rafay_final_chat_close svg,
#rafay_final_chat_close * {
  fill: #ffffff !important;
}
