/* =======================================================
   Ceylon Secure Network — Chatbot Widget
   HARDCODED values — works even if CSS variables fail
   ======================================================= */

/* ── Floating button ──────────────────────────────────── */
#csn-chat-widget {
  position: fixed !important;
  bottom: 24px !important;
  right: 24px !important;
  z-index: 9000 !important;
  font-family: 'DM Sans', Arial, sans-serif !important;
  line-height: 1.4 !important;
}

#csn-chat-btn {
  position: relative;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #C9A84C, #b8922e);
  color: #000;
  border: none;
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(201,168,76,.5), 0 2px 8px rgba(0,0,0,.2);
  transition: transform .25s ease, box-shadow .25s ease;
  outline: none;
}
#csn-chat-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(201,168,76,.65);
}
#csn-chat-btn.active {
  background: linear-gradient(135deg, #2d3748, #1a202c);
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}
/* Pulse ring */
#csn-chat-btn::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(201,168,76,.35);
  animation: cwnPulse 2.5s ease infinite;
  pointer-events: none;
}
#csn-chat-btn.active::after { display: none; }
@keyframes cwnPulse {
  0%   { transform: scale(1);    opacity: .6; }
  70%  { transform: scale(1.28); opacity: 0;  }
  100% { transform: scale(1.28); opacity: 0;  }
}

/* Unread badge */
#cwUnreadBadge {
  position: absolute;
  top: -3px;
  right: -3px;
  background: #e53e3e;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  padding: 0 4px;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  line-height: 1;
}

/* ── Chat box ─────────────────────────────────────────── */
#csn-chat-box {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 340px;
  background: #12121a;
  border: 1px solid #23233a;
  border-radius: 18px;
  box-shadow: 0 16px 56px rgba(0,0,0,.65), 0 4px 16px rgba(0,0,0,.3);
  display: flex !important;
  flex-direction: column;
  overflow: hidden;
  max-height: 510px;
  min-height: 200px;
  /* Hidden by default via opacity + pointer-events */
  opacity: 0;
  pointer-events: none;
  transform: scale(.9) translateY(8px);
  transform-origin: bottom right;
  transition: opacity .22s ease, transform .22s cubic-bezier(.34,1.4,.64,1);
}
#csn-chat-box.open {
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: scale(1) translateY(0) !important;
}

/* ── Header ───────────────────────────────────────────── */
.cw-header {
  background: linear-gradient(135deg, #0c0c14 0%, #171730 100%);
  padding: 13px 15px;
  display: flex !important;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  position: relative;
}
.cw-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #C9A84C, #8a6820);
  display: flex !important;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 2px solid rgba(201,168,76,.3);
}
.cw-header-info { flex: 1; min-width: 0; }
.cw-header-name {
  font-weight: 700;
  font-size: 13px;
  color: #fff !important;
  display: flex !important;
  align-items: center;
  gap: 6px;
  font-family: 'DM Sans', Arial, sans-serif;
}
.cw-badge {
  background: rgba(201,168,76,.18);
  border: 1px solid rgba(201,168,76,.4);
  color: #C9A84C;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.cw-status {
  font-size: 11px;
  color: #48bb78 !important;
  display: flex !important;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
  font-family: 'DM Sans', Arial, sans-serif;
}
.cw-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #48bb78;
  flex-shrink: 0;
  display: inline-block;
  animation: cwnOnline 2s ease infinite;
}
@keyframes cwnOnline {
  0%, 100% { box-shadow: 0 0 3px #48bb78; }
  50%       { box-shadow: 0 0 9px #48bb78; }
}
.cw-close-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.1);
  color: rgba(255,255,255,.55);
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  transition: background .15s, color .15s;
  flex-shrink: 0;
  outline: none;
}
.cw-close-btn:hover {
  background: rgba(229,62,62,.2);
  color: #fc8181;
  border-color: rgba(229,62,62,.3);
}

/* ── Messages area ────────────────────────────────────── */
.cw-messages {
  flex: 1;
  overflow-y: auto !important;
  overflow-x: hidden;
  padding: 14px;
  display: flex !important;
  flex-direction: column;
  gap: 9px;
  min-height: 160px;
  max-height: 260px;
  background: #0b0b12;
  scroll-behavior: smooth;
}
.cw-messages::-webkit-scrollbar { width: 3px; }
.cw-messages::-webkit-scrollbar-track { background: transparent; }
.cw-messages::-webkit-scrollbar-thumb { background: #2d2d4a; border-radius: 2px; }

/* Message rows */
.cw-msg {
  display: flex !important;
  flex-direction: column;
  max-width: 88%;
  gap: 3px;
}
.cw-msg.from-customer { align-self: flex-end; align-items: flex-end; }
.cw-msg.from-bot,
.cw-msg.from-admin    { align-self: flex-start; align-items: flex-start; }

/* Bubbles */
.cw-bubble {
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
  font-family: 'DM Sans', Arial, sans-serif;
}
.from-customer .cw-bubble {
  background: linear-gradient(135deg, #C9A84C, #b8922e) !important;
  color: #000 !important;
  border-bottom-right-radius: 4px;
  font-weight: 500;
}
.from-bot .cw-bubble {
  background: #1e1e30 !important;
  color: #e8e8f0 !important;
  border: 1px solid #2a2a40;
  border-bottom-left-radius: 4px;
}
.from-admin .cw-bubble {
  background: rgba(201,168,76,.1) !important;
  color: #e8e8f0 !important;
  border: 1px solid rgba(201,168,76,.28);
  border-bottom-left-radius: 4px;
}
.cw-time {
  font-size: 10px;
  color: #4a4a6a;
  display: block;
  font-family: 'DM Sans', Arial, sans-serif;
}
.from-customer .cw-time { text-align: right; }

/* Typing dots */
.cw-typing {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 9px 12px;
  background: #1e1e30;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  border: 1px solid #2a2a40;
  width: fit-content;
  align-self: flex-start;
}
.cw-typing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #5a5a7a;
  animation: cwnTypeDot 1.3s ease infinite;
}
.cw-typing span:nth-child(2) { animation-delay: .18s; }
.cw-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes cwnTypeDot {
  0%, 80%, 100% { transform: scale(.6); opacity: .35; }
  40%           { transform: scale(1);  opacity: 1;   }
}

/* ── Quick replies ────────────────────────────────────── */
.cw-quick-replies {
  padding: 7px 12px;
  display: flex !important;
  gap: 5px;
  flex-wrap: wrap;
  border-top: 1px solid #1e1e30;
  flex-shrink: 0;
  background: #12121a;
}
.cw-qr-btn {
  padding: 5px 11px;
  border-radius: 100px;
  border: 1px solid rgba(201,168,76,.4);
  background: rgba(201,168,76,.07);
  color: #C9A84C !important;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s, transform .15s;
  white-space: nowrap;
  font-family: 'DM Sans', Arial, sans-serif;
  outline: none;
}
.cw-qr-btn:hover {
  background: #C9A84C !important;
  color: #000 !important;
  border-color: #C9A84C;
  transform: translateY(-1px);
}

/* ── Input area ───────────────────────────────────────── */
.cw-input-area {
  padding: 10px 12px;
  border-top: 1px solid #1e1e30;
  display: flex !important;
  gap: 7px;
  align-items: center;
  flex-shrink: 0;
  background: #12121a;
}
#cwInput {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid #2a2a40;
  border-radius: 100px;
  background: #1a1a28;
  color: #e8e8f0 !important;
  font-size: 13px;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
  font-family: 'DM Sans', Arial, sans-serif;
  min-width: 0;
}
#cwInput:focus {
  border-color: #C9A84C;
  box-shadow: 0 0 0 3px rgba(201,168,76,.12);
}
#cwInput::placeholder { color: #3a3a55; }
#cwInput:disabled { opacity: .45; cursor: not-allowed; }
#cwSendBtn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, #C9A84C, #b8922e);
  color: #000;
  border: none;
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  transition: transform .18s, box-shadow .18s;
  flex-shrink: 0;
  outline: none;
}
#cwSendBtn:hover {
  transform: scale(1.1);
  box-shadow: 0 3px 12px rgba(201,168,76,.4);
}
#cwSendBtn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Onboarding form ──────────────────────────────────── */
.cw-onboard {
  padding: 18px 15px;
  background: #0b0b12;
  display: flex !important;
  flex-direction: column;
  gap: 10px;
}
.cw-onboard h3 {
  font-family: 'Sora', 'DM Sans', Arial, sans-serif;
  font-size: 14px;
  color: #fff !important;
  font-weight: 700;
  margin: 0;
}
.cw-onboard p {
  font-size: 12px;
  color: #6868a0 !important;
  line-height: 1.6;
  margin: 0;
  font-family: 'DM Sans', Arial, sans-serif;
}
.cw-onboard-input {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid #2a2a40;
  border-radius: 9px;
  background: #1a1a28;
  color: #e8e8f0 !important;
  font-size: 13px;
  outline: none;
  font-family: 'DM Sans', Arial, sans-serif;
  transition: border-color .18s;
  box-sizing: border-box;
}
.cw-onboard-input:focus { border-color: #C9A84C; }
.cw-onboard-input::placeholder { color: #3a3a55; }
.cw-start-btn {
  width: 100%;
  padding: 11px;
  border-radius: 9px;
  border: none;
  background: linear-gradient(135deg, #C9A84C, #b8922e);
  color: #000 !important;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  font-family: 'DM Sans', Arial, sans-serif;
  transition: transform .18s, box-shadow .18s;
  outline: none;
}
.cw-start-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(201,168,76,.4);
}
.cw-skip-link {
  background: none;
  border: none;
  color: #4a4a6a;
  font-size: 11px;
  cursor: pointer;
  font-family: 'DM Sans', Arial, sans-serif;
  display: block;
  margin: 0 auto;
  transition: color .15s;
  outline: none;
  padding: 2px;
}
.cw-skip-link:hover { color: #C9A84C; }

/* ── Responsive ───────────────────────────────────────── */
@media (max-width: 480px) {
  #csn-chat-widget { bottom: 14px !important; right: 12px !important; }
  #csn-chat-box    { width: calc(100vw - 24px) !important; right: -8px; bottom: 66px; max-height: 78vh; border-radius: 14px; }
  #csn-chat-btn    { width: 52px; height: 52px; }
  .cw-bubble       { font-size: 12px; }
  .cw-messages     { max-height: 240px; }
}
