/**
 * DevkTool - Floating Contact Button Widget
 * Mẫu thiết kế chuẩn hiện đại theo phong cách vnode.vn
 * Màu chủ đạo: #205FF5
 */

:root {
    --devk-contact-color: #205FF5;
}

.devk-contact-wrapper {
    position: fixed;
    z-index: 999999;
    user-select: none;
    -webkit-user-select: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    line-height: normal;
}

.devk-contact-wrapper,
.devk-contact-wrapper * {
    box-sizing: border-box;
}

/* Nút trigger chính (tai nghe / đóng) */
.devk-contact-toggle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #ffffff;
    border: 2px solid var(--devk-contact-color);
    cursor: pointer;
    position: relative;
    transition: all 0.28s ease;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.devk-contact-toggle:hover {
    transform: scale(1.05);
}

.devk-contact-toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: opacity 0.22s ease, transform 0.22s ease;
}

.devk-contact-icon-headset {
    color: var(--devk-contact-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.devk-contact-agent-img {
    width: 26px;
    height: 26px;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

.devk-contact-icon-close {
    color: #1e293b;
    display: none;
}

/* Trạng thái đóng: hiệu ứng sóng ripple lan toả */
.devk-contact-wrapper:not(.show) .devk-contact-toggle {
    animation: devk_contact_ripple 1.5s infinite cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes devk_contact_ripple {
    0% {
        box-shadow: 0 0 0 0 rgba(32, 95, 245, 0.4), 0 0 0 5px rgba(32, 95, 245, 0.18);
    }
    50% {
        box-shadow: 0 0 0 9px rgba(32, 95, 245, 0.16), 0 0 0 16px rgba(32, 95, 245, 0.06);
    }
    100% {
        box-shadow: 0 0 0 14px rgba(32, 95, 245, 0), 0 0 0 22px rgba(32, 95, 245, 0);
    }
}

/* Trạng thái mở (.show) */
.devk-contact-wrapper.show .devk-contact-toggle {
    border: 1px solid rgba(32, 95, 245, 0.22);
    background: linear-gradient(135deg, rgba(32, 95, 245, 0.18) 0%, rgba(32, 95, 245, 0.05) 100%);
    background-color: #ffffff;
    box-shadow: 0 4px 14px rgba(32, 95, 245, 0.15);
    animation: none;
}

.devk-contact-wrapper.show .devk-contact-icon-headset {
    display: none;
}

.devk-contact-wrapper.show .devk-contact-icon-close {
    display: flex;
}

/* Hộp chứa danh sách kênh liên hệ */
.devk-contact-box {
    position: relative;
    overflow: hidden;
    width: 44px;
    height: 0;
    margin-bottom: 14px;
    transition: height 0.32s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    justify-content: center;
}

.devk-contact-wrapper.show .devk-contact-box {
    height: var(--devk-inner-height, 225px);
}

.devk-contact-box.is-hovered {
    overflow: visible !important;
}

.devk-contact-inner {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: 44px;
    padding-bottom: 2px;
}

/* Từng nút kênh liên hệ */
.devk-contact-channel {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--devk-contact-color);
    color: #ffffff !important;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none !important;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    cursor: pointer;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.devk-contact-channel:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 18px rgba(32, 95, 245, 0.48);
}

.devk-contact-channel .devk-contact-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    color: #ffffff;
}

.devk-contact-channel .devk-contact-icon svg {
    display: block;
    fill: currentColor;
}

/* Tooltip nhãn bay sang cạnh */
.devk-contact-tooltip {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    display: none;
    background-image: linear-gradient(135deg, var(--devk-contact-color) 0%, #1742ad 100%);
    color: #ffffff !important;
    font-size: 13px;
    font-weight: 500;
    padding: 5px 14px;
    border-radius: 6px;
    white-space: nowrap;
    width: max-content;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
    pointer-events: none;
    z-index: 10;
    letter-spacing: 0.2px;
}

/* Tooltip bên phải website (bay sang trái) */
.devk-contact-right .devk-contact-tooltip {
    right: calc(100% + 12px);
    left: auto;
}

/* Tooltip bên trái website (bay sang phải) */
.devk-contact-left .devk-contact-tooltip {
    left: calc(100% + 12px);
    right: auto;
}

.devk-contact-channel:hover .devk-contact-tooltip {
    display: block;
    animation: devk_tooltip_in 0.2s ease-out;
}

@keyframes devk_tooltip_in {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(6px);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

.devk-contact-left .devk-contact-channel:hover .devk-contact-tooltip {
    animation: devk_tooltip_in_left 0.2s ease-out;
}

@keyframes devk_tooltip_in_left {
    from {
        opacity: 0;
        transform: translateY(-50%) translateX(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(-50%) translateX(0);
    }
}

/* Tối ưu hiển thị di động */
@media (max-width: 768px) {
    .devk-contact-wrapper {
        bottom: 130px !important;
    }
    .devk-contact-toggle {
        width: 42px;
        height: 42px;
    }
    .devk-contact-channel {
        width: 38px;
        height: 38px;
    }
    .devk-contact-box {
        width: 42px;
    }
    .devk-contact-inner {
        width: 42px;
        gap: 10px;
    }
    .devk-contact-tooltip {
        font-size: 12px;
        padding: 4px 10px;
    }
}
