/* ===== CIPH CHATBOT WIDGET ===== */

/* Floating trigger button */
#ciph-chat-btn {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9000;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, #71bf5c, #71bf5c);
  border: none;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(255, 79, 109, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
#ciph-chat-btn:hover {
  opacity: 0.92;
}
#ciph-chat-btn svg { width: 26px; height: 26px; }
#ciph-chat-btn .icon-close { display: none; }
#ciph-chat-btn.is-open .icon-chat  { display: none; }
#ciph-chat-btn.is-open .icon-close { display: block; }

/* Notification dot */
#ciph-chat-btn::after {
  content: '';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 10px;
  height: 10px;
  background: #0ABFA3;
  border-radius: 50%;
  border: 2px solid #fff;
}

#ciph-chat-btn.is-open::after { display: none; }

/* Chat panel */
#ciph-chat-panel {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 8999;
  width: 370px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 130px);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(21, 16, 43, 0.22);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
#ciph-chat-panel.is-open {
  display: flex;
}

/* Header */
.ciph-chat-head {
  background: linear-gradient(135deg, #15102B 0%, #1f1748 100%);
  padding: 18px 20px 16px;
  flex-shrink: 0;
}
.ciph-chat-head-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.ciph-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #71bf5c, #71bf5c);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}
.ciph-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.ciph-msg-avatar .ciph-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.ciph-chat-avatar::after {
  content: '';
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 9px;
  height: 9px;
  background: #0ABFA3;
  border-radius: 50%;
  border: 2px solid #15102B;
}
.ciph-chat-info h4 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  margin: 0 0 2px;
}
.ciph-chat-info span {
  font-family: 'Space Mono', monospace;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.5);
  letter-spacing: 0.06em;
}

/* Messages area */
.ciph-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ciph-chat-messages::-webkit-scrollbar { width: 4px; }
.ciph-chat-messages::-webkit-scrollbar-track { background: transparent; }
.ciph-chat-messages::-webkit-scrollbar-thumb { background: rgba(21,16,43,0.15); border-radius: 4px; }

/* Message bubbles */
.ciph-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  max-width: 90%;
}
.ciph-msg.bot { align-self: flex-start; }
.ciph-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.ciph-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #FF4F6D, #FFB35C);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.ciph-msg.user .ciph-msg-avatar {
  background: linear-gradient(135deg, #3B5BDB, #0ABFA3);
}

.ciph-msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.88rem;
  line-height: 1.55;
  max-width: 100%;
  word-break: break-word;
}
.ciph-msg.bot .ciph-msg-bubble {
  background: #F3F2F7;
  color: #15102B;
  border-bottom-left-radius: 4px;
}
.ciph-msg.user .ciph-msg-bubble {
  background: linear-gradient(135deg, #FF4F6D, #ff2d50);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ciph-msg-bubble a { color: #FF4F6D; text-decoration: underline; }
.ciph-msg.user .ciph-msg-bubble a { color: rgba(255,255,255,0.85); }

/* Typing indicator */
.ciph-typing {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  align-self: flex-start;
}
.ciph-typing-dots {
  background: #F3F2F7;
  padding: 12px 16px;
  border-radius: 16px 16px 16px 4px;
  display: flex;
  gap: 5px;
  align-items: center;
}
.ciph-typing-dots span {
  width: 6px;
  height: 6px;
  background: #15102B;
  border-radius: 50%;
  opacity: 0.5;
}

/* Quick reply chips */
.ciph-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 16px 8px;
  flex-shrink: 0;
}
.ciph-chip {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 13px;
  border-radius: 100px;
  border: 1.5px solid rgba(255, 79, 109, 0.4);
  background: rgba(255, 79, 109, 0.06);
  color: #FF4F6D;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.ciph-chip:hover {
  background: rgba(255, 79, 109, 0.14);
  border-color: #FF4F6D;
}

/* WhatsApp / Telegram contact bar */
.ciph-contact-bar {
  display: flex;
  gap: 8px;
  padding: 0 16px 10px;
  flex-shrink: 0;
}
.ciph-contact-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 10px;
  border-radius: 10px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  text-decoration: none;
  transition: opacity 0.15s, transform 0.15s;
}
.ciph-contact-btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.ciph-contact-btn:hover { opacity: 0.88; }
.ciph-contact-btn--wa {
  background: rgba(37, 211, 102, 0.12);
  color: #128C7E;
  border: 1.5px solid rgba(37, 211, 102, 0.35);
}
.ciph-contact-btn--tg {
  background: rgba(0, 136, 204, 0.1);
  color: #0088cc;
  border: 1.5px solid rgba(0, 136, 204, 0.3);
}
[data-theme="dark"] .ciph-contact-btn--wa { color: #25D366; }
[data-theme="dark"] .ciph-contact-btn--tg { color: #4db8ff; }

/* Input area */
.ciph-chat-footer {
  padding: 10px 12px 14px;
  border-top: 1px solid rgba(21,16,43,0.08);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: #fff;
}
#ciph-chat-input {
  flex: 1;
  border: 1.5px solid rgba(21,16,43,0.15);
  border-radius: 12px;
  padding: 9px 13px;
  font-family: 'Inter', sans-serif;
  font-size: 0.875rem;
  color: #15102B;
  resize: none;
  outline: none;
  max-height: 100px;
  min-height: 40px;
  line-height: 1.4;
  transition: border-color 0.2s;
  background: #fff;
}
#ciph-chat-input:focus { border-color: #FF4F6D; }
#ciph-chat-input::placeholder { color: rgba(21,16,43,0.4); }

#ciph-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #FF4F6D;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}
#ciph-chat-send:hover { opacity: 0.9; }
#ciph-chat-send:disabled { background: rgba(21,16,43,0.2); cursor: not-allowed; opacity: 0.6; }
#ciph-chat-send svg { width: 18px; height: 18px; }

/* Mobile adjustments */
@media (max-width: 480px) {
  #ciph-chat-panel { width: calc(100vw - 24px); right: 12px; bottom: 90px; }
  #ciph-chat-btn { right: 16px; bottom: 20px; }
}

/* ===== DARK THEME OVERRIDES ===== */
[data-theme="dark"] #ciph-chat-panel {
  background: #1A1630;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}
[data-theme="dark"] .ciph-msg.bot .ciph-msg-bubble {
  background: #2A2448;
  color: #EDE9FA;
}
[data-theme="dark"] .ciph-chat-footer {
  background: #1A1630;
  border-top-color: rgba(237, 233, 250, 0.08);
}
[data-theme="dark"] #ciph-chat-input {
  background: #2A2448;
  border-color: rgba(237, 233, 250, 0.14);
  color: #EDE9FA;
}
[data-theme="dark"] #ciph-chat-input::placeholder {
  color: rgba(237, 233, 250, 0.35);
}
[data-theme="dark"] .ciph-typing-dots {
  background: #2A2448;
}
[data-theme="dark"] .ciph-typing-dots span {
  background: #EDE9FA;
}
[data-theme="dark"] .ciph-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(237, 233, 250, 0.15);
}
