/* ================================
   Custom Floating Buttons (CFB)
   - Orbit cho NÚT (a)
   - Desktop phone box: luôn PULSE trên .cfb-content-wrapper (không còn cảm giác 2 khung)
   ================================ */

/* --- Cấu trúc và Style cơ bản --- */
.cfb-container {
    position: fixed !important; 
    bottom: var(--cfb-margin-bottom, 20px);
    z-index: 99999 !important; 
    display: flex;
    width: auto;
}
.cfb-pos-left  { left: var(--cfb-margin-side, 20px);  right: auto; }
.cfb-pos-right { right: var(--cfb-margin-side, 20px); left: auto; }

/* Dùng GAP hiện đại */
.cfb-align-vertical { 
    flex-direction: column;
    gap: var(--cfb-spacing, 10px);
}
.cfb-align-horizontal { 
    flex-direction: row;
    align-items: center;
    gap: var(--cfb-spacing, 10px);
}

/* Item chung */
.cfb-container > * {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    transition: transform 0.3s ease;
}
.cfb-container > *:hover { transform: scale(1.1); }

/* Nút icon (thẻ a) */
.cfb-container a {
    width: var(--cfb-size, 3rem);
    height: var(--cfb-size, 3rem);
    padding: 0;
    border-radius: 50%;
}

/* Ảnh & SVG icon */
.cfb-container img {
    width: 100%; height: 100%;
    object-fit: cover; display: block; border-radius: 50%;
}
.cfb-container a svg.cfb-theme-icon {
    width: 60%; height: 60%; fill: #007bff;
}

/* =========================================
   HIỆU ỨNG 1: PHÁT SÁNG TỎA RA (PULSE)
   ========================================= */
@keyframes cfb-rainbow-glow {
    0%   { box-shadow: 0 0 12px 4px rgba(255,107,107,.8); }
    20%  { box-shadow: 0 0 12px 4px rgba(255,215,  0,.8); }
    40%  { box-shadow: 0 0 12px 4px rgba(138,255,138,.8); }
    60%  { box-shadow: 0 0 12px 4px rgba(173,216,230,.8); }
    80%  { box-shadow: 0 0 12px 4px rgba(255,182,193,.8); }
    100% { box-shadow: 0 0 12px 4px rgba(255,107,107,.8); }
}
.cfb-container .glowing.cfb-glow-pulse {
    animation: cfb-rainbow-glow infinite alternate ease-in-out;
}
.cfb-container .glowing.cfb-glow-pulse.animation-slow   { animation-duration: 10s; }
.cfb-container .glowing.cfb-glow-pulse.animation-medium { animation-duration: 5s;  }
.cfb-container .glowing.cfb-glow-pulse.animation-fast   { animation-duration: 2s;  }

/* ==================================================
   HIỆU ỨNG 2: VỆT SÁNG CHẠY QUANH (ORBIT) – CHỈ CHO NÚT ICON
   ================================================== */
@keyframes cfb-orbit-rotate {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
.cfb-container a.glowing.cfb-glow-orbit::before {
    content: '';
    position: absolute;
    z-index: -1;
    top:    calc(-1 * var(--cfb-orbit-width, 0.15rem));
    left:   calc(-1 * var(--cfb-orbit-width, 0.15rem));
    right:  calc(-1 * var(--cfb-orbit-width, 0.15rem));
    bottom: calc(-1 * var(--cfb-orbit-width, 0.15rem));
    border-radius: 50%;
    background: conic-gradient(
        from 90deg,
        transparent 0%,
        var(--cfb-orbit-color, #00aaff) 25%, 
        transparent 40%
    );
    animation: cfb-orbit-rotate linear infinite;
}
.cfb-container a.glowing.cfb-glow-orbit.animation-slow::before   { animation-duration: 6s; }
.cfb-container a.glowing.cfb-glow-orbit.animation-medium::before { animation-duration: 4s; }
.cfb-container a.glowing.cfb-glow-orbit.animation-fast::before   { animation-duration: 2s; }

/* ==================================================
   Desktop Phone Number Box – LUÔN PULSE (trên wrapper), KHÔNG orbit
   ================================================== */
.cfb-desktop-phone-box {
    display: none; 
    overflow: visible;
    border-radius: 50px;
    /* KHÔNG đặt box-shadow ở khung ngoài để tránh cảm giác 2 khung */
    box-shadow: none;
}

/* Nội dung trong box (một khối duy nhất: nền, bo góc, pulse, shadow) */
.cfb-desktop-phone-box .cfb-content-wrapper {
    display: flex;
    align-items: center;
    background-color: #007bff;
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    width: 100%;
    height: 100%;
    gap: 0.6rem;
    position: relative;
    z-index: 1;
}

/* --- Keyframes cho hiệu ứng PULSE (NHẠT HƠN 20% NỮA) --- */
@keyframes cfb-neon-pulse {
    0%, 100% {
        /* Giảm độ mờ của cả hai lớp bóng */
        box-shadow: 0 0 4px rgba(0, 170, 255, 0.4),  /* từ 0.5 xuống 0.4 */
                    0 0 8px rgba(255, 255, 255, 0.08); /* từ 0.1 xuống 0.08 */
    }
    50% {
        /* Giảm đáng kể độ tỏa sáng ở điểm sáng nhất */
        box-shadow: 0 0 10px rgba(0, 170, 255, 0.5), /* từ 0.6 xuống 0.5 */
                    0 0 20px rgba(0, 170, 255, 0.3), /* từ 0.4 xuống 0.3 */
                    0 0 35px rgba(255, 255, 255, 0.15);/* từ 0.2 xuống 0.15 */
    }
}

/* Luôn pulse: khi khung ngoài có .glowing ⇒ wrapper nhận animation */
.cfb-desktop-phone-box.glowing .cfb-content-wrapper {
    animation: cfb-neon-pulse 3s infinite ease-in-out;
}
.cfb-desktop-phone-box.glowing.animation-slow   .cfb-content-wrapper { animation-duration: 5s; }
.cfb-desktop-phone-box.glowing.animation-medium .cfb-content-wrapper { animation-duration: 3s; }
.cfb-desktop-phone-box.glowing.animation-fast   .cfb-content-wrapper { animation-duration: 1.5s; }

/* Nếu admin chọn "chạy quanh" và plugin gán .cfb-glow-orbit cho box:
   → Vẫn giữ pulse trên WRAPPER, đồng thời chặn pseudo orbit nếu có */
.cfb-desktop-phone-box.glowing.cfb-glow-orbit .cfb-content-wrapper {
    animation: cfb-neon-pulse 3s infinite ease-in-out !important;
}
.cfb-desktop-phone-box.glowing.cfb-glow-orbit::before {
    content: none !important;
    display: none !important;
}

/* Desktop hiển thị box */
@media screen and (min-width: 1024px) {
    .cfb-desktop-phone-box {
        display: flex;
    }
    .cfb-desktop-phone-box .cfb-desktop-phone-icon {
        width: 1.2rem;
        height: 1.2rem;
        fill: white;
    }
    .cfb-pos-right.cfb-align-horizontal { flex-direction: row-reverse; }
}
