/* UI VERSION: OKRANK_CHAT_UI_v1.0
   STATUS: FROZEN
   LAST UPDATED: 2026-02-10
*/


/* ================================
   OKRANK Chat Widget – UI Polish
   WhatsApp-style | Mobile-first
================================ */

/* ---------- GLOBAL SAFETY ---------- */
#okrank-chat,
#okrank-chat * {
  box-sizing: border-box;
}

/* ---------- ROOT ---------- */
#okrank-chat {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  font-family: Inter, system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---------- TOGGLE ---------- */
#chat-toggle {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: #fff;
  font-size: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10000;
  box-shadow: 0 12px 28px rgba(0,0,0,0.25);
  -webkit-tap-highlight-color: transparent;
}

/* ---------- CHAT BOX ---------- */
#chat-box {
  position: fixed;
  bottom: 90px;
  right: 20px;
  width: min(360px, 95vw);
  max-height: calc(85vh - 105px);
  background: #ffffff;
  border-radius: 14px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.25);
  display: none;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- HEADER ---------- */
#chat-header {
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: #ffffff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;

  border-top-left-radius: 18px;
  border-top-right-radius: 18px;

  box-shadow: inset 0 -1px 0 rgba(255,255,255,0.15);
}


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

.chat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;

  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}


.chat-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.2px;
}

.chat-status {
  font-size: 11px;
  opacity: 0.9;
  font-weight: 400;
}


#chat-close {
  cursor: pointer;
  font-size: 17px;
  line-height: 1;
  opacity: 0.75;
}

/* ---------- BODY ---------- */
#chat-body {
  padding: 12px 10px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #ecfdf3;
  flex: 1;
  scroll-behavior: smooth;
}

/* ---------- MESSAGE BASE ---------- */
.msg {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 14px;
  margin-bottom: 10px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
  white-space: pre-line;   /* 🔥 ADD THIS */
}

/* ---------- USER MESSAGE ---------- */
.msg.user {
  margin-left: auto;
  background: #16a34a;
  color: #ffffff;
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
}

/* ---------- AI MESSAGE ---------- */
.msg.ai {
  margin-right: auto;
  background: #ffffff;
  color: #111827;
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
}

/* ---------- LINKS ---------- */
.msg a {
  text-decoration: underline;
  word-break: break-word;
  font-weight: 500;
}

.msg.ai a {
  color: #16a34a;
}

.msg.user a {
  color: #ffffff;
  text-decoration-color: rgba(255,255,255,0.7);
}

.msg a:hover {
  opacity: 0.85;
}

.msg a:active {
  opacity: 0.75;
}

/* ---------- TYPING INDICATOR ---------- */
.msg.typing {
  background: #ffffff;
  width: fit-content;
  padding: 6px 10px;
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.msg.typing span {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 2px;
  background: #9ca3af;
  border-radius: 50%;
  animation: typing 1.4s infinite;
}

.msg.typing span:nth-child(2) { animation-delay: .2s; }
.msg.typing span:nth-child(3) { animation-delay: .4s; }

@keyframes typing {
  0% { opacity: .3; }
  50% { opacity: 1; }
  100% { opacity: .3; }
}

/* ---------- MESSAGE APPEAR ---------- */
@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.msg:not(.typing) {
  animation: msgFadeIn 0.18s ease-out;
}

/* ---------- INPUT ---------- */
.chat-input {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: #ffffff;
  gap: 8px;

  box-shadow: 0 -2px 8px rgba(0,0,0,0.03);
}

#chat-input {
  flex: 1;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  padding: 11px 16px;
  font-size: 14px;
  background: #f9fafb;
  transition: all .2s ease;
}

#chat-input:focus {
  border-color: #16a34a;
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(22,163,74,0.15);
  outline: none;
}

/* ---------- SEND BUTTON ---------- */
#chat-send {
  background: #16a34a;
  color: #ffffff;
  border: none;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;

  box-shadow: 0 6px 16px rgba(22,163,74,0.35);
  transition: all .15s ease;
}
#chat-send:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(22,163,74,0.35);
}


#chat-send:hover {
  background: #15803d;
  transform: translateY(-1px);
}

#chat-send:active {
  transform: scale(0.96);
}

/* ---------- MOBILE ---------- */
@media (max-width: 480px) {
  #chat-box {
    right: 10px;
    bottom: 72px;
    width: calc(100vw - 20px);
    max-height: calc(80vh - 72px);
  }

  #chat-header {
    padding: 9px 10px;
  }

  .chat-avatar {
    width: 30px;
    height: 30px;
  }

  .msg {
    max-width: 82%;
    font-size: 13.5px;
  }

  #chat-input {
    padding: 9px;
    font-size: 14px;
  }

  #chat-send {
    width: 42px;
    height: 42px;
  }

  #chat-toggle {
    right: 10px;
    bottom: 10px;
  }
}

/* ---------- WhatsApp-style Toggle Icon ---------- */

/* Hide any text / emoji inside toggle safely */
#chat-toggle {
  color: transparent;
}

/* WHATSAPP TOGGLE ICON
   STATUS: FINAL / FROZEN
   Do NOT modify SVG, offsets, or centering
*/


#chat-toggle {
  background: #25D366 !important;
  display: flex;
  align-items: center;
  justify-content: center;
}


#chat-toggle::before {
  content: "";
  width: 42px;
  height: 42px;
  
  transform: translateX(11px) translateY(0.7px);

  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;

  background-image: url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'>\
<path d='M12 4c-4.42 0-8 3.13-8 7 0 1.73.73 3.33 1.95 4.6L4 20l4.6-1.95c1.05.35 2.2.55 3.4.55 4.42 0 8-3.13 8-7s-3.58-7-8-7z' fill='none' stroke='white' stroke-width='2' stroke-linejoin='round'/>\
</svg>");
}


/* Match WhatsApp green exactly */
#chat-toggle {
  background: #25D366 !important;
}

/* ---------- WhatsApp Subtle Pulse (Conversion Boost) ---------- */

@keyframes whatsappPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(37, 211, 102, 0.5);
  }
  70% {
    box-shadow: 0 0 0 12px rgba(37, 211, 102, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(37, 211, 102, 0);
  }
}

#chat-toggle.pulse {
  animation: whatsappPulse 2.4s infinite;
}

/* ---------- Attention Nudge Animation ---------- */

@keyframes nudgeShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
}

#chat-toggle.nudge {
  animation: nudgeShake 0.6s ease-in-out;
}

/* ---------- Suggestion Chips ---------- */

/* ---------- Premium Suggestion Chips ---------- */

.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.chat-chip {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-weight: 500;
  color: #111827;
  white-space: nowrap;
}

.chat-chip:hover {
  background: #16a34a;
  color: #ffffff;
  border-color: #16a34a;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(22,163,74,0.25);
}

.chat-chip:active {
  transform: scale(0.96);
}
.chat-chip.active {
  background: #16a34a;
  color: #ffffff;
  border-color: #16a34a;
  box-shadow: 0 4px 10px rgba(22,163,74,0.25);
}
/* ---------- Refined Inline CTA Buttons ---------- */

.chat-inline-buttons {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-inline-btn {
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  padding: 8px 12px;
  font-size: 13px;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 500;
  color: #111827;

  display: flex;
  align-items: center;
  justify-content: center;

  flex: 1 1 calc(50% - 4px); /* two buttons per row */
  max-width: calc(50% - 4px);

  transition: all 0.18s ease;
}

/* WhatsApp button */
.chat-inline-btn:last-child {
  background: linear-gradient(135deg,#16a34a,#22c55e);
  color: #fff;
  border: none;
}

/* Hover */
.chat-inline-btn:hover {
  transform: translateY(-1px);
}

/* Click */
.chat-inline-btn:active {
  transform: scale(0.96);
}

/* Remove browser focus ring */
.chat-inline-btn:focus {
  outline: none;
}


/* Primary WhatsApp button style */
.chat-inline-btn:last-child {
  flex: 1.2;
}

/* Hover effect */
.chat-inline-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 22px rgba(0,0,0,0.08);
}

/* Active click */
.chat-inline-btn:active {
  transform: scale(0.97);
}

/* Better spacing inside AI bubble */
.msg.ai .chat-inline-buttons {
  margin-top: 8px;
  padding-top: 6px;
}

/* Stronger hover on green only */
.chat-inline-btn:last-child:hover {
  box-shadow: 0 14px 32px rgba(22,163,74,0.45);
  transform: translateY(-2px);
}

/* Stronger card separation for CTA messages */
.msg.ai {
  transition: box-shadow 0.2s ease;
}

/* ---------- Smooth Button Entrance Animation ---------- */

.chat-inline-btn {
  animation: fadeSlideUp 0.35s ease both;
}

.chat-inline-btn:nth-child(1) {
  animation-delay: 0.05s;
}

.chat-inline-btn:nth-child(2) {
  animation-delay: 0.12s;
}


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

#chat-body {
  overflow-anchor: auto;
  scroll-behavior: auto;
}

.msg.system {
  font-size: 12px;
  text-align: center;
  background: transparent;
  color: #6b7280;
  margin: 8px auto;
  padding: 4px 8px;
}

/* Badge */
.chat-unread-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: #ef4444;
  color: white;
  font-size: 11px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}
.chat-nudge-bubble{
position:absolute;
right:70px;
bottom:10px;
background:#fff;
color:#333;
padding:10px 14px;
border-radius:14px;
font-size:13px;
box-shadow:0 8px 18px rgba(0,0,0,0.15);
white-space:nowrap;
animation:chatNudgeIn .3s ease;
}

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