/**
 * Xuan Cuong Handicraft - Module: floating-contacts.css
 * Global Floating Contacts & Back-to-Top Cluster (Social buttons, Message toggle & Back to top)
 */

/* ==========================================================================
   Global Floating Contacts Widget (Bottom-Right Cluster)
   ========================================================================== */
   .site-floating-contacts {
    position: fixed;
    right: 28px;
    bottom: 28px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    pointer-events: none;
    /* Allows clicks through empty cluster areas */
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Ensure interactive child elements receive pointer events */
.site-floating-contacts>* {
    pointer-events: auto;
}

/* --------------------------------------------------------------------------
   1. Social Buttons Group (Instagram, Messenger, Zalo)
   Appears vertically ABOVE the message toggle trigger button
   -------------------------------------------------------------------------- */
.floating-items-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 0;
    margin: 0;
    background: transparent;
    border: none;
    box-shadow: none;
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    transform-origin: bottom center;
    transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
        visibility 0.28s;
}

/* Collapsed state: 3 social buttons hidden */
.site-floating-contacts.is-collapsed .floating-items-group {
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(0.85);
    pointer-events: none;
}

.floating-items-group .float-btn {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1E1B18;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    text-decoration: none;
    outline: none;
    touch-action: manipulation;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
        box-shadow 0.25s ease,
        background-color 0.25s ease;
}

.floating-items-group .float-btn:hover {
    transform: scale(1.12);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
    background: #2A2521;
}

.floating-items-group .float-btn:active {
    transform: scale(0.96);
}

.float-social-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   2. Main Message Trigger Button (Chat-2 icon <-> Close icon)
   -------------------------------------------------------------------------- */
.floating-main-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
}

.btn-float-toggle {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: #D6BF89;
    cursor: pointer;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    outline: none;
    touch-action: manipulation;
    transition: background-color 0.25s ease,
        transform 0.25s cubic-bezier(0.16, 1, 0.3, 1),
        box-shadow 0.25s ease;
}

.btn-float-toggle:hover {
    background: #c5ad75;
    transform: scale(1.06);
    box-shadow: 0 8px 26px rgba(0, 0, 0, 0.4);
}

.btn-float-toggle:active {
    transform: scale(0.96);
}

.toggle-icon-wrap {
    position: relative;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.float-toggle-img {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 26px;
    height: 26px;
    display: block;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Closed state (default): Show chat icon, hide close icon */
.site-floating-contacts.is-collapsed .icon-open {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
    visibility: visible;
}

.site-floating-contacts.is-collapsed .icon-close {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(-90deg) scale(0.5);
    visibility: hidden;
}

/* Opened state: Hide chat icon, show close (X) icon */
.site-floating-contacts:not(.is-collapsed) .icon-open {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(90deg) scale(0.5);
    visibility: hidden;
}

.site-floating-contacts:not(.is-collapsed) .icon-close {
    opacity: 1;
    transform: translate(-50%, -50%) rotate(0deg) scale(1);
    visibility: visible;
}

/* --------------------------------------------------------------------------
   3. Back to Top Button
   Positioned directly UNDER the message trigger button
   -------------------------------------------------------------------------- */
.site-floating-contacts .back-to-top {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--xc-primary, #881111);
    color: #FFFFFF;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    position: relative;
    touch-action: manipulation;

    /* Hidden by default until user scrolls > 400px */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: scale(0.6) translateY(12px);
    max-height: 0;
    margin-top: -12px;
    /* Collapses the flex gap seamlessly */
    overflow: hidden;

    transition: opacity 0.28s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
        visibility 0.28s ease,
        max-height 0.28s ease,
        margin-top 0.28s ease,
        background-color 0.25s ease,
        box-shadow 0.25s ease;
}

/* Visible state when scrolled down */
.site-floating-contacts .back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: scale(1) translateY(0);
    max-height: 48px;
    margin-top: 0;
}

.site-floating-contacts .back-to-top:hover {
    background-color: #9E1515;
    transform: scale(1.08) translateY(-2px);
    box-shadow: 0 8px 24px rgba(136, 17, 17, 0.45);
}

.site-floating-contacts .back-to-top:active {
    transform: scale(0.95);
}

.site-floating-contacts .back-to-top-icon,
.site-floating-contacts .back-to-top i {
    width: 28px;
    height: 28px;
    stroke: currentColor;
    font-size: 16px;
    line-height: 1;
    display: block;
    pointer-events: none;
    transition: transform 0.25s ease;
}

.site-floating-contacts .back-to-top:hover .back-to-top-icon,
.site-floating-contacts .back-to-top:hover i {
    transform: translateY(-2px);
}

/* ==========================================================================
   RESPONSIVE BREAKPOINTS FOR FLOATING BUTTONS CLUSTER
   ========================================================================== */


/* ==========================================================================
   TranslatePress Language Switcher Floater (Relocate to bottom-left)
   Prevents overlapping with floating contact actions and back to top
   ========================================================================== */
#trp-floater-ls {
    left: 24px !important;
    right: auto !important;
    bottom: 24px !important;
    z-index: 99990 !important;
}


/* Tablet Landscape & Portrait (<= 1024px) */
@media (max-width: 1024px) {
    .site-floating-contacts {
        right: 20px;
        bottom: 20px;
        gap: 10px;
    }

    .floating-items-group {
        gap: 9px;
    }

    .floating-items-group .float-btn {
        width: 48px;
        height: 44px;
    }

    .float-social-img {
        width: 22px;
        height: 22px;
    }

    .btn-float-toggle {
        width: 50px;
        height: 50px;
    }

    .toggle-icon-wrap {
        width: 24px;
        height: 24px;
    }

    .float-toggle-img {
        width: 24px;
        height: 24px;
    }

    .site-floating-contacts .back-to-top {
        width: 44px;
        height: 44px;
        margin-top: -10px;
    }

    .site-floating-contacts .back-to-top.is-visible {
        max-height: 44px;
        margin-top: 0;
    }

    .site-floating-contacts .back-to-top-icon,
    .site-floating-contacts .back-to-top i {
        width: 17px;
        height: 17px;
        font-size: 15px;
    }
}

@media (max-width: 768px) {

    /* Mobile Devices (<= 768px) */
    .site-floating-contacts {
        right: 16px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        gap: 8px;
    }

    .floating-items-group {
        gap: 8px;
    }

    .floating-items-group .float-btn {
        width: 44px;
        height: 44px;
    }

    .float-social-img {
        width: 20px;
        height: 20px;
    }

    .btn-float-toggle {
        width: 46px;
        height: 46px;
    }

    .toggle-icon-wrap {
        width: 22px;
        height: 22px;
    }

    .float-toggle-img {
        width: 22px;
        height: 22px;
    }

    .site-floating-contacts .back-to-top {
        width: 40px;
        height: 40px;
        margin-top: -8px;
    }

    .site-floating-contacts .back-to-top.is-visible {
        max-height: 40px;
        margin-top: 0;
    }

    .site-floating-contacts .back-to-top-icon,
    .site-floating-contacts .back-to-top i {
        width: 15px;
        height: 15px;
        font-size: 14px;
    }

    #trp-floater-ls {
        left: 14px !important;
        right: auto !important;
        bottom: calc(14px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* Small Mobile Devices (<= 480px) */
@media (max-width: 480px) {
    .site-floating-contacts {
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        gap: 7px;
    }

    .floating-items-group {
        gap: 7px;
    }

    .floating-items-group .float-btn {
        width: 40px;
        height: 40px;
    }

    .float-social-img {
        width: 18px;
        height: 18px;
    }

    .btn-float-toggle {
        width: 48px;
        height: 44px;
    }

    .toggle-icon-wrap {
        width: 20px;
        height: 20px;
    }

    .float-toggle-img {
        width: 20px;
        height: 20px;
    }

    .site-floating-contacts .back-to-top {
        width: 38px;
        height: 38px;
        margin-top: -7px;
    }

    .site-floating-contacts .back-to-top.is-visible {
        max-height: 38px;
        margin-top: 0;
    }

    .site-floating-contacts .back-to-top-icon,
    .site-floating-contacts .back-to-top i {
        width: 14px;
        height: 14px;
        font-size: 13px;
    }
}