/* ==========================================================================
   CareFirst Dental Clinic - AI Patient Assistant ("Ask CareFirst") UI
   Ultra-Modern Floating AI Widget (Left Aligned, Elevated & Levitating)
   ========================================================================== */

/* ── Floating Launcher Container (Elevated from Bottom-Left) ── */
.cf-chat-launcher-container {
  position: fixed;
  bottom: 22px;
  left: 22px;
  right: auto;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

/* ── Proactive Welcome Callout Speech Bubble ── */
.cf-chat-callout {
  position: relative;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: #0B2545;
  padding: 10px 16px;
  border-radius: 16px;
  font-size: 0.84rem;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(8, 28, 51, 0.16), 0 0 0 1.5px rgba(2, 132, 199, 0.2);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 280px;
  cursor: pointer;
  opacity: 0;
  transform: translateY(12px) scale(0.92);
  pointer-events: none;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--cf-font-body, 'Inter', sans-serif);
}

.cf-chat-callout.show {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.cf-chat-callout::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 24px;
  width: 12px;
  height: 12px;
  background: #FFFFFF;
  transform: rotate(45deg);
  box-shadow: 2px 2px 3px rgba(8, 28, 51, 0.04);
}

.cf-callout-wave {
  font-size: 1.15rem;
  animation: cfHandWave 2.5s infinite;
  display: inline-block;
  transform-origin: 70% 70%;
}

.cf-chat-callout-close {
  background: transparent;
  border: none;
  color: #94A3B8;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  transition: color 0.2s ease;
}

.cf-chat-callout-close:hover {
  color: #EF4444;
}

/* ── Ultra-Modern Levitating Floating Launcher ── */
.cf-chat-launcher {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  background: linear-gradient(135deg, #0B2545 0%, #0284C7 100%);
  color: #FFFFFF;
  padding: 10px 20px 10px 12px;
  border-radius: 50px;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 14px 34px rgba(2, 132, 199, 0.35), 0 4px 12px rgba(8, 28, 51, 0.2);
  cursor: pointer;
  pointer-events: auto !important;
  z-index: 1050;
  font-family: var(--cf-font-nav, 'Plus Jakarta Sans', sans-serif);
  font-weight: 700;
  font-size: 0.92rem;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  animation: cfFloatingLevitate 4s infinite ease-in-out;
}

.cf-chat-launcher:hover {
  transform: translateY(-6px) scale(1.05) !important;
  box-shadow: 0 20px 45px rgba(2, 132, 199, 0.5), 0 6px 16px rgba(8, 28, 51, 0.25);
  background: linear-gradient(135deg, #0369A1 0%, #081C33 100%);
}

.cf-chat-launcher.is-open {
  background: #081C33;
  box-shadow: 0 8px 24px rgba(8, 28, 51, 0.3);
  animation: none;
}

/* Outer Glowing Aura Pulse */
.cf-launcher-ripple {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  border-radius: 50px;
  transform: translate(-50%, -50%);
  border: 2px solid rgba(56, 189, 248, 0.6);
  animation: cfAuraPulse 3s infinite cubic-bezier(0.25, 1, 0.5, 1);
  pointer-events: none;
}

/* Shimmer Highlight Gliding Across */
.cf-chat-launcher::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 60%;
  height: 100%;
  background: linear-gradient(
    120deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.3) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: cfShimmerLight 4.5s infinite ease-in-out;
}

/* Floating Orb Avatar */
.cf-chat-launcher-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  background: #FFFFFF;
  color: #0284C7;
  border-radius: 50%;
  font-size: 1.15rem;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
  transition: transform 0.3s ease;
}

.cf-chat-launcher-badge::after {
  content: '';
  position: absolute;
  top: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10B981;
  border: 2px solid #FFFFFF;
  box-shadow: 0 0 6px #10B981;
}

.cf-chat-launcher:hover .cf-chat-launcher-badge {
  transform: scale(1.1) rotate(6deg);
}

.cf-launcher-icon-emoji {
  font-size: 1.15rem;
  line-height: 1;
  display: inline-block;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
}

.cf-chat-launcher-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  transition: opacity 0.22s ease, transform 0.22s ease;
  min-width: 140px;
}

.cf-chat-launcher-text.cf-text-fade-out {
  opacity: 0;
  transform: translateY(-3px);
}

.cf-chat-launcher-text.cf-text-fade-in {
  opacity: 1;
  transform: translateY(0);
}

.cf-launcher-dynamic-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: #FFFFFF;
  white-space: nowrap;
  letter-spacing: -0.2px;
}

.cf-launcher-dynamic-sub {
  font-size: 0.68rem;
  color: #BAE6FD;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

/* ── Chat Main Panel Container (Elevated Above Launcher) ── */
.cf-chat-panel {
  position: fixed;
  bottom: 100px;
  left: 30px;
  right: auto;
  width: 410px;
  max-width: calc(100vw - 36px);
  height: 620px;
  max-height: calc(100vh - 140px);
  background: #FFFFFF;
  border-radius: 22px;
  border: 1px solid #E2E8F0;
  box-shadow: 0 28px 75px rgba(8, 28, 51, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1050;
  opacity: 0;
  visibility: hidden;
  transform: translateY(24px) scale(0.92);
  transform-origin: bottom left;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--cf-font-body, 'Inter', sans-serif);
}

.cf-chat-panel.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* ── Header ── */
.cf-chat-header {
  background: linear-gradient(135deg, #0B2545 0%, #081C33 100%);
  color: #FFFFFF;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid #0284C7;
}

.cf-chat-header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cf-chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #FFFFFF;
  padding: 2px;
  border: 2px solid #38BDF8;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cf-chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 50%;
}

.cf-chat-header-title {
  font-family: var(--cf-font-head, 'Outfit', sans-serif);
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.2;
  margin: 0;
  color: #FFFFFF;
}

.cf-chat-header-subtitle {
  font-size: 0.75rem;
  color: #BAE6FD;
  display: flex;
  align-items: center;
  gap: 5px;
}

.cf-chat-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10B981;
  box-shadow: 0 0 6px #10B981;
}

.cf-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cf-chat-header-btn {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #FFFFFF;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cf-chat-header-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  color: #38BDF8;
}

/* ── Chat Messages Body ── */
.cf-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #F8FAFC;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.cf-chat-body::-webkit-scrollbar {
  width: 5px;
}
.cf-chat-body::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 10px;
}

/* Message Rows */
.cf-chat-msg-row {
  display: flex;
  gap: 10px;
  width: 100%;
}

.cf-chat-msg-row.user {
  justify-content: flex-end;
}

.cf-chat-msg-row.assistant {
  justify-content: flex-start;
}

.cf-chat-msg-bubble {
  max-width: 86%;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.55;
  position: relative;
  word-wrap: break-word;
}

.cf-chat-msg-row.user .cf-chat-msg-bubble {
  background: #0284C7;
  color: #FFFFFF;
  border-bottom-right-radius: 4px;
}

.cf-chat-msg-row.assistant .cf-chat-msg-bubble {
  background: #FFFFFF;
  color: #1E293B;
  border: 1px solid #E2E8F0;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(8, 28, 51, 0.04);
}

.cf-chat-msg-time {
  font-size: 0.68rem;
  color: #94A3B8;
  margin-top: 4px;
  text-align: right;
}

/* Rich Cards inside Chat */
.cf-chat-card {
  background: #FFFFFF;
  border: 1.5px solid #E2E8F0;
  border-radius: 14px;
  padding: 14px;
  margin-top: 10px;
  box-shadow: 0 4px 12px rgba(8, 28, 51, 0.05);
}

.cf-chat-card-title {
  font-family: var(--cf-font-head, 'Outfit', sans-serif);
  font-weight: 800;
  font-size: 0.95rem;
  color: #0B2545;
  margin-bottom: 6px;
}

.cf-chat-card-price {
  font-size: 0.85rem;
  color: #0284C7;
  font-weight: 700;
  margin-bottom: 8px;
}

.cf-chat-card-btn {
  display: block;
  text-align: center;
  background: #0284C7;
  color: #FFFFFF;
  padding: 8px 12px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 700;
  font-size: 0.82rem;
  transition: background 0.2s ease;
  margin-top: 8px;
}

.cf-chat-card-btn:hover {
  background: #0369A1;
  color: #FFFFFF;
}

.cf-chat-card-btn.outline {
  background: transparent;
  color: #0284C7;
  border: 1px solid #0284C7;
}

.cf-chat-card-btn.outline:hover {
  background: #F0F9FF;
}

.cf-chat-card-btn.whatsapp {
  background: #25D366;
  color: #FFFFFF;
}

.cf-chat-card-btn.whatsapp:hover {
  background: #1EBE5D;
}

/* Quick Action Chips */
.cf-chat-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 16px;
  background: #F8FAFC;
  border-top: 1px solid #F1F5F9;
}

.cf-chat-chip {
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
  color: #0284C7;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.cf-chat-chip:hover {
  background: #0284C7;
  color: #FFFFFF;
  border-color: #0284C7;
}

/* Typing Indicator */
.cf-chat-typing-wrap {
  padding: 8px 16px 12px 16px;
  background: transparent;
  display: flex;
  align-items: center;
  animation: cfFadeIn 0.3s ease;
}

.cf-chat-typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #FFFFFF;
  border-radius: 18px;
  border: 1px solid #E2E8F0;
  box-shadow: 0 4px 14px rgba(8, 28, 51, 0.06);
  width: fit-content;
}

.cf-chat-panel img {
  max-width: 100%;
}

.cf-chat-typing-avatar {
  width: 22px !important;
  height: 22px !important;
  min-width: 22px !important;
  min-height: 22px !important;
  max-width: 22px !important;
  max-height: 22px !important;
  border-radius: 50% !important;
  overflow: hidden !important;
  background: #F1F5F9 !important;
  flex-shrink: 0 !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.cf-chat-typing-avatar img {
  width: 22px !important;
  height: 22px !important;
  max-width: 22px !important;
  max-height: 22px !important;
  object-fit: cover !important;
  display: block !important;
  border-radius: 50% !important;
}

.cf-chat-typing-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #0284C7;
  letter-spacing: -0.1px;
}

.cf-chat-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 2px;
}

.cf-chat-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #0284C7;
  animation: cfBounce 1.4s infinite ease-in-out both;
}

.cf-chat-dot:nth-child(1) { animation-delay: -0.32s; }
.cf-chat-dot:nth-child(2) { animation-delay: -0.16s; }

/* ── Rich Markdown Typography & Paragraphs in Chat Bubbles ── */
.cf-chat-msg-bubble {
  max-width: 88%;
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 0.92rem;
  line-height: 1.7;
  position: relative;
  word-wrap: break-word;
}

.cf-chat-msg-bubble p,
.cf-md-p {
  margin-top: 0;
  margin-bottom: 12px;
  line-height: 1.7;
}

.cf-chat-msg-bubble p:last-child,
.cf-md-p:last-child {
  margin-bottom: 0;
}

.cf-chat-msg-bubble strong,
.cf-md-bold {
  font-weight: 700;
  color: #0F172A;
}

.cf-chat-msg-row.user .cf-chat-msg-bubble strong {
  color: #FFFFFF;
  font-weight: 700;
}

.cf-md-heading {
  font-family: var(--cf-font-head, 'Outfit', sans-serif);
  font-weight: 800;
  color: #0B2545;
  font-size: 1rem;
  margin-top: 16px;
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid #F1F5F9;
  line-height: 1.4;
  display: block;
}

.cf-md-heading:first-child {
  margin-top: 0;
}

/* Key-Value Block Card */
.cf-md-card {
  background: #F8FAFC;
  border-left: 3.5px solid #0284C7;
  padding: 10px 14px;
  margin: 10px 0;
  border-radius: 0 10px 10px 0;
}

.cf-md-card-head {
  font-weight: 700;
  color: #0B2545;
  font-size: 0.92rem;
  margin-bottom: 4px;
}

.cf-md-card-body {
  color: #334155;
  font-size: 0.88rem;
  line-height: 1.6;
}

.cf-md-list {
  padding-left: 0;
  margin: 8px 0;
  list-style: none;
}

.cf-md-list-item {
  position: relative;
  padding-left: 18px;
  margin-bottom: 6px;
  line-height: 1.6;
}

.cf-md-list-item::before {
  content: '•';
  position: absolute;
  left: 3px;
  top: 0;
  color: #0284C7;
  font-weight: 900;
  font-size: 1.15rem;
  line-height: 1.3;
}

.cf-md-table-wrap {
  width: 100%;
  overflow-x: auto;
  margin: 12px 0;
  border-radius: 10px;
  border: 1px solid #E2E8F0;
  background: #FFFFFF;
}

.cf-md-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  text-align: left;
}

.cf-md-table th {
  background: #F8FAFC;
  color: #0F172A;
  font-weight: 700;
  padding: 9px 12px;
  border-bottom: 2px solid #E2E8F0;
  white-space: nowrap;
}

.cf-md-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #F1F5F9;
  color: #334155;
  vertical-align: top;
  line-height: 1.55;
}

.cf-md-table tr:last-child td {
  border-bottom: none;
}

.cf-md-table tr:hover td {
  background: #F0F9FF;
}

.cf-md-quote {
  border-left: 3px solid #0284C7;
  padding: 8px 14px;
  margin: 10px 0;
  background: #F0F9FF;
  border-radius: 0 8px 8px 0;
  color: #0369A1;
  font-size: 0.88rem;
  font-style: italic;
  line-height: 1.6;
}

.cf-md-hr {
  border: none;
  height: 1px;
  background: #E2E8F0;
  margin: 14px 0;
}

.cf-md-code-block {
  background: #0F172A;
  color: #E2E8F0;
  padding: 12px 14px;
  border-radius: 8px;
  font-family: monospace;
  font-size: 0.82rem;
  overflow-x: auto;
  margin: 10px 0;
}

/* Footer Input Bar */
.cf-chat-footer {
  padding: 12px 16px;
  background: #FFFFFF;
  border-top: 1px solid #E2E8F0;
}

.cf-chat-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
  border-radius: 25px;
  padding: 4px 6px 4px 14px;
  transition: border-color 0.2s ease;
}

.cf-chat-input-wrap:focus-within {
  border-color: #0284C7;
  background: #FFFFFF;
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

.cf-chat-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.88rem;
  color: #0F172A;
  font-family: inherit;
}

.cf-chat-send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #0284C7;
  color: #FFFFFF;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.cf-chat-send-btn:hover {
  background: #0369A1;
  transform: scale(1.05);
}

.cf-chat-send-btn:disabled {
  background: #CBD5E1;
  cursor: not-allowed;
  transform: none;
}

/* ── Keyframe Animations ── */
@keyframes cfFloatingLevitate {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-8px);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes cfAuraPulse {
  0% {
    opacity: 0.85;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.4);
  }
}

@keyframes cfShimmerLight {
  0% { left: -100%; }
  30% { left: 140%; }
  100% { left: 140%; }
}

@keyframes cfHandWave {
  0% { transform: rotate(0deg); }
  10% { transform: rotate(14deg); }
  20% { transform: rotate(-8deg); }
  30% { transform: rotate(14deg); }
  40% { transform: rotate(-4deg); }
  50% { transform: rotate(10deg); }
  60% { transform: rotate(0deg); }
  100% { transform: rotate(0deg); }
}

@keyframes cfBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* ── Mobile Responsive Overlay ── */
@media (max-width: 576px) {
  .cf-chat-launcher-container {
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    left: 14px;
    z-index: 1030;
  }
  .cf-chat-panel {
    bottom: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: 100vw;
    max-height: 100dvh;
    border-radius: 0;
    transform-origin: center;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
  .cf-chat-launcher {
    padding: 8px 14px 8px 10px;
    font-size: 0.84rem;
  }
  .cf-chat-input {
    font-size: 16px !important; /* Prevent iOS Safari auto-zoom */
  }
}
