/* ─── Wrapper ─────────────────────────────────────────── */
.rxsu-chat-wrapper {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: 'Sarabun', sans-serif;
}

/* ─── Floating Action Button ───────────────────────────── */
.rxsu-fab {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #8a8f3c;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.22);
  transition: background 0.2s, transform 0.2s;
  position: relative;
  flex-shrink: 0;
}
.rxsu-fab:hover {
  background: #6f7330;
  transform: scale(1.08);
}

/* Facebook FAB */
.rxsu-fab--facebook {
  background: #1877F2;
  text-decoration: none;
}
.rxsu-fab--facebook:hover {
  background: #1565d8;
  transform: scale(1.08);
}

/* Badge (unread count) */
.rxsu-fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e74c3c;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}
.rxsu-fab-badge.rxsu-hidden {
  display: none;
}

/* ─── Chat Box ─────────────────────────────────────────── */
.rxsu-chat-box {
  width: 340px;
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;

  /* hidden state */
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.rxsu-chat-box.rxsu-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Header */
.rxsu-chat-header {
  background: #8a8f3c;
  color: #fff;
  padding: 14px 16px;
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.rxsu-chat-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  opacity: 0.85;
  transition: opacity 0.15s;
}
.rxsu-chat-close:hover { opacity: 1; }

/* Messages area */
.rxsu-chat-messages {
  padding: 14px;
  height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #f9f9f7;
}

.rxsu-msg {
  padding: 9px 13px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.5;
  max-width: 80%;
  word-break: break-word;
}
.rxsu-msg--bot {
  background: #8a8f3c;
  color: #fff;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  animation: rxsu-slide-in-left 0.2s ease;
}
.rxsu-msg--user {
  background: #e8e8e8;
  color: #333;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
  animation: rxsu-slide-in-right 0.2s ease;
}
@keyframes rxsu-slide-in-left {
  from { opacity: 0; transform: translateX(-10px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes rxsu-slide-in-right {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Typing indicator */
.rxsu-msg--typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
}
.rxsu-msg--typing span {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  flex-shrink: 0;
  animation: rxsu-bounce 1.1s infinite ease-in-out;
}
.rxsu-msg--typing span:nth-child(2) { animation-delay: 0.18s; }
.rxsu-msg--typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes rxsu-bounce {
  0%, 70%, 100% { transform: translateY(0);   opacity: 0.4; }
  35%           { transform: translateY(-7px); opacity: 1;   }
}

/* Input area */
.rxsu-chat-input {
  display: flex;
  align-items: center;
  border-top: 1px solid #e5e5e5;
  background: #fff;
  padding: 8px 10px;
  gap: 8px;
}
.rxsu-chat-input input {
  flex: 1;
  border: 1px solid #ddd;
  border-radius: 20px;
  padding: 9px 14px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.rxsu-chat-input input:focus {
  border-color: #8a8f3c;
}
.rxsu-chat-input button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #8a8f3c;
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}
.rxsu-chat-input button:hover {
  background: #6f7330;
  transform: scale(1.05);
}

/* Typewriter cursor */
.rxsu-msg--typing-cursor::after {
  content: '|';
  display: inline-block;
  margin-left: 2px;
  opacity: 1;
  animation: rxsu-blink 0.6s step-start infinite;
}
@keyframes rxsu-blink {
  50% { opacity: 0; }
}

/* Inline link inside bot message */
.rxsu-msg-link {
  color: #d4e06a;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}
.rxsu-msg-link:hover {
  color: #fff;
}

/* File attachment card */
.rxsu-file-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 6px;
  text-decoration: none;
  color: #fff;
  transition: background 0.18s;
  cursor: pointer;
  width: 100%;
  box-sizing: border-box;
}
.rxsu-file-card:hover {
  background: rgba(255, 255, 255, 0.26);
  color: #fff;
}
.rxsu-file-icon {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0.9;
}
.rxsu-file-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rxsu-file-open {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  opacity: 0.7;
}

/* File attachment standalone bubble */
.rxsu-file-bubble {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1.5px solid #e0e3c5;
  border-radius: 14px;
  padding: 12px 14px;
  text-decoration: none;
  color: #333;
  align-self: flex-start;
  max-width: 88%;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.15s;
  animation: rxsu-slide-in-left 0.22s ease;
  cursor: pointer;
}
.rxsu-file-bubble:hover {
  border-color: #8a8f3c;
  box-shadow: 0 4px 14px rgba(138,143,60,0.18);
  transform: translateY(-1px);
  color: #333;
  text-decoration: none;
}
.rxsu-fb-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: #f0f1e0;
  color: #8a8f3c;
  flex-shrink: 0;
}
.rxsu-fb-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.rxsu-fb-label {
  font-size: 11px;
  color: #9ca3af;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.rxsu-fb-name {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rxsu-fb-open {
  display: flex;
  align-items: center;
  color: #8a8f3c;
  flex-shrink: 0;
  opacity: 0.8;
}

/* Responsive */
@media (max-width: 400px) {
  .rxsu-chat-wrapper {
    bottom: 16px;
    right: 16px;
  }
  .rxsu-chat-box {
    width: calc(100vw - 32px);
  }
}
/* Mobile: ปรับ Floating Chat/Facebook ไม่ให้ wrapper บังการคลิกหน้าเว็บ */
@media (max-width: 767px) {

  .rxsu-chat-wrapper {
    position: fixed !important;
    right: 20px !important;
    bottom: 20px !important;

    width: 56px !important;
    height: auto !important;
    max-width: 56px !important;
    min-width: 56px !important;

    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 12px !important;

    z-index: 99999 !important;

    /* สำคัญที่สุด: ไม่ให้พื้นที่โปร่งใสบังการคลิก */
    pointer-events: none !important;
  }

  #rxsuFab,
  .rxsu-fab,
  .rxsu-fab--facebook {
    width: 56px !important;
    height: 56px !important;
    min-width: 56px !important;
    min-height: 56px !important;

    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;

    pointer-events: auto !important;
    cursor: pointer !important;
    z-index: 100000 !important;
  }

  #rxsuChatBox {
    display: none !important;
  }

}