/* ===== Base ===== */
*{ box-sizing:border-box; }
body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  background:#ffffff;
  color:#1f2937;
}

/* ===== Utilities ===== */
.hidden { display: none !important; }

/* ===== Floating action button (bottom-right) ===== */
.chat-fab{
  position:fixed;
  right:18px;
  bottom:18px;
  width:54px;
  height:54px;
  border-radius:999px;
  border:none;
  background:#22c55e;
  color:#fff;
  font-size:22px;
  cursor:pointer;
  box-shadow:0 12px 30px rgba(0,0,0,.25);
  display:grid;
  place-items:center;
  transition:transform .15s ease, background .15s ease;
  z-index:99999;
}
.chat-fab:hover{ background:#16a34a; transform:translateY(-1px); }
.chat-fab:active{ transform:translateY(0px) scale(0.97); }

/* ===== Widget container ===== */
.chat-widget{
  position:fixed;
  right:18px;
  bottom:86px;
  width:360px;
  max-width:calc(100vw - 36px);
  height:520px;
  max-height:calc(100vh - 130px);
  background:#fff;
  border:1px solid #e5e7eb;
  border-radius:16px;
  overflow:hidden;
  box-shadow:0 18px 50px rgba(0,0,0,.18);
  z-index:99999;
  display:flex;
  flex-direction:column;
}

/* ===== Topbar/Header ===== */
.chat-topbar{
  padding:12px 12px;
  border-bottom:1px solid #eef2f7;
  display:flex;
  align-items:center;
  justify-content:space-between;
  background:#fff;
}

.brand{
  display:flex;
  align-items:center;
  gap:10px;
}

.site-logo{
  height:34px;
  width:auto;
  object-fit:contain;
}

.chat-title{ font-weight:800; color:#111827; line-height:1.1; }
.chat-sub{ font-size:12px; color:#6b7280; margin-top:2px; }

.chat-close{
  border:none;
  background:transparent;
  font-size:18px;
  cursor:pointer;
  color:#6b7280;
}
.chat-close:hover{ color:#111827; }

/* ===== Chat Body ===== */
.chat-body{
  flex:1;
  padding:12px;
  overflow:auto;
  background:#fafafa;
}

/* If you use .chat as the messages container in HTML */
.chat{
  display:flex;
  flex-direction:column;
  gap:10px;
}

/* ===== Messages (Fixed Alignment) ===== */
.bubble{
  display:inline-block;
  max-width:82%;
  padding:10px 12px;
  border-radius:16px;
  line-height:1.45;
  white-space:pre-wrap;
  word-wrap:break-word;
  overflow-wrap:anywhere;
  border:1px solid #e5e7eb;
  font-size:14px;
}

/* Row wrappers for perfect alignment */
.row{
  width:100%;
  display:flex;
}

.row-bot{ justify-content:flex-start; }
.row-me{ justify-content:flex-end; }

/* User = RIGHT */
.bubble.me{
  margin-left:auto;
  margin-right:0;
  background:#ecfdf5;
  border-color:#bbf7d0;
  border-bottom-right-radius:6px;
  color:#111827;
}

/* Bot = LEFT */
.bubble.bot{
  margin-right:auto;
  margin-left:0;
  background:#f3f4f6;
  border-color:#e5e7eb;
  border-bottom-left-radius:6px;
  color:#111827;
}

/* ===== Composer ===== */
.chat-compose,
.composer{
  display:flex;
  gap:8px;
  padding:10px;
  border-top:1px solid #eef2f7;
  background:#fff;
}

.chat-compose input,
.composer input{
  flex:1;
  padding:10px 12px;
  border:1px solid #d1d5db;
  border-radius:12px;
  outline:none;
  font-size:14px;
}

.chat-compose input:focus,
.composer input:focus{
  border-color:#22c55e;
  box-shadow:0 0 0 2px rgba(34,197,94,0.15);
}

/* Send button */
.send-btn,
.composer button{
  padding:10px 14px;
  border:none;
  border-radius:12px;
  background:#22c55e;
  color:#fff;
  cursor:pointer;
  font-weight:700;
}
.send-btn:hover,
.composer button:hover{ background:#16a34a; }

/* ===== Reset Button / Footer ===== */
.reset-btn{
  margin:10px;
  padding:8px 10px;
  border-radius:12px;
  border:1px solid #e5e7eb;
  background:#fff;
  cursor:pointer;
}
.reset-btn:hover{ background:#f9fafb; }

.footer{
  padding:10px 12px 12px;
  display:flex;
  justify-content:flex-end;
  background:#fafafa;
}

.link{
  background:transparent;
  border:none;
  color:#6b7280;
  cursor:pointer;
}
.link:hover{ color:#111827; }

/* ===== Typing / Loader ===== */
.typing {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 2px 0;
}

.typing span{
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #9ca3af;
  display: inline-block;
  animation: typingBounce 1.1s infinite ease-in-out;
}

.typing span:nth-child(2){ animation-delay: 0.15s; }
.typing span:nth-child(3){ animation-delay: 0.30s; }

@keyframes typingBounce{
  0%, 80%, 100% { transform: translateY(0); opacity: .55; }
  40% { transform: translateY(-4px); opacity: 1; }
}

.loader .dots { display:inline-flex; gap:6px; align-items:center; }
.loader .dots i{
  width:6px; height:6px; border-radius:999px; background:#6b7280;
  display:inline-block; animation: dotPulse 1s infinite ease-in-out;
}
.loader .dots i:nth-child(2){ animation-delay: .15s; }
.loader .dots i:nth-child(3){ animation-delay: .30s; }

@keyframes dotPulse{
  0%, 80%, 100% { transform: translateY(0); opacity:.35; }
  40% { transform: translateY(-3px); opacity: 1; }
}

/* ===== Links inside chat ===== */
.chat-link {
  color: #22c55e;
  font-weight: 600;
  text-decoration: none;
}
.chat-link:hover {
  text-decoration: underline;
}