/* NX Floating UI — back-to-top + contact stack (global) */
/* ========== BACK TO TOP (#top-link) — left side ========== */
:root {
    --nx-btt-size: 44px;
    --nx-btt-green: #6f9608;
    --nx-btt-green-deep: #5a7c06;
}

#top-link.back-to-top,
a.back-to-top#top-link {
    left: max(12px, env(safe-area-inset-left, 0px)) !important;
    right: auto !important;
    bottom: max(16px, env(safe-area-inset-bottom, 0px)) !important;
    width: var(--nx-btt-size) !important;
    height: var(--nx-btt-size) !important;
    min-width: var(--nx-btt-size) !important;
    min-height: var(--nx-btt-size) !important;
    max-width: var(--nx-btt-size) !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
    border-radius: 50% !important;
    background: linear-gradient(160deg, #8fbf12 0%, var(--nx-btt-green) 55%, var(--nx-btt-green-deep) 100%) !important;
    color: #fff !important;
    box-shadow:
        0 6px 16px rgba(111, 150, 8, 0.35),
        0 2px 4px rgba(0, 0, 0, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.28) !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    line-height: 1 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(12px) scale(0.92);
    transition:
        opacity 0.28s ease,
        transform 0.28s cubic-bezier(0.22, 1, 0.36, 1),
        box-shadow 0.2s ease,
        filter 0.2s ease !important;
    z-index: 2147483646 !important;
}

#top-link.back-to-top.active,
a.back-to-top#top-link.active {
    opacity: 1 !important;
    pointer-events: auto !important;
    transform: translateY(0) scale(1);
}

#top-link.back-to-top:hover,
#top-link.back-to-top:focus-visible,
a.back-to-top#top-link:hover,
a.back-to-top#top-link:focus-visible {
    filter: brightness(1.06) saturate(1.08);
    box-shadow:
        0 10px 22px rgba(111, 150, 8, 0.42),
        0 4px 8px rgba(0, 0, 0, 0.14),
        inset 0 1px 0 rgba(255, 255, 255, 0.32) !important;
    transform: translateY(-2px) scale(1.04);
    outline: none;
}

#top-link.back-to-top:active,
a.back-to-top#top-link:active {
    transform: translateY(0) scale(0.96);
    filter: brightness(0.96);
}

#top-link.back-to-top i,
#top-link.back-to-top .icon-angle-up,
a.back-to-top#top-link i {
    margin: 0 !important;
    font-size: 18px !important;
    line-height: 1 !important;
    color: #fff !important;
}

@media (max-width: 549px) {
    :root {
        --nx-btt-size: 40px;
    }

    #top-link.back-to-top,
    a.back-to-top#top-link {
        left: max(10px, env(safe-area-inset-left, 0px)) !important;
        right: auto !important;
        bottom: max(14px, env(safe-area-inset-bottom, 0px)) !important;
    }

    #top-link.back-to-top i,
    a.back-to-top#top-link i {
        font-size: 16px !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    #top-link.back-to-top,
    a.back-to-top#top-link {
        transition: opacity 0.15s ease !important;
        transform: none !important;
    }

    #top-link.back-to-top.active,
    a.back-to-top#top-link.active {
        transform: none !important;
    }
}

/* ========== NX FLOATING CONTACTS ========== */
/* Performance optimized floating contacts */
#nxfc-contact-stack {
    position: fixed !important;
    right: max(10px, env(safe-area-inset-right, 0px)) !important;
    bottom: max(14px, env(safe-area-inset-bottom, 0px)) !important;
    z-index: 2147483647 !important;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    contain: layout style paint;
    --nx-width: clamp(150px, 38vw, 180px);
    --nx-fs: clamp(10px, 2.6vw, 12px);
    --nx-py: 8px;
    --nx-px: 8px;
}

#nxfc-contact-stack * {
    box-sizing: border-box;
}

#nxfc-contact-stack a {
    text-decoration: none;
}

/* Chip styles */
.nxfc-chip,
.nxfc-map {
    width: var(--nx-width) !important;
    max-width: calc(100vw - 24px);
}

.nxfc-ring {
    width: var(--nx-width) !important;
}

.nxfc-chip {
    width: var(--nx-width);
    padding: var(--nx-py) var(--nx-px);
    font-size: var(--nx-fs);
    line-height: 1;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: flex-start;
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,.06);
    background: linear-gradient(180deg, #ffffff 0%, #f7f9fb 100%);
    color: #141414;
    box-shadow: 0 8px 16px rgba(0,0,0,.10);
    transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    will-change: transform;
}

.nxfc-chip:hover {
    transform: translateY(-2px) scale(1.03);
    filter: saturate(1.06);
    box-shadow: 0 12px 24px rgba(0,0,0,.16);
}

.nxfc-ico {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    border-radius: 50%;
    background: #fff;
    display: grid;
    place-items: center;
    box-shadow: inset 0 -1px 0 rgba(0,0,0,.06);
}

.nxfc-ico img {
    width: 12px;
    height: 12px;
}

/* Home button */
.nxfc-home {
    background: linear-gradient(180deg, #d5ff7d 0%, #b6ff4a 100%);
    border-color: #9bd837;
}

.nxfc-home:hover {
    background: linear-gradient(180deg, #c8ff57 0%, #9eff2e 100%);
    border-color: #7fc91f;
}

/* Google Map */
.nxfc-map {
    padding: 0 4px;
    border-radius: 12px;
    border: 2px solid #2ecc71;
    background: linear-gradient(180deg, #ffffff 0%, #f2fff5 100%);
    box-shadow: 0 10px 22px rgba(46,204,113,.18), 0 4px 10px rgba(0,0,0,.06);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
    will-change: transform;
}

.nxfc-map:hover {
    transform: translateY(-2px) scale(1.03);
    border-color: #27ae60;
    background: linear-gradient(180deg, #ffffff 0%, #eaffef 100%);
    box-shadow: 0 14px 32px rgba(39,174,96,.26), 0 6px 14px rgba(0,0,0,.08);
}

.nxfc-map > a {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #111;
}

.nxfc-map .nxfc-ico {
    width: 20px;
    height: 20px;
}

.nxfc-map .nxfc-ico img {
    width: 16px;
    height: 16px;
}

.nxfc-text-top {
    font-size: var(--nx-fs);
    font-weight: 800;
    text-transform: uppercase;
    white-space: nowrap;
}

.nxfc-text-sub {
    font-size: 8px;
    margin-top: 2px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
}

/* Zalo button */
.nxfc-zalo {
    color: #fff;
    border: 1px solid rgba(106,71,201,.35);
    background: linear-gradient(180deg, #a48dff 0%, #6a47c9 100%);
    box-shadow: 0 10px 22px rgba(106,71,201,.22), 0 4px 10px rgba(0,0,0,.06);
}

.nxfc-zalo .nxfc-ico img {
    width: 12px;
    height: 12px;
}

.nxfc-zalo:hover {
    background: linear-gradient(180deg, #b7a3ff 0%, #7a59da 100%);
    box-shadow: 0 14px 30px rgba(106,71,201,.30), 0 6px 14px rgba(0,0,0,.08);
}

/* Call ring animation */
.nxfc-ring {
    width: var(--nx-width);
    height: 56px;
    position: relative;
    contain: layout style paint;
}

.nxfc-ring-circle {
    width: 64px;
    height: 64px;
    top: -4px;
    left: -8px;
    position: absolute;
    border-radius: 50%;
    border: 2px solid #e60808;
    opacity: .5;
    animation: nxfc-alo-circle 1.2s infinite ease-in-out;
}

.nxfc-ring-circle-fill {
    width: 50px;
    height: 50px;
    top: 3px;
    left: 0;
    position: absolute;
    border-radius: 50%;
    background: rgba(230, 8, 8, .78);
    animation: nxfc-alo-fill 2.3s infinite ease-in-out;
}

.nxfc-ring-img-circle {
    width: 30px;
    height: 30px;
    top: 13px;
    left: 10px;
    position: absolute;
    border-radius: 50%;
    background: #e60808;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: nxfc-alo-img 1s infinite ease-in-out;
}

.nxfc-ring-img-circle img {
    width: 14px;
    height: 14px;
}

.nxfc-hotline-bar {
    left: 44px;
    bottom: 10px;
    position: absolute;
    height: 34px;
    line-height: 34px;
    width: calc(var(--nx-width) - 40px);
    border-radius: 999px;
    background: linear-gradient(180deg, #ff5a51 0%, #e62e24 100%);
    box-shadow: 0 10px 22px rgba(230, 46, 36, .22), 0 4px 10px rgba(0, 0, 0, .06);
    transition: filter .18s ease, transform .18s ease;
    will-change: transform;
}

.nxfc-hotline-bar > a {
    color: #fff;
    font-size: 1em;
    font-weight: 800;
    text-indent: 12px;
    font-family: Arial, Helvetica, sans-serif;
    display: block;
    white-space: nowrap;
}

.nxfc-ring:hover .nxfc-hotline-bar {
    filter: saturate(1.1);
    transform: translateY(-1px);
    background: linear-gradient(180deg, #ff6a62 0%, #f03529 100%);
}

/* Optimized keyframes */
@keyframes nxfc-alo-circle {
    0% { transform: scale(.5); opacity: .1; }
    30% { transform: scale(.72); opacity: .55; }
    100% { transform: scale(1); opacity: .1; }
}

@keyframes nxfc-alo-fill {
    0% { transform: scale(.7); opacity: .65; }
    50% { transform: scale(1); opacity: .65; }
    100% { transform: scale(.7); opacity: .65; }
}

@keyframes nxfc-alo-img {
    0% { transform: rotate(0); }
    10% { transform: rotate(-20deg); }
    20% { transform: rotate(20deg); }
    30% { transform: rotate(-20deg); }
    40% { transform: rotate(20deg); }
    50% { transform: rotate(0); }
    100% { transform: rotate(0); }
}

/* Accessibility: reduce motion */
@media (prefers-reduced-motion: reduce) {
    .nxfc-chip,
    .nxfc-map,
    .nxfc-ring,
    .nxfc-ring * {
        animation: none !important;
        transition: none !important;
    }
}

/* Mobile optimization */
@media (max-width: 549px) {
    #nxfc-contact-stack {
        right: 6px !important;
        bottom: 10px !important;
        --nx-width: 148px;
        --nx-fs: 10px;
        --nx-py: 6px;
    }

    .nxfc-ring {
        height: 48px !important;
    }

    .nxfc-hotline-bar {
        height: 30px !important;
        line-height: 30px !important;
    }
}

@media (max-width: 400px) {
    #nxfc-contact-stack {
        right: 8px !important;
        bottom: 10px !important;
        --nx-width: 148px;
    }
}

/* Lazy loading for FAB images */
#nxfc-contact-stack img[data-src] {
    opacity: 0;
    transition: opacity 0.3s;
}

#nxfc-contact-stack img[data-src].loaded {
    opacity: 1;
}
