/* Contact Buttons Manager - Frontend Styles */

.cbm-container {
    display: flex;
    flex-flow: column;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    position: fixed;
    z-index: 999;
    bottom: 10%;
    right: 15px;
}

.cbm-container.cbm-vertical {
    flex-direction: column;
    align-items: flex-start;
}

.cbm-button {
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.cbm-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.cbm-button .cbm-icon {
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cbm-button .cbm-icon-img {
    width: 56px;
    height: 56px;
    border-radius: 100%;
    object-fit: contain;
    display: block;
}

.cbm-button .cbm-label {
    white-space: nowrap;
}

/* Nút chat với Bot Zalo */
.cbm-button.cbm-zalo-bot {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: #0068ff;
    box-shadow: 0 4px 12px rgba(0, 104, 255, 0.35);
    text-decoration: none;
}

.cbm-button.cbm-zalo-bot svg {
    width: 30px;
    height: 30px;
    fill: none;
    stroke: #fff;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.cbm-button.cbm-zalo-bot .cbm-bot-tag {
    position: absolute;
    right: -2px;
    bottom: -2px;
    padding: 1px 6px;
    border-radius: 10px;
    background: #d4af37;
    color: #141717;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.04em;
    line-height: 1.5;
}

@media (max-width: 576px) {
    .cbm-button.cbm-zalo-bot { width: 44px; height: 44px; }
    .cbm-button.cbm-zalo-bot svg { width: 24px; height: 24px; }
    .cbm-button.cbm-zalo-bot .cbm-bot-tag { font-size: 8px; padding: 1px 5px; }
}

/* Icon Only Style */
.cbm-button.cbm-icon-only {
    padding: 12px 14px;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    justify-content: center;
}

.cbm-button.cbm-icon-only .cbm-label {
    display: none;
}

/* Responsive */
@media (max-width: 576px) {
    .cbm-container {
        gap: 8px;
    }

    .cbm-button .cbm-icon {
        font-size: 16px;
    }

    .cbm-button .cbm-icon-img {
        width: 44px;
        height: 44px;
    }
}

/* Widget Styles */
.widget_cbm_contact_buttons_widget {
    padding: 15px;
}

.widget_cbm_contact_buttons_widget .cbm-container {
    margin-top: 10px;
}

/* ============ Gom nút liên hệ (máy tính: giữ nguyên dạng cũ) ============ */
.cbm-items {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: inherit;
}

.cbm-toggle,
.cbm-backdrop,
.cbm-tip {
    display: none;
}

/* ============ Mobile: 1 nút "Liên hệ", bấm vào xổ ra ============ */
@media (max-width: 849px) {
    .cbm-container {
        right: 16px;
        bottom: calc(16px + 52px + 12px + env(safe-area-inset-bottom, 0px));
        width: 52px;
        gap: 0;
        z-index: 100000;
    }

    /* Giỏ hàng luôn nằm dưới cùng, nút Liên hệ ngay trên */
    #stdm-floating-cart-btn.stdm-floating-cart-btn {
        right: 16px !important;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
        width: 52px;
        height: 52px;
    }

    #stdm-floating-cart-btn .stdm-cart-icon svg {
        width: 26px;
        height: 26px;
    }

    #stdm-floating-cart-btn .stdm-cart-count {
        top: -4px;
        right: -4px;
        height: 20px;
        min-width: 20px;
        padding: 0 5px;
        font-size: 11px;
        border-width: 1.5px;
    }

    .cbm-toggle {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 52px;
        height: 52px;
        margin: 0;
        padding: 0;
        border: 1px solid rgba(212, 177, 107, 0.65);
        border-radius: 50%;
        background: radial-gradient(circle at 30% 25%, #262a2a, #111313 70%);
        color: #e5b246;
        box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: transform 0.3s ease, border-color 0.3s ease;
    }

    /* Vòng sáng nhẹ gợi ý bấm */
    .cbm-toggle::after {
        content: "";
        position: absolute;
        inset: -1px;
        border-radius: 50%;
        border: 1px solid rgba(229, 178, 70, 0.55);
        animation: cbm-ring 2.8s ease-out infinite;
        pointer-events: none;
    }

    .cbm-toggle svg {
        position: absolute;
        width: 24px;
        height: 24px;
        fill: none;
        stroke: currentColor;
        stroke-width: 1.6;
        stroke-linecap: round;
        stroke-linejoin: round;
        transition: opacity 0.25s ease, transform 0.3s ease;
    }

    .cbm-toggle-close {
        opacity: 0;
        transform: rotate(-90deg) scale(0.6);
    }

    .cbm-items {
        position: absolute;
        right: 0;
        bottom: calc(100% + 14px);
        width: 52px;
        flex-direction: column;
        gap: 12px;
        pointer-events: none;
    }

    .cbm-items .cbm-button {
        position: relative;
        opacity: 0;
        transform: translateY(18px) scale(0.6);
        transition: opacity 0.22s ease, transform 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
    }

    .cbm-items .cbm-button:hover {
        box-shadow: none;
    }

    .cbm-tip {
        display: block;
        position: absolute;
        top: 50%;
        right: calc(100% + 12px);
        padding: 6px 12px;
        border: 1px solid rgba(212, 177, 107, 0.28);
        border-radius: 999px;
        background: rgba(17, 19, 19, 0.92);
        color: #f2ebda;
        font-size: 13px;
        line-height: 1.3;
        white-space: nowrap;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
        transform: translate(8px, -50%);
        opacity: 0;
        transition: opacity 0.25s ease, transform 0.25s ease;
        pointer-events: none;
    }

    .cbm-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: -1;
        background: rgba(8, 9, 9, 0.55);
        -webkit-backdrop-filter: blur(2px);
        backdrop-filter: blur(2px);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.25s ease, visibility 0.25s ease;
    }

    /* --- Khi mở --- */
    .cbm-container.is-open .cbm-backdrop {
        opacity: 1;
        visibility: visible;
    }

    .cbm-container.is-open .cbm-items {
        pointer-events: auto;
    }

    .cbm-container.is-open .cbm-items .cbm-button,
    .cbm-container.is-open .cbm-tip {
        opacity: 1;
    }

    .cbm-container.is-open .cbm-items .cbm-button {
        transform: none;
    }

    .cbm-container.is-open .cbm-tip {
        transform: translate(0, -50%);
    }

    /* Nút gần tay nhất hiện trước */
    .cbm-container.is-open .cbm-items .cbm-button:nth-last-child(1) { transition-delay: 0s; }
    .cbm-container.is-open .cbm-items .cbm-button:nth-last-child(2) { transition-delay: 0.04s; }
    .cbm-container.is-open .cbm-items .cbm-button:nth-last-child(3) { transition-delay: 0.08s; }
    .cbm-container.is-open .cbm-items .cbm-button:nth-last-child(4) { transition-delay: 0.12s; }

    .cbm-container.is-open .cbm-toggle {
        border-color: #e5b246;
    }

    .cbm-container.is-open .cbm-toggle::after {
        animation: none;
        opacity: 0;
    }

    .cbm-container.is-open .cbm-toggle-open {
        opacity: 0;
        transform: rotate(90deg) scale(0.6);
    }

    .cbm-container.is-open .cbm-toggle-close {
        opacity: 1;
        transform: none;
    }
}

@keyframes cbm-ring {
    0%   { transform: scale(1);    opacity: 0.8; }
    70%  { transform: scale(1.35); opacity: 0; }
    100% { transform: scale(1.35); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    .cbm-toggle::after { animation: none; }
    .cbm-items .cbm-button,
    .cbm-tip,
    .cbm-toggle svg,
    .cbm-backdrop { transition: none; }
}
