:root {
  --mrsparky-accent: #F2D204;   /* brand yellow — floating button */
  --mrsparky-primary: #174888;  /* brand blue — header, focus lines, send */
  --mrsparky-bg: #ffffff;       /* popup background (configurable in settings) */
  --mrsparky-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Self-contained typography so the widget looks the same on any theme. */
.mrsparky-textus-fab,
.mrsparky-textus-modal,
.mrsparky-textus-modal input,
.mrsparky-textus-modal textarea,
.mrsparky-textus-modal button {
  font-family: var(--mrsparky-font);
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.4;
  box-sizing: border-box;
}

/* Floating action button — yellow pill, morphs into circle while the panel is open */
.mrsparky-textus-fab {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 100000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 26px !important;
  border: none !important;
  border-radius: 999px !important;   /* full pill — beats Elementor's square button radius */
  background: var(--mrsparky-accent) !important;
  color: var(--mrsparky-primary) !important;
  font-size: 17px;
  line-height: 1 !important;         /* tight line box so icon + text sit centred */
  text-align: center !important;
  cursor: pointer !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

/* Icon + label centred both axes inside the pill */
.mrsparky-textus-fab .mrsparky-fab-closed {
  justify-content: center;
  line-height: 1;
}

.mrsparky-textus-fab svg {
  display: block !important;   /* kills the SVG baseline gap that pushed it off-centre */
  flex-shrink: 0;
}

.mrsparky-textus-fab .mrsparky-fab-closed > span {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}

/* Bold / italic toggles for the button label (set in settings) */
.mrsparky-textus-fab .mrsparky-fab-closed > span { font-weight: 400; }
.mrsparky-textus-fab.mrsparky-bold .mrsparky-fab-closed > span { font-weight: 700; }
.mrsparky-textus-fab.mrsparky-italic .mrsparky-fab-closed > span { font-style: italic; }

.mrsparky-textus-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
  background: var(--mrsparky-accent) !important;
  color: var(--mrsparky-primary) !important;
}

/* Gentle entrance for the teaser bubble */
@keyframes mrsparky-teaser-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* Auto-popup teaser bubble — sits ABOVE the button (Podium-style) */
.mrsparky-textus-tooltip {
  position: fixed;
  right: 28px;
  left: auto;
  bottom: 100px;            /* clears the ~54px button + gap */
  animation: mrsparky-teaser-in 0.28s ease-out;
  z-index: 99999;
  max-width: 264px;
  padding: 16px 18px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
  color: var(--mrsparky-primary);
  font-size: 15.5px;
  line-height: 1.5;
  font-family: var(--mrsparky-font);
  display: flex;
  gap: 8px;
  align-items: flex-start;
}

/* When the button is on the left, the teaser follows it to the left */
.mrsparky-textus-tooltip.mrsparky-tooltip-left {
  right: auto;
  left: 28px;
}

/* Little tail pointing down at the button */
.mrsparky-textus-tooltip::after {
  content: "";
  position: absolute;
  bottom: -7px;
  right: 34px;
  left: auto;
  width: 14px;
  height: 14px;
  background: #fff;
  transform: rotate(45deg);
  box-shadow: 3px 3px 6px rgba(0, 0, 0, 0.06);
}

.mrsparky-textus-tooltip.mrsparky-tooltip-left::after {
  right: auto;
  left: 34px;
}

.mrsparky-textus-tooltip[hidden] {
  display: none !important;
}

.mrsparky-tooltip-text {
  flex: 1;
  font-weight: 500;
}

.mrsparky-tooltip-close {
  flex-shrink: 0;
  background: none !important;   /* strip the theme's button box + border */
  border: none !important;
  box-shadow: none !important;
  outline: none !important;
  color: #8a919c !important;     /* plain visible grey × (not pink, not white) */
  font-size: 18px !important;
  line-height: 1 !important;
  cursor: pointer !important;
  padding: 0 !important;
  margin: 0 !important;
  min-width: 0 !important;
  width: auto !important;
  height: auto !important;
  /* Hidden until the visitor hovers the bubble (Podium-style, but visible when shown) */
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.mrsparky-textus-tooltip:hover .mrsparky-tooltip-close,
.mrsparky-tooltip-close:focus-visible {
  opacity: 1;
  pointer-events: auto;
}

/* Touch screens can't hover — keep the ✕ always visible there */
@media (hover: none) {
  .mrsparky-tooltip-close {
    opacity: 1;
    pointer-events: auto;
  }
}

.mrsparky-tooltip-close:hover {
  color: var(--mrsparky-primary) !important;
}

/* Optional brand logo in the teaser bubble */
.mrsparky-tooltip-logo {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}

.mrsparky-fab-closed {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.mrsparky-fab-x {
  display: none;
  font-size: 22px;
  line-height: 1;
}

.mrsparky-textus-fab.mrsparky-open {
  width: 54px !important;
  height: 54px !important;
  padding: 0 !important;   /* must beat the base pill's !important padding, else the × is pushed off-centre */
  border-radius: 50% !important;
  background: var(--mrsparky-primary);
  color: #fff;
}

.mrsparky-textus-fab.mrsparky-open .mrsparky-fab-closed {
  display: none;
}

.mrsparky-textus-fab.mrsparky-open .mrsparky-fab-x {
  display: block;
}

/* Bottom-left placement (set in WordPress settings) */
.mrsparky-textus-fab.mrsparky-pos-left {
  right: auto;
  left: 28px;
}

.mrsparky-textus-fab.mrsparky-pos-left ~ .mrsparky-textus-overlay .mrsparky-textus-modal {
  right: auto;
  left: 20px;
}

/* Panel container — no dark overlay; page stays interactive around the panel */
.mrsparky-textus-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  pointer-events: none;
}

.mrsparky-textus-overlay[hidden] {
  display: none !important;
}

/* Panel docked bottom-right, above the button */
.mrsparky-textus-modal {
  pointer-events: auto;
  position: absolute;
  right: 20px;
  bottom: 90px;
  width: 372px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 120px);
  overflow: hidden auto;
  border-radius: 14px;
  background: var(--mrsparky-bg);
  color: #1a1a1a;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

/* Blue header bar */
.mrsparky-textus-header {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 15px 20px;
  background: var(--mrsparky-primary);
  color: #fff;
  z-index: 1;
}

.mrsparky-textus-header svg {
  flex-shrink: 0;
}

.mrsparky-header-logo {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  object-fit: cover;
}

.mrsparky-textus-header h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 400;
  color: #fff;
}

/* Header close ✕ — phones only; on desktop the FAB circle-X closes the panel */
#mrsparky-textus-overlay .mrsparky-textus-close {
  display: none !important;
  margin-left: auto;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 32px !important;
  height: 32px !important;
  border: none !important;
  border-radius: 50% !important;
  background: rgba(255, 255, 255, 0.18) !important;
  box-shadow: none !important;
  font-size: 20px !important;
  line-height: 1 !important;
  color: #fff !important;
  cursor: pointer !important;
  padding: 0 !important;
}

.mrsparky-textus-body {
  padding: 18px 22px 22px;
}

/* Grey speech bubble under the header (hidden after successful submit) */
.mrsparky-textus-bubble {
  margin: 0 0 8px;
  padding: 14px 16px;
  background: #e8ecf3;
  border-radius: 12px;
  color: #333;
  font-size: 15px;
}

/* Underline-style fields with floating labels */
.mrsparky-field {
  position: relative;
  margin: 28px 0 4px;
}

/* ID prefix (#mrsparky-textus-overlay) raises specificity so aggressive theme
   button/input rules can't win a source-order tie — beats class-based CSS. */
#mrsparky-textus-overlay .mrsparky-field input,
#mrsparky-textus-overlay .mrsparky-field textarea {
  display: block;
  width: 100%;
  padding: 8px 0 7px !important;
  border: none !important;                       /* theme boxes → clean underline */
  border-bottom: 1px solid #c7ccd4 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  font-size: 16px;
  color: #1a1a1a !important;
  outline: none !important;
  resize: vertical;
}

#mrsparky-textus-overlay .mrsparky-field input:focus,
#mrsparky-textus-overlay .mrsparky-field textarea:focus {
  border: none !important;
  border-bottom: 2px solid var(--mrsparky-primary) !important;
  box-shadow: none !important;
  padding-bottom: 6px !important; /* compensate the thicker line so nothing jumps */
}

.mrsparky-field label {
  position: absolute;
  left: 0;
  top: 8px;
  color: #8a919c;
  font-size: 16px;
  font-weight: 400;
  pointer-events: none;
  transition: top 0.15s ease, font-size 0.15s ease, color 0.15s ease;
}

/* Float the label up when the field is focused or has content */
.mrsparky-field input:focus ~ label,
.mrsparky-field textarea:focus ~ label,
.mrsparky-field input:not(:placeholder-shown) ~ label,
.mrsparky-field textarea:not(:placeholder-shown) ~ label {
  top: -15px;
  font-size: 12px;
  font-weight: 600;
}

.mrsparky-field input:focus ~ label,
.mrsparky-field textarea:focus ~ label {
  color: var(--mrsparky-primary);
}

/* Live character counter under the message field */
.mrsparky-textus-count {
  margin: 2px 0 0;
  text-align: right;
  font-size: 12px;
  color: #8a919c;
}

/* Photo upload */
.mrsparky-photos {
  margin: 14px 0 0;
}

#mrsparky-textus-overlay .mrsparky-photos-btn {
  width: 100%;
  padding: 10px !important;
  border: 1px dashed #aab3c0 !important;   /* not the theme's pink */
  border-radius: 8px !important;
  background: #f7f9fd !important;
  color: #48505e !important;
  box-shadow: none !important;
  text-shadow: none !important;
  font-size: 14px;
  font-weight: 400 !important;
  cursor: pointer !important;
}

#mrsparky-textus-overlay .mrsparky-photos-btn:hover {
  border-color: var(--mrsparky-primary) !important;
  color: var(--mrsparky-primary) !important;
  background: #f7f9fd !important;
}

.mrsparky-thumbs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.mrsparky-thumb {
  position: relative;
  width: 62px;
  height: 62px;
}

.mrsparky-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 8px;
}

#mrsparky-textus-overlay .mrsparky-thumb button {
  position: absolute;
  top: -7px;
  right: -7px;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 20px !important;
  height: 20px !important;
  border: none !important;
  border-radius: 50% !important;
  background: #1c2430 !important;
  color: #fff !important;
  font-size: 13px !important;
  line-height: 1 !important;
  cursor: pointer !important;
  padding: 0 !important;
  box-shadow: none !important;
}

/* Honeypot stays visually hidden */
.mrsparky-textus-hp {
  position: absolute !important;
  left: -9999px !important;
}

/* Consent fine print (above the Send button) */
.mrsparky-textus-fineprint {
  margin: 16px 0 14px;
  color: #777;
  font-size: 12px;
  line-height: 1.5;
}

#mrsparky-textus-overlay .mrsparky-textus-fineprint a {
  color: var(--mrsparky-primary) !important;
  text-decoration: underline !important;
}

.mrsparky-textus-policy {
  display: inline-block;
  margin-top: 4px;
  font-weight: 600;
}

.mrsparky-textus-error {
  margin: 0 0 12px;
  color: #c0392b;
  font-size: 14px;
}

#mrsparky-textus-overlay .mrsparky-textus-submit {
  display: block !important;
  margin: 0 auto !important;
  padding: 12px 44px !important;
  border: none !important;
  border-radius: 8px !important;
  background: var(--mrsparky-primary) !important;
  color: #fff !important;
  font-size: 16px !important;
  font-weight: 400 !important;
  cursor: pointer !important;
  box-shadow: none !important;
  text-shadow: none !important;
}

#mrsparky-textus-overlay .mrsparky-textus-submit:hover {
  filter: brightness(1.15) !important;
}

.mrsparky-textus-submit:disabled {
  opacity: 0.6 !important;
  cursor: wait !important;
}

.mrsparky-textus-success {
  text-align: center;
  padding: 16px 0;
}

.mrsparky-textus-success h3 {
  color: var(--mrsparky-primary);
}

@media (max-width: 480px) {
  .mrsparky-textus-fab {
    right: 14px;
    bottom: 14px;
    padding: 10px 18px !important;
    font-size: 15px;
  }
}

/* ---- Phones: Podium-style top-anchored sheet ----
   The panel docks to the TOP of the screen so the fields sit in the half the
   keyboard never covers. JS keeps --mrsparky-vvh equal to the visible area
   (visualViewport) so the sheet resizes live when the keyboard opens. */
@media (max-width: 640px) {
  #mrsparky-textus-overlay .mrsparky-textus-modal {
    top: 0 !important;
    bottom: auto !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: var(--mrsparky-vvh, 100vh);
    height: var(--mrsparky-vvh, 100dvh);
    max-height: none !important;
    border-radius: 0 0 16px 16px;
    overflow: hidden auto;
  }

  /* Phones get the header ✕ — the bottom FAB is unreachable under the keyboard */
  #mrsparky-textus-overlay .mrsparky-textus-close {
    display: inline-flex !important;
  }
}
