/* ==========================================================================
   Confia Floating Contact Widget (WhatsApp + WeChat)
   Lightweight, responsive, passive (no auto-popup). v1.0.0
   ========================================================================== */

/* --- Floating button container (bottom-right) --- */
/* Positioned above the theme's existing scroll-to-top button
   (which sits at bottom:20px / right:20px) to avoid overlap. */
.confia-contact-widget {
    position: fixed;
    right: 20px;
    bottom: 80px;                      /* sits above the scroll-top button */
    z-index: 99998;
    display: flex;
    flex-direction: column;   /* label first in DOM, icons below it (top→bottom: label, WeChat, WhatsApp) */
    align-items: flex-end;
    gap: 10px;               /* 8–10px gap between label and top icon */
    pointer-events: none;             /* let only the icons receive clicks */
}

/* "We're here to help" label - fades in gently */
.confia-cw-label {
    background: #ffffff;
    color: #111827;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 12px;
    font-weight: 700;
    padding: 6px 12px;
    border-radius: 16px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.18);
    pointer-events: auto;
    opacity: 0;
    transform: translateY(6px);
    animation: confiaCwFadeIn 0.6s ease forwards;
    animation-delay: 1.2s;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

@keyframes confiaCwFadeIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Icon buttons --- */
.confia-cw-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    padding: 0;
}

.confia-cw-icon:hover,
.confia-cw-icon:focus-visible {
    transform: scale(1.08);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
    outline: none;
}

.confia-cw-whatsapp {
    background: #25D366;   /* official WhatsApp green */
}

.confia-cw-wechat {
    background: #07C160;   /* official WeChat green */
}

/* --- Modal / popup --- */
.confia-cw-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.confia-cw-modal.is-open {
    display: flex;
}

/* Dim background overlay (click to close) */
.confia-cw-modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    animation: confiaCwOverlayIn 0.25s ease;
}

@keyframes confiaCwOverlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* Modal box */
.confia-cw-modal-box {
    position: relative;
    background: #ffffff;
    border-radius: 16px;
    padding: 24px 24px 20px;
    max-width: 320px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: confiaCwPopIn 0.3s cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

@keyframes confiaCwPopIn {
    from { transform: scale(0.85); opacity: 0; }
    to   { transform: scale(1);    opacity: 1; }
}

/* Close button (X) */
.confia-cw-close {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    font-size: 26px;
    line-height: 1;
    color: #6b7280;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.2s ease, color 0.2s ease;
}

.confia-cw-close:hover {
    background: #f3f4f6;
    color: #111827;
}

.confia-cw-modal-title-text {
    margin: 4px 0 14px;
    font-size: 18px;
    font-weight: 700;
    color: #111827;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* QR code image - must sit on white to scan reliably */
.confia-cw-modal-img {
    display: block;
    margin: 0 auto 12px;
    width: 220px;
    height: 220px;
    max-width: 100%;
    object-fit: contain;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 6px;
}

.confia-cw-modal-hint {
    margin: 0;
    font-size: 13px;
    color: #6b7280;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* --- Responsive: tablets & phones --- */
@media (max-width: 768px) {
    .confia-contact-widget {
        right: 14px;
        bottom: 18px;
        gap: 10px;
    }
    .confia-cw-icon {
        width: 46px;
        height: 46px;
    }
    .confia-cw-label {
        font-size: 11px;
        padding: 5px 10px;
    }
    .confia-cw-modal-img {
        width: 180px;
        height: 180px;
    }
    .confia-cw-modal-box {
        padding: 20px 18px 16px;
    }
}

@media (max-width: 380px) {
    .confia-cw-modal-img {
        width: 150px;
        height: 150px;
    }
    .confia-cw-icon {
        width: 42px;
        height: 42px;
    }
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    .confia-cw-label,
    .confia-cw-modal-overlay,
    .confia-cw-modal-box {
        animation: none;
    }
    .confia-cw-icon {
        transition: none;
    }
}
