/* ============================================================
   VuwaniTalk Support Chat Widget
   Premium live-chat widget for vuwanitalk.com
   ============================================================ */

/* ── CSS Variables ────────────────────────────────────────── */
:root {
  --qf-widget-primary: #228195;
  --qf-widget-primary-dark: #1a6a7a;
  --qf-widget-accent: #D33858;
  --qf-widget-bg: #FFFFFF;
  --qf-widget-bg-secondary: #F5F7F5;
  --qf-widget-bg-tertiary: #ECEFEC;
  --qf-widget-text: #2D332E;
  --qf-widget-text-secondary: #5E6660;
  --qf-widget-border: rgba(45,51,46,0.10);
  --qf-widget-bubble-border: rgba(45,51,46,0.06);
  --qf-widget-shadow: 0 16px 44px rgba(30,40,35,0.14), 0 4px 12px rgba(30,40,35,0.06);
  --qf-widget-radius: 18px;
  --qf-widget-font: 'Outfit', 'Inter', system-ui, -apple-system, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --qf-widget-bg: #171B19;
    --qf-widget-bg-secondary: #262D29;
    --qf-widget-bg-tertiary: #2F3733;
    --qf-widget-text: #EEF1EE;
    --qf-widget-text-secondary: #9BA6A0;
    --qf-widget-border: rgba(255,255,255,0.10);
    --qf-widget-bubble-border: rgba(255,255,255,0.06);
    --qf-widget-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 4px 16px rgba(0,0,0,0.3);
  }
}

/* ── Widget Container ─────────────────────────────────────── */
#qf-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999999;
  font-family: var(--qf-widget-font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#qf-chat-widget *,
#qf-chat-widget *::before,
#qf-chat-widget *::after {
  /* Box-model isolation only. Do NOT zero margin/padding here: this selector
     carries an ID, so it outranks every `.qf-...` component rule and would
     silently kill all bubble, input and button padding. */
  box-sizing: border-box;
}

/* ── Floating Toggle Button ───────────────────────────────── */
#qf-widget-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--qf-widget-primary), var(--qf-widget-primary-dark));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(34,129,149,0.35);
  transition: all 0.3s cubic-bezier(0.4,0,0.2,1);
  position: relative;
  outline: none;
}

#qf-widget-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(34,129,149,0.45);
}

#qf-widget-toggle:active {
  transform: scale(0.95);
}

#qf-widget-toggle svg {
  width: 28px;
  height: 28px;
  fill: #fff;
  transition: transform 0.3s ease;
}

#qf-widget-toggle.qf-open svg {
  transform: rotate(90deg);
}

/* Notification badge */
#qf-widget-toggle .qf-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 20px;
  height: 20px;
  background: var(--qf-widget-accent);
  border-radius: 50%;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--qf-widget-bg);
  opacity: 0;
  transform: scale(0);
  transition: all 0.25s ease;
}

#qf-widget-toggle .qf-badge.qf-visible {
  opacity: 1;
  transform: scale(1);
}

/* Pulse animation when there's a new message */
@keyframes qf-pulse {
  0% { box-shadow: 0 0 0 0 rgba(34,129,149,0.5); }
  70% { box-shadow: 0 0 0 14px rgba(34,129,149,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,129,149,0); }
}

#qf-widget-toggle.qf-pulse {
  animation: qf-pulse 1.5s ease-out 2;
}

/* ── Chat Window ──────────────────────────────────────────── */
#qf-chat-window {
  position: absolute;
  bottom: 76px;
  right: 0;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 120px);
  background: var(--qf-widget-bg);
  border-radius: var(--qf-widget-radius);
  box-shadow: var(--qf-widget-shadow);
  border: 1px solid var(--qf-widget-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.2,0.8,0.2,1);
  transform-origin: bottom right;
}

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

/* ── Chat Header ──────────────────────────────────────────── */
.qf-header {
  background: linear-gradient(135deg, var(--qf-widget-primary), var(--qf-widget-primary-dark));
  color: #fff;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(0,0,0,0.12);
  position: relative;
  z-index: 1;
}

.qf-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.qf-header-avatar svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

.qf-header-info {
  flex: 1;
  min-width: 0;
}

.qf-header-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}

.qf-header-subtitle {
  font-size: 12px;
  opacity: 0.85;
  line-height: 1.3;
}

.qf-header-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}

.qf-header-close:hover {
  background: rgba(255,255,255,0.25);
}

.qf-header-close svg {
  width: 16px;
  height: 16px;
  fill: #fff;
}

/* ── Pre-Chat Form ────────────────────────────────────────── */
#qf-prechat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  text-align: center;
}

.qf-prechat-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--qf-widget-primary), var(--qf-widget-primary-dark));
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.qf-prechat-icon svg {
  width: 32px;
  height: 32px;
  fill: #fff;
}

.qf-prechat h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--qf-widget-text);
  margin-bottom: 6px;
}

.qf-prechat p {
  font-size: 13px;
  color: var(--qf-widget-text-secondary);
  margin-bottom: 24px;
  max-width: 280px;
}

.qf-prechat-form {
  width: 100%;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.qf-input {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--qf-widget-border);
  border-radius: 10px;
  font-size: 14px;
  font-family: var(--qf-widget-font);
  color: var(--qf-widget-text);
  background: var(--qf-widget-bg);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.qf-input::placeholder {
  color: var(--qf-widget-text-secondary);
  opacity: 0.6;
}

.qf-input:focus {
  border-color: var(--qf-widget-primary);
  box-shadow: 0 0 0 3px rgba(34,129,149,0.12);
}

.qf-btn-primary {
  width: 100%;
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--qf-widget-primary), var(--qf-widget-primary-dark));
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--qf-widget-font);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.qf-btn-primary:hover {
  box-shadow: 0 4px 16px rgba(34,129,149,0.3);
  transform: translateY(-1px);
}

.qf-btn-primary:active {
  transform: translateY(0);
}

.qf-btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.qf-btn-primary .qf-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: qf-spin 0.6s linear infinite;
  margin: 0 auto;
}

.qf-btn-primary.qf-loading .qf-btn-text { display: none; }
.qf-btn-primary.qf-loading .qf-spinner { display: block; }

@keyframes qf-spin {
  to { transform: rotate(360deg); }
}

.qf-error-text {
  font-size: 12px;
  color: var(--qf-widget-accent);
  margin-top: -4px;
  text-align: left;
}

/* ── Chat Messages Area ───────────────────────────────────── */
#qf-chat-body {
  flex: 1;
  display: none;
  flex-direction: column;
  min-height: 0;
}

#qf-chat-body.qf-active {
  display: flex;
}

.qf-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  background: var(--qf-widget-bg);
}

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

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

.qf-messages::-webkit-scrollbar-thumb {
  background: var(--qf-widget-border);
  border-radius: 10px;
}

/* Message bubble */
.qf-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: qf-msg-in 0.25s ease-out;
}

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

.qf-msg-guest {
  align-self: flex-end;
  align-items: flex-end;
}

.qf-msg-admin{
  align-self:flex-start;
  align-items:flex-start;
  max-width:88%;
  margin-top:10px;
}

.qf-msg-system {
  align-self: center;
  align-items: center;
  max-width: 90%;
}

.qf-msg-bubble {
  padding: 12px 16px;
  font-size: 13.5px;
  line-height: 1.55;
  letter-spacing: 0.1px;
  word-break: break-word;
  white-space: pre-wrap;
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}

.qf-msg-guest .qf-msg-bubble {
  background: var(--qf-widget-primary);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
}

.qf-msg-admin .qf-msg-bubble {
  background: var(--qf-widget-bg-tertiary);
  color: var(--qf-widget-text);
  border: 1px solid var(--qf-widget-bubble-border);
  border-radius: 14px 14px 14px 4px;
}

.qf-msg-system .qf-msg-bubble {
  background: transparent;
  color: var(--qf-widget-text-secondary);
  font-size: 12px;
  text-align: center;
  padding: 4px 12px;
  box-shadow: none;
}

.qf-msg-time {
  font-size: 10.5px;
  color: var(--qf-widget-text-secondary);
  opacity: 0.6;
  margin-top: 4px;
  padding: 0 4px;
}

/* Message attachments (images) */
.qf-msg-atts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.qf-msg-atts.qf-atts-1 { max-width: 240px; }
.qf-msg-atts.qf-atts-2 { max-width: 300px; }

.qf-msg-att {
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  background: var(--qf-widget-bg-secondary);
}

.qf-msg-att img {
  width: 100%;
  height: auto;
  display: block;
  max-height: 180px;
  object-fit: cover;
  transition: opacity 0.3s;
}

.qf-msg-att.qf-loading img {
  opacity: 0;
}

.qf-msg-att .qf-att-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 24px;
  height: 24px;
  border: 2px solid var(--qf-widget-border);
  border-top-color: var(--qf-widget-primary);
  border-radius: 50%;
  animation: qf-spin 0.6s linear infinite;
}

.qf-msg-att.qf-loaded .qf-att-spinner { display: none; }
.qf-msg-att.qf-loaded img { opacity: 1; }

/* Typing indicator */
.qf-typing {
  display: none;
  align-self: flex-start;
  padding: 10px 14px;
  background: var(--qf-widget-bg-secondary);
  border-radius: 14px 14px 14px 4px;
  margin-top: 4px;
}

.qf-typing.qf-visible {
  display: flex;
  align-items: center;
  gap: 4px;
}

.qf-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--qf-widget-text-secondary);
  opacity: 0.4;
  animation: qf-typing-bounce 1.2s ease-in-out infinite;
}

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

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

/* ── Connection Status ────────────────────────────────────── */
.qf-connection-status {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 12px;
  font-size: 11.5px;
  font-weight: 500;
  color: #fff;
  text-align: center;
}

.qf-connection-status.qf-visible {
  display: flex;
}

.qf-connection-status.qf-connecting {
  background: #E65100;
}

.qf-connection-status.qf-reconnecting {
  background: #E65100;
}

.qf-connection-status.qf-disconnected {
  background: var(--qf-widget-accent);
}

.qf-connection-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff;
  flex-shrink: 0;
}

.qf-connection-status.qf-connecting .qf-connection-dot,
.qf-connection-status.qf-reconnecting .qf-connection-dot {
  animation: qf-blink 1s ease-in-out infinite;
}

@keyframes qf-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ── Chat Input Area ──────────────────────────────────────── */
.qf-footer {
  border-top: 1px solid var(--qf-widget-border);
  background: var(--qf-widget-bg);
  padding: 12px;
  display: none;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}

.qf-footer.qf-active {
  display: flex;
}

/* Image preview strip */
.qf-image-preview-strip {
  display: none;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 4px;
}

.qf-image-preview-strip.qf-visible {
  display: flex;
}

.qf-image-preview {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid var(--qf-widget-border);
}

.qf-image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.qf-image-preview-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.qf-image-preview-remove:hover {
  background: var(--qf-widget-accent);
}

.qf-image-preview-remove svg {
  width: 10px;
  height: 10px;
  fill: #fff;
}

.qf-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.qf-input-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
  padding-bottom: 2px;
}

.qf-input-action {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
  color: var(--qf-widget-text-secondary);
  opacity: 0.85;
}

.qf-input-action:hover {
  opacity: 1;
}

.qf-input-action:hover {
  background: var(--qf-widget-bg-secondary);
  color: var(--qf-widget-primary);
}

.qf-input-action svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.qf-text-input {
  flex: 1;
  min-height: 38px;
  max-height: 100px;
  padding: 9px 14px;
  border: 1.5px solid var(--qf-widget-border);
  border-radius: 20px;
  font-size: 13.5px;
  font-family: var(--qf-widget-font);
  color: var(--qf-widget-text);
  background: var(--qf-widget-bg-secondary);
  outline: none;
  resize: none;
  line-height: 1.4;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.qf-text-input::placeholder {
  color: var(--qf-widget-text-secondary);
  opacity: 0.65;
}

.qf-text-input:focus {
  border-color: var(--qf-widget-primary);
  box-shadow: 0 0 0 3px rgba(34,129,149,0.14);
}

.qf-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--qf-widget-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}

.qf-send-btn:hover {
  background: var(--qf-widget-primary-dark);
  transform: scale(1.05);
}

.qf-send-btn:active {
  transform: scale(0.95);
}

.qf-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.qf-send-btn svg {
  width: 18px;
  height: 18px;
  fill: #fff;
}

/* Hidden file input */
#qf-file-input {
  display: none;
}

/* ── Image Lightbox ───────────────────────────────────────── */
#qf-lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999999;
  background: rgba(0,0,0,0.85);
  display: none;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
  backdrop-filter: blur(4px);
}

#qf-lightbox.qf-open {
  display: flex;
}

#qf-lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: 8px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

#qf-lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

#qf-lightbox-close:hover {
  background: rgba(255,255,255,0.3);
}

#qf-lightbox-close svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 480px) {
  #qf-chat-widget {
    bottom: 16px;
    right: 16px;
  }

  #qf-chat-window {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    max-height: none;
    bottom: 72px;
    right: -8px;
    border-radius: 14px;
  }

  #qf-widget-toggle {
    width: 54px;
    height: 54px;
  }

  #qf-widget-toggle svg {
    width: 24px;
    height: 24px;
  }
}

/* ── Paste indicator overlay ──────────────────────────────── */
.qf-paste-indicator {
  position: absolute;
  inset: 0;
  background: rgba(34,129,149,0.08);
  border: 2px dashed var(--qf-widget-primary);
  border-radius: var(--qf-widget-radius);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
}

.qf-paste-indicator.qf-visible {
  display: flex;
}

.qf-paste-indicator-text {
  background: var(--qf-widget-primary);
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 16px rgba(34,129,149,0.3);
}

/* ============================================================
   VuwaniTalk Support Widget — V2 Conversation + Pre-chat UI
   Visual goal: premium human support chat, NOT an AI assistant.
   Append-only override: existing functionality/selectors retained.
   ============================================================ */

/* ---------- Overall window ---------- */
#qf-chat-window {
  width: 400px;
  height: 600px;
  max-width: calc(100vw - 28px);
  max-height: calc(100vh - 105px);
  border-radius: 20px;
  border: 1px solid rgba(25, 42, 46, 0.12);
  background: var(--qf-widget-bg);
  box-shadow:
          0 24px 70px rgba(15, 35, 40, 0.20),
          0 8px 22px rgba(15, 35, 40, 0.10);
}

/* ---------- Header ---------- */
.qf-header {
  min-height: 74px;
  padding: 14px 16px;
  background: #23879b;
  box-shadow: 0 1px 0 rgba(255,255,255,.10);
}

.qf-header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.13);
}

.qf-header-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.qf-header-subtitle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  font-size: 11.5px;
  opacity: .90;
}

.qf-header-subtitle::before {
  content: "";
  width: 6px;
  height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: #bcebd5;
  box-shadow: 0 0 0 2px rgba(188,235,213,.12);
}

.qf-header-close {
  width: 32px;
  height: 32px;
  background: rgba(255,255,255,.12);
}

.qf-header-close:hover {
  background: rgba(255,255,255,.21);
}

/* ---------- Conversation surface ---------- */
#qf-chat-body {
  background:
          radial-gradient(circle at 15% 0%, rgba(35,135,155,.035), transparent 30%),
          var(--qf-widget-bg);
}

.qf-messages {
  padding: 20px 15px 18px;
  gap: 14px;
  background: transparent;
}

/* Each message gets a little more breathing room */
.qf-msg {
  max-width: 84%;
  animation: qf-msg-in .20s ease-out;
}

.qf-msg-guest {
  align-self: flex-end;
  align-items: flex-end;
}

.qf-msg-admin {
  align-self: flex-start;
  align-items: flex-start;
}

/* Guest bubble: stronger, compact, clearly outgoing */
.qf-msg-guest .qf-msg-bubble {
  max-width: 100%;
  padding: 14px 16px;
  background: #23879b;
  color: #fff;
  border: 0;
  border-radius: 17px 17px 5px 17px;
  box-shadow: 0 3px 8px rgba(35,135,155,.18);
}

/* Support bubble: white/soft card instead of another generic bubble */
.qf-msg-admin {
  position: relative;
  padding-left: 14px;
}

/* Small support avatar */
.qf-msg-admin::before {
  content:"";
  display:block;
  width:28px;
  height:28px;
  margin-bottom:6px;
  border-radius:10px;
  background:#23879b;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M12 2a8 8 0 00-8 8v5a3 3 0 003 3h2v-6H6v-2a6 6 0 1112 0v2h-3v6h2a3 3 0 003-3v-5a8 8 0 00-8-8z'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:center;
  background-size:15px;
}

/* Human-support label */
.qf-msg-admin::after {
  content:"  ";
  display:block;
  margin-top:-34px;
  margin-left:38px;
  margin-bottom:8px;
  font-size:11px;
  font-weight:600;
  color: var(--qf-widget-text-secondary);
}

.qf-msg-admin .qf-msg-bubble {
  margin-left:38px;
  background: var(--qf-widget-bg);
  color: var(--qf-widget-text);
  border:1px solid var(--qf-widget-bubble-border);
  border-radius:6px 18px 18px 18px;
  padding:13px 16px;
  line-height:1.6;
  letter-spacing:0.1px;
  box-shadow:
          0 2px 6px rgba(0,0,0,.04),
          0 1px 2px rgba(0,0,0,.03);
}

/* Prevent label from colliding with consecutive messages */
.qf-msg-admin + .qf-msg-admin {
  margin-top: 4px;
}

.qf-msg-admin + .qf-msg-admin::after {
  display: none;
}

/* Time should be quieter and closer to the bubble */
.qf-msg-time {
  margin-top: 4px;
  padding: 0 3px;
  font-size: 9.5px;
  line-height: 1;
  color: var(--qf-widget-text-secondary);
  opacity: .60;
}

/* Dark mode: lift the support bubble off the chat background */
@media (prefers-color-scheme: dark) {
  .qf-msg-admin .qf-msg-bubble {
    background: var(--qf-widget-bg-secondary);
    border-color: var(--qf-widget-border);
  }
  .qf-msg-guest .qf-msg-bubble {
    box-shadow: 0 3px 10px rgba(0,0,0,.35);
  }
}

/* Outgoing time aligned cleanly */
.qf-msg-guest .qf-msg-time {
  text-align: right;
}
.qf-msg-admin .qf-msg-time{
  margin-left:42px;
  margin-top:5px;
  font-size:10px;
  color:#8B979B;
}
/* ---------- Closed conversation ---------- */
.qf-footer.qf-closed .qf-input-row {
  opacity: .45;
}
.qf-text-input:disabled {
  opacity: .6;
  cursor: not-allowed;
}
.qf-send-btn:disabled,
.qf-input-action:disabled {
  opacity: .4;
  cursor: not-allowed;
}
.qf-closed-bar {
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px 14px;
  border-bottom: 1px solid var(--qf-widget-border);
  background: var(--qf-widget-bg-secondary);
}
.qf-closed-text {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--qf-widget-text-secondary);
  text-align: center;
}
.qf-new-convo-btn {
  width: 100%;
}

/* ---------- Failed send + resend ---------- */
.qf-msg-failed {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 0 4px;
}
.qf-msg-guest .qf-msg-failed {
  justify-content: flex-end;
}
.qf-msg-failed-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--qf-widget-accent);
}
.qf-resend-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--qf-widget-accent);
  background: transparent;
  color: var(--qf-widget-accent);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.qf-resend-btn svg {
  width: 13px;
  height: 13px;
  fill: currentColor;
}
.qf-resend-btn:hover {
  background: var(--qf-widget-accent);
  color: #fff;
}

/* ---------- Typing indicator ---------- */
.qf-typing {
  margin-left: 14px;
  padding: 10px 13px;
  background: var(--qf-widget-bg-tertiary);
  border: 1px solid rgba(32,42,45,.065);
  border-radius: 5px 16px 16px 16px;
  box-shadow: none;
}

/* ---------- Pre-chat screen ---------- */
#qf-prechat {
  position: relative;
  justify-content: flex-start;
  padding: 38px 28px 28px;
  text-align: left;
  overflow-y: auto;
  background:
          radial-gradient(circle at 50% 0%, rgba(35,135,155,.055), transparent 38%),
          var(--qf-widget-bg);
}

/* Replace the large generic icon with a compact brand/support mark */
.qf-prechat-icon {
  width: 52px;
  height: 52px;
  margin: 8px auto 18px;
  border-radius: 15px;
  background: #e7f3f5;
  border: 1px solid rgba(35,135,155,.10);
  box-shadow: none;
}

.qf-prechat-icon svg {
  width: 26px;
  height: 26px;
  fill: #23879b;
}

.qf-prechat h3 {
  width: 100%;
  margin: 0 0 7px;
  text-align: center;
  font-size: 21px;
  line-height: 1.2;
  font-weight: 750;
  letter-spacing: -.025em;
  color: var(--qf-widget-text);
}

.qf-prechat p {
  width: 100%;
  max-width: 315px;
  margin: 0 auto 25px;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--qf-widget-text-secondary);
}

/* Form becomes a proper small support form */
.qf-prechat-form {
  width: 100%;
  max-width: 330px;
  margin: 0 auto;
  gap: 14px;
}

/* Put fields inside a visual group without requiring HTML changes */
.qf-prechat-form .qf-input {
  min-height: 47px;
  padding: 12px 14px;
  border: 1px solid rgba(32,42,45,.13);
  border-radius: 12px;
  background: var(--qf-widget-bg-secondary);
  color: var(--qf-widget-text);
  font-size: 13.5px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.35);
}

.qf-prechat-form .qf-input:hover {
  border-color: rgba(35,135,155,.25);
}

.qf-prechat-form .qf-input:focus {
  border-color: #23879b;
  background: var(--qf-widget-bg);
  box-shadow: 0 0 0 3px rgba(35,135,155,.10);
}

.qf-prechat-form .qf-input::placeholder {
  color: var(--qf-widget-text-secondary);
  opacity: .72;
}

/* Button: less generic, more substantial */
.qf-prechat-form .qf-btn-primary {
  min-height: 47px;
  margin-top: 2px;
  border-radius: 12px;
  background: #23879b;
  color: #fff;
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -.005em;
  box-shadow: 0 6px 15px rgba(35,135,155,.20);
}

.qf-prechat-form .qf-btn-primary:hover {
  background: #176b7c;
  transform: translateY(-1px);
  box-shadow: 0 8px 19px rgba(35,135,155,.24);
}

.qf-prechat-form .qf-btn-primary:active {
  transform: translateY(0);
}

/* Add a simple arrow without changing JS */
.qf-prechat-form .qf-btn-text::after {
  content: "  →";
  font-size: 15px;
  font-weight: 600;
}

/* Validation errors */
.qf-error-text {
  margin-top: -8px;
  padding-left: 3px;
  font-size: 11px;
  color: var(--qf-widget-accent);
}

/* ---------- Composer ---------- */
.qf-footer {
  padding: 10px 11px 11px;
  background: var(--qf-widget-bg);
  border-top: 1px solid var(--qf-widget-border);
}

.qf-input-row {
  gap: 7px;
  padding: 1px;
  align-items: flex-end;
}

.qf-input-action {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: transparent;
}

.qf-input-action:hover {
  background: var(--qf-widget-bg-secondary);
}

.qf-input-action svg {
  width: 18px;
  height: 18px;
}

.qf-text-input {
  min-height: 40px;
  padding: 9px 14px;
  border: 1px solid rgba(32,42,45,.12);
  border-radius: 20px;
  background: var(--qf-widget-bg-secondary);
  font-size: 13px;
}

.qf-text-input:focus {
  border-color: #23879b;
  background: var(--qf-widget-bg);
  box-shadow: 0 0 0 3px rgba(35,135,155,.09);
}

.qf-send-btn {
  width: 40px;
  height: 40px;
  background: #23879b;
  box-shadow: 0 4px 10px rgba(35,135,155,.20);
}

.qf-send-btn:hover {
  background: #176b7c;
  transform: translateY(-1px);
}

/* ---------- Image previews ---------- */
.qf-image-preview-strip {
  padding: 0 3px 2px;
  gap: 7px;
}

.qf-image-preview {
  width: 58px;
  height: 58px;
  border-radius: 10px;
}

/* ---------- Mobile ---------- */
@media (max-width: 480px) {
  #qf-chat-window {
    width: calc(100vw - 24px);
    height: calc(100vh - 82px);
    max-height: none;
    right: -2px;
    bottom: 68px;
    border-radius: 18px;
  }

  #qf-prechat {
    padding: 32px 22px 24px;
  }

  .qf-msg {
    max-width: 86%;
  }

  .qf-msg-admin {
    padding-left: 11px;
  }

  .qf-msg-admin::before {
    width: 24px;
    height: 24px;
    border-radius: 8px;
  }

  .qf-msg-admin::after {
    left: 31px;
  }
}
