/* ═══════════════════════════════════════════════════════
   COMPONENTS — Tawk/LiveChat Button
   Extracted from layout_desktop.php & layout_mobile.php
   ═══════════════════════════════════════════════════════ */

/* ── Heartbeat animation ── */
@keyframes heartbeat-tawk {
    0% { transform: scale(1); }
    15% { transform: scale(1.15); }
    30% { transform: scale(1); }
    45% { transform: scale(1.15); }
    60% { transform: scale(1); }
    100% { transform: scale(1); }
}

/* ── Desktop Tawk Button ── */
.floating-tawk-btn-desktop {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 110px;
    height: 110px;
    z-index: 1040;
    border-radius: 50%;
    box-shadow: 0 8px 25px rgba(0,0,0,0.5);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    background: transparent;
    animation: heartbeat-tawk 2.5s infinite;
}
.floating-tawk-btn-desktop:hover {
    animation: none;
    transform: scale(1.15);
}
.floating-tawk-btn-desktop img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* ── Mobile Tawk Button ── */
.floating-tawk-btn {
    position: fixed;
    bottom: 85px; /* Above bottom nav */
    right: 15px;
    width: 90px;
    height: 90px;
    z-index: 1040;
    border-radius: 50%;
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    animation: heartbeat-tawk 2.5s infinite;
}
.floating-tawk-btn:active,
.floating-tawk-btn:hover {
    animation: none;
    transform: scale(1.15);
}
.floating-tawk-btn img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

/* Immediate feedback while the third-party chat finishes preparing. */
.floating-tawk-btn-desktop.is-loading,
.floating-tawk-btn.is-loading {
    animation: none;
    cursor: wait;
}
.floating-tawk-btn-desktop.is-loading img,
.floating-tawk-btn.is-loading img {
    opacity: 0.45;
}
.floating-tawk-btn-desktop.is-loading::after,
.floating-tawk-btn.is-loading::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    border: 3px solid rgba(255, 255, 255, 0.45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: live-support-spin 0.75s linear infinite;
}
.live-support-status {
    position: absolute;
    right: 0;
    bottom: calc(100% + 8px);
    width: max-content;
    max-width: min(240px, 75vw);
    padding: 7px 10px;
    border-radius: 8px;
    background: rgba(18, 18, 22, 0.96);
    color: #fff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    text-align: left;
    pointer-events: none;
}
.live-support-status:empty {
    display: none;
}
.live-support-status.is-error {
    background: rgba(139, 25, 25, 0.97);
}
@keyframes live-support-spin {
    to { transform: rotate(360deg); }
}

/* ── Hide default chat widgets (keep custom button only) ── */
/* LiveChat default bubble */
#chat-widget-container {
    display: none !important;
}
/* Tawk.to default bubble */
iframe[title="chat widget"] {
    display: none !important;
}

/* ══════ MOBILE PERFORMANCE ══════
   Disable heavy GPU animations on mobile to prevent device heating */
@media (max-width: 768px) {
    .floating-tawk-btn {
        animation: none !important;
    }
}

/* Respect user's motion preference (accessibility) */
@media (prefers-reduced-motion: reduce) {
    .floating-tawk-btn-desktop,
    .floating-tawk-btn {
        animation: none !important;
    }
}
