/* ============================================================
   Sura Chatbot Widget — chatbot.css
   Brand colors: #006ea8 (dark) / #00a2d2 (primary) / #c9e8fb (light)
   ============================================================ */

#rc-chatbot-widget {
  --sura-primary: #00a2d2;
  --sura-dark: #006ea8;
  --sura-light: #c9e8fb;
  --sura-light-2: #e9f5fc;
  --sura-text: #1f2937;
  --sura-muted: #6b7280;
  --sura-border: #e5e7eb;
  --sura-shadow: 0 18px 50px rgba(0, 110, 168, 0.18), 0 4px 12px rgba(0, 0, 0, 0.06);
  --sura-radius: 20px;
  --sura-bubble-radius: 16px;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--sura-text);
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   LAUNCHER (closed-state floating button)
   ============================================================ */
#rc-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

#rc-launcher-btn {
  position: relative;
  width: 64px;
  height: 64px;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: linear-gradient(135deg, var(--sura-primary), var(--sura-dark));
  box-shadow: 0 10px 30px rgba(0, 110, 168, 0.35), 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

#rc-launcher-btn:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 16px 40px rgba(0, 110, 168, 0.45), 0 4px 12px rgba(0, 0, 0, 0.1);
}

#rc-launcher-btn::before {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sura-primary), var(--sura-dark));
  opacity: 0.35;
  z-index: -1;
  animation: sura-pulse 2.6s ease-in-out infinite;
}

@keyframes sura-pulse {
  0%, 100% { transform: scale(1); opacity: 0.35; }
  50% { transform: scale(1.18); opacity: 0; }
}

#rc-launcher-btn .rc-avatar-img {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.85);
  background: var(--sura-light);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#rc-launcher-btn .rc-close-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: white;
  opacity: 0;
  transition: opacity 0.2s ease;
  font-weight: 600;
}

#rc-chatbot-widget.rc-open #rc-launcher-btn::before {
  animation: none;
  opacity: 0;
}
#rc-chatbot-widget.rc-open #rc-launcher-btn .rc-avatar-img {
  opacity: 0;
  transform: scale(0.6);
}
#rc-chatbot-widget.rc-open #rc-launcher-btn .rc-close-icon {
  opacity: 1;
}

#rc-notification-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 14px;
  height: 14px;
  background: #ef4444;
  border: 2px solid white;
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s ease;
}
#rc-notification-badge.rc-visible {
  opacity: 1;
}
#rc-chatbot-widget.rc-open #rc-notification-badge { opacity: 0; }

/* Proactive bubble (peeks above launcher when closed) */
#rc-proactive-bubble {
  position: relative;
  background: white;
  color: var(--sura-text);
  font-size: 14px;
  font-weight: 500;
  padding: 12px 36px 12px 16px;
  border-radius: 16px 16px 4px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  max-width: 240px;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#rc-proactive-bubble.rc-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
#rc-chatbot-widget.rc-open #rc-proactive-bubble {
  opacity: 0 !important;
  pointer-events: none !important;
}

#rc-proactive-bubble::after {
  content: '';
  position: absolute;
  bottom: -6px;
  right: 22px;
  width: 14px;
  height: 14px;
  background: white;
  transform: rotate(45deg);
  box-shadow: 4px 4px 8px -2px rgba(0, 0, 0, 0.08);
}

#rc-proactive-dismiss {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: var(--sura-muted);
  cursor: pointer;
  border-radius: 50%;
  transition: background 0.15s ease;
}
#rc-proactive-dismiss:hover {
  background: var(--sura-light-2);
  color: var(--sura-text);
}

/* ============================================================
   CHAT WINDOW
   ============================================================ */
#rc-chat-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 130px);
  z-index: 1001;
  background: white;
  border-radius: var(--sura-radius);
  box-shadow: var(--sura-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.28s cubic-bezier(0.22, 1, 0.36, 1),
              transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  transform-origin: bottom right;
}

#rc-chatbot-widget.rc-open #rc-chat-window {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Header ── */
#rc-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, var(--sura-dark) 0%, var(--sura-primary) 100%);
  color: white;
  position: relative;
}

#rc-header::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top right, rgba(255, 255, 255, 0.18) 0%, transparent 60%);
  pointer-events: none;
}

.rc-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: white;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  position: relative;
  z-index: 1;
}
.rc-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.rc-header-info {
  flex: 1;
  min-width: 0;
  position: relative;
  z-index: 1;
}
.rc-header-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.2;
}
.rc-header-status {
  font-size: 12px;
  opacity: 0.88;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.rc-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.35);
  animation: sura-status-pulse 2s ease-in-out infinite;
}

@keyframes sura-status-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.35); }
  50% { box-shadow: 0 0 0 5px rgba(52, 211, 153, 0); }
}

#rc-header-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s ease, transform 0.18s ease;
  position: relative;
  z-index: 1;
  padding: 0;
}
#rc-header-close:hover {
  background: rgba(255, 255, 255, 0.28);
  transform: rotate(90deg);
}

/* ── Message area ── */
#rc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background:
    radial-gradient(circle at 20% 0%, var(--sura-light-2) 0%, transparent 40%),
    linear-gradient(180deg, #fafcfe 0%, white 100%);
  scroll-behavior: smooth;
}

#rc-messages::-webkit-scrollbar {
  width: 6px;
}
#rc-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 110, 168, 0.18);
  border-radius: 3px;
}
#rc-messages::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 110, 168, 0.32);
}

.rc-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
  animation: sura-msg-in 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes sura-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.rc-msg-row.rc-user {
  flex-direction: row-reverse;
}

.rc-msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  overflow: hidden;
  background: var(--sura-light);
}
.rc-msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.rc-msg-row.rc-user .rc-msg-avatar {
  background: var(--sura-light-2);
  font-size: 16px;
}

.rc-bubble {
  padding: 11px 15px;
  border-radius: var(--sura-bubble-radius);
  font-size: 14px;
  line-height: 1.55;
  max-width: calc(100% - 50px);
  word-wrap: break-word;
  position: relative;
}

.rc-msg-row.rc-bot .rc-bubble {
  background: white;
  color: var(--sura-text);
  border: 1px solid var(--sura-border);
  border-bottom-left-radius: 6px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.rc-msg-row.rc-user .rc-bubble {
  background: linear-gradient(135deg, var(--sura-primary), var(--sura-dark));
  color: white;
  border-bottom-right-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 110, 168, 0.22);
}

.rc-bubble a {
  color: var(--sura-dark);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.rc-msg-row.rc-user .rc-bubble a { color: white; }

.rc-bubble strong { font-weight: 700; }

/* Typing indicator */
#rc-typing-indicator {
  display: none;
}
#rc-typing-indicator.rc-visible {
  display: flex;
}
.rc-typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  height: 18px;
}
.rc-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sura-primary);
  opacity: 0.5;
  animation: sura-dot-bounce 1.3s infinite ease-in-out;
}
.rc-typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.rc-typing-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes sura-dot-bounce {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ── Quick-action buttons ── */
.rc-quick-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.rc-quick-btn {
  background: white;
  color: var(--sura-dark);
  border: 1.5px solid var(--sura-light);
  padding: 8px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.18s ease;
  font-family: inherit;
  white-space: nowrap;
}
.rc-quick-btn:hover {
  background: var(--sura-light-2);
  border-color: var(--sura-primary);
  color: var(--sura-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 110, 168, 0.12);
}
.rc-quick-btn:active {
  transform: translateY(0);
}
.rc-quick-btn.rc-btn-accent {
  background: linear-gradient(135deg, var(--sura-primary), var(--sura-dark));
  color: white;
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(0, 110, 168, 0.22);
}
.rc-quick-btn.rc-btn-accent:hover {
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0, 110, 168, 0.32);
}

/* ── Lead capture form ── */
.rc-lead-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  margin-left: 40px;
}
.rc-lead-form input,
.rc-lead-form textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--sura-border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: white;
  color: var(--sura-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
}
.rc-lead-form input:focus,
.rc-lead-form textarea:focus {
  outline: none;
  border-color: var(--sura-primary);
  box-shadow: 0 0 0 3px rgba(0, 162, 210, 0.18);
}
.rc-lead-submit {
  background: linear-gradient(135deg, var(--sura-primary), var(--sura-dark));
  color: white;
  border: none;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.rc-lead-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 110, 168, 0.30);
}

/* ── Input area ── */
#rc-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--sura-border);
  background: white;
}

#rc-input {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--sura-border);
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: inherit;
  line-height: 1.4;
  max-height: 100px;
  background: white;
  color: var(--sura-text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}
#rc-input::placeholder { color: var(--sura-muted); }
#rc-input:focus {
  border-color: var(--sura-primary);
  box-shadow: 0 0 0 3px rgba(0, 162, 210, 0.16);
}

#rc-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(135deg, var(--sura-primary), var(--sura-dark));
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
  box-shadow: 0 4px 12px rgba(0, 110, 168, 0.25);
}
#rc-send-btn:hover {
  transform: scale(1.06);
  box-shadow: 0 6px 16px rgba(0, 110, 168, 0.35);
}
#rc-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}
#rc-send-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  margin-left: 1px;
}

/* ============================================================
   MOBILE
   ============================================================ */
@media (max-width: 480px) {
  #rc-launcher {
    bottom: 16px;
    right: 16px;
  }
  #rc-launcher-btn {
    width: 56px;
    height: 56px;
  }
  #rc-launcher-btn .rc-avatar-img {
    width: 48px;
    height: 48px;
  }
  #rc-chat-window {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  #rc-proactive-bubble { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #rc-launcher-btn::before,
  .rc-status-dot,
  .rc-typing-dots span {
    animation: none !important;
  }
  #rc-chat-window,
  .rc-msg-row {
    transition: none !important;
    animation: none !important;
  }
}
