/* ============================================================
   PAGE CONTEXT CHATBOT v30.2
   All colors driven by CSS variables + inline style="background:"
   No hardcoded colors on launchers — everything respects saved settings
   ============================================================ */

/* ── Animations ── */
@keyframes pcgFloat {
    0%,100% { transform: translateY(0px); }
    50%      { transform: translateY(-7px); }
}
@keyframes pcgPulseRing {
    0%   { transform: scale(1);    opacity: 0.55; }
    100% { transform: scale(1.6);  opacity: 0; }
}
@keyframes pcgBounce {
    0%,60%,100% { transform: translateY(0);   opacity: 0.4; }
    30%          { transform: translateY(-6px); opacity: 1; }
}
@keyframes pcgSlideIn {
    from { opacity:0; transform:translateY(12px) scale(.96); }
    to   { opacity:1; transform:translateY(0)    scale(1);   }
}

/* ── Main chatbot launcher ── */
#pcg-launcher {
    position: fixed;
    bottom: 20px; right: 20px;
    width: 62px;  height: 62px;
    /* background set inline from brand color */
    border-radius: 50%;
    box-shadow: 0 6px 24px rgba(0,0,0,0.24);
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 999999;
    animation: pcgFloat 3.6s ease-in-out infinite;
    transition: transform .2s, box-shadow .2s;
}
#pcg-launcher::after {
    content: '';
    position: absolute; inset: -4px;
    border-radius: 50%;
    border: 2px solid var(--pcg-primary);
    opacity: 0;
    animation: pcgPulseRing 2.2s ease-out infinite;
}
#pcg-launcher:hover {
    animation-play-state: paused;
    transform: scale(1.08);
    box-shadow: 0 10px 30px rgba(0,0,0,0.28);
}

/* ── Chat container ── */
#pcg-chatbot-container {
    position: fixed;
    bottom: 100px; right: 20px;
    width: 360px;
    height: 560px;
    max-height: min(560px, calc(100vh - 130px));
    min-height: 320px;
    background: #ffffff; border-radius: 20px;
    box-shadow: 0 16px 48px rgba(0,0,0,0.18);
    display: flex; flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    z-index: 999999;
    border: 1px solid rgba(0,0,0,0.06);
    overflow: hidden;
    animation: pcgSlideIn .25s ease;
}
.pcg-hidden { display: none !important; }

/* ── Resize handles ── */
/* Invisible 8px strips on the top and left edges + a corner grab */
.pcg-resize-top {
    position: absolute;
    top: 0; left: 12px; right: 12px;
    height: 8px;
    cursor: ns-resize;
    z-index: 10;
    border-radius: 20px 20px 0 0;
}
.pcg-resize-left {
    position: absolute;
    top: 12px; bottom: 12px; left: 0;
    width: 8px;
    cursor: ew-resize;
    z-index: 10;
    border-radius: 20px 0 0 20px;
}
.pcg-resize-corner {
    position: absolute;
    top: 0; left: 0;
    width: 18px; height: 18px;
    cursor: nwse-resize;
    z-index: 11;
    border-radius: 20px 0 0 0;
}
/* Subtle visual cue on hover */
.pcg-resize-top:hover,
.pcg-resize-corner:hover {
    background: rgba(0,0,0,0.06);
    border-top: 2px dashed rgba(0,0,0,0.12);
}
.pcg-resize-left:hover {
    background: rgba(0,0,0,0.06);
    border-left: 2px dashed rgba(0,0,0,0.12);
}

/* ── Header ── */
#pcg-header {
    background: var(--pcg-primary);
    color: var(--pcg-header-text, #ffffff); padding: 14px 16px;
    display: flex; justify-content: space-between; align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    flex-shrink: 0;
}
.pcg-header-left { display: flex; align-items: center; gap: 12px; }
.pcg-avatar-head {
    width: 40px; height: 40px; border-radius: 50%;
    object-fit: cover; border: 2.5px solid rgba(255,255,255,0.35);
    background: white;
}
.pcg-header-info { line-height: 1.2; }
.pcg-bot-name   { font-weight: 700; font-size: var(--pcg-header-name-size, 15px); }
.pcg-bot-status { font-size: var(--pcg-header-status-size, 12px); opacity: 0.9; display: flex; align-items: center; gap: 5px; }
.pcg-dot        { width: 8px; height: 8px; background-color: #4ade80; border-radius: 50%; box-shadow: 0 0 6px rgba(74,222,128,0.7); }
#pcg-close-btn {
    background: rgba(255,255,255,0.18); border: none; color: white;
    font-size: 20px; cursor: pointer; line-height: 1;
    width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s;
}
#pcg-close-btn:hover { background: rgba(255,255,255,0.32); }

/* ── Hybrid hint bar ── */
#pcg-hybrid-hint {
    flex-shrink: 0;
}

/* ── Messages ── */
#pcg-messages {
    flex: 1; padding: 16px; overflow-y: auto;
    background: var(--pcg-messages-bg, #f8fafc); font-size: var(--pcg-msg-font-size, 14px);
    scroll-behavior: smooth;
}
.pcg-msg-row  { display: flex; gap: 10px; margin-bottom: 12px; align-items: flex-end; }
.pcg-ai-row   { justify-content: flex-start; }
.pcg-user-row { justify-content: flex-end; }
.pcg-avatar-chat {
    width: 30px; height: 30px; border-radius: 50%;
    object-fit: cover; flex-shrink: 0; margin-bottom: 2px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1); background: white;
}
.pcg-ai {
    background: var(--pcg-ai-bg, #ffffff); color: var(--pcg-ai-color, #1e293b);
    border-radius: 18px 18px 18px 4px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.06);
    border: 1px solid var(--pcg-ai-border, #e2e8f0);
    padding: 11px 15px; max-width: 80%;
    line-height: 1.55;
}
.pcg-user {
    background: var(--pcg-user-bg, var(--pcg-primary)); color: var(--pcg-user-color, #ffffff);
    border-radius: 18px 18px 4px 18px;
    padding: 10px 15px; max-width: 80%; text-align: left;
    line-height: 1.55;
}
.pcg-ai a { color: var(--pcg-primary); text-decoration: none; font-weight: 600; }
.pcg-ai a:hover { text-decoration: underline; }

/* ── Input area ── */
#pcg-input-area {
    padding: 12px 14px; background: var(--pcg-inputarea-bg, #ffffff);
    border-top: 1px solid #f1f5f9;
    display: flex; gap: 8px; align-items: center;
    flex-shrink: 0;
}
#pcg-input {
    flex: 1; border: 1.5px solid var(--pcg-input-border, #e2e8f0);
    padding: 10px 16px; border-radius: 24px;
    outline: none; font-size: var(--pcg-input-font-size, 14px); transition: border-color 0.2s;
    background: var(--pcg-input-bg, #f8fafc);
}
#pcg-input:focus { border-color: var(--pcg-primary); background: white; }
#pcg-send-btn {
    background: var(--pcg-send-btn-bg, var(--pcg-primary)); color: var(--pcg-send-btn-color, #ffffff); border: none;
    width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: background .2s, transform .15s;
    flex-shrink: 0;
}
#pcg-send-btn:hover { background: var(--pcg-send-btn-hover, var(--pcg-primary-dark)); transform: scale(1.08); }

/* ── Lead form ── */
/* ── Lead form card — breaks out of bubble max-width ── */
.pcg-ai.pcg-lead-form-container {
    max-width: 96%;
    width: 96%;
    padding: 0;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}
.pcg-form-card-header {
    background: var(--pcg-form-header-bg, var(--pcg-primary));
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.pcg-form-card-header-icon {
    width: 34px; height: 34px; border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0;
}
.pcg-form-card-header-title {
    font-size: 14px; font-weight: 700; color: #fff; line-height: 1.3;
}
.pcg-form-card-header-sub {
    font-size: 11.5px; color: rgba(255,255,255,0.78); margin-top: 1px;
}
.pcg-form-card-body {
    padding: 16px 16px 14px;
    background: #fff;
}
.pcg-form-field {
    margin-bottom: 10px;
}
.pcg-form-label {
    display: block;
    font-size: var(--pcg-form-label-size, 11px); font-weight: 600;
    color: var(--pcg-form-label-color, #64748b);
    margin-bottom: 5px;
    letter-spacing: 0.3px;
}
.pcg-form-input {
    width: 100%; padding: 9px 11px;
    border: 1.5px solid var(--pcg-form-input-border, #e2e8f0);
    border-radius: 8px; font-size: var(--pcg-form-input-size, 13px);
    color: var(--pcg-form-input-color, #1e293b); background: var(--pcg-form-input-bg, #f8fafc);
    box-sizing: border-box; outline: none;
    font-family: inherit;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.pcg-form-input::placeholder { color: #c0c8d2; }
.pcg-form-input:focus {
    border-color: var(--pcg-primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
}
.pcg-form-textarea {
    resize: none; min-height: 70px;
    font-family: inherit; line-height: 1.5;
}
.pcg-form-btn {
    width: 100%; background: var(--pcg-form-btn-bg, var(--pcg-primary)); color: var(--pcg-form-btn-color, #ffffff);
    border: none; padding: 12px 18px; border-radius: 10px;
    font-weight: 700; cursor: pointer; font-size: 14px;
    margin-top: 8px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    letter-spacing: 0.3px; line-height: 1;
    box-shadow: 0 3px 10px rgba(0,0,0,0.15);
    transition: background .18s, box-shadow .18s, transform .12s;
}
.pcg-form-btn:hover  { background: var(--pcg-form-btn-hover, var(--pcg-btn-hover)) !important; box-shadow: 0 5px 16px rgba(0,0,0,0.22); }
.pcg-form-btn:active { transform: scale(0.97); box-shadow: 0 2px 6px rgba(0,0,0,0.12); }
/* Lead success */
.pcg-lead-success { display:flex; align-items:center; gap:12px; padding:4px 2px; }
.pcg-lead-success-icon { width:38px; height:38px; border-radius:50%; flex-shrink:0; background:#dcfce7; display:flex; align-items:center; justify-content:center; font-size:18px; }
.pcg-lead-success-text strong { display:block; font-size:13px; color:#15803d; font-weight:700; }
.pcg-lead-success-text span { font-size:12px; color:#64748b; }

/* ── Typing indicator ── */
.pcg-typing {
    display: flex !important;
    align-items: center; gap: 4px;
    padding: 14px 18px !important; min-width: 52px;
}
.pcg-typing span {
    width: 7px; height: 7px; background: #94a3b8;
    border-radius: 50%; display: inline-block;
    animation: pcgBounce 1.2s infinite;
}
.pcg-typing span:nth-child(2) { animation-delay: 0.2s; }
.pcg-typing span:nth-child(3) { animation-delay: 0.4s; }

/* ── Flow Bot buttons ── */
.pcg-flow-options {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 4px 14px 10px 14px;
}
.pcg-flow-btn {
    background: var(--pcg-primary);
    color: #fff !important;
    border: none;
    border-radius: 8px !important;
    padding: 9px 14px !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    cursor: pointer;
    transition: opacity .15s, transform .15s;
    font-family: inherit !important;
    line-height: 1.3 !important;
    text-align: left !important;
    width: 100% !important;
    display: block !important;
    box-sizing: border-box !important;
}
.pcg-flow-btn:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}
.pcg-flow-btn:active { transform: translateY(0); }
.pcg-flow-btn-restart {
    background: #f1f5f9 !important;
    color: #64748b !important;
    font-size: 12px !important;
    border: 1px solid #e2e8f0 !important;
}
.pcg-flow-btn-restart:hover {
    background: #e2e8f0 !important;
    color: #334155 !important;
    opacity: 1;
}

/* ============================================================
   EXTRA LAUNCHERS — floating buttons (WhatsApp, Call, etc.)
   Color set via inline style="background: <saved_color>;"
   Pulse ring matches button color via --pcg-btn-bg custom prop
   ============================================================ */
.pcg-extra-launcher {
    position: fixed;
    bottom: 20px; right: 20px;
    width: 58px; height: 58px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 6px 20px rgba(0,0,0,0.22);
    cursor: pointer; z-index: 99998;
    text-decoration: none; color: inherit;
    animation: pcgFloat 3.6s ease-in-out infinite;
    transition: box-shadow .2s, transform .2s;
    /* Stagger set by JS */
}
/* Pulse ring — inherits color from currentColor which mirrors the element's own bg via filter */
.pcg-extra-launcher::after {
    content: '';
    position: absolute; inset: -4px;
    border-radius: 50%;
    /* We use box-shadow to fake a colored ring matching the button bg */
    box-shadow: 0 0 0 2px currentColor;
    opacity: 0;
    animation: pcgPulseRing 2.4s ease-out infinite;
}
.pcg-extra-launcher:hover {
    animation-play-state: paused;
    transform: scale(1.1);
    box-shadow: 0 10px 28px rgba(0,0,0,0.3);
}
.pcg-extra-launcher:hover::after { animation-play-state: paused; }

/* Tooltip on hover (circle style only) */
.pcg-extra-launcher:not(.pcg-launcher-pill)::before {
    content: attr(data-label);
    position: absolute; right: 70px;
    background: rgba(15,15,15,0.82); color: #fff;
    padding: 5px 12px; border-radius: 8px;
    font-size: 12px; font-weight: 600; white-space: nowrap;
    opacity: 0; pointer-events: none; transition: opacity 0.2s;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.pcg-extra-launcher:not(.pcg-launcher-pill):hover::before { opacity: 1; }
.pcg-extra-launcher[data-side="left"]:not(.pcg-launcher-pill)::before { right: auto; left: 70px; }

/* ── Pill style ── */
.pcg-launcher-pill {
    width: auto !important; height: 50px !important;
    border-radius: 100px !important;
    padding: 0 20px 0 14px !important;
    font-family: inherit;
}
.pcg-launcher-pill svg,
.pcg-launcher-pill img { flex-shrink: 0; }
.pcg-launcher-pill[data-side="left"] { padding: 0 14px 0 20px !important; flex-direction: row-reverse; }

/* ── White/light pill ── */
.pcg-launcher-light {
    background: #ffffff !important;
    border: 1.5px solid #e2e8f0 !important;
    box-shadow: 0 4px 20px rgba(0,0,0,0.14) !important;
}
.pcg-launcher-light:hover {
    box-shadow: 0 8px 28px rgba(0,0,0,0.20) !important;
    border-color: #cbd5e1 !important;
}

/* ============================================================
   RESPONSIVE — mobile
   ============================================================ */
@media (max-width: 440px) {
    #pcg-chatbot-container {
        width: calc(100vw - 20px) !important;
        right: 10px !important;
        left: 10px !important;
        bottom: 90px !important;
        height: calc(100vh - 110px) !important;
        max-height: calc(100vh - 110px) !important;
        min-height: 380px !important;
    }
}

/* ── Hybrid hint bar ── */
#pcg-hybrid-hint {
    flex-shrink: 0;
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
    padding: 8px 14px;
    font-size: 12px;
    color: #92400e;
    display: flex;
    align-items: center;
    gap: 7px;
    line-height: 1.4;
}

/* ── Contact info list styling in chat ── */
.pcg-ai ul {
    margin: 6px 0 0;
    padding: 0;
    list-style: none;
}
.pcg-ai ul li {
    padding: 4px 0;
    line-height: 1.7;
    font-size: 13px;
    border-bottom: 1px solid #f1f5f9;
}
.pcg-ai ul li:last-child {
    border-bottom: none;
}
.pcg-ai p {
    margin: 0 0 6px;
}
.pcg-ai strong {
    color: #1e293b;
}
