/* ──────────────────────────────────────────────
   Live Chat Widget — ColorFixers v2.0
   Smooth, responsive, accessible chat UI
   ────────────────────────────────────────────── */

:root {
  --cf-chat-primary: #0052FF;
  --cf-chat-dark: #0B1528;
  --cf-chat-navy: #122340;
}

/* ── SVG Icon Fixes (override Elementor/theme resets) ── */
.cf-livechat svg,
.cf-livechat svg * {
  pointer-events: none;
}

.cf-livechat .cf-chat-toggle-icon {
  display: block !important;
  width: 24px !important;
  height: 24px !important;
  fill: none !important;
  stroke: currentColor !important;
  stroke-width: 2 !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
  color: #fff !important;
}

.cf-livechat .cf-chat-qa-btn svg {
  display: block !important;
  width: 14px !important;
  height: 14px !important;
  fill: currentColor !important;
  stroke: none !important;
  color: inherit !important;
  flex-shrink: 0 !important;
}

.cf-livechat .cf-chat-header-btn svg {
  display: block !important;
  width: 16px !important;
  height: 16px !important;
  fill: none !important;
  stroke: currentColor !important;
  stroke-width: 2 !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
  color: inherit !important;
  flex-shrink: 0 !important;
}

.cf-livechat .cf-chat-security svg {
  display: block !important;
  width: 12px !important;
  height: 12px !important;
  fill: currentColor !important;
  stroke: none !important;
  flex-shrink: 0 !important;
}

.cf-livechat .cf-chat-email-header svg {
  display: block !important;
  width: 16px !important;
  height: 16px !important;
  fill: currentColor !important;
  stroke: none !important;
  flex-shrink: 0 !important;
}

.cf-livechat .cf-chat-preset-btn svg {
  display: block !important;
  width: 10px !important;
  height: 10px !important;
  fill: none !important;
  stroke: currentColor !important;
  stroke-width: 2 !important;
  stroke-linecap: round !important;
  stroke-linejoin: round !important;
  flex-shrink: 0 !important;
}

/* ── Floating Button ── */
.cf-livechat {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  font-family: var(--cf-font-body, 'DM Sans'), -apple-system, BlinkMacSystemFont, sans-serif;
}

.cf-chat-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--cf-chat-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 32px rgba(0, 82, 255, 0.4);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  will-change: transform;
}

.cf-chat-toggle:hover {
  background: #0043d1;
  transform: scale(1.08);
  box-shadow: 0 12px 40px rgba(0, 82, 255, 0.5);
}

.cf-chat-toggle:focus-visible {
  outline: 3px solid var(--primary-blue, #0052FF);
  outline-offset: 3px;
}

.cf-chat-toggle:active {
  transform: scale(0.92);
  transition-duration: 0.1s;
}

.cf-chat-toggle-icon {
  width: 24px;
  height: 24px;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.cf-chat-toggle.is-open .cf-chat-toggle-icon {
  transform: rotate(90deg) scale(0.7);
}

/* Notification badge */
.cf-chat-toggle-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  background: #10B981;
  border-radius: 50%;
  border: 2.5px solid #fff;
  animation: cf-chat-pulse 2s ease-in-out infinite;
}

.cf-chat-toggle.is-open .cf-chat-toggle-badge {
  animation: none;
  opacity: 0;
  transform: scale(0);
  transition: all 0.2s ease;
}

@keyframes cf-chat-pulse {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  50% { transform: scale(1.1); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

/* Tooltip */
.cf-chat-tooltip {
  position: absolute;
  right: 68px;
  top: 50%;
  transform: translateY(-50%) translateX(4px);
  background: #0F172A;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 6px 12px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.cf-chat-tooltip::after {
  content: '';
  position: absolute;
  right: -5px;
  top: 50%;
  transform: translateY(-50%);
  border-left: 6px solid #0F172A;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

.cf-chat-toggle:hover .cf-chat-tooltip {
  opacity: 1;
  transform: translateY(-50%) translateX(0);
}

/* ── Chat Widget Container ── */
.cf-chat-widget {
  position: fixed;
  bottom: 92px;
  right: 24px;
  width: 380px;
  height: 540px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 24px;
  border: 1px solid rgba(226, 232, 240, 0.6);
  box-shadow:
    0 24px 80px rgba(0, 0, 0, 0.12),
    0 8px 24px rgba(0, 0, 0, 0.06),
    0 0 0 1px rgba(0, 0, 0, 0.02);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cf-chat-slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform, opacity;
}

@keyframes cf-chat-slide-up {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.92);
    filter: blur(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

/* ── Header ── */
.cf-chat-header {
  background: linear-gradient(135deg, var(--cf-chat-dark) 0%, var(--cf-chat-navy) 100%);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: relative;
}

.cf-chat-header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 16px;
  right: 16px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
}

.cf-chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.cf-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), rgba(255,255,255,0.05));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  flex-shrink: 0;
  position: relative;
  border: 1px solid rgba(255,255,255,0.1);
}

.cf-chat-online-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background: #10B981;
  border-radius: 50%;
  border: 2.5px solid var(--cf-chat-dark);
  animation: cf-online-glow 3s ease-in-out infinite;
}

@keyframes cf-online-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.3); }
  50% { box-shadow: 0 0 0 4px rgba(16, 185, 129, 0); }
}

.cf-chat-header-info {
  min-width: 0;
}

.cf-chat-agent-name {
  font-size: 13px;
  font-weight: 900;
  color: #fff;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.cf-chat-agent-title {
  font-size: 9px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.5);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  line-height: 1.3;
  margin-top: 1px;
}

.cf-chat-header-right {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

/* Quick Actions */
.cf-chat-quick-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-right: 6px;
  padding-right: 6px;
  border-right: 1px solid rgba(255,255,255,0.1);
}

.cf-chat-qa-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.cf-chat-qa-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  transform: scale(1.1);
}

.cf-chat-header-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.6);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.cf-chat-header-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

/* ── Security Bar ── */
.cf-chat-security {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  background: linear-gradient(180deg, #F8FAFC, #F1F5F9);
  border-bottom: 1px solid #E2E8F0;
  font-size: 10px;
  font-weight: 700;
  color: #64748B;
  flex-shrink: 0;
}

.cf-chat-session-id {
  margin-left: auto;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 9px;
  color: #94A3B8;
  letter-spacing: 0.08em;
  background: rgba(148, 163, 184, 0.1);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ── Messages Area ── */
.cf-chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  background: linear-gradient(180deg, #FAFBFC 0%, #F8FAFC 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.cf-chat-messages::-webkit-scrollbar {
  width: 5px;
}

.cf-chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

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

.cf-chat-messages::-webkit-scrollbar-thumb:hover {
  background: #94A3B8;
}

/* Message bubbles */
.cf-chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: cf-msg-enter 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
  will-change: transform, opacity;
}

.cf-chat-msg--bot {
  align-self: flex-start;
}

.cf-chat-msg--user {
  align-self: flex-end;
}

@keyframes cf-msg-enter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.cf-chat-msg-bubble {
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.cf-chat-msg--bot .cf-chat-msg-bubble {
  background: #fff;
  border: 1px solid rgba(226, 232, 240, 0.7);
  color: #1E293B;
  border-top-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

.cf-chat-msg--user .cf-chat-msg-bubble {
  background: var(--cf-chat-primary);
  color: #fff;
  border-top-right-radius: 4px;
  box-shadow: 0 2px 12px rgba(0, 82, 255, 0.25);
}

.cf-chat-msg-time {
  font-size: 10px;
  font-weight: 600;
  color: #94A3B8;
  margin-top: 4px;
  padding: 0 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.cf-chat-msg:hover .cf-chat-msg-time {
  opacity: 1;
}

.cf-chat-msg--user .cf-chat-msg-time {
  text-align: right;
}

/* Typing indicator */
.cf-chat-typing {
  display: flex;
  align-self: flex-start;
  padding: 12px 16px;
  background: #fff;
  border: 1px solid rgba(226, 232, 240, 0.7);
  border-radius: 18px;
  border-top-left-radius: 4px;
  gap: 5px;
  align-items: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
  animation: cf-msg-enter 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.cf-chat-typing-dot {
  width: 7px;
  height: 7px;
  background: #94A3B8;
  border-radius: 50%;
  animation: cf-typing-bounce 1.4s ease-in-out infinite;
}

.cf-chat-typing-dot:nth-child(2) { animation-delay: 0.15s; }
.cf-chat-typing-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes cf-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Email Capture ── */
.cf-chat-email-capture {
  padding: 0 16px 12px;
  animation: cf-msg-enter 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.cf-chat-email-card {
  background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
  border: 1px solid rgba(255, 91, 26, 0.35);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.25);
}

.cf-chat-email-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 800;
  color: #FF5B1A;
  margin-bottom: 4px;
}

.cf-chat-email-desc {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.8);
  margin: 0 0 10px;
  line-height: 1.4;
}

.cf-chat-email-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cf-chat-email-field {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: #0A111F;
  color: #FFFFFF;
  box-sizing: border-box;
  transition: all 0.2s ease;
}

.cf-chat-email-field::placeholder {
  color: rgba(255, 255, 255, 0.45);
}

.cf-chat-email-field:focus {
  border-color: #FF5B1A;
  box-shadow: 0 0 0 3px rgba(255, 91, 26, 0.2);
  background: #0F172A;
}

.cf-chat-email-btn {
  width: 100%;
  padding: 11px 16px;
  background: linear-gradient(135deg, #FF5B1A 0%, #E0480A 100%);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 14px rgba(255, 91, 26, 0.35);
}

.cf-chat-email-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(255, 91, 26, 0.45);
}

.cf-chat-email-btn:active {
  transform: translateY(0);
}

.cf-chat-email-btn:disabled {
  background: #475569;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ── Preset Questions (Quickchat Options) ── */
.cf-chat-presets {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
  position: relative;
  scroll-behavior: smooth;
  transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
  max-height: 60px;
  box-sizing: border-box;
}

.cf-chat-presets::-webkit-scrollbar {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
}

.cf-chat-preset-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  background: #F1F5F9;
  color: #334155;
  border: 1px solid #CBD5E1;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
  user-select: none;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  -webkit-tap-highlight-color: transparent;
}

.cf-chat-preset-btn:active {
  transform: scale(0.96);
}

.cf-chat-preset-btn:hover {
  background: #EEF2FF;
  border-color: rgba(0, 82, 255, 0.4);
  color: var(--cf-chat-primary, #0052FF);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 82, 255, 0.15);
}

/* ── Typebox / Input Area ── */
.cf-chat-input-area {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: #fff;
  border-top: 1px solid #F1F5F9;
  flex-shrink: 0;
}

.cf-chat-input {
  flex: 1;
  height: 42px;
  padding: 0 16px;
  border: 1.5px solid #CBD5E1;
  border-radius: 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  color: #0F172A;
  outline: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 0;
  background: #F8FAFC;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.03);
  box-sizing: border-box;
}

.cf-chat-input::placeholder {
  color: #94A3B8;
  font-weight: 400;
}

.cf-chat-input:focus {
  border-color: var(--cf-chat-primary, #0052FF);
  box-shadow: 0 0 0 3px rgba(0, 82, 255, 0.12), inset 0 1px 2px rgba(0, 0, 0, 0.02);
  background: #FFFFFF;
}

.cf-chat-input:focus-visible {
  outline: none;
}

.cf-chat-send {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: var(--cf-chat-primary, #0052FF);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.cf-chat-send:hover:not(:disabled) {
  background: #0043d1;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 82, 255, 0.3);
}

.cf-chat-send:active:not(:disabled) {
  transform: scale(0.95);
}

.cf-chat-send:disabled {
  background: #E2E8F0;
  color: #94A3B8;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .cf-livechat {
    bottom: 16px;
    right: 16px;
  }

  .cf-chat-widget {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    top: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
  }

  .cf-chat-toggle {
    width: 52px;
    height: 52px;
  }

  .cf-chat-toggle:hover {
    transform: scale(1.05);
  }

  .cf-chat-tooltip {
    display: none;
  }

  .cf-chat-quick-actions {
    display: none;
  }

  .cf-chat-header-right {
    gap: 2px;
  }

  .cf-chat-presets {
    padding: 10px 12px;
    gap: 5px;
  }

  .cf-chat-presets::before,
  .cf-chat-presets::after {
    width: 12px;
  }

  .cf-chat-messages {
    padding: 12px;
    gap: 8px;
  }

  .cf-chat-input-area {
    padding: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }

  .cf-chat-msg {
    max-width: 88%;
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .cf-chat-widget {
    width: 360px;
    height: 500px;
    right: 16px;
    bottom: 88px;
  }

  .cf-chat-quick-actions {
    display: none;
  }
}

@media (min-width: 769px) {
  .cf-chat-quick-actions {
    display: flex;
  }
}

/* High contrast / reduced motion */
@media (prefers-reduced-motion: reduce) {
  .cf-chat-widget,
  .cf-chat-msg,
  .cf-chat-typing,
  .cf-chat-email-capture,
  .cf-chat-toggle,
  .cf-chat-toggle-badge {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
  .cf-chat-widget {
    background: #1E293B;
    border-color: rgba(51, 65, 85, 0.5);
  }

  .cf-chat-messages {
    background: #0F172A;
  }

  .cf-chat-msg--bot .cf-chat-msg-bubble {
    background: #1E293B;
    border-color: rgba(51, 65, 85, 0.5);
    color: #F1F5F9;
  }

  .cf-chat-typing {
    background: #1E293B;
    border-color: rgba(51, 65, 85, 0.5);
  }

  .cf-chat-input-area {
    background: #1E293B;
    border-color: rgba(51, 65, 85, 0.5);
  }

  .cf-chat-input {
    background: #0F172A;
    border-color: rgba(51, 65, 85, 0.5);
    color: #F1F5F9;
  }

  .cf-chat-input:focus {
    background: #1E293B;
  }

  .cf-chat-presets::before,
  .cf-chat-presets::after {
    background: linear-gradient(90deg, #1E293B 0%, transparent 100%);
  }

  .cf-chat-presets::after {
    background: linear-gradient(-90deg, #1E293B 0%, transparent 100%);
  }

  .cf-chat-preset-btn {
    background: #334155;
    color: #CBD5E1;
    border-color: transparent;
  }

  .cf-chat-preset-btn:hover {
    background: #475569;
    color: #F1F5F9;
  }

  .cf-chat-security {
    background: linear-gradient(180deg, #1E293B, #0F172A);
    border-color: rgba(51, 65, 85, 0.5);
    color: #94A3B8;
  }

  .cf-chat-session-id {
    background: rgba(51, 65, 85, 0.3);
  }

  .cf-chat-send:disabled {
    background: #334155;
    color: #64748B;
  }

  .cf-chat-messages::-webkit-scrollbar-thumb {
    background: #475569;
  }
}
