/* Cardwell Chatbot Widget Styles */

/* ── Reset for widget scope ─────────────────────────────────────────── */
#cw-chatbot *, #cw-chatbot *::before, #cw-chatbot *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── Floating Bubble ────────────────────────────────────────────────── */
#cw-chatbot-bubble-wrap {
  position: fixed;
  bottom: 6px;
  right: 6px;
  width: 120px;
  height: 120px;
  z-index: 99999;
  cursor: pointer;
}
#cw-chatbot-bubble {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid #250c64;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(37, 12, 100, 0.35);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: cw-pulse 3s ease-in-out infinite;
}
#cw-chatbot-bubble-wrap:hover #cw-chatbot-bubble {
  transform: translate(-50%, -50%) scale(1.08);
  box-shadow: 0 6px 28px rgba(37, 12, 100, 0.5);
}
#cw-chatbot-ring {
  position: absolute;
  top: 0;
  left: 0;
  width: 120px;
  height: 120px;
  animation: cw-ring-spin 18s linear infinite;
  pointer-events: none;
}
#cw-chatbot-ring svg {
  filter: drop-shadow(0 0 3px rgba(255,255,255,0.9)) drop-shadow(0 0 6px rgba(255,255,255,0.5));
}
#cw-chatbot-bubble-wrap:hover #cw-chatbot-ring {
  animation-play-state: paused;
}
@keyframes cw-ring-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
#cw-chatbot-bubble img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
@keyframes cw-pulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(37, 12, 100, 0.35); }
  50% { box-shadow: 0 4px 20px rgba(37, 12, 100, 0.55), 0 0 0 8px rgba(37, 12, 100, 0.1); }
}

/* ── Chat Panel ─────────────────────────────────────────────────────── */
#cw-chatbot-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  height: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
  z-index: 99998;
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
#cw-chatbot-panel.cw-open {
  display: flex;
}

/* ── Header ─────────────────────────────────────────────────────────── */
#cw-chatbot-header {
  background: #250c64;
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#cw-chatbot-header img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.3);
  object-fit: cover;
}
#cw-chatbot-header-info {
  flex: 1;
}
#cw-chatbot-header-name {
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}
#cw-chatbot-header-sub {
  font-size: 12px;
  opacity: 0.8;
}
#cw-chatbot-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  opacity: 0.7;
  transition: opacity 0.15s;
}
#cw-chatbot-close:hover { opacity: 1; }

/* ── Messages ───────────────────────────────────────────────────────── */
#cw-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f9fafb;
}
.cw-msg-wrapper {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}
.cw-msg-wrapper-user {
  align-self: flex-end;
  align-items: flex-end;
}
.cw-msg-name {
  font-size: 11px;
  font-weight: 600;
  color: #9ca3af;
  margin-bottom: 3px;
  padding: 0 4px;
}
.cw-msg-name-user {
  text-align: right;
}
.cw-msg {
  max-width: 82%;
  padding: 16px 22px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
  overflow-wrap: anywhere;
  animation: cw-fadein 0.2s ease;
}
.cw-msg-wrapper .cw-msg {
  max-width: 100%;
}
.cw-msg-bot {
  align-self: flex-start;
  background: #fff;
  color: #1d2240;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 8px;
}
.cw-msg-user {
  align-self: flex-end;
  background: #ce0d2d;
  color: #fff;
  border-bottom-right-radius: 8px;
}
.cw-msg-typing {
  align-self: flex-start;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 8px;
  color: #9ca3af;
  font-style: italic;
  font-size: 13px;
}
@keyframes cw-fadein {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Lead Capture Form ──────────────────────────────────────────────── */
#cw-chatbot-form {
  padding: 14px 16px;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  display: none;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
#cw-chatbot-form.cw-show { display: flex; }
#cw-chatbot-form label {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
}
#cw-chatbot-form input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
#cw-chatbot-form input:focus {
  border-color: #250c64;
}
#cw-chatbot-form-submit {
  background: #250c64;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
#cw-chatbot-form-submit:hover { background: #3a1a8a; }
#cw-chatbot-form-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Input bar ──────────────────────────────────────────────────────── */
#cw-chatbot-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  flex-shrink: 0;
}
#cw-chatbot-input {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
#cw-chatbot-input:focus {
  border-color: #250c64;
}
#cw-chatbot-send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #ce0d2d;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
#cw-chatbot-send:hover { background: #a80b24; }
#cw-chatbot-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Powered-by ─────────────────────────────────────────────────────── */
#cw-chatbot-footer {
  text-align: center;
  padding: 6px;
  font-size: 10px;
  color: #9ca3af;
  background: #fff;
  flex-shrink: 0;
}
#cw-chatbot-footer a {
  color: #6366f1;
  text-decoration: none;
}

/* ── Mobile ─────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #cw-chatbot-panel {
    width: calc(100vw - 16px);
    height: calc(100vh - 120px);
    bottom: 88px;
    right: 8px;
    border-radius: 12px;
  }
  #cw-chatbot-bubble {
    bottom: 16px;
    right: 16px;
  }
}
