/* Giới hạn toàn bộ kiểu dáng trong vùng của tiện ích để tránh ảnh hưởng giao diện khác. */
#isb-contact-buttons {
    --isb-size: 48px;
    position: fixed;
    right: max(20px, env(safe-area-inset-right, 0px));
    bottom: max(24px, var(--isb-theme-clearance, 0px), env(safe-area-inset-bottom, 0px));
    z-index: 9999;
    /* Vùng bao và khoảng trống phải cho phép bấm xuyên xuống giao diện bên dưới. */
    pointer-events: none;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    line-height: 1.4;
    color: #172d45;
    -webkit-tap-highlight-color: transparent;
    /* Cụm nút tự dịch lên khi website có nút nổi khác: chuyển mượt để không giật. */
    transition: bottom .18s ease;
}
#isb-contact-buttons, #isb-contact-buttons * { box-sizing: border-box; }
#isb-contact-buttons .isb-contact-list {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    max-height: calc(100vh - 140px - var(--isb-theme-clearance, 0px));
    max-height: calc(100dvh - 140px - var(--isb-theme-clearance, 0px));
    overflow-y: auto;
    /* Chừa chỗ cho nhãn bên trái, kể cả khi danh sách cần cuộn dọc. */
    padding: 8px 8px 8px min(280px, calc(100vw - 100px));
    margin: -8px;
    scrollbar-width: thin;
    pointer-events: none;
}
#isb-contact-buttons .contact-btn, #isb-contact-buttons .isb-back-to-top {
    position: relative;
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: var(--isb-size);
    height: var(--isb-size);
    min-width: 0;
    min-height: 0;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    font: inherit;
    text-decoration: none;
    text-transform: none;
    letter-spacing: normal;
    cursor: pointer;
    pointer-events: auto;
    touch-action: manipulation;
    box-shadow: none;
    transition: transform .18s ease;
}
#isb-contact-buttons .contact-btn::before, #isb-contact-buttons .contact-btn::after,
#isb-contact-buttons .isb-back-to-top::before, #isb-contact-buttons .isb-back-to-top::after { content: none; }
#isb-contact-buttons .isb-icon {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: var(--isb-size);
    height: var(--isb-size);
    border: 1px solid rgb(255 255 255 / 45%);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgb(23 45 69 / 14%), 0 1px 3px rgb(23 45 69 / 8%);
}
#isb-contact-buttons .isb-icon img {
    display: block;
    width: 30px;
    height: 30px;
    max-width: none;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    object-fit: contain;
}
#isb-contact-buttons .zalo-btn .isb-icon { background: #fff; border-color: #dbeafe; }
#isb-contact-buttons .zalo-btn img { width: 34px; height: 34px; }
#isb-contact-buttons .fb-btn .isb-icon { background: #087aff; }
#isb-contact-buttons .hotline-btn .isb-icon { background: #e84451; }
#isb-contact-buttons .hotline-btn img, #isb-contact-buttons .isb-back-to-top img { width: 24px; height: 24px; }
#isb-contact-buttons .telegram-btn .isb-icon { background: #269fd6; }
#isb-contact-buttons .telegram-btn img { width: 42px; height: 42px; }
#isb-contact-buttons .isb-back-to-top .isb-icon { background: #17846b; }
#isb-contact-buttons .isb-back-to-top[hidden], #isb-contact-buttons .isb-contact-list[hidden] { display: none; }
#isb-contact-buttons .isb-text {
    position: absolute;
    right: calc(100% + 12px);
    width: max-content;
    max-width: min(260px, calc(100vw - 110px));
    padding: 9px 13px;
    border-radius: 10px;
    background: #172d45;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.5;
    text-align: left;
    overflow-wrap: anywhere;
    box-shadow: 0 4px 16px rgb(23 45 69 / 12%);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(4px);
    transition: opacity .18s ease, transform .18s ease;
}
#isb-contact-buttons .contact-btn:hover .isb-text,
#isb-contact-buttons .contact-btn:focus-visible .isb-text,
#isb-contact-buttons .isb-back-to-top:hover .isb-text,
#isb-contact-buttons .isb-back-to-top:focus-visible .isb-text { opacity: 1; visibility: visible; transform: none; }
#isb-contact-buttons .contact-btn:focus-visible, #isb-contact-buttons .isb-back-to-top:focus-visible {
    outline: 3px solid #172d45;
    outline-offset: 4px;
}
@media (hover: hover) {
    #isb-contact-buttons .contact-btn:hover, #isb-contact-buttons .isb-back-to-top:hover { transform: translateY(-2px); }
}
#isb-contact-spacer { display: none; }
@media (max-width: 767px) {
    #isb-contact-buttons {
        --isb-size: 44px;
        right: 0;
        left: 0;
        bottom: var(--isb-theme-clearance, 0px);
        width: auto;
        gap: 0;
    }
    #isb-contact-buttons .isb-contact-list {
        flex-direction: row;
        align-items: flex-start;
        gap: 4px;
        width: 100%;
        max-height: none;
        margin: 0;
        padding: 10px max(10px, env(safe-area-inset-right, 0px)) calc(9px + env(safe-area-inset-bottom, 0px)) max(10px, env(safe-area-inset-left, 0px));
        border-top: 1px solid #e5ebf2;
        background: #fff;
        box-shadow: 0 -4px 24px rgb(23 45 69 / 7%);
        overflow-x: auto;
        overflow-y: hidden;
        overscroll-behavior-x: contain;
        pointer-events: auto;
    }
    #isb-contact-buttons .contact-btn {
        flex: 1 0 64px;
        flex-direction: column;
        justify-content: flex-start;
        gap: 5px;
        width: auto;
        height: auto;
        padding: 2px 3px;
        border-radius: 10px;
    }
    #isb-contact-buttons .contact-btn .isb-text {
        position: static;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        width: 100%;
        max-width: 120px;
        max-height: 34px;
        padding: 0;
        background: transparent;
        color: #243c55;
        box-shadow: none;
        border-radius: 0;
        font-size: 12px;
        font-weight: 600;
        line-height: 17px;
        text-align: center;
        overflow: hidden;
        opacity: 1;
        visibility: visible;
        transform: none;
    }
    #isb-contact-buttons .isb-back-to-top {
        position: absolute;
        right: max(16px, env(safe-area-inset-right, 0px));
        bottom: calc(100% + 12px);
    }
    #isb-contact-buttons.isb-empty .isb-back-to-top { bottom: max(16px, env(safe-area-inset-bottom, 0px)); }
    #isb-contact-spacer { display: block; width: 100%; pointer-events: none; }
    #isb-contact-buttons .contact-btn:focus-visible { outline-offset: -2px; }
}
@media (prefers-reduced-motion: reduce) {
    #isb-contact-buttons, #isb-contact-buttons .contact-btn, #isb-contact-buttons .isb-back-to-top, #isb-contact-buttons .isb-text { transition: none; }
}
@media print {
    #isb-contact-buttons, #isb-contact-spacer { display: none !important; }
}
