/**
 * QTH Smart Contact - Frontend Styles
 * Ultra-smooth, responsive, high-performance floating contact channels
 */

:root {
    --qth-hotline-color: #fa1667;
    --qth-zalo-color: #0068ff;
    --qth-messenger-color: #0084ff;
    --qth-trigger-color: #20958e;
}

/* Base Container */
.qth-contact-container {
    position: fixed !important;
    z-index: 999999 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 16px !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* Device Visibility Control */
@media (max-width: 767px) {
    .qth-contact-container.vis-desktop_only {
        display: none !important;
    }
}

@media (min-width: 768px) {
    .qth-contact-container.vis-mobile_only {
        display: none !important;
    }
}

/* Contact List (Channels wrapper) */
.qth-contact-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 16px !important;
    align-items: center !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
}

/* Individual Channel Item */
#qth-smart-contact .qth-contact-item,
.qth-contact-container .qth-contact-item {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Button Base */
.qth-contact-btn {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 52px !important;
    height: 52px !important;
    border-radius: 50% !important;
    background: var(--qth-btn-bg, #20958e) !important;
    color: #ffffff !important;
    text-decoration: none !important;
    box-shadow: 0 8px 24px -2px rgba(15, 23, 42, 0.22), 0 3px 8px rgba(0, 0, 0, 0.12) !important;
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.28s ease !important;
    cursor: pointer !important;
    outline: none !important;
    border: none !important;
    -webkit-tap-highlight-color: transparent !important;
    z-index: 2 !important;
}

.qth-contact-btn:hover {
    transform: translateY(-4px) scale(1.08) !important;
    box-shadow: 0 14px 30px -4px rgba(15, 23, 42, 0.32), 0 6px 12px rgba(0, 0, 0, 0.16) !important;
    color: #ffffff !important;
    text-decoration: none !important;
}

.qth-contact-btn:active {
    transform: scale(0.94) !important;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.2) !important;
}

/* Icon Wrapper inside button */
.qth-icon-wrap {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    height: 100% !important;
    position: relative !important;
    z-index: 3 !important;
}

.qth-svg {
    width: 26px !important;
    height: 26px !important;
    display: block !important;
    transition: transform 0.2s ease !important;
}

/* Specific Button Styles */
.qth-btn-hotline {
    background: linear-gradient(135deg, #ff2a7a 0%, #fa1667 100%) !important;
}

.qth-btn-hotline .qth-svg {
    stroke: #ffffff !important;
    color: #ffffff !important;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15)) !important;
}

.qth-btn-hotline .qth-wave {
    background: #fa1667 !important;
}

.qth-btn-zalo {
    background: transparent !important;
    box-shadow: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.qth-img-zalo {
    width: 52px !important;
    height: 52px !important;
    max-width: 52px !important;
    max-height: 52px !important;
    object-fit: contain !important;
    display: block !important;
    filter: drop-shadow(0 6px 16px rgba(0, 104, 255, 0.42));
    transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.28s ease !important;
}

.qth-btn-zalo:hover .qth-img-zalo {
    transform: translateY(-4px) scale(1.08) !important;
    filter: drop-shadow(0 12px 24px rgba(0, 104, 255, 0.58)) !important;
}

.qth-btn-zalo .qth-wave {
    background: #0068ff !important;
}

.qth-btn-messenger {
    background: linear-gradient(135deg, #00b2fe 0%, #006aff 50%, #9b51e0 100%) !important;
    box-shadow: 0 8px 24px -2px rgba(0, 106, 255, 0.45), 0 3px 8px rgba(0, 0, 0, 0.12) !important;
}

.qth-btn-messenger:hover {
    box-shadow: 0 14px 30px -4px rgba(155, 81, 224, 0.55), 0 6px 12px rgba(0, 0, 0, 0.16) !important;
}

.qth-btn-messenger .qth-svg {
    width: 32px !important;
    height: 32px !important;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
}

.qth-btn-messenger .qth-wave {
    background: #0084ff !important;
}

/* Circular Wave / Ripple Animation (Sóng tròn tỏa ra) */
.has-wave .qth-contact-btn .qth-wave {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 50% !important;
    transform: translate(-50%, -50%) scale(1) !important;
    background: var(--qth-btn-bg, #20958e) !important;
    pointer-events: none !important;
    z-index: 1 !important;
    opacity: 0.65 !important;
}

.has-wave .qth-contact-btn .qth-wave-1 {
    animation: qthRippleWave 2.6s cubic-bezier(0.1, 0.8, 0.3, 1) infinite !important;
}

.has-wave .qth-contact-btn .qth-wave-2 {
    animation: qthRippleWave 2.6s cubic-bezier(0.1, 0.8, 0.3, 1) infinite !important;
    animation-delay: 0.85s !important;
}

@keyframes qthRippleWave {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.75;
    }
    40% {
        opacity: 0.45;
    }
    100% {
        transform: translate(-50%, -50%) scale(2.05);
        opacity: 0;
    }
}

/* Subtle Phone Wiggle / Shake Animation */
.qth-shake {
    animation: qthPhoneWiggle 5s ease-in-out infinite !important;
}

@keyframes qthPhoneWiggle {
    0%, 100%, 80% {
        transform: rotate(0deg);
    }
    82% {
        transform: rotate(-18deg) scale(1.05);
    }
    84% {
        transform: rotate(18deg) scale(1.05);
    }
    86% {
        transform: rotate(-14deg) scale(1.05);
    }
    88% {
        transform: rotate(14deg) scale(1.05);
    }
    90% {
        transform: rotate(-8deg);
    }
    92% {
        transform: rotate(8deg);
    }
    94% {
        transform: rotate(0deg);
    }
}

/* Tooltips (Hover labels) */
.qth-tooltip {
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) scale(0.92) !important;
    background: rgba(15, 23, 42, 0.92) !important;
    backdrop-filter: blur(8px) !important;
    -webkit-backdrop-filter: blur(8px) !important;
    color: #ffffff !important;
    font-size: 13.5px !important;
    font-weight: 600 !important;
    line-height: 1.4 !important;
    padding: 7px 15px !important;
    border-radius: 9999px !important;
    white-space: nowrap !important;
    box-shadow: 0 10px 25px -4px rgba(0, 0, 0, 0.28) !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
    transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1) !important;
    z-index: 10 !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
}

/* Position: Right -> Tooltip to the Left */
.pos-right .qth-tooltip {
    right: calc(100% + 14px) !important;
    left: auto !important;
    transform: translateY(-50%) translateX(8px) scale(0.92) !important;
}

.pos-right .qth-tooltip::after {
    content: '' !important;
    position: absolute !important;
    top: 50% !important;
    right: -6px !important;
    transform: translateY(-50%) !important;
    border-width: 6px 0 6px 6px !important;
    border-style: solid !important;
    border-color: transparent transparent transparent rgba(15, 23, 42, 0.92) !important;
}

/* Position: Left -> Tooltip to the Right */
.pos-left .qth-tooltip {
    left: calc(100% + 14px) !important;
    right: auto !important;
    transform: translateY(-50%) translateX(-8px) scale(0.92) !important;
}

.pos-left .qth-tooltip::after {
    content: '' !important;
    position: absolute !important;
    top: 50% !important;
    left: -6px !important;
    transform: translateY(-50%) !important;
    border-width: 6px 6px 6px 0 !important;
    border-style: solid !important;
    border-color: transparent rgba(15, 23, 42, 0.92) transparent transparent !important;
}

/* Tooltip Hover State */
@media (min-width: 992px) {
    .with-tooltips .qth-contact-item:hover .qth-tooltip,
    .with-tooltips .qth-contact-trigger:hover + .qth-trigger-tooltip {
        opacity: 1 !important;
        visibility: visible !important;
        transform: translateY(-50%) translateX(0) scale(1) !important;
    }
}

/* Master Floating Trigger Button (Collapsible Mode) */
.qth-contact-trigger {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 60px !important;
    height: 60px !important;
    border-radius: 50% !important;
    background: var(--qth-trigger-bg, #20958e) !important;
    color: #ffffff !important;
    border: none !important;
    box-shadow: 0 10px 28px -3px rgba(32, 149, 142, 0.5), 0 4px 12px rgba(0, 0, 0, 0.15) !important;
    cursor: pointer !important;
    outline: none !important;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease !important;
    z-index: 10 !important;
    -webkit-tap-highlight-color: transparent !important;
    overflow: visible !important; /* CRITICAL: Never clip badge or ripple waves */
}

/* Attention pulse when collapsed - so it never looks sunken */
.mode-collapsible.state-closed .qth-contact-trigger {
    animation: qthTriggerHeartbeat 4.5s ease-in-out infinite !important;
}

@keyframes qthTriggerHeartbeat {
    0%, 100%, 75% {
        transform: scale(1);
    }
    80% {
        transform: scale(1.08);
    }
    85% {
        transform: scale(0.96);
    }
    90% {
        transform: scale(1.06);
    }
    95% {
        transform: scale(1);
    }
}

.qth-contact-trigger:hover {
    transform: scale(1.1) !important;
    box-shadow: 0 16px 36px -4px rgba(32, 149, 142, 0.6), 0 6px 16px rgba(0, 0, 0, 0.18) !important;
}

.qth-contact-trigger:active {
    transform: scale(0.94) !important;
}

/* Dedicated Waves on Trigger Button - radiating continuously behind button */
.has-wave .qth-contact-trigger .qth-wave {
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 50% !important;
    transform: translate(-50%, -50%) scale(1) !important;
    background: var(--qth-trigger-bg, #20958e) !important;
    pointer-events: none !important;
    z-index: -1 !important; /* Always BEHIND the trigger button */
    opacity: 0.7 !important;
}

.has-wave .qth-contact-trigger .qth-wave-1 {
    animation: qthTriggerWave 2.6s cubic-bezier(0.1, 0.8, 0.3, 1) infinite !important;
}

.has-wave .qth-contact-trigger .qth-wave-2 {
    animation: qthTriggerWave 2.6s cubic-bezier(0.1, 0.8, 0.3, 1) infinite !important;
    animation-delay: 0.85s !important;
}

@keyframes qthTriggerWave {
    0% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.75;
    }
    45% {
        opacity: 0.45;
    }
    100% {
        transform: translate(-50%, -50%) scale(2.2);
        opacity: 0;
    }
}

.qth-trigger-icon {
    position: absolute !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 32px !important;
    height: 32px !important;
    z-index: 2 !important;
    transition: transform 0.3s ease, opacity 0.25s ease !important;
}

.qth-trigger-icon svg {
    width: 32px !important;
    height: 32px !important;
}

.qth-trigger-svg {
    fill: #ffffff !important;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.18));
}

.qth-icon-open {
    opacity: 1 !important;
    transform: scale(1) rotate(0deg) !important;
}

.qth-icon-close {
    opacity: 0 !important;
    transform: scale(0.5) rotate(-90deg) !important;
}

/* Collapsible Toggle States */
.mode-collapsible.state-closed .qth-contact-list {
    opacity: 0 !important;
    visibility: hidden !important;
    transform: translateY(24px) scale(0.85) !important;
    pointer-events: none !important;
    height: 0 !important;
    gap: 0 !important;
}

.mode-collapsible.state-opened .qth-contact-list {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) scale(1) !important;
    pointer-events: auto !important;
}

.mode-collapsible.state-opened .qth-icon-open {
    opacity: 0 !important;
    transform: scale(0.5) rotate(90deg) !important;
}

.mode-collapsible.state-opened .qth-icon-close {
    opacity: 1 !important;
    transform: scale(1) rotate(0deg) !important;
}

/* Badge on Master Trigger - On top of button and waves */
.qth-trigger-badge {
    position: absolute !important;
    top: -4px !important;
    right: -4px !important;
    width: 22px !important;
    height: 22px !important;
    background: #e11d48 !important; /* Vibrant Red / Rose */
    color: #ffffff !important;
    font-size: 12px !important;
    font-weight: 800 !important;
    line-height: 22px !important;
    text-align: center !important;
    border-radius: 50% !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35) !important;
    border: 2px solid #ffffff !important;
    transition: transform 0.25s ease, opacity 0.2s ease !important;
    z-index: 9999 !important; /* ALWAYS ON TOP */
    pointer-events: none !important;
}

.mode-collapsible.state-opened .qth-trigger-badge {
    transform: scale(0) !important;
    opacity: 0 !important;
}

/* Mobile Adjustments */
@media (max-width: 600px) {
    .qth-contact-btn {
        width: 48px !important;
        height: 48px !important;
    }
    .qth-img-zalo {
        width: 48px !important;
        height: 48px !important;
        max-width: 48px !important;
        max-height: 48px !important;
    }
    .qth-svg {
        width: 24px !important;
        height: 24px !important;
    }
    .qth-btn-messenger .qth-svg {
        width: 28px !important;
        height: 28px !important;
    }
    .qth-contact-trigger {
        width: 54px !important;
        height: 54px !important;
    }
    .qth-trigger-icon {
        width: 28px !important;
        height: 28px !important;
    }
    .qth-trigger-icon svg {
        width: 28px !important;
        height: 28px !important;
    }
    .qth-trigger-badge {
        width: 20px !important;
        height: 20px !important;
        font-size: 11px !important;
        line-height: 20px !important;
    }
    .qth-tooltip {
        display: none !important;
    }
}
