/* ContactPulse Widget — Frontend CSS v1.0.0
   All selectors scoped to #cpls-wrap, #cpls-modal, #cpls-panel.
   No global rules. No :root variable overrides. */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');

/* ── Wrap / FAB anchor ────────────────────────────── */
#cpls-wrap {
    position: fixed;
    bottom: 24px;
    right:  24px;
    z-index: 99990;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    font-family: 'DM Sans', sans-serif;
    pointer-events: none; /* children set their own */
}
#cpls-wrap[data-pos="left"] {
    right: auto;
    left: 24px;
    align-items: flex-start;
}

/* ── Tray ─────────────────────────────────────────── */
#cpls-tray {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}
#cpls-wrap[data-pos="left"] #cpls-tray { align-items: flex-start; }

.cpls-tray-row {
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transform: translateY(16px) scale(0.86);
    transition:
        opacity   0.22s cubic-bezier(.34,1.3,.64,1),
        transform 0.22s cubic-bezier(.34,1.3,.64,1);
    transition-delay: calc(var(--idx,0) * 50ms);
    pointer-events: none;
}
#cpls-tray.cpls-tray-open .cpls-tray-row {
    opacity: 1;
    transform: none;
    pointer-events: all;
}
#cpls-tray:not(.cpls-tray-open) .cpls-tray-row {
    transition-delay: calc((2 - var(--idx,0)) * 32ms);
}
#cpls-wrap[data-pos="left"] .cpls-tray-row { flex-direction: row-reverse; }

.cpls-tray-label {
    background: rgba(15,20,35,.82);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: #fff;
    font-family: 'DM Sans', sans-serif;
    font-size: 12.5px;
    font-weight: 500;
    padding: 5px 13px;
    border-radius: 30px;
    white-space: nowrap;
    box-shadow: 0 2px 10px rgba(0,0,0,.2);
    user-select: none;
    pointer-events: none;
}

.cpls-tray-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-decoration: none;
    box-shadow: 0 3px 16px rgba(0,0,0,.2);
    transition: transform .18s cubic-bezier(.34,1.56,.64,1), box-shadow .18s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.cpls-tray-btn:hover  { transform: scale(1.12); }
.cpls-tray-btn:active { transform: scale(.94);  }
.cpls-tray-btn svg    { width: 22px; height: 22px; fill: #fff; pointer-events: none; }

.cpls-wa      { background: #25D366; box-shadow: 0 3px 14px rgba(37,211,102,.4); }
.cpls-call    { background: #0ea5e9; box-shadow: 0 3px 14px rgba(14,165,233,.4); }
.cpls-contact { background: #6366f1; box-shadow: 0 3px 14px rgba(99,102,241,.4); }

/* ── Main FAB ─────────────────────────────────────── */
#cpls-fab {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 22px rgba(99,102,241,.45), 0 2px 8px rgba(0,0,0,.12);
    transition: transform .28s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    outline: none;
    pointer-events: all;
    flex-shrink: 0;
}
#cpls-fab:hover  { transform: scale(1.08); box-shadow: 0 6px 28px rgba(99,102,241,.55); }
#cpls-fab:active { transform: scale(.94); }
#cpls-fab svg    { width: 26px; height: 26px; fill: #fff; transition: transform .28s, opacity .2s; }

/* Pulse ring */
#cpls-fab::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: #6366f1;
    opacity: .38;
    animation: cplsPing 2.4s cubic-bezier(0,0,.2,1) infinite;
}
@keyframes cplsPing {
    0%        { transform: scale(1);   opacity: .38; }
    80%,100%  { transform: scale(1.7); opacity: 0;   }
}
#cpls-fab.cpls-fab-open::before { display: none; }

/* Icon swap */
.cpls-ico-open  { display: block; }
.cpls-ico-close { display: none; position: absolute; }
#cpls-fab.cpls-fab-open .cpls-ico-open  { display: none; }
#cpls-fab.cpls-fab-open .cpls-ico-close { display: block; }

/* ══════════════════════════════════════════════════
   MODAL OVERLAY
   display:none by default — ZERO render-tree presence.
   Never opacity:0 on a position:fixed + backdrop-filter
   element — that silently creates a GPU compositing layer
   that eats stacking contexts (nav / sticky headers).
   ══════════════════════════════════════════════════ */
#cpls-modal {
    display: none;          /* fully out of render tree */
    position: fixed;
    inset: 0;
    z-index: 99995;
    align-items: flex-end;
    justify-content: center;
    overscroll-behavior: contain;
}
/* Step 1 — JS adds this to switch display:none → flex */
#cpls-modal.cpls-show { display: flex; }

/* Step 2 — JS adds this one rAF later to trigger animation */
/* Dim backdrop appears only when truly open */
#cpls-modal.cpls-open::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.46);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: -1;
    animation: cplsFadeIn .26s ease forwards;
}
@keyframes cplsFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ── Panel ────────────────────────────────────────── */
#cpls-panel {
    width: 100%;
    max-width: 460px;
    max-height: 88vh;
    border-radius: 22px 22px 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 -6px 40px rgba(0,0,0,.2);
    font-family: 'DM Sans', sans-serif;
    /* start state */
    opacity: 0;
    transform: translateY(48px);
    transition: transform .34s cubic-bezier(.32,.72,0,1), opacity .28s ease;
    will-change: transform, opacity;
}
#cpls-modal.cpls-open #cpls-panel {
    opacity: 1;
    transform: translateY(0);
}

/* Handle */
.cpls-handle {
    width: 38px; height: 4px;
    background: rgba(0,0,0,.14);
    border-radius: 4px;
    margin: 10px auto 0;
    flex-shrink: 0;
}

/* Header */
.cpls-panel-head {
    padding: 18px 20px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    flex-shrink: 0;
    position: relative;
    overflow: hidden;
}
.cpls-panel-head::after {
    content: '';
    position: absolute;
    top: -28px; right: -18px;
    width: 100px; height: 100px;
    border-radius: 50%;
    background: rgba(255,255,255,.08);
    pointer-events: none;
}
.cpls-head-inner    { display: flex; align-items: center; gap: 14px; }
.cpls-head-icon     { width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.18); border: 2px solid rgba(255,255,255,.32); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.cpls-head-icon svg { width: 20px; height: 20px; fill: #fff; }
.cpls-head-title    { margin: 0; font-size: 16px; font-weight: 700; line-height: 1.2; }
.cpls-head-sub      { margin: 3px 0 0; font-size: 12px; opacity: .82; }

#cpls-form-close {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,.15);
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background .18s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
#cpls-form-close:hover { background: rgba(255,255,255,.28); }
#cpls-form-close svg   { width: 16px; height: 16px; fill: #fff; }

/* Body / scroll area */
.cpls-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.cpls-panel-body::-webkit-scrollbar { width: 4px; }
.cpls-panel-body::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 4px; }

/* Fields */
.cpls-field     { margin-bottom: 14px; }
.cpls-lbl       { display: block; font-size: 12.5px; font-weight: 600; color: #374151; margin-bottom: 5px; }
.cpls-req       { color: #ef4444; margin-left: 2px; }
.cpls-inp {
    width: 100%;
    box-sizing: border-box;
    padding: 11px 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 11px;
    font-size: 15px; /* ≥16 prevents iOS zoom */
    font-family: 'DM Sans', sans-serif;
    color: #111827;
    background: #f9fafb;
    transition: border-color .18s, box-shadow .18s, background .18s;
    outline: none;
    -webkit-appearance: none;
}
.cpls-inp:focus {
    border-color: #6366f1;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}
.cpls-inp::placeholder { color: #9ca3af; }
.cpls-ta { resize: vertical; min-height: 78px; line-height: 1.5; }

.cpls-error-txt {
    color: #dc2626;
    font-size: 12.5px;
    font-weight: 500;
    min-height: 18px;
    margin: 2px 0 10px;
}

#cpls-submit {
    width: 100%;
    padding: 13px;
    border: none;
    border-radius: 11px;
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    font-family: 'DM Sans', sans-serif;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: opacity .18s, transform .14s;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
#cpls-submit:hover   { opacity: .9; }
#cpls-submit:active  { transform: scale(.98); }
#cpls-submit:disabled { opacity: .55; cursor: not-allowed; }
#cpls-btn-spin svg   { width: 18px; height: 18px; fill: #fff; animation: cplsSpin .7s linear infinite; }
@keyframes cplsSpin  { to { transform: rotate(360deg); } }

/* Success state */
#cpls-done {
    text-align: center;
    padding: 36px 16px;
}
.cpls-done-check {
    width: 60px; height: 60px;
    border-radius: 50%;
    background: #dcfce7;
    color: #16a34a;
    font-size: 28px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 14px;
}
.cpls-done-msg {
    font-size: 15px; font-weight: 500; color: #111827; line-height: 1.5; margin: 0;
}

.cpls-footer {
    text-align: center;
    font-size: 10.5px;
    color: #9ca3af;
    padding: 10px 0 14px;
    margin: 0;
    flex-shrink: 0;
    font-family: 'DM Sans', sans-serif;
}
.cpls-footer a { color: #9ca3af; text-decoration: none; }
.cpls-footer a:hover { color: #6366f1; }

/* ── Desktop (≥601px) ─────────────────────────────── */
@media (min-width: 601px) {
    #cpls-modal {
        align-items: flex-end;
        justify-content: flex-end;
        padding: 0 24px 100px;
    }
    #cpls-wrap[data-pos="left"] ~ #cpls-modal {
        justify-content: flex-start;
        padding: 0 0 100px 24px;
    }
    #cpls-panel {
        max-width: 380px;
        max-height: calc(100vh - 130px);
        border-radius: 20px;
        transform: translateY(22px) scale(.93);
        transform-origin: bottom right;
    }
    #cpls-wrap[data-pos="left"] ~ #cpls-modal #cpls-panel {
        transform-origin: bottom left;
    }
    #cpls-modal.cpls-open #cpls-panel {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    .cpls-handle { display: none; }
}

/* ── Mobile (≤600px) ──────────────────────────────── */
@media (max-width: 600px) {
    #cpls-wrap { bottom: 14px; right: 14px; }
    #cpls-wrap[data-pos="left"] { left: 14px; right: auto; }

    #cpls-fab    { width: 56px; height: 56px; }
    #cpls-fab svg { width: 24px; height: 24px; }

    .cpls-tray-btn { width: 52px; height: 52px; }
    .cpls-tray-btn svg { width: 23px; height: 23px; }

    #cpls-modal {
        align-items: flex-end;
        justify-content: center;
    }
    #cpls-panel {
        max-width: 100%;
        max-height: 94vh;
        max-height: 94dvh;
        border-radius: 20px 20px 0 0;
        transform: translateY(100%);
        opacity: 1;
        transition: transform .36s cubic-bezier(.32,.72,0,1);
    }
    #cpls-modal.cpls-open #cpls-panel {
        transform: translateY(0);
        opacity: 1;
    }
    .cpls-panel-head {
        padding: 16px;
        padding-top: max(16px, env(safe-area-inset-top, 16px));
    }
    .cpls-panel-body { padding: 16px; }
    .cpls-footer {
        padding-bottom: max(14px, env(safe-area-inset-bottom, 14px));
    }
}
