/**
 * Finy Floating Widget - Stylesheet
 * Version: 1.0.0
 * Author: Finy Web Team
 */

:root {
    --finy-fw-primary: #582f87;
    --finy-fw-primary-light: #7c3aed;
    --finy-fw-accent: #d32f2f;
    --finy-fw-zalo: #0068ff;
    --finy-fw-messenger: #0084ff;
    --finy-fw-shadow: 0 10px 25px -3px rgba(88, 47, 135, 0.35);
}

/* --------------------------------------------------------------------------
   Floating Widget Container Wrapper
   -------------------------------------------------------------------------- */
.finy-fw-wrapper {
    position: fixed;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--fw-gap, 10px);
    bottom: var(--fw-bottom, 80px);
    transition: all 0.3s ease;
    user-select: none;
    font-family: 'Roboto', 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
}

.finy-fw-wrapper.pos-right {
    right: var(--fw-side, 24px);
    left: auto;
}

.finy-fw-wrapper.pos-left {
    left: var(--fw-side, 24px);
    right: auto;
}

/* --------------------------------------------------------------------------
   1. Mascot "Vay Ngay" Item
   -------------------------------------------------------------------------- */
.finy-fw-mascot {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.finy-fw-mascot-link {
    display: inline-block;
    text-decoration: none !important;
    border: none !important;
    outline: none !important;
    position: relative;
    transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.finy-fw-mascot-img {
    width: var(--finy-fw-mascot-w, 95px);
    height: auto;
    max-width: var(--finy-fw-mascot-w, 95px);
    display: block;
    object-fit: contain;
    filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.22));
    transform-origin: center bottom;
    transition: transform 0.25s ease, filter 0.25s ease;
}

.finy-fw-mascot:hover .finy-fw-mascot-img {
    transform: scale(1.08) translateY(-4px);
    filter: drop-shadow(0 14px 26px rgba(88, 47, 135, 0.38));
}

/* Mascot Animations */
.anim-float .finy-fw-mascot-img,
.finy-fw-mascot-img.anim-float {
    animation: finyMascotFloat 3.4s ease-in-out infinite;
}

.anim-pulse .finy-fw-mascot-img,
.finy-fw-mascot-img.anim-pulse {
    animation: finyMascotPulse 2s ease-in-out infinite;
}

.anim-wiggle .finy-fw-mascot-img,
.finy-fw-mascot-img.anim-wiggle {
    animation: finyMascotWiggle 2.5s ease-in-out infinite;
}

.anim-none .finy-fw-mascot-img,
.finy-fw-mascot-img.anim-none {
    animation: none;
}

@keyframes finyMascotFloat {
    0%, 100% {
        transform: translateY(0px) rotate(0deg);
    }
    50% {
        transform: translateY(-8px) rotate(-1.5deg);
    }
}

@keyframes finyMascotPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.08);
    }
}

@keyframes finyMascotWiggle {
    0%, 100% {
        transform: rotate(0deg) translateY(0);
    }
    20% {
        transform: rotate(-6deg) translateY(-2px);
    }
    40% {
        transform: rotate(5deg) translateY(-4px);
    }
    60% {
        transform: rotate(-3deg) translateY(-2px);
    }
    80% {
        transform: rotate(2deg) translateY(0);
    }
}

/* Speech Bubble Tooltip */
.finy-fw-speech-bubble {
    position: absolute;
    top: -28px;
    right: -10px;
    background: linear-gradient(135deg, #d32f2f 0%, #b71c1c 100%);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.2px;
    padding: 3.5px 9px;
    border-radius: 999px;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(211, 47, 47, 0.45);
    pointer-events: none;
    animation: finyBubblePulse 2s ease-in-out infinite;
    z-index: 2;
}

.finy-fw-speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 45%;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 5px solid #b71c1c;
}

@keyframes finyBubblePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.06); }
}

/* --------------------------------------------------------------------------
   2. Support Circle Button
   -------------------------------------------------------------------------- */
.finy-fw-support {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.finy-fw-support-btn {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #7c3aed 0%, #582f87 100%);
    border: 2.5px solid #ffffff;
    box-shadow: var(--finy-fw-shadow);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    margin: 0;
    outline: none;
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
    z-index: 2;
    text-decoration: none !important;
}

.finy-fw-support-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 28px rgba(88, 47, 135, 0.55);
}

.finy-fw-support-btn svg {
    width: 26px;
    height: 26px;
    fill: currentColor;
    display: block;
    transition: transform 0.2s ease;
}

.finy-fw-support-btn:hover svg {
    transform: scale(1.08);
}

/* Pulse Ripple Ring */
.finy-fw-pulse-ring {
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(124, 58, 237, 0.55);
    animation: finyRipple 2.4s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
    pointer-events: none;
    z-index: 1;
}

@keyframes finyRipple {
    0% {
        transform: scale(0.9);
        opacity: 1;
    }
    100% {
        transform: scale(1.55);
        opacity: 0;
    }
}

/* --------------------------------------------------------------------------
   3. Quick Contact Popup Card
   -------------------------------------------------------------------------- */
.finy-fw-popup {
    position: absolute;
    bottom: 64px;
    width: 250px;
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.2), 0 0 0 1px rgba(88, 47, 135, 0.08);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(12px) scale(0.94);
    transform-origin: bottom right;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 100;
}

.pos-left .finy-fw-popup {
    right: auto;
    left: 0;
    transform-origin: bottom left;
}

.pos-right .finy-fw-popup {
    right: 0;
    left: auto;
    transform-origin: bottom right;
}

.finy-fw-popup.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.finy-fw-popup-head {
    background: linear-gradient(135deg, #582f87 0%, #4a2574 100%);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #ffffff;
}

.finy-fw-popup-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
    line-height: 1.3;
}

.finy-fw-popup-close {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.8);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
    transition: color 0.2s;
    outline: none;
}

.finy-fw-popup-close:hover {
    color: #ffffff;
}

.finy-fw-popup-body {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.finy-fw-contact-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    border-radius: 12px;
    text-decoration: none !important;
    color: #1e293b !important;
    background: #f8fafc;
    border: 1px solid #f1f5f9;
    transition: all 0.2s ease;
}

.finy-fw-contact-item:hover {
    background: #f1f5f9;
    transform: translateX(-2px);
    border-color: rgba(88, 47, 135, 0.2);
}

.finy-fw-icon-wrap {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.finy-fw-icon-wrap.hotline {
    background: #fee2e2;
    color: #dc2626;
}

.finy-fw-icon-wrap.zalo {
    background: #dbeafe;
    color: #0068ff;
}

.finy-fw-icon-wrap.messenger {
    background: #eff6ff;
    color: #0084ff;
}

.finy-fw-icon-wrap.loan {
    background: #f3e8ff;
    color: #6b21a8;
}

.finy-fw-icon-wrap svg,
.finy-fw-icon-wrap img {
    width: 19px;
    height: 19px;
    display: block;
}

.finy-fw-item-text {
    display: flex;
    flex-direction: column;
}

.finy-fw-item-label {
    font-size: 11px;
    color: #64748b;
    line-height: 1.2;
}

.finy-fw-item-value {
    font-size: 13.5px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
}


/* --------------------------------------------------------------------------
   4. Harmonized Back-to-Top (Scroll Up) Button
   -------------------------------------------------------------------------- */
#top-link.back-to-top {
    /* Dimensions & Shape */
    width: 44px !important;
    height: 44px !important;
    min-height: 44px !important;
    border-radius: 50% !important;
    padding: 0 !important;
    margin: 0 !important;
    
    /* Perfect Center Alignment with Floating Column */
    /* Wrapper is at right: 24px, mascot width is 95px -> center is 71.5px. For 44px button: right = 71.5 - 22 = 49.5px */
    position: fixed !important;
    right: 49.5px !important;
    bottom: 22px !important;
    left: auto !important;
    z-index: 999998 !important;
    
    /* Premium Modern Aesthetics matching Finy */
    background: #ffffff !important;
    border: 2px solid rgba(88, 47, 135, 0.18) !important;
    color: #582f87 !important;
    box-shadow: 0 8px 20px rgba(88, 47, 135, 0.16), 0 2px 6px rgba(0, 0, 0, 0.04) !important;
    
    /* Layout */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    text-decoration: none !important;
    outline: none !important;
    
    /* Smooth Transitions & Appearance */
    transition: all 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(16px) scale(0.85);
}

/* Left position support */
.pos-left ~ #top-link.back-to-top,
#top-link.back-to-top.left {
    right: auto !important;
    left: 49.5px !important;
}

/* Active State (When Scrolled Down) */
#top-link.back-to-top.active {
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    transform: translateY(0) scale(1) !important;
}

/* Hover State - Purple Gradient & Glow Lift */
#top-link.back-to-top:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #582f87 100%) !important;
    border-color: #7c3aed !important;
    color: #ffffff !important;
    transform: translateY(-3px) scale(1.08) !important;
    box-shadow: 0 12px 28px rgba(88, 47, 135, 0.45) !important;
}

/* Active Click State */
#top-link.back-to-top:active {
    transform: translateY(-1px) scale(1) !important;
}

/* Icon inside Back-To-Top */
#top-link.back-to-top i,
#top-link.back-to-top svg {
    color: currentColor !important;
    stroke: currentColor !important;
    fill: none !important;
    font-size: 16px !important;
    line-height: 1 !important;
    width: 18px !important;
    height: 18px !important;
    display: block !important;
    margin: 0 auto !important;
    transition: transform 0.25s ease, color 0.25s ease !important;
}

#top-link.back-to-top:hover i,
#top-link.back-to-top:hover svg {
    transform: translateY(-2px);
    color: #ffffff !important;
    stroke: #ffffff !important;
}

/* --------------------------------------------------------------------------
   Mobile Responsiveness (< 768px)
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .finy-fw-wrapper {
        bottom: var(--fw-bottom, 30px);
        gap: var(--fw-gap, 8px);
    }

    .finy-fw-wrapper.pos-right {
        right: var(--fw-side, 12px);
        left: auto;
    }

    .finy-fw-wrapper.pos-left {
        left: var(--fw-side, 12px);
        right: auto;
    }

    .finy-fw-mascot-img {
        width: var(--fw-mascot-w, 75px) !important;
        max-width: var(--fw-mascot-w, 75px) !important;
    }

    .finy-fw-speech-bubble {
        top: -24px;
        right: -6px;
        font-size: 10px;
        padding: 2.5px 7px;
    }

    .finy-fw-support-btn {
        width: 46px;
        height: 46px;
    }

    .finy-fw-support-btn svg {
        width: 22px;
        height: 22px;
    }

    .finy-fw-popup {
        width: 220px;
        bottom: 56px;
    }

    #top-link.back-to-top {
        display: flex !important;
        width: 38px !important;
        height: 38px !important;
        min-height: 38px !important;
        right: 32px !important; /* Centered with 74px mobile mascot: 14px + (74 - 38)/2 = 32px */
        bottom: 22px !important;
    }

    #top-link.back-to-top i,
    #top-link.back-to-top svg {
        width: 15px !important;
        height: 15px !important;
        font-size: 14px !important;
    }
}

