/* CheaperForex AI Chat Widget */

:root {
  --cfai-brand-1: #16a34a;
  --cfai-brand-2: #22c55e;
}

.cf-ai-launcher {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--cfai-brand-2) 0%, var(--cfai-brand-1) 100%);
  box-shadow: 0 6px 20px rgba(22,163,74,0.4), 0 2px 6px rgba(0,0,0,0.1);
  cursor: pointer;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  border: none;
}
.cf-ai-launcher:hover {
  transform: scale(1.06);
  box-shadow: 0 8px 24px rgba(22,163,74,0.5), 0 3px 8px rgba(0,0,0,0.12);
}
.cf-ai-launcher.cf-ai-open {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
}
.cf-ai-launcher-icon-close { display: none; }
.cf-ai-launcher.cf-ai-open .cf-ai-launcher-icon { display: none; }
.cf-ai-launcher.cf-ai-open .cf-ai-launcher-icon-close { display: block; }

.cf-ai-pulse {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  border-radius: 50%;
  background: rgba(34,197,94,0.45);
  animation: cfAiPulse 2.2s ease-out infinite;
  pointer-events: none;
}
.cf-ai-launcher.cf-ai-open .cf-ai-pulse { display: none; }
@keyframes cfAiPulse {
  0% { transform: scale(1); opacity: 0.7; }
  70%, 100% { transform: scale(1.45); opacity: 0; }
}

.cf-ai-panel {
  position: fixed;
  bottom: 100px;
  right: 24px;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 130px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9998;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.cf-ai-panel.cf-ai-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.cf-ai-header {
  background: linear-gradient(135deg, var(--cfai-brand-1) 0%, #15803d 100%);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
}
.cf-ai-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cf-ai-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.cf-ai-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}
.cf-ai-subtitle {
  font-size: 12px;
  opacity: 0.9;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cf-ai-status-dot {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(74,222,128,0.7);
  animation: cfAiDotPulse 2s infinite;
}
@keyframes cfAiDotPulse {
  0% { box-shadow: 0 0 0 0 rgba(74,222,128,0.7); }
  70% { box-shadow: 0 0 0 6px rgba(74,222,128,0); }
  100% { box-shadow: 0 0 0 0 rgba(74,222,128,0); }
}
.cf-ai-close,
button.cf-ai-close {
  background: transparent !important;
  border: none !important;
  color: #fff !important;
  cursor: pointer;
  padding: 4px !important;
  border-radius: 6px !important;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
  transition: opacity 0.2s, background 0.2s;
  box-shadow: none !important;
}
.cf-ai-close:hover { opacity: 1; background: rgba(255,255,255,0.15) !important; }

.cf-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8fafc;
}
.cf-ai-msg {
  display: flex;
  max-width: 85%;
}
.cf-ai-msg-bot { align-self: flex-start; }
.cf-ai-msg-user { align-self: flex-end; }
.cf-ai-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
}
.cf-ai-msg-bot .cf-ai-bubble {
  background: #fff;
  color: #111827;
  border: 1px solid #e5e7eb;
  border-bottom-left-radius: 4px;
}
.cf-ai-msg-user .cf-ai-bubble {
  background: linear-gradient(135deg, var(--cfai-brand-2) 0%, var(--cfai-brand-1) 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.cf-ai-msg-bot .cf-ai-bubble a {
  color: var(--cfai-brand-1);
  text-decoration: underline;
}

.cf-ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.cf-ai-chip,
button.cf-ai-chip {
  background: #fff !important;
  border: 1px solid #d1d5db !important;
  color: var(--cfai-brand-1) !important;
  padding: 7px 12px !important;
  border-radius: 18px !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit !important;
  line-height: 1.2 !important;
  box-shadow: none !important;
}
.cf-ai-chip:hover {
  background: #f0fdf4 !important;
  border-color: var(--cfai-brand-1) !important;
  transform: translateY(-1px);
}
.cf-ai-chips.cf-ai-chips-hidden { display: none; }

.cf-ai-typing {
  display: none;
  padding: 0 18px 4px;
  align-items: center;
  gap: 4px;
  background: #f8fafc;
}
.cf-ai-typing.cf-ai-active { display: flex; }
.cf-ai-typing span {
  width: 7px;
  height: 7px;
  background: #9ca3af;
  border-radius: 50%;
  animation: cfAiTyping 1.4s infinite ease-in-out;
}
.cf-ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.cf-ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes cfAiTyping {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}

.cf-ai-input-row {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
}
#cf-ai-input {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 22px;
  padding: 10px 16px;
  /* iOS Safari auto-zooms any input under 16px. Keep at 16px to prevent zoom. */
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  background: #fff;
  color: #111827;
}
#cf-ai-input:focus {
  border-color: var(--cfai-brand-1);
  box-shadow: 0 0 0 3px rgba(22,163,74,0.12);
}
.cf-ai-send,
button.cf-ai-send {
  width: 40px;
  height: 40px;
  border-radius: 50% !important;
  background: linear-gradient(135deg, var(--cfai-brand-2) 0%, var(--cfai-brand-1) 100%) !important;
  border: none !important;
  color: #fff !important;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(22,163,74,0.3) !important;
  padding: 0 !important;
}
.cf-ai-send:hover { transform: scale(1.05); }
.cf-ai-send:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.cf-ai-privacy {
  padding: 8px 14px;
  font-size: 11px;
  color: #6b7280;
  text-align: center;
  background: #f8fafc;
  border-top: 1px solid #f3f4f6;
  line-height: 1.4;
}

.cf-ai-footer {
  padding: 8px 14px;
  font-size: 11px;
  color: #6b7280;
  text-align: center;
  background: #fff;
  border-top: 1px solid #f3f4f6;
}
.cf-ai-footer a {
  color: var(--cfai-brand-1);
  text-decoration: none;
  font-weight: 600;
}
.cf-ai-footer a:hover { text-decoration: underline; }

@media (max-width: 600px) {
  /* Hide the launcher bubble entirely while the panel is open on mobile.
     The X in the panel header is the only close affordance needed,
     and this stops the launcher overlapping the send button. */
  .cf-ai-launcher.cf-ai-open { display: none; }

  .cf-ai-launcher { bottom: 84px; right: 16px; width: 54px; height: 54px; }
  .cf-ai-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }
  body.cf-sticky-active .cf-ai-launcher { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
}

body.cf-sticky-active .cf-ai-launcher { bottom: 96px; }
body.cf-sticky-active .cf-ai-panel { bottom: 170px; }
@media (max-width: 600px) {
  body.cf-sticky-active .cf-ai-panel {
    bottom: 0;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
  }
}