/* Lead Autopsy WhatsApp & Call Connect - frontend widget
   Colours come from --lacrm-wa-color and --lacrm-phone-color set inline on #lacrm-wa-root. */

/* ── Reset: undo any inherited or leaked styles from deactivated plugins ── */
#lacrm-wa-root,
#lacrm-wa-root *,
.lacrm-wa-root,
.lacrm-wa-root * {
    box-sizing: border-box;
    letter-spacing: normal;
    text-transform: none;
    text-indent: 0;
    text-shadow: none;
    float: none;
}

.lacrm-wa-root {
    --lacrm-wa-color: #25D366;
    --lacrm-phone-color: #2563eb;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    /* Ensure our root is always visible even if a theme hides fixed elements */
    visibility: visible !important;
    opacity: 1 !important;
}

/* ----- Launcher buttons ----- */
.lacrm-wa-launcher {
    position: fixed !important;
    bottom: 22px;
    z-index: 999990 !important;
    width: 58px !important;
    height: 58px !important;
    border-radius: 50% !important;
    border: none !important;
    cursor: pointer;
    display: flex !important;
    align-items: center;
    justify-content: center;
    color: #fff !important;
    box-shadow: 0 6px 22px rgba(0,0,0,.28);
    transition: transform .18s ease, box-shadow .18s ease;
    -webkit-tap-highlight-color: transparent;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    /* Reset common theme overrides */
    margin: 0 !important;
    padding: 0 !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: none !important;
    max-height: none !important;
    text-decoration: none !important;
    outline: none !important;
    overflow: visible !important;
}
.lacrm-wa-launcher:hover { transform: scale(1.07); box-shadow: 0 8px 28px rgba(0,0,0,.34); }
.lacrm-wa-launcher:active { transform: scale(.96); }
/* Icon hardening. Some page builders ship global SVG resets (for example
   forcing every svg to 1em or auto height, or overriding fill) that win over
   the SVG width/height/fill attributes and shrink or hide our icons. The rules
   below lock the widget icons down so no theme can interfere. */
.lacrm-wa-launcher svg {
    position: relative;
    z-index: 2;
    display: block !important;
    flex: 0 0 auto !important;
    max-width: none !important;
    max-height: none !important;
}
.lacrm-whatsapp-launcher svg { width: 30px !important; height: 30px !important; }
.lacrm-phone-launcher svg    { width: 26px !important; height: 26px !important; }
.lacrm-wa-launcher svg,
.lacrm-wa-launcher svg path { fill: #fff !important; }

/* Same protection for the panel, submit and inline-button icons. */
.lacrm-wa-root svg,
.lacrm-wa-inline svg { max-width: none !important; max-height: none !important; vertical-align: middle; }
.lacrm-wa-header-avatar svg { width: 22px !important; height: 22px !important; }
.lacrm-wa-submit svg        { width: 18px !important; height: 18px !important; }
.lacrm-wa-inline-btn svg    { width: 22px !important; height: 22px !important; }
.lacrm-wa-header-avatar svg, .lacrm-wa-header-avatar svg path,
.lacrm-wa-submit svg, .lacrm-wa-submit svg path,
.lacrm-wa-inline-btn svg, .lacrm-wa-inline-btn svg path { fill: #fff !important; }

.lacrm-wa-launcher.lacrm-pos-right { right: 22px; }
.lacrm-wa-launcher.lacrm-pos-left  { left: 22px; }

.lacrm-whatsapp-launcher { background: var(--lacrm-wa-color); }

/* ── Phone group: ring icon + number bar ── */
.lacrm-phone-group {
    position: fixed !important;
    bottom: var(--phone-bottom, 22px);
    z-index: 999990 !important;
    display: flex !important;
    align-items: center;
    gap: 0;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}
.lacrm-phone-group.lacrm-pos-left  {
    left: var(--phone-side, 22px);
    flex-direction: row;        /* icon on left, bar slides right */
}
.lacrm-phone-group.lacrm-pos-right {
    right: var(--phone-side, 22px);
    flex-direction: row-reverse; /* icon on right, bar slides left */
}

/* When stacked with WhatsApp on the same side, push the whole group up */
.lacrm-phone-group.lacrm-stacked { bottom: calc(var(--phone-bottom, 22px) + 70px); }

/* The ring button inside the group no longer needs fixed positioning */
.lacrm-phone-group .lacrm-phone-launcher {
    position: relative !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    flex-shrink: 0;
    background: var(--lacrm-phone-color);
}

/* ── Number bar ── */
.lacrm-phone-bar {
    display: flex !important;
    align-items: center;
    height: 40px;
    padding: 0 16px;
    background: var(--lacrm-phone-color);
    color: #fff !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.3px;
    white-space: nowrap;
    text-decoration: none !important;
    border: none !important;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    animation: lacrm-bar-slide .4s ease .6s both;
}
.lacrm-phone-bar:hover,
.lacrm-phone-bar:focus {
    filter: brightness(1.1);
    color: #fff !important;
    text-decoration: none !important;
}
.lacrm-phone-bar-num {
    display: inline;
}

/* Bar shape: rounded end away from the icon */
.lacrm-phone-group.lacrm-pos-left .lacrm-phone-bar {
    border-radius: 0 22px 22px 0;
    margin-left: -4px;  /* tuck under the round icon edge */
    padding-left: 12px;
}
.lacrm-phone-group.lacrm-pos-right .lacrm-phone-bar {
    border-radius: 22px 0 0 22px;
    margin-right: -4px;
    padding-right: 12px;
}

/* Slide-in animation */
@keyframes lacrm-bar-slide {
    from { max-width: 0; padding-left: 0; padding-right: 0; opacity: 0; overflow: hidden; }
    to   { max-width: 260px; opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
    .lacrm-phone-bar { animation: none; }
}

/* ── Bar device visibility ── */
.lacrm-bar-desktop-only .lacrm-phone-bar { display: flex !important; }
.lacrm-bar-mobile-only  .lacrm-phone-bar { display: none !important; }
@media (max-width: 768px) {
    .lacrm-bar-desktop-only .lacrm-phone-bar { display: none !important; }
    .lacrm-bar-mobile-only  .lacrm-phone-bar { display: flex !important; }
}

/* When both buttons share a side, PHP adds .lacrm-stacked to the phone
   launcher so it sits above WhatsApp instead of overlapping it. */

/* ----- CTA bubble beside the WhatsApp icon ----- */
.lacrm-wa-cta {
    position: fixed;
    bottom: 30px;
    z-index: 999989;
    background: var(--cta-bg, #fff);
    color: var(--cta-fg, #1f2937);
    font-size: var(--cta-fs, 13px);
    max-width: var(--cta-maxw, 150px);
    line-height: 1.25;
    padding: 9px 24px 9px 13px;
    border-radius: 12px;
    box-shadow: 0 6px 22px rgba(0,0,0,.18);
    cursor: pointer;
    font-weight: 600;
    -webkit-tap-highlight-color: transparent;
    animation: lacrm-cta-in .35s ease .9s both;
}
.lacrm-wa-cta.lacrm-pos-right { right: 90px; }
.lacrm-wa-cta.lacrm-pos-left  { left: 90px; }

/* little tail pointing at the icon */
.lacrm-wa-cta::after {
    content: "";
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    border: 7px solid transparent;
}
.lacrm-wa-cta.lacrm-pos-right::after { right: -12px; border-left-color: var(--cta-bg, #fff); }
.lacrm-wa-cta.lacrm-pos-left::after  { left: -12px;  border-right-color: var(--cta-bg, #fff); }

.lacrm-wa-cta-text { display: block; }

.lacrm-wa-cta-close {
    position: absolute;
    top: 3px;
    right: 6px;
    width: 16px;
    height: 16px;
    padding: 0;
    border: none;
    background: none;
    color: inherit;
    opacity: .45;
    font-size: 15px;
    line-height: 14px;
    cursor: pointer;
}
.lacrm-wa-cta-close:hover { opacity: 1; }

@keyframes lacrm-cta-in {
    from { opacity: 0; transform: translateY(8px) scale(.96); }
    to   { opacity: 1; transform: translateY(0)   scale(1); }
}
@media (prefers-reduced-motion: reduce) {
    .lacrm-wa-cta { animation: none; }
}

/* ----- WhatsApp pulse ----- */
.lacrm-wa-pulse {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--lacrm-wa-color);
    opacity: .55;
    z-index: 1;
    animation: lacrm-wa-pulse 2.2s ease-out infinite;
}
@keyframes lacrm-wa-pulse {
    0%   { transform: scale(1);   opacity: .55; }
    70%  { transform: scale(1.7); opacity: 0; }
    100% { transform: scale(1.7); opacity: 0; }
}

/* ----- Phone ring waves ----- */
.lacrm-ring-wave {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid var(--lacrm-phone-color);
    z-index: 1;
    animation: lacrm-ring 1.8s ease-out infinite;
    pointer-events: none;
}
.lacrm-ring-wave-2 { animation-delay: .6s; }
@keyframes lacrm-ring {
    0%   { transform: scale(1);   opacity: .8; }
    100% { transform: scale(2.1); opacity: 0; }
}
.lacrm-phone-launcher svg { animation: lacrm-shake 2.4s ease-in-out infinite; transform-origin: center; }
@keyframes lacrm-shake {
    0%, 60%, 100% { transform: rotate(0); }
    5%, 15%, 25%  { transform: rotate(-14deg); }
    10%, 20%, 30% { transform: rotate(14deg); }
}

/* ----- Chat panel ----- */
.lacrm-wa-panel {
    position: fixed;
    bottom: 92px;
    z-index: 999991;
    width: 340px;
    max-width: calc(100vw - 32px);
    background: #fff;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 18px 50px rgba(0,0,0,.28);
    opacity: 0;
    transform: translateY(16px) scale(.98);
    transition: opacity .2s ease, transform .2s ease;
    pointer-events: none;
}
.lacrm-wa-panel.open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }
.lacrm-wa-panel.lacrm-pos-right { right: 22px; }
.lacrm-wa-panel.lacrm-pos-left  { left: 22px; }

.lacrm-wa-panel-header {
    background: var(--lacrm-wa-color);
    color: #fff;
    padding: 16px 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}
.lacrm-wa-header-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex; align-items: center; justify-content: center;
    flex: 0 0 auto;
}
.lacrm-wa-header-text { display: flex; flex-direction: column; line-height: 1.25; }
.lacrm-wa-header-text strong { font-size: 15px; }
.lacrm-wa-header-text span { font-size: 12px; opacity: .92; }
.lacrm-wa-close {
    position: absolute; top: 10px; right: 12px;
    background: transparent; border: none; color: #fff;
    font-size: 22px; line-height: 1; cursor: pointer; opacity: .85; padding: 2px 6px;
}
.lacrm-wa-close:hover { opacity: 1; }

.lacrm-wa-panel-body {
    padding: 14px 16px 16px;
    background: #f5f6f6;
    max-height: 70vh;
    overflow-y: auto;
}

/* WhatsApp-style greeting bubble */
.lacrm-wa-greeting { margin-bottom: 14px; }
.lacrm-wa-bubble {
    background: #fff;
    border-radius: 0 12px 12px 12px;
    padding: 10px 12px;
    font-size: 13px;
    color: #1f2937;
    box-shadow: 0 1px 2px rgba(0,0,0,.08);
    line-height: 1.45;
}
.lacrm-wa-bubble small { color: #6b7280; display: inline-block; margin-top: 4px; }

/* Fields */
.lacrm-wa-field { display: block; margin-bottom: 10px; }
.lacrm-wa-field > span { display: block; font-size: 12px; font-weight: 600; color: #374151; margin-bottom: 4px; }
.lacrm-wa-field > span em { color: #dc2626; font-style: normal; }
.lacrm-wa-field input,
.lacrm-wa-field textarea,
.lacrm-wa-field select {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 9px;
    padding: 10px 12px;
    font-size: 14px;
    background: #fff;
    color: #111827;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.lacrm-wa-field input:focus,
.lacrm-wa-field textarea:focus,
.lacrm-wa-field select:focus {
    border-color: var(--lacrm-wa-color);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--lacrm-wa-color) 22%, transparent);
}
.lacrm-wa-field textarea { resize: vertical; min-height: 44px; }

/* Branch/agent picker — make it unmistakably a dropdown, not a text field */
.lacrm-wa-field select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    cursor: pointer;
    font-weight: 600;
    padding-right: 38px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%23374151' stroke-width='2' fill='none' fill-rule='evenodd' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 14px 9px;
}
.lacrm-wa-field select:hover {
    border-color: var(--lacrm-wa-color);
}

/* Branch selector gets an extra highlight so it doesn't blend in with the rest of the form */
.lacrm-wa-field-branch {
    background: color-mix(in srgb, var(--lacrm-wa-color) 6%, #fff);
    border: 1px solid color-mix(in srgb, var(--lacrm-wa-color) 30%, #e5e7eb);
    border-radius: 10px;
    padding: 10px 10px 12px;
    margin-bottom: 14px;
}
.lacrm-wa-field-branch > span {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--lacrm-wa-color);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .02em;
}
.lacrm-wa-field-branch > span::before {
    content: "📍";
    font-size: 13px;
}
.lacrm-wa-field-branch select {
    border-color: color-mix(in srgb, var(--lacrm-wa-color) 45%, #d1d5db);
    background-color: #fff;
}

.lacrm-wa-invalid { border-color: #dc2626 !important; box-shadow: 0 0 0 3px rgba(220,38,38,.18) !important; }

.lacrm-wa-error {
    background: #fef2f2; color: #b91c1c;
    border: 1px solid #fecaca; border-radius: 8px;
    padding: 8px 10px; font-size: 12px; margin-bottom: 10px;
}

/* Submit */
.lacrm-wa-submit {
    width: 100%;
    background: var(--lacrm-wa-color);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 13px 16px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: filter .15s ease, transform .1s ease;
}
.lacrm-wa-submit:hover { filter: brightness(1.05); }
.lacrm-wa-submit:active { transform: scale(.985); }
.lacrm-wa-submit.sending { opacity: .75; pointer-events: none; }

.lacrm-wa-footer-note { text-align: center; font-size: 11px; color: #9ca3af; margin-top: 10px; }

/* ----- Inline shortcode button ----- */
.lacrm-wa-inline {
    --lacrm-wa-color: #25D366;
    margin: 16px 0;
}
.lacrm-wa-inline-btn {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    background: var(--lacrm-wa-color);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 12px 20px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(37,211,102,.35);
    transition: transform .12s ease, filter .15s ease;
    font-family: inherit;
}
.lacrm-wa-inline-btn:hover { transform: translateY(-1px); filter: brightness(1.04); }

/* ----- Mobile ----- */
@media (max-width: 480px) {
    .lacrm-wa-panel { width: calc(100vw - 24px); bottom: 88px; }
    .lacrm-wa-panel.lacrm-pos-right { right: 12px; }
    .lacrm-wa-panel.lacrm-pos-left  { left: 12px; }
    .lacrm-wa-launcher { width: 54px; height: 54px; bottom: 18px; }
    .lacrm-wa-launcher.lacrm-pos-right { right: 16px; }
    .lacrm-wa-launcher.lacrm-pos-left  { left: 16px; }
}

/* ----- Inline humanised pill (Ninja-style chat invite) ----- */
.lacrm-wa-inline { display: inline-block; max-width: 100%; }
.lacrm-wa-pill {
    display: inline-flex; align-items: center; gap: 12px;
    background: var(--lacrm-wa-color, #25D366);
    border: 0; border-radius: 999px; cursor: pointer;
    padding: 8px 18px 8px 8px; color: #fff; text-align: left; max-width: 100%;
    box-shadow: 0 6px 18px rgba(0,0,0,.18);
    font-family: inherit; transition: transform .15s ease, box-shadow .15s ease;
}
.lacrm-wa-pill:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(0,0,0,.22); }
.lacrm-wa-pill-ava { position: relative; flex: 0 0 auto; width: 52px; height: 52px; }
.lacrm-wa-pill-ava img,
.lacrm-wa-pill-initial {
    width: 52px; height: 52px; border-radius: 50%; object-fit: cover;
    background: #fff; display: flex; align-items: center; justify-content: center;
    color: var(--lacrm-wa-color, #25D366); font-weight: 700; font-size: 22px;
    border: 2px solid #fff; box-sizing: border-box;
}
.lacrm-wa-pill-wa {
    position: absolute; right: -2px; bottom: -2px;
    width: 22px; height: 22px; border-radius: 50%;
    background: #25D366; border: 2px solid #fff;
    display: flex; align-items: center; justify-content: center;
}
.lacrm-wa-pill-wa svg { width: 13px !important; height: 13px !important; }
.lacrm-wa-pill-body { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.lacrm-wa-pill-title { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lacrm-wa-pill-online {
    font-size: 10px; font-weight: 600; background: rgba(255,255,255,.25);
    padding: 1px 8px; border-radius: 999px;
}
.lacrm-wa-pill-msg { font-size: 13px; opacity: .95; margin-top: 2px; }
.lacrm-wa-pill-arrow { flex: 0 0 auto; font-size: 22px; line-height: 1; opacity: .9; margin-left: 4px; }

/* ----- Panel header staff photo + online dot ----- */
.lacrm-wa-header-avatar { position: relative; }
.lacrm-wa-header-avatar.has-photo { background: transparent !important; padding: 0 !important; overflow: visible; }
.lacrm-wa-header-avatar.has-photo img {
    width: 40px; height: 40px; border-radius: 50%; object-fit: cover; display: block;
    border: 2px solid rgba(255,255,255,.6); box-sizing: border-box;
}
.lacrm-wa-online-dot {
    position: absolute; right: -1px; bottom: -1px; width: 11px; height: 11px;
    border-radius: 50%; background: #4ade80; border: 2px solid #fff;
}

/* ----- WooCommerce "Ask in WhatsApp" button ----- */
.lacrm-wa-woo-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    background: #25D366; color: #fff !important; border: 0; cursor: pointer;
    border-radius: 6px; padding: 10px 16px; font-weight: 600; font-size: 14px;
    text-decoration: none; line-height: 1.2; margin-top: 8px; width: 100%;
    box-sizing: border-box; transition: background .15s ease;
}
.lacrm-wa-woo-btn:hover { background: #1da851; color: #fff !important; }
.lacrm-wa-woo-ic { flex: 0 0 auto; }
