/**
 * 559CCW AI Chat Widget - Front-end Stylesheet
 * Scoped strictly under #ccw-chat-widget to prevent theme collision.
 * Dynamically inherits active WordPress theme design tokens.
 */

:root {
  --ccw-theme-primary: var(--wp--preset--color--primary, #1e3a8a);
  --ccw-theme-primary-hover: var(--wp--preset--color--primary-hover, #172554);
  --ccw-theme-icon-color: #ffffff;
  --ccw-theme-badge-color: #10b981;
  --ccw-theme-contrast: var(--wp--preset--color--contrast, #0f172a);
  --ccw-theme-bg: var(--wp--preset--color--background, #ffffff);
  --ccw-theme-font: var(
    --wp--preset--font-family--body,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Oxygen,
    Ubuntu,
    Cantarell,
    "Helvetica Neue",
    sans-serif
  );
}

#ccw-chat-widget {
  position: fixed !important;
  z-index: 2147483647 !important; /* Maximum 32-bit integer z-index: ensures widget is always on top */
  font-family: var(--ccw-theme-font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ccw-theme-contrast);
  box-sizing: border-box !important;
  -webkit-font-smoothing: antialiased;
  display: block !important;
  visibility: visible !important;
  opacity: 1 !important;
  margin: 0 !important;
  padding: 0 !important;
  pointer-events: auto !important;
  direction: ltr;
}

#ccw-chat-widget *,
#ccw-chat-widget *::before,
#ccw-chat-widget *::after {
  box-sizing: inherit;
  margin: 0;
  padding: 0;
}

/* Position Presets with Safe Area Inset Support */
#ccw-chat-widget.ccw-pos-bottom-right {
  bottom: 24px !important;
  right: 24px !important;
  left: auto !important;
  top: auto !important;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px)) !important;
  right: calc(24px + env(safe-area-inset-right, 0px)) !important;
}

#ccw-chat-widget.ccw-pos-bottom-left {
  bottom: 24px !important;
  left: 24px !important;
  right: auto !important;
  top: auto !important;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px)) !important;
  left: calc(24px + env(safe-area-inset-left, 0px)) !important;
}

/* Launcher Button Base */
#ccw-chat-widget .ccw-launcher-btn {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--ccw-theme-primary);
  color: var(--ccw-theme-icon-color, #ffffff);
  border: none;
  cursor: pointer;
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(255, 255, 255, 0.15) inset;
  transition:
    transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.25s ease,
    background-color 0.2s ease,
    width 0.35s cubic-bezier(0.34, 1.56, 0.64, 1),
    padding 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  outline: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  z-index: 10;
  visibility: visible !important;
  opacity: 1 !important;
}

#ccw-chat-widget .ccw-launcher-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  background: var(--ccw-theme-primary-hover);
}

#ccw-chat-widget .ccw-launcher-btn:focus-visible {
  box-shadow:
    0 0 0 3px rgba(30, 58, 138, 0.45),
    0 6px 20px rgba(0, 0, 0, 0.25);
}

/* Sizing Presets */
#ccw-chat-widget.ccw-size-compact
  .ccw-launcher-btn:not(.ccw-launcher-pill-text) {
  width: 52px;
  height: 52px;
  border-radius: 50%;
}
#ccw-chat-widget.ccw-size-standard
  .ccw-launcher-btn:not(.ccw-launcher-pill-text) {
  width: 60px;
  height: 60px;
  border-radius: 50%;
}
#ccw-chat-widget.ccw-size-large .ccw-launcher-btn:not(.ccw-launcher-pill-text) {
  width: 68px;
  height: 68px;
  border-radius: 50%;
}

#ccw-chat-widget .ccw-launcher-icon-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: relative;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

#ccw-chat-widget.ccw-size-compact .ccw-launcher-icon-wrap {
  width: 24px;
  height: 24px;
}
#ccw-chat-widget.ccw-size-large .ccw-launcher-icon-wrap {
  width: 32px;
  height: 32px;
}

#ccw-chat-widget .ccw-launcher-icon,
#ccw-chat-widget .ccw-launcher-close-icon {
  width: 100%;
  height: 100%;
  fill: currentColor;
  transition:
    transform 0.25s ease,
    opacity 0.25s ease;
  position: absolute;
}

#ccw-chat-widget .ccw-launcher-close-icon {
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}

#ccw-chat-widget.ccw-is-open .ccw-launcher-icon {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}

#ccw-chat-widget.ccw-is-open .ccw-launcher-close-icon {
  opacity: 1;
  transform: rotate(0) scale(1);
}

/* Launcher Layout: Pill Text & Pill Hover */
#ccw-chat-widget .ccw-launcher-pill-text {
  width: auto;
  height: 58px;
  border-radius: 29px;
  padding: 0 20px 0 16px;
  gap: 10px;
}

#ccw-chat-widget.ccw-size-compact .ccw-launcher-pill-text {
  height: 50px;
  border-radius: 25px;
  padding: 0 16px 0 14px;
  gap: 8px;
}

#ccw-chat-widget.ccw-size-large .ccw-launcher-pill-text {
  height: 66px;
  border-radius: 33px;
  padding: 0 24px 0 18px;
  gap: 12px;
}

#ccw-chat-widget .ccw-launcher-label {
  color: var(--ccw-theme-icon-color, #ffffff);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  letter-spacing: 0.2px;
}

#ccw-chat-widget.ccw-size-compact .ccw-launcher-label {
  font-size: 13px;
}
#ccw-chat-widget.ccw-size-large .ccw-launcher-label {
  font-size: 16px;
}

#ccw-chat-widget .ccw-launcher-pill-hover {
  width: 60px;
  height: 60px;
  border-radius: 30px;
  padding: 0;
  justify-content: flex-start;
  padding-left: 16px;
}
#ccw-chat-widget.ccw-size-compact .ccw-launcher-pill-hover {
  width: 52px;
  height: 52px;
  border-radius: 26px;
  padding-left: 14px;
}
#ccw-chat-widget.ccw-size-large .ccw-launcher-pill-hover {
  width: 68px;
  height: 68px;
  border-radius: 34px;
  padding-left: 18px;
}

#ccw-chat-widget .ccw-launcher-pill-hover .ccw-launcher-label {
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateX(-6px);
  transition:
    max-width 0.3s ease,
    opacity 0.25s ease,
    transform 0.25s ease;
  margin-left: 0;
}

#ccw-chat-widget .ccw-launcher-pill-hover:hover {
  width: auto;
  padding-right: 20px;
}
#ccw-chat-widget .ccw-launcher-pill-hover:hover .ccw-launcher-label {
  max-width: 140px;
  opacity: 1;
  transform: translateX(0);
  margin-left: 10px;
}

/* ==========================================================================
   ATTENTION FLARE ANIMATIONS
   ========================================================================== */

/* 1. Radar Pulse Waves */
#ccw-chat-widget .ccw-radar-ring {
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid var(--ccw-theme-primary);
  opacity: 0;
  pointer-events: none;
  animation: ccwRadarRing 2.8s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}

#ccw-chat-widget .ccw-radar-ring.ring-2 {
  animation-delay: 1.4s;
}

@keyframes ccwRadarRing {
  0% {
    transform: scale(0.96);
    opacity: 0.85;
  }
  70% {
    opacity: 0.2;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

/* 2. Breathing Ambient Glow */
#ccw-chat-widget .ccw-flare-glow-pulse {
  animation: ccwGlowPulse 3s ease-in-out infinite;
}

@keyframes ccwGlowPulse {
  0%,
  100% {
    box-shadow:
      0 4px 14px rgba(0, 0, 0, 0.22),
      0 0 0 0 rgba(30, 58, 138, 0);
  }
  50% {
    box-shadow:
      0 6px 20px rgba(0, 0, 0, 0.28),
      0 0 22px 6px var(--ccw-theme-primary);
  }
}

/* 3. Periodic Bounce Nudge */
#ccw-chat-widget .ccw-flare-bounce-periodic:not(:hover):not(.ccw-is-open) {
  animation: ccwBouncePeriodic 6s infinite cubic-bezier(0.28, 0.84, 0.42, 1);
}

@keyframes ccwBouncePeriodic {
  0%,
  14%,
  100% {
    transform: translateY(0);
  }
  3% {
    transform: translateY(-12px);
  }
  6% {
    transform: translateY(0);
  }
  9% {
    transform: translateY(-6px);
  }
}

/* 4. Periodic Attention Wiggle */
#ccw-chat-widget .ccw-flare-wiggle-periodic:not(:hover):not(.ccw-is-open) {
  animation: ccwWigglePeriodic 6s infinite ease-in-out;
}

@keyframes ccwWigglePeriodic {
  0%,
  14%,
  100% {
    transform: rotate(0);
  }
  2% {
    transform: rotate(-14deg) scale(1.04);
  }
  4% {
    transform: rotate(12deg) scale(1.04);
  }
  6% {
    transform: rotate(-8deg);
  }
  8% {
    transform: rotate(6deg);
  }
  10% {
    transform: rotate(-3deg);
  }
  12% {
    transform: rotate(0);
  }
}

/* 5. Light Sheen Shimmer without overflow clipping */
#ccw-chat-widget .ccw-flare-shimmer::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0) 25%,
    rgba(255, 255, 255, 0.45) 50%,
    rgba(255, 255, 255, 0) 75%
  );
  background-size: 250% 250%;
  pointer-events: none;
  animation: ccwShimmerSweep 4.5s ease-in-out infinite;
}

@keyframes ccwShimmerSweep {
  0%,
  65% {
    background-position: 200% 200%;
    opacity: 0;
  }
  70% {
    opacity: 1;
  }
  100% {
    background-position: -50% -50%;
    opacity: 0;
  }
}

/* ==========================================================================
   NOTIFICATION BADGES & INDICATORS
   ========================================================================== */

/* Green Pulsing Live Dot */
#ccw-chat-widget .ccw-badge-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--ccw-theme-badge-color, #10b981);
  border: 2.5px solid #ffffff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  z-index: 5;
}

#ccw-chat-widget .ccw-badge-ping {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background: inherit;
  opacity: 0.75;
  animation: ccwBadgePing 2s cubic-bezier(0, 0, 0.2, 1) infinite;
  pointer-events: none;
}

@keyframes ccwBadgePing {
  75%,
  100% {
    transform: scale(2.2);
    opacity: 0;
  }
}

/* "1" Unread Message Count Badge */
#ccw-chat-widget .ccw-badge-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 10px;
  background: #ef4444;
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.35);
  z-index: 5;
  animation: ccwBadgePop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes ccwBadgePop {
  0% {
    transform: scale(0);
  }
  100% {
    transform: scale(1);
  }
}

/* Sparkle Star Badge */
#ccw-chat-widget .ccw-badge-sparkle {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #ffffff;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.4);
  z-index: 5;
  animation: ccwSparkleTwinkle 3s ease-in-out infinite;
}

@keyframes ccwSparkleTwinkle {
  0%,
  100% {
    transform: scale(1) rotate(0);
  }
  50% {
    transform: scale(1.15) rotate(15deg);
  }
}

/* Hide badges and pulse rings when widget is open */
#ccw-chat-widget.ccw-is-open .ccw-badge-dot,
#ccw-chat-widget.ccw-is-open .ccw-badge-count,
#ccw-chat-widget.ccw-is-open .ccw-badge-sparkle,
#ccw-chat-widget.ccw-is-open .ccw-radar-ring {
  display: none !important;
}

/* ==========================================================================
   PROACTIVE ENGAGEMENT CALLOUT CARD OVERHAUL
   ========================================================================== */

#ccw-chat-widget .ccw-proactive-bubble {
  position: absolute;
  bottom: 78px;
  width: 310px;
  max-width: calc(100vw - 48px);
  padding: 14px 16px;
  border-radius: 16px;
  cursor: pointer;
  z-index: 25;
  transition:
    opacity 0.3s ease,
    transform 0.3s ease,
    visibility 0.3s ease;
  outline: none;
  animation: ccwFloat 3.5s ease-in-out infinite alternate;
}

#ccw-chat-widget.ccw-pos-bottom-right .ccw-proactive-bubble {
  right: 0;
}

#ccw-chat-widget.ccw-pos-bottom-left .ccw-proactive-bubble {
  left: 0;
}

/* Proactive Speech Bubble Pointer Tail */
#ccw-chat-widget .ccw-proactive-bubble::after {
  content: "";
  position: absolute;
  bottom: -7px;
  width: 14px;
  height: 14px;
  transform: rotate(45deg);
  border-bottom: inherit;
  border-right: inherit;
  background: inherit;
  box-shadow: 3px 3px 6px rgba(0, 0, 0, 0.04);
}

#ccw-chat-widget.ccw-pos-bottom-right .ccw-proactive-bubble::after {
  right: 23px;
}

#ccw-chat-widget.ccw-pos-bottom-left .ccw-proactive-bubble::after {
  left: 23px;
}

/* Proactive Style 1: Modern Light */
#ccw-chat-widget .ccw-proactive-modern-light {
  background: #ffffff;
  color: #0f172a;
  border: 1px solid #e2e8f0;
  box-shadow:
    0 14px 35px -4px rgba(15, 23, 42, 0.16),
    0 4px 12px rgba(15, 23, 42, 0.08);
}

/* Proactive Style 2: Glassmorphism */
#ccw-chat-widget .ccw-proactive-glassmorphism {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  color: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow:
    0 16px 36px rgba(0, 0, 0, 0.12),
    0 2px 10px rgba(0, 0, 0, 0.04);
}

/* Proactive Style 3: Dark Sleek */
#ccw-chat-widget .ccw-proactive-dark-sleek {
  background: #0f172a;
  color: #f8fafc;
  border: 1px solid #334155;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.35);
}

/* Proactive Style 4: Brand Accent */
#ccw-chat-widget .ccw-proactive-brand-color {
  background: var(--ccw-theme-primary);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.25);
}

/* Proactive Header & Avatar */
#ccw-chat-widget .ccw-proactive-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 7px;
  padding-right: 18px;
}

#ccw-chat-widget .ccw-proactive-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  background: #eff6ff;
  border: 1.5px solid rgba(0, 0, 0, 0.08);
  overflow: visible;
}

#ccw-chat-widget .ccw-proactive-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
}

#ccw-chat-widget .ccw-proactive-avatar svg {
  width: 100%;
  height: 100%;
  fill: #3b82f6;
}

#ccw-chat-widget .ccw-proactive-status-dot {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #10b981;
  border: 1.5px solid #ffffff;
}

#ccw-chat-widget .ccw-proactive-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

#ccw-chat-widget .ccw-proactive-title {
  font-size: 13.5px;
  font-weight: 700;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#ccw-chat-widget .ccw-proactive-status-pill {
  font-size: 10.5px;
  font-weight: 600;
  color: #10b981;
  line-height: 1;
}

#ccw-chat-widget .ccw-proactive-dark-sleek .ccw-proactive-status-pill,
#ccw-chat-widget .ccw-proactive-brand-color .ccw-proactive-status-pill {
  color: #6ee7b7;
}

#ccw-chat-widget .ccw-proactive-text {
  font-size: 13px;
  line-height: 1.45;
  margin: 0;
  font-weight: 450;
  opacity: 0.95;
}

/* Proactive CTA Button */
#ccw-chat-widget .ccw-proactive-footer {
  margin-top: 10px;
  display: flex;
  align-items: center;
}

#ccw-chat-widget .ccw-proactive-cta {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 13px;
  border-radius: 20px;
  background: var(--ccw-theme-primary);
  color: var(--ccw-theme-icon-color, #ffffff);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    opacity 0.2s ease;
}

#ccw-chat-widget .ccw-proactive-bubble:hover .ccw-proactive-cta {
  transform: translateX(3px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.16);
}

#ccw-chat-widget .ccw-proactive-brand-color .ccw-proactive-cta {
  background: #ffffff;
  color: var(--ccw-theme-primary);
}

#ccw-chat-widget .ccw-proactive-dark-sleek .ccw-proactive-cta {
  background: #3b82f6;
  color: #ffffff;
}

/* Proactive Dismiss Button */
#ccw-chat-widget .ccw-proactive-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: 17px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background-color 0.2s ease,
    color 0.2s ease;
  z-index: 10;
}

#ccw-chat-widget .ccw-proactive-close:hover {
  background-color: rgba(0, 0, 0, 0.06);
  color: #475569;
}

#ccw-chat-widget .ccw-proactive-dark-sleek .ccw-proactive-close:hover,
#ccw-chat-widget .ccw-proactive-brand-color .ccw-proactive-close:hover {
  background-color: rgba(255, 255, 255, 0.15);
  color: #ffffff;
}

/* Proactive Entrance Animations */
#ccw-chat-widget .ccw-proactive-anim-pop-in.ccw-proactive-visible {
  animation: ccwPopIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

#ccw-chat-widget .ccw-proactive-anim-slide-up.ccw-proactive-visible {
  animation: ccwSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

#ccw-chat-widget .ccw-proactive-anim-bounce-in.ccw-proactive-visible {
  animation: ccwBounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes ccwPopIn {
  0% {
    opacity: 0;
    transform: scale(0.7) translateY(14px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes ccwSlideUp {
  0% {
    opacity: 0;
    transform: translateY(24px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes ccwBounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3) translateY(20px);
  }
  50% {
    opacity: 1;
    transform: scale(1.08) translateY(-6px);
  }
  70% {
    transform: scale(0.96) translateY(2px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes ccwFloat {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(-4px);
  }
}

/* Chat Window Container - viewport constrained */
#ccw-chat-widget .ccw-chat-window {
  position: absolute;
  bottom: 80px;
  background: var(--ccw-theme-bg);
  border-radius: 18px;
  box-shadow:
    0 16px 40px -10px rgba(0, 0, 0, 0.22),
    0 0 0 1px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 999995;
  /* Viewport constraint: never exceed the browser viewport */
  max-height: calc(100vh - 120px);
  max-width: calc(100vw - 48px);
}

#ccw-chat-widget.ccw-pos-bottom-right .ccw-chat-window {
  right: 0;
  transform-origin: bottom right;
}

#ccw-chat-widget.ccw-pos-bottom-left .ccw-chat-window {
  left: 0;
  transform-origin: bottom left;
}

/* Size Variations */
#ccw-chat-widget.ccw-size-compact .ccw-chat-window {
  width: 330px;
  height: 480px;
}

#ccw-chat-widget.ccw-size-standard .ccw-chat-window {
  width: 380px;
  height: 560px;
}

#ccw-chat-widget.ccw-size-large .ccw-chat-window {
  width: 440px;
  height: 640px;
}

/* Open State Animation Presets */
#ccw-chat-widget.ccw-is-open .ccw-chat-window {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

#ccw-chat-widget.ccw-anim-slide-up .ccw-chat-window {
  transform: translateY(24px) scale(0.96);
}
#ccw-chat-widget.ccw-anim-slide-up.ccw-is-open .ccw-chat-window {
  transform: translateY(0) scale(1);
}

#ccw-chat-widget.ccw-anim-fade-in .ccw-chat-window {
  transform: scale(1);
}

#ccw-chat-widget.ccw-anim-bounce .ccw-chat-window {
  transform: translateY(30px) scale(0.85);
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#ccw-chat-widget.ccw-anim-bounce.ccw-is-open .ccw-chat-window {
  transform: translateY(0) scale(1);
}

#ccw-chat-widget.ccw-anim-none .ccw-chat-window {
  transition: none !important;
}

/* Chat Header */
#ccw-chat-widget .ccw-header {
  background: var(--ccw-theme-primary);
  color: #ffffff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  position: relative;
  flex-shrink: 0;
}

#ccw-chat-widget .ccw-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

#ccw-chat-widget .ccw-avatar-badge {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  flex-shrink: 0;
  overflow: hidden;
}

#ccw-chat-widget .ccw-avatar-badge svg {
  width: 22px;
  height: 22px;
  fill: #ffffff;
}

/* Custom avatar image in header */
#ccw-chat-widget .ccw-avatar-badge .ccw-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

#ccw-chat-widget .ccw-status-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  background: #10b981;
  border: 2px solid var(--ccw-theme-primary);
  border-radius: 50%;
}

#ccw-chat-widget .ccw-header-text {
  min-width: 0;
}

#ccw-chat-widget .ccw-header-text h3 {
  font-size: 15.5px;
  font-weight: 600;
  color: #ffffff;
  margin: 0;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#ccw-chat-widget .ccw-header-text span {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
}

#ccw-chat-widget .ccw-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

#ccw-chat-widget .ccw-icon-btn {
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

#ccw-chat-widget .ccw-icon-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

#ccw-chat-widget .ccw-icon-btn svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

/* Offline Notice Bar */
#ccw-chat-widget .ccw-offline-bar {
  background: #ef4444;
  color: #ffffff;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  text-align: center;
  display: none;
  flex-shrink: 0;
}
#ccw-chat-widget .ccw-offline-bar.ccw-visible {
  display: block;
}

/* Disclosure / Privacy Banner */
#ccw-chat-widget .ccw-disclosure-banner {
  background: #f1f5f9;
  color: #64748b;
  padding: 8px 14px;
  font-size: 11px;
  text-align: center;
  border-bottom: 1px solid #e2e8f0;
  line-height: 1.35;
  flex-shrink: 0;
}

/* Chat Messages Container */
#ccw-chat-widget .ccw-messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
  scroll-behavior: smooth;
  min-height: 0;
}

/* Custom Scrollbar */
#ccw-chat-widget .ccw-messages-container::-webkit-scrollbar {
  width: 6px;
}
#ccw-chat-widget .ccw-messages-container::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}

/* Message Bubble Base */
#ccw-chat-widget .ccw-msg-row {
  display: flex;
  flex-direction: column;
  max-width: 84%;
}

#ccw-chat-widget .ccw-msg-row.ccw-msg-user {
  align-self: flex-end;
  align-items: flex-end;
}

#ccw-chat-widget .ccw-msg-row.ccw-msg-bot,
#ccw-chat-widget .ccw-msg-row.ccw-msg-system {
  align-self: flex-start;
  align-items: flex-start;
}

#ccw-chat-widget .ccw-bubble {
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.45;
  word-break: break-word;
  position: relative;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

#ccw-chat-widget .ccw-msg-user .ccw-bubble {
  background: var(--ccw-theme-primary);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

#ccw-chat-widget .ccw-msg-bot .ccw-bubble {
  background: #ffffff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
}

#ccw-chat-widget .ccw-msg-system .ccw-bubble {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fee2e2;
  font-size: 12.5px;
  border-radius: 12px;
}

/* ==========================================================================
   MARKDOWN CONTENT STYLES (Bot Reply Bubbles)
   ========================================================================== */

#ccw-chat-widget .ccw-bubble .ccw-md-h1 {
  display: block;
  font-size: 16px;
  font-weight: 700;
  margin: 6px 0 4px;
  line-height: 1.3;
}

#ccw-chat-widget .ccw-bubble .ccw-md-h2 {
  display: block;
  font-size: 14.5px;
  font-weight: 700;
  margin: 5px 0 3px;
  line-height: 1.3;
}

#ccw-chat-widget .ccw-bubble .ccw-md-h3 {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  margin: 4px 0 2px;
  line-height: 1.3;
}

#ccw-chat-widget .ccw-bubble .ccw-md-codeblock {
  display: block;
  background: #1e293b;
  color: #e2e8f0;
  padding: 10px 12px;
  border-radius: 8px;
  font-family: "SF Mono", "Fira Code", "Cascadia Code", Consolas, monospace;
  font-size: 12px;
  line-height: 1.5;
  margin: 6px 0;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

#ccw-chat-widget .ccw-bubble .ccw-md-codeblock code {
  background: transparent;
  padding: 0;
  font-size: inherit;
  color: inherit;
}

#ccw-chat-widget .ccw-bubble .ccw-md-inline-code {
  background: rgba(0, 0, 0, 0.07);
  color: #c7254e;
  padding: 1.5px 5px;
  border-radius: 4px;
  font-family: "SF Mono", "Fira Code", Consolas, monospace;
  font-size: 12px;
}

#ccw-chat-widget .ccw-bubble .ccw-md-link {
  color: var(--ccw-theme-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
  font-weight: 500;
  transition: opacity 0.15s ease;
}

#ccw-chat-widget .ccw-bubble .ccw-md-link:hover {
  opacity: 0.75;
}

#ccw-chat-widget .ccw-bubble .ccw-md-ul,
#ccw-chat-widget .ccw-bubble .ccw-md-ol {
  margin: 4px 0;
  padding-left: 18px;
}

#ccw-chat-widget .ccw-bubble .ccw-md-li,
#ccw-chat-widget .ccw-bubble .ccw-md-oli {
  margin: 2px 0;
  line-height: 1.45;
}

#ccw-chat-widget .ccw-bubble .ccw-md-ul {
  list-style-type: disc;
}

#ccw-chat-widget .ccw-bubble .ccw-md-ol {
  list-style-type: decimal;
}

#ccw-chat-widget .ccw-bubble strong {
  font-weight: 700;
}

#ccw-chat-widget .ccw-bubble em {
  font-style: italic;
}

#ccw-chat-widget .ccw-msg-time {
  font-size: 10.5px;
  color: #94a3b8;
  margin-top: 4px;
  padding: 0 4px;
}

/* Message Status Pill (Sending state) */
#ccw-chat-widget .ccw-msg-status {
  font-size: 10px;
  color: #64748b;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Typing & Sending Indicator */
#ccw-chat-widget .ccw-typing-indicator {
  display: none;
  align-items: center;
  gap: 5px;
  padding: 10px 16px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

#ccw-chat-widget .ccw-typing-indicator.ccw-active {
  display: flex;
}

#ccw-chat-widget .ccw-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: ccwBlink 1.4s infinite both;
}

#ccw-chat-widget .ccw-typing-dot:nth-child(1) {
  animation-delay: 0s;
}
#ccw-chat-widget .ccw-typing-dot:nth-child(2) {
  animation-delay: 0.2s;
}
#ccw-chat-widget .ccw-typing-dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes ccwBlink {
  0%,
  80%,
  100% {
    opacity: 0.3;
    transform: scale(0.85);
  }
  40% {
    opacity: 1;
    transform: scale(1.15);
  }
}

/* Input Area Form */
#ccw-chat-widget .ccw-input-area {
  padding: 12px 14px;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  position: relative;
  flex-shrink: 0;
}

#ccw-chat-widget .ccw-input-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  background: #f1f5f9;
  border-radius: 22px;
  padding: 6px 6px 6px 14px;
  border: 1.5px solid transparent;
  transition:
    border-color 0.2s ease,
    background-color 0.2s ease;
}

#ccw-chat-widget .ccw-input-form:focus-within {
  border-color: var(--ccw-theme-primary);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.08);
}

#ccw-chat-widget .ccw-textarea {
  flex: 1;
  border: none;
  background: transparent;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--ccw-theme-contrast);
  resize: none;
  max-height: 90px;
  min-height: 22px;
  outline: none;
  padding: 3px 0;
}

#ccw-chat-widget .ccw-send-btn {
  background: var(--ccw-theme-primary);
  color: #ffffff;
  border: none;
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition:
    transform 0.15s ease,
    background-color 0.15s ease;
  flex-shrink: 0;
}

#ccw-chat-widget .ccw-send-btn:hover {
  background: var(--ccw-theme-primary-hover);
  transform: scale(1.05);
}

#ccw-chat-widget .ccw-send-btn:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  transform: none;
}

#ccw-chat-widget .ccw-send-btn svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
  transform: translateX(1px);
}

/* Honeypot Trap Field - Strictly Hidden from Humans */
#ccw-chat-widget .ccw-hp-field {
  display: none !important;
  position: absolute !important;
  left: -9999px !important;
  opacity: 0 !important;
  visibility: hidden !important;
}

/* =============================================
   RESPONSIVE: Viewport-safe on ALL screen sizes
   ============================================= */

/* Desktop: ensure chat window never overflows the viewport */
@media screen and (min-width: 769px) {
  #ccw-chat-widget .ccw-chat-window {
    max-height: calc(100vh - 120px);
    max-width: calc(100vw - 60px);
  }
}

/* Tablet: slightly reduced margins */
@media screen and (min-width: 481px) and (max-width: 768px) {
  #ccw-chat-widget.ccw-pos-bottom-right {
    bottom: 16px !important;
    right: 16px !important;
    left: auto !important;
    top: auto !important;
  }

  #ccw-chat-widget.ccw-pos-bottom-left {
    bottom: 16px !important;
    left: 16px !important;
    right: auto !important;
    top: auto !important;
  }

  #ccw-chat-widget .ccw-chat-window {
    max-height: calc(100vh - 100px);
    max-width: calc(100vw - 40px);
  }

  #ccw-chat-widget.ccw-size-large .ccw-chat-window {
    width: 380px;
    height: 560px;
  }

  #ccw-chat-widget .ccw-proactive-bubble {
    max-width: calc(100vw - 60px);
  }
}

/* Mobile: full-screen-ish safe layout */
@media screen and (max-width: 480px) {
  #ccw-chat-widget.ccw-pos-bottom-right {
    bottom: 16px !important;
    right: 16px !important;
    left: auto !important;
    top: auto !important;
  }

  #ccw-chat-widget.ccw-pos-bottom-left {
    bottom: 16px !important;
    left: 16px !important;
    right: auto !important;
    top: auto !important;
  }

  #ccw-chat-widget .ccw-launcher-icon,
  #ccw-chat-widget .ccw-launcher-close-icon {
    width: 24px;
    height: 24px;
  }

  #ccw-chat-widget .ccw-chat-window {
    position: fixed;
    top: 8px;
    bottom: 8px;
    left: 8px;
    right: 8px !important;
    width: auto !important;
    height: auto !important;
    max-height: none;
    max-width: none;
    border-radius: 16px;
  }

  #ccw-chat-widget .ccw-header {
    padding: 14px 14px;
  }

  #ccw-chat-widget .ccw-header-text h3 {
    font-size: 14px;
  }

  #ccw-chat-widget .ccw-messages-container {
    padding: 12px;
  }

  #ccw-chat-widget .ccw-bubble {
    font-size: 13px;
  }

  #ccw-chat-widget .ccw-input-area {
    padding: 10px 10px;
  }

  #ccw-chat-widget .ccw-proactive-bubble {
    max-width: calc(100vw - 60px);
    bottom: 70px;
  }
}

/* Landscape phones: ensure chat doesn't exceed viewport height */
@media screen and (max-height: 500px) {
  #ccw-chat-widget .ccw-chat-window {
    max-height: calc(100vh - 80px);
  }

  /* On very short viewports, use fixed positioning for mobile-like layout */
  #ccw-chat-widget .ccw-chat-window {
    position: fixed;
    top: 6px;
    bottom: 6px;
    right: 6px;
    width: 360px !important;
    height: auto !important;
    max-height: none;
    border-radius: 14px;
  }

  #ccw-chat-widget .ccw-header {
    padding: 10px 14px;
  }

  #ccw-chat-widget .ccw-disclosure-banner {
    padding: 4px 10px;
    font-size: 10px;
  }
}
