/* CTM Chat Widget — matches existing CTM purple brand (#0d1b4b → #5c1a8a) */

/* ── Floating bubble ─────────────────────────────────────────────────────── */
/*
 * Positioned at bottom:90px to clear the Side Cart basket button which sits at
 * bottom:12px with a 64px height (12 + 64 + 14px gap = 90px).
 * Both bubble and panel use right:20px to align cleanly above the basket.
 */
#ctm-chat-bubble {
  position: fixed;
  bottom: 90px;
  right: 20px;
  z-index: 9990;
  height: 46px;
  width: auto;
  border-radius: 23px;
  padding: 0 16px 0 12px;
  gap: 8px;
  background: linear-gradient(135deg, #3b1278 0%, #5c1a8a 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(92,26,138,0.5);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  user-select: none;
  white-space: nowrap;
}
#ctm-chat-bubble:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(92,26,138,0.65);
}
#ctm-chat-bubble.ctm-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8);
}
.ctm-chat-label {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1;
}

/* ── Chat panel ──────────────────────────────────────────────────────────── */
#ctm-chat-panel {
  position: fixed;
  bottom: 148px; /* bubble bottom(90) + bubble height(46) + 12px gap */
  right: 20px;
  z-index: 9991;
  width: 340px;
  height: 490px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.22), 0 2px 8px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Closed state */
  opacity: 0;
  transform: scale(0.92) translateY(16px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
#ctm-chat-panel.ctm-open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: all;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
#ctm-chat-header {
  flex-shrink: 0;
  background: linear-gradient(135deg, #0d1b4b 0%, #1a1060 40%, #3b1278 70%, #5c1a8a 100%);
  color: #fff;
  padding: 13px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: 'Segoe UI', system-ui, sans-serif;
}
#ctm-chat-header-text {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
}
#ctm-chat-close {
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.75);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  transition: color 0.15s;
}
#ctm-chat-close:hover { color: #fff; }

/* ── Message list ────────────────────────────────────────────────────────── */
#ctm-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  scroll-behavior: smooth;
}
#ctm-chat-messages::-webkit-scrollbar { width: 4px; }
#ctm-chat-messages::-webkit-scrollbar-track { background: transparent; }
#ctm-chat-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

.ctm-msg {
  max-width: 85%;
  padding: 9px 13px;
  border-radius: 14px;
  word-break: break-word;
  white-space: pre-wrap;
}
.ctm-msg-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #3b1278, #5c1a8a);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ctm-msg-bot {
  align-self: flex-start;
  background: #f1f0f5;
  color: #1d2327;
  border-bottom-left-radius: 4px;
}

/* Typing indicator */
.ctm-typing {
  align-self: flex-start;
  background: #f1f0f5;
  padding: 10px 14px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  display: flex;
  gap: 5px;
  align-items: center;
}
.ctm-typing span {
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #9b6ec4;
  border-radius: 50%;
  animation: ctm-dot-bounce 1.2s ease-in-out infinite;
}
.ctm-typing span:nth-child(2) { animation-delay: 0.2s; }
.ctm-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ctm-dot-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-7px); }
}

/* ── Email verification mini-form ────────────────────────────────────────── */
#ctm-chat-verify-form {
  flex-shrink: 0;
  border-top: 1px solid #eee;
  background: #f8f7fb;
  padding: 11px 14px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 12px;
  color: #3d3d4d;
}
#ctm-chat-verify-form p {
  margin: 0 0 8px;
  font-weight: 600;
  color: #1d2327;
}
#ctm-chat-verify-form input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  padding: 7px 10px;
  margin-bottom: 7px;
  border: 1px solid #d0cfe0;
  border-radius: 7px;
  font-size: 12px;
  font-family: inherit;
  transition: border-color 0.15s;
}
#ctm-chat-verify-form input:focus {
  outline: none;
  border-color: #5c1a8a;
}
#ctm-verify-submit {
  width: 100%;
  background: linear-gradient(135deg, #3b1278, #5c1a8a);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s;
}
#ctm-verify-submit:hover { opacity: 0.9; }

/* ── Input row ───────────────────────────────────────────────────────────── */
#ctm-chat-input-row {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #eee;
  background: #fff;
}
#ctm-chat-input {
  flex: 1;
  border: 1px solid #d0cfe0;
  border-radius: 20px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  outline: none;
  transition: border-color 0.15s;
  background: #fafafa;
}
#ctm-chat-input:focus {
  border-color: #5c1a8a;
  background: #fff;
}
#ctm-chat-send {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b1278, #5c1a8a);
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s;
}
#ctm-chat-send:hover  { transform: scale(1.1); }
#ctm-chat-send:active { transform: scale(0.96); }
#ctm-chat-send:disabled { opacity: 0.45; cursor: default; transform: none; }

/* ── Mobile: full-width bottom sheet ─────────────────────────────────────── */
@media (max-width: 480px) {
  #ctm-chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 72vh;
    border-radius: 18px 18px 0 0;
  }
  #ctm-chat-bubble {
    bottom: 86px; /* same logic on mobile: clear the cart basket */
    right: 16px;
  }
}
