/* ===================================================================
   SUN OF JUSTICE - REAL-TIME SIGNALR LIVE CHAT WIDGET
   Luxury Gold & Slate Styling (Bilingual RTL / LTR Responsive)
=================================================================== */

:root {
  --chat-primary: #b39366;
  --chat-primary-hover: #9c7e52;
  --chat-primary-gradient: linear-gradient(135deg, #c5a880 0%, #a68453 100%);
  --chat-dark: #0f172a;
  --chat-dark-light: #1e293b;
  --chat-surface: #ffffff;
  --chat-bubble-visitor: linear-gradient(135deg, #b39366 0%, #8f7243 100%);
  --chat-bubble-admin: #f1f5f9;
  --chat-border: rgba(179, 147, 102, 0.22);
  --chat-shadow: 0 12px 36px rgba(15, 23, 42, 0.2), 0 4px 12px rgba(179, 147, 102, 0.15);
  --chat-radius: 18px;
}

/* 0. Floating WhatsApp Button (Stacked right above Chat Launcher) */
#sjllccWhatsAppFloat {
  position: fixed;
  bottom: 98px;
  right: 26px;
  z-index: 99997;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #25D366 0%, #128C7E 100%);
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 8px 24px rgba(37, 211, 102, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  text-decoration: none;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

html[dir="ltr"] #sjllccWhatsAppFloat,
body.ltr #sjllccWhatsAppFloat {
  right: auto;
  left: 26px;
}

#sjllccWhatsAppFloat:hover {
  transform: scale(1.1) translateY(-3px);
  box-shadow: 0 12px 28px rgba(37, 211, 102, 0.65);
  color: #ffffff;
}

#sjllccWhatsAppFloat:active {
  transform: scale(0.95);
}

#sjllccWhatsAppFloat i {
  font-size: 30px;
  color: #ffffff;
  line-height: 1;
  transition: transform 0.3s ease;
}

#sjllccWhatsAppFloat:hover i {
  transform: scale(1.08);
}

#sjllccWhatsAppFloat.chat-open {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.6) translateY(20px);
}

.whatsapp-float-pulse::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid #25D366;
  opacity: 0.8;
  animation: waRipple 2.2s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}

@keyframes waRipple {
  0% { transform: scale(0.95); opacity: 0.9; }
  100% { transform: scale(1.45); opacity: 0; }
}

.whatsapp-float-tooltip {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: #0f172a;
  color: #ffffff;
  font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  font-size: 13px;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 20px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(37, 211, 102, 0.4);
}

[dir="rtl"] .whatsapp-float-tooltip,
body.rtl .whatsapp-float-tooltip {
  right: 70px;
  left: auto;
}

[dir="ltr"] .whatsapp-float-tooltip,
body.ltr .whatsapp-float-tooltip {
  left: 70px;
  right: auto;
}

#sjllccWhatsAppFloat:hover .whatsapp-float-tooltip {
  opacity: 1;
}

/* WhatsApp in Chat Header */
.chat-whatsapp-header-btn {
  color: #25D366 !important;
  text-decoration: none !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
}

.chat-whatsapp-header-btn:hover {
  background: rgba(37, 211, 102, 0.2) !important;
  color: #25D366 !important;
  transform: scale(1.15);
}

.chat-whatsapp-header-btn i {
  font-size: 18px;
}

/* 1. Floating Toggle Button */
#sjllccChatLauncher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99998;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--chat-primary-gradient);
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 8px 24px rgba(166, 132, 83, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* LTR position adjustment if page is LTR */
html[dir="ltr"] #sjllccChatLauncher,
body.ltr #sjllccChatLauncher {
  right: auto;
  left: 24px;
}

#sjllccChatLauncher:hover {
  transform: scale(1.08) translateY(-2px);
  box-shadow: 0 12px 28px rgba(166, 132, 83, 0.6);
}

#sjllccChatLauncher:active {
  transform: scale(0.95);
}

#sjllccChatLauncher i {
  font-size: 28px;
  line-height: 1;
  transition: transform 0.3s ease;
}

#sjllccChatLauncher .chat-icon-close {
  display: none;
}

#sjllccChatLauncher.active .chat-icon-open {
  display: none;
}

#sjllccChatLauncher.active .chat-icon-close {
  display: block;
}

/* Unread Badge */
#sjllccChatBadge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 22px;
  height: 22px;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4);
  animation: chatPulseBadge 2s infinite;
}

@keyframes chatPulseBadge {
  0% { transform: scale(1); }
  50% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* Pulse ripple effect around launcher */
.chat-launcher-pulse::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid #c5a880;
  opacity: 0.8;
  animation: chatRipple 2s cubic-bezier(0.24, 0, 0.38, 1) infinite;
}

@keyframes chatRipple {
  0% { transform: scale(0.95); opacity: 0.9; }
  100% { transform: scale(1.45); opacity: 0; }
}

/* 2. Chat Main Container Window */
#sjllccChatBox {
  position: fixed;
  bottom: 96px;
  right: 24px;
  z-index: 99999;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: #ffffff;
  border-radius: var(--chat-radius);
  box-shadow: var(--chat-shadow);
  border: 1px solid var(--chat-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.96);
  transform-origin: bottom right;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
}

html[dir="ltr"] #sjllccChatBox,
body.ltr #sjllccChatBox {
  right: auto;
  left: 24px;
  transform-origin: bottom left;
}

#sjllccChatBox.open {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* 3. Header */
.sjllcc-chat-header {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 2px solid #c5a880;
  flex-shrink: 0;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-avatar-box {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #c5a880;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #0f172a;
  font-size: 20px;
  flex-shrink: 0;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.chat-avatar-box img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.chat-online-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #0f172a;
  box-shadow: 0 0 6px #10b981;
}

.chat-header-titles h4 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
  line-height: 1.2;
}

.chat-header-titles span {
  font-size: 11px;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-btn-action {
  background: transparent;
  border: none;
  color: #cbd5e1;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 16px;
  transition: all 0.2s;
}

.chat-btn-action:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #c5a880;
}

/* 4. Connection Status Banner */
#sjllccChatStatus {
  background: #fef3c7;
  color: #92400e;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  text-align: center;
  display: none;
  border-bottom: 1px solid #fde68a;
}

/* 5. Messages Body Area */
.sjllcc-chat-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
  scroll-behavior: smooth;
}

.sjllcc-chat-body::-webkit-scrollbar {
  width: 5px;
}
.sjllcc-chat-body::-webkit-scrollbar-thumb {
  background: rgba(179, 147, 102, 0.3);
  border-radius: 4px;
}

/* Welcome Card */
.chat-welcome-card {
  background: #ffffff;
  border: 1px solid var(--chat-border);
  border-radius: 12px;
  padding: 14px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.chat-welcome-card i {
  font-size: 26px;
  color: var(--chat-primary);
  margin-bottom: 6px;
  display: inline-block;
}

.chat-welcome-card h5 {
  font-size: 14px;
  font-weight: 700;
  color: var(--chat-dark);
  margin-bottom: 4px;
}

.chat-welcome-card p {
  font-size: 12px;
  color: #64748b;
  margin-bottom: 10px;
  line-height: 1.4;
}

.chat-quick-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.chat-pill-btn {
  background: rgba(179, 147, 102, 0.1);
  color: #8a6c38;
  border: 1px solid rgba(179, 147, 102, 0.25);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.chat-pill-btn:hover {
  background: var(--chat-primary-gradient);
  color: #ffffff;
  border-color: transparent;
  transform: translateY(-1px);
}

/* Message Rows & Bubbles */
.chat-message-row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: chatMsgFadeIn 0.25s ease-out;
}

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

.chat-message-row.visitor {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-message-row.admin {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-sender-name {
  font-size: 10px;
  font-weight: 700;
  margin-bottom: 2px;
  color: #64748b;
  padding: 0 4px;
}

.chat-message-row.visitor .chat-sender-name {
  color: #a68453;
}

.chat-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
  position: relative;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.chat-message-row.visitor .chat-bubble {
  background: var(--chat-bubble-visitor);
  color: #ffffff;
  border-bottom-left-radius: 3px;
}

html[dir="ltr"] .chat-message-row.visitor .chat-bubble,
body.ltr .chat-message-row.visitor .chat-bubble {
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 3px;
}

.chat-message-row.admin .chat-bubble {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-right-radius: 3px;
}

html[dir="ltr"] .chat-message-row.admin .chat-bubble,
body.ltr .chat-message-row.admin .chat-bubble {
  border-bottom-right-radius: 14px;
  border-bottom-left-radius: 3px;
}

.chat-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 10px;
  color: #94a3b8;
  margin-top: 3px;
  padding: 0 4px;
}

.chat-message-row.visitor .chat-meta {
  color: #94a3b8;
}

.chat-meta i {
  font-size: 12px;
}

.btn-chat-bubble-translate {
  background: transparent;
  border: none;
  color: #94a3b8;
  padding: 0 4px;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
}

.btn-chat-bubble-translate:hover {
  color: #c5a880;
  transform: scale(1.15);
}

.chat-bubble-trans-box {
  margin-top: 4px;
  padding: 6px 10px;
  border-radius: 10px;
  background: #fffdfa;
  border: 1px solid #f3e8d2;
  border-right: 3px solid #b39366 !important;
  font-size: 12px;
  color: #1e293b;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
  animation: chatMsgFadeIn 0.2s ease-out;
}

/* Typing Indicator */
.chat-typing-indicator {
  display: none;
  align-self: flex-start;
  background: #ffffff;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.chat-typing-indicator.active {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-typing-text {
  font-size: 11px;
  color: #64748b;
  font-weight: 600;
}

.chat-typing-dots {
  display: flex;
  gap: 3px;
}

.chat-typing-dots span {
  width: 5px;
  height: 5px;
  background: #94a3b8;
  border-radius: 50%;
  animation: chatDotBlink 1.4s infinite both;
}

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

@keyframes chatDotBlink {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1.1); opacity: 1; background: #c5a880; }
}

/* 6. Footer Input Area */
.sjllcc-chat-footer {
  padding: 10px 14px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.chat-input-wrapper {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
}

#sjllccChatInput {
  width: 100%;
  border: 1.5px solid #e2e8f0;
  border-radius: 24px;
  padding: 9px 16px;
  font-size: 13.5px;
  outline: none;
  background: #f8fafc;
  color: #1e293b;
  font-family: inherit;
  transition: all 0.2s;
  resize: none;
}

#sjllccChatInput:focus {
  background: #ffffff;
  border-color: var(--chat-primary);
  box-shadow: 0 0 0 3px rgba(179, 147, 102, 0.15);
}

#sjllccChatSendBtn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--chat-primary-gradient);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 17px;
  flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: 0 3px 10px rgba(166, 132, 83, 0.35);
}

#sjllccChatSendBtn:hover:not(:disabled) {
  transform: scale(1.06);
  box-shadow: 0 4px 14px rgba(166, 132, 83, 0.5);
}

#sjllccChatSendBtn:active:not(:disabled) {
  transform: scale(0.94);
}

#sjllccChatSendBtn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* User Info Prompt Modal/Bar */
#sjllccChatUserInfoBar {
  background: #f1f5f9;
  border-top: 1px solid #e2e8f0;
  padding: 8px 12px;
  display: none;
  flex-direction: column;
  gap: 6px;
}

#sjllccChatUserInfoBar.active {
  display: flex;
}

.chat-user-fields {
  display: flex;
  gap: 6px;
}

.chat-user-fields input {
  flex: 1;
  padding: 5px 10px;
  font-size: 12px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  outline: none;
}

.chat-user-fields button {
  background: var(--chat-primary);
  color: #fff;
  border: none;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

/* Mobile Responsiveness */
@media (max-width: 480px) {
  #sjllccChatBox {
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 100vh !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
  }

  #sjllccChatLauncher {
    bottom: 16px;
    right: 16px;
    width: 54px;
    height: 54px;
  }
  html[dir="ltr"] #sjllccChatLauncher,
  body.ltr #sjllccChatLauncher {
    left: 16px;
    right: auto;
  }

  #sjllccWhatsAppFloat {
    bottom: 78px;
    right: 17px;
    width: 50px;
    height: 50px;
  }
  #sjllccWhatsAppFloat i {
    font-size: 26px;
  }
  html[dir="ltr"] #sjllccWhatsAppFloat,
  body.ltr #sjllccWhatsAppFloat {
    left: 17px;
    right: auto;
  }
  .whatsapp-float-tooltip {
    display: none !important;
  }
}
