/* ============================================================
   GLOBAL STICKY CHATBOT
   Keep this file independent from footer.css
============================================================ */

:root {
  --f-gold: #ffc844;
  --f-blue: #4f6fff;
  --f-red: #ff4f4f;
  --f-font: "Kanit", sans-serif;
}

/* Fixed/sticky position across whole page */
.f4-chat-area {
  position: fixed !important;
  right: clamp(18px, 4vw, 72px) !important;
  bottom: clamp(18px, 4vw, 46px) !important;
  top: auto !important;
  left: auto !important;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  z-index: 99999 !important;
  pointer-events: none;
}

/* Chat widget */
.site-chat-widget {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  z-index: 99999;
  min-width: 66px;
  min-height: 66px;
  pointer-events: auto;
}

.site-chat-panel {
  width: min(450px, calc(100vw - 32px));
  height: min(540px, 72vh);
  background: #0b0b10;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  overflow: hidden;
  box-shadow:
    0 28px 70px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 189, 74, 0.07);
  display: none;
  flex-direction: column;
  position: absolute;
  bottom: calc(100% + 16px);
  right: 0;
  top: auto;
  transform: none;
  transform-origin: bottom right;
}

.site-chat-widget.is-open .site-chat-panel {
  display: flex;
}

.site-chat-widget.is-open .site-chat-trigger {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transform: scale(0.75);
}

/* Floating close button appears exactly where circular trigger was */
.site-chat-floating-close {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: radial-gradient(circle at 35% 30%, #1a1b28, #050506);
  color: #fff;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.45),
    0 0 0 2px rgba(255, 92, 92, 0.14);
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
  position: absolute !important;
  right: 0 !important;
  top: 0 !important;
  z-index: 6 !important;
  padding: 0;
}

.site-chat-floating-close::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--f-red), var(--f-blue), var(--f-gold), var(--f-red));
  z-index: -1;
  filter: blur(10px);
  opacity: 0.65;
  animation: spinGlow 4s linear infinite;
}

.site-chat-floating-close:hover {
  transform: scale(1.08);
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.5),
    0 0 0 2px rgba(255, 92, 92, 0.32);
}

.site-chat-widget.is-open .site-chat-floating-close {
  display: inline-flex !important;
}

/* Header */
.site-chat-widget-header {
  padding: 16px 18px 14px;
  background: #0f1017;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.site-chat-widget-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.site-chat-widget-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  overflow: hidden;
  flex-shrink: 0;
  background: #1a1a1a;
  border: 1px solid rgba(255, 189, 74, 0.28);
}

.site-chat-widget-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.site-chat-widget-title {
  font-size: 0.93rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 3px;
  font-family: var(--f-font);
}

.site-chat-widget-status {
  font-size: 0.68rem;
  color: #06ffa5;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--f-font);
}

.site-chat-widget-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #06ffa5;
  animation: statusPulse 2s ease-in-out infinite;
}

@keyframes statusPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.site-chat-widget-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  padding: 0;
}

.site-chat-widget-close:hover {
  background: rgba(255, 92, 92, 0.2);
  border-color: rgba(255, 92, 92, 0.4);
}

/* Messages */
.site-chat-widget-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 13px;
  padding: 16px;
  background: #050508;
}

.site-chat-widget-messages::-webkit-scrollbar {
  width: 3px;
}

.site-chat-widget-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
}

.site-chat-msg {
  max-width: 85%;
  padding: 11px 14px;
  border-radius: 15px;
  font-size: 0.88rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--f-font);
}

.site-chat-msg.ai {
  background: #0f0f18;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
}

.site-chat-msg.user {
  background: linear-gradient(135deg, rgba(255, 189, 74, 0.14), rgba(82, 113, 255, 0.11));
  border: 1px solid rgba(255, 189, 74, 0.22);
  color: #121212 !important;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
  font-weight: 500;
}

.site-chat-typing {
  display: flex;
  gap: 4px;
  padding: 11px 14px;
  background: #0f0f18;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 15px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  width: fit-content;
}

.site-chat-typing span {
  width: 6px;
  height: 6px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 50%;
  animation: typeBounce 1.4s infinite ease-in-out both;
}

.site-chat-typing span:nth-child(1) { animation-delay: -0.32s; }
.site-chat-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typeBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Suggestions + form */
.site-chat-suggestions {
  display: flex;
  flex-direction: column;
  gap: 9px;
  align-items: flex-end;
  padding: 12px 16px 0;
  background: #050508;
}

.site-chat-quick-header {
  font-size: 0.6rem;
  color: var(--f-gold);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  font-family: var(--f-font);
}

.site-chat-suggestion-pill {
  background: #0f0f18;
  border: 1px solid rgba(255, 189, 74, 0.22);
  border-radius: 8px;
  padding: 7px 14px;
  color: #fff;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--f-font);
  transition: background 0.2s, border-color 0.2s;
}

.site-chat-suggestion-pill:hover {
  background: rgba(255, 189, 74, 0.1);
  border-color: rgba(255, 189, 74, 0.42);
}

.site-chat-widget-bottom {
  padding: 13px 15px;
  background: #050508;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.site-chat-widget-form {
  display: flex;
  gap: 9px;
}

.site-chat-widget-input {
  flex: 1;
  min-width: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: #0f0f18 !important;
  color: #fff !important;
  padding: 11px 18px;
  font-size: 0.88rem;
  outline: none;
  font-family: var(--f-font);
  box-shadow: 0 0 0 1000px #0f0f18 inset !important;
  -webkit-text-fill-color: #fff !important;
  caret-color: var(--f-gold);
  color-scheme: dark;
  transition: border-color 0.2s;
}

.site-chat-widget-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
  opacity: 1;
}

.site-chat-widget-input:focus {
  border-color: rgba(255, 189, 74, 0.38);
}

.site-chat-widget-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 189, 74, 0.3);
  background: linear-gradient(135deg, rgba(255, 189, 74, 0.14), rgba(82, 113, 255, 0.14)) !important;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
  transition: transform 0.2s, border-color 0.2s;
}

.site-chat-widget-send:hover {
  transform: scale(1.1);
  border-color: rgba(255, 189, 74, 0.55);
}

/* Circular trigger */
.site-chat-trigger {
  width: 66px;
  height: 66px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: radial-gradient(circle at 35% 30%, #1a1b28, #050506);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.45),
    0 0 0 2px rgba(255, 189, 74, 0.12);
  cursor: pointer;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    opacity 0.2s ease;
  position: relative;
  padding: 0;
}

.site-chat-trigger::before {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--f-gold), var(--f-blue), var(--f-red), var(--f-gold));
  z-index: -1;
  filter: blur(10px);
  opacity: 0.7;
  animation: spinGlow 4s linear infinite;
}

@keyframes spinGlow {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.site-chat-trigger:hover {
  transform: scale(1.1);
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.5),
    0 0 0 2px rgba(255, 189, 74, 0.35);
}

/* No tooltip/popup */
.site-chat-trigger::after,
.site-chat-trigger .site-chat-tooltip-tail {
  display: none !important;
  content: none !important;
}

.site-chat-trigger img {
  width: 34px;
  max-width: 34px;
  height: auto;
  display: block;
  border-radius: 50%;
  object-fit: contain;
  transform: none !important;
}

/* Mobile responsiveness */
@media (max-width: 680px) {
  .f4-chat-area {
    right: 16px !important;
    bottom: 16px !important;
  }

  .site-chat-panel {
    right: 0 !important;
    bottom: calc(100% + 14px) !important;
    width: min(400px, calc(100vw - 20px)) !important;
    max-height: 72vh;
  }

  .site-chat-trigger,
  .site-chat-floating-close {
    width: 62px;
    height: 62px;
  }

  .site-chat-widget {
    min-width: 62px;
    min-height: 62px;
  }

  .site-chat-trigger img {
    width: 32px;
    max-width: 32px;
  }
}

@media (max-width: 420px) {
  .site-chat-panel {
    width: calc(100vw - 20px) !important;
    height: min(520px, 72vh);
  }

  .site-chat-widget-header {
    padding: 14px;
  }

  .site-chat-widget-messages {
    padding: 14px;
  }

  .site-chat-msg {
    max-width: 90%;
    font-size: 0.86rem;
  }
}


.site-chat-widget-input { text-transform: none !important; }
