 /* ========================================================= 
   247ChatMate — Widget V2
   CLEAN BASELINE — SCROLL SAFE (RECOVERY — STABLE)
   BEHAVIOUR + UX POLISH PASS
========================================================= */

:root {
  --matewa-accent: #25D366;
  --matewa-accent-dark: #1fb85a;

  --matewa-bg-soft: #f1f5f9;
  --matewa-bg-white: #ffffff;

  --matewa-text-main: #0f172a;
  --matewa-text-muted: #334155;

  --matewa-vertical-gap: 12px;

  --matewa-radius: 22px;
  --matewa-radius-inner: 16px;

  --matewa-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* ---------------------------------------------------------
   SAFETY
--------------------------------------------------------- */

#matewa-widget,
#matewa-widget * {
  box-sizing: border-box;
}

/* ---------------------------------------------------------
   WIDGET SHELL
--------------------------------------------------------- */

#matewa-widget {
  position: fixed;
  bottom: 96px;
  left: 50%;
  transform: translateX(-50%);

  width: 320px;
  height: 520px;

  display: flex;
  flex-direction: column;

  visibility: hidden;
  opacity: 0;
  pointer-events: none;

  background: var(--matewa-bg-white);
  border-radius: var(--matewa-radius);
  overflow: hidden;

  box-shadow: 0 32px 70px rgba(0,0,0,.35);
  font-family: var(--matewa-font);

  z-index: 9998;
}

#matewa-widget.is-open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

/* ---------------------------------------------------------
   HEADER
--------------------------------------------------------- */

.matewa-header {
  height: 64px;
  padding: 0 18px;

  display: flex;
  align-items: center;
  justify-content: space-between;

  background: linear-gradient(
    180deg,
    var(--matewa-accent),
    var(--matewa-accent-dark)
  );

  color: #fff;
  margin-bottom: calc(var(--matewa-vertical-gap) - 16px);
}

.matewa-header-title {
  font-size: 17px;
  font-weight: 700;
}

.matewa-close {
  width: 44px;
  height: 44px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 50%;
  border: none;

  background: rgba(255,255,255,.32);
  color: #fff;

  font-size: 22px;
  font-weight: 800;
  cursor: pointer;
}

/* ---------------------------------------------------------
   SCROLL AREA (ONLY THIS SCROLLS)
--------------------------------------------------------- */

.matewa-bubbles {
  position: relative;

  flex: 1;
  display: flex;
  flex-direction: column;

  overflow-y: auto;
  overflow-x: hidden;

  padding: 16px;
  padding-bottom: 140px;

  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* ---------------------------------------------------------
   STREAM
--------------------------------------------------------- */

.matewa-stream {
  display: flex;
  flex-direction: column;
  gap: var(--matewa-vertical-gap);
}

/* ---------------------------------------------------------
   INTRO
--------------------------------------------------------- */

.matewa-intro {
  display: flex;
  flex-direction: column;
  gap: var(--matewa-vertical-gap);
}

.matewa-intro .matewa-bubble {
  opacity: 0;
  transition: opacity 0.35s ease;
}

.matewa-intro .matewa-bubble.is-visible {
  opacity: 1;
}

/* ---------------------------------------------------------
   BUBBLES
--------------------------------------------------------- */

.matewa-bubble {
  padding: 14px 16px;
  border-radius: var(--matewa-radius-inner);
  background: var(--matewa-bg-soft);

  font-size: 15px;
  line-height: 1.5;
  color: var(--matewa-text-main);

  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.95),
    0 4px 10px rgba(15,23,42,.12);
}

.matewa-muted {
  color: var(--matewa-text-muted);
}

/* ---------------------------------------------------------
   TASK APPEARANCE
--------------------------------------------------------- */

.matewa-task,
.matewa-notes,
.matewa-phone,
.matewa-contact {
  opacity: 0;
  transition: opacity 0.35s ease;
}

.matewa-task.is-active,
.matewa-notes.is-active,
.matewa-phone.is-active,
.matewa-contact.is-active {
  opacity: 1;
}

/* ---------------------------------------------------------
   CHIPS
--------------------------------------------------------- */

.matewa-chip-group {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

/* MIN FIX — breathing room ABOVE chips so prompt bubble shadow shows */
.matewa-task .matewa-chip-group {
  margin-top: 8px;
}

.matewa-chip {
  height: 48px;
  border-radius: 14px;
  border: 1.5px solid var(--matewa-accent);
  background: #fff;
  color: var(--matewa-accent);

  font-size: 13px;
  font-weight: 600;
  cursor: pointer;

  transition:
    transform 0.12s ease,
    background 0.18s ease,
    box-shadow 0.18s ease;
}

.matewa-chip.is-selected {
  background: linear-gradient(
    180deg,
    var(--matewa-accent),
    var(--matewa-accent-dark)
  );
  color: #fff;
  border-color: transparent;
}

/* ---------------------------------------------------------
   INPUTS
--------------------------------------------------------- */

.matewa-notes,
.matewa-phone,
.matewa-contact {
  display: none;
  flex-direction: column;
  gap: 6px;
}

.matewa-notes.is-active,
.matewa-phone.is-active,
.matewa-contact.is-active {
  display: flex;
}

/* ---------- TEXTAREA (WHATSAPP-LIKE — 1 LINE) ---------- */

.matewa-notes textarea {
  width: 100%;

  font-family: var(--matewa-font);
  font-size: 15px;
  line-height: 1.4;

  padding: 10px 16px;
  border-radius: 14px;
  border: 1.5px solid var(--matewa-accent);

  height: calc(1.4em + 20px);
  max-height: calc(1.4em + 20px);

  resize: none;
  overflow-y: auto;

  display: block;
}

.matewa-notes textarea {
  scroll-behavior: auto;
}

/* ---------------------------------------------------------
   OTHER INPUTS
--------------------------------------------------------- */

.matewa-phone input,
.matewa-contact input {
  height: 48px;
  border-radius: 14px;
  border: 1.5px solid var(--matewa-accent);
  padding: 0 16px;

  font-family: var(--matewa-font);
  font-size: 15px;
}

/* ---------------------------------------------------------
   CHARACTER COUNTER
--------------------------------------------------------- */

.matewa-notes {
  position: relative;
}

/* required for phone helper anchoring */
.matewa-phone {
  position: relative;
}

.matewa-char-counter {
  position: absolute;
  right: 26px; /* pulled inward to clear scrollbar */
  bottom: 8px;

  font-size: 10px;
  font-weight: 600;
  color: var(--matewa-text-muted);

  pointer-events: none;
}

/* ⭐ MIN FIX — micro-lowered to clear bubble radius cleanly */
.matewa-phone .matewa-char-counter {
  bottom: 80px;
}

/* ---------------------------------------------------------
   CTA — CLICK-SAFE MIN FIX (WIDTH ALIGNMENT CORRECTED)
--------------------------------------------------------- */

.matewa-cta {
  position: absolute;
  left: 0;                 /* match stream padding system */
  right: 0;
  bottom: 56px;

  padding: 0 16px;         /* identical horizontal rhythm to .matewa-bubbles */
  display: flex;
  flex-direction: column;
  gap: var(--matewa-vertical-gap);

  background: linear-gradient(
    to top,
    rgba(255,255,255,0.96),
    rgba(255,255,255,0.92)
  );

  border-radius: 0;        /* no artificial inner rounding */

  z-index: 2;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;

  transition: opacity 0.25s ease;
}

.matewa-cta.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  z-index: 5;
}

.matewa-cta .matewa-chip-group {
  margin-top: 4px;
}

/* ---------------------------------------------------------
   CTA CHIP LAYOUT (2-COLUMN OVERRIDE)
--------------------------------------------------------- */

.matewa-cta .matewa-chip-group {
  grid-template-columns: 1fr 1fr; /* force 2 equal columns */
}

.matewa-cta .matewa-chip {
  height: 48px;           /* slightly stronger presence */
  font-size: 14px;        /* tiny increase for clarity */
}

.matewa-cta .matewa-chip {
  display: flex;
  align-items: center;     /* vertical centre */
  justify-content: center; /* horizontal centre */
  text-align: center;
}


/* ---------------------------------------------------------
   BRANDING
--------------------------------------------------------- */

.matewa-branding {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;

  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;

  background: #fff;
  border-top: 1px solid #eef2f7;

  font-size: 12px;
  z-index: 3;
}

.matewa-branding a {
  color: var(--matewa-accent);
  font-weight: 600;
}

/* ---------------------------------------------------------
   LAUNCHER (UNCHANGED)
--------------------------------------------------------- */

#matewa-launcher {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);

  height: 52px;
  padding: 0 22px;

  border-radius: 26px;
  border: none;

  background: linear-gradient(
    180deg,
    var(--matewa-accent),
    var(--matewa-accent-dark)
  );

  color: #fff;
  font-size: 15px;
  font-weight: 700;

  box-shadow: 0 14px 36px rgba(0,0,0,.28);
  cursor: pointer;
  z-index: 9999;
}

#matewa-launcher::before {
  content: "Chat on WhatsApp";
}

/* ---------------------------------------------------------
   LOCKED INPUT VISUAL (PAINT ONLY)
--------------------------------------------------------- */

.matewa-notes textarea.is-locked,
.matewa-phone input.is-locked,
.matewa-contact input.is-locked {
  background: linear-gradient(
    180deg,
    var(--matewa-accent),
    var(--matewa-accent-dark)
  ) !important;

  color: #ffffff !important;
  border-color: transparent !important;
  box-shadow: none !important;
  caret-color: transparent;
}

.matewa-notes textarea.is-locked::placeholder,
.matewa-phone input.is-locked::placeholder,
.matewa-contact input.is-locked::placeholder {
  color: rgba(255,255,255,.9) !important;
}

/* ---------------------------------------------------------
   FOCUS STATE
--------------------------------------------------------- */

.matewa-notes textarea:focus,
.matewa-phone input:focus,
.matewa-contact input:focus {
  outline: none !important;
  border-color: var(--matewa-accent);
  box-shadow: 0 0 0 2px rgba(37,211,102,.25);
}

.matewa-notes textarea:not(.is-locked):focus,
.matewa-phone input:not(.is-locked):focus,
.matewa-contact input:not(.is-locked):focus {
  background: #f6fff9;
}
/* =========================================================
   PHONE HELPER — INLINE, STABLE, TEXT-SWAP ONLY
   Restores helper under input + Mickey-mouse warning
========================================================= */

/* override absolute positioning for PHONE ONLY */
.matewa-phone .matewa-char-counter {
  position: static;          /* inline flow */
  margin-top: 4px;           /* small fixed gap under input */
  padding-left: 16px;        /* align with input text */

  font-size: 11px;
  line-height: 1.3;
  font-weight: 500;

  color: var(--matewa-text-muted);
  text-align: left;

  pointer-events: none;
}
/* =========================================================
   CONTACT HELPER — EXACT MATCH TO PHONE HELPER
   Reserved space, text-swap only
========================================================= */

.matewa-contact .matewa-soft-hint {
  display: block;

  height: 14px;            /* reserve space permanently */
  margin-top: 4px;         /* same rhythm as phone */
  padding-left: 16px;      /* align with input text */

  font-size: 11px;         /* EXACT match */
  line-height: 1.3;
  font-weight: 500;

  color: var(--matewa-text-muted);
  text-align: left;

  opacity: 0;              /* invisible by default */
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.matewa-contact .matewa-soft-hint.is-visible {
  opacity: 1;
}
/* =========================================================
   FINAL MICRO-RHYTHM FIX — PHONE + CONTACT HELPERS
   Symmetric spacing, no layout shift, text-swap only
========================================================= */

/* shared helper rhythm (phone + contact) */
.matewa-phone .matewa-char-counter,
.matewa-contact .matewa-soft-hint {
  display: block;

  /* 👇 equal vertical rhythm */
  margin-top: 4px;
  margin-bottom: 4px;

  padding-left: 16px; /* align with input text */

  font-size: 12px;
  line-height: 10px;
  font-weight: 500;

  color: var(--matewa-text-muted);
  opacity: 0.8;

  pointer-events: none;
}

/* ensure helpers never push layout when empty */
.matewa-contact .matewa-soft-hint {
  height: 14px; /* reserve exactly one line */
}

/* warnings override colour only (no spacing change) */
.matewa-phone .matewa-char-counter.is-warning,
.matewa-contact .matewa-soft-hint.is-warning {
  color: var(--matewa-text-muted);
  opacity: 1;
}
/* =========================================================
   RTL SUPPORT — MINIMAL, AUTO (NO BLOAT)
========================================================= */

#matewa-wrapper[dir="rtl"] {
  direction: rtl;
}

#matewa-wrapper[dir="rtl"] .matewa-stream,
#matewa-wrapper[dir="rtl"] .matewa-intro,
#matewa-wrapper[dir="rtl"] .matewa-bubble,
#matewa-wrapper[dir="rtl"] .matewa-phone .matewa-char-counter,
#matewa-wrapper[dir="rtl"] .matewa-contact .matewa-soft-hint {
  text-align: right;
}

#matewa-wrapper[dir="rtl"] .matewa-chip-group {
  direction: rtl; /* keeps visual grid natural */
}

#matewa-wrapper[dir="rtl"] .matewa-char-counter {
  right: auto;
  left: 26px; /* mirror positioning */
}