/* 1. Global Overlay (Background Blur) */
.fab-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 9998;
}

.fab-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 2. Namespaced FAB Container */
.custom-contact-fab .fab-wrapper {
    position: fixed !important;
    bottom: 30px !important;
    right: 30px !important;
    z-index: 9999 !important;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

/* 3. Main Button - Combined Animations */
.custom-contact-fab .fab-main {
    position: relative;
    width: 60px;
    height: 60px;
    border-radius: 18px;
    background: #1a1a1a;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    border: 2px solid transparent;
    background-clip: padding-box;
    overflow: hidden;
    outline: none !important;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    
    /* Combined: Rotating border logic handled in ::before, pulse handled here */
    animation: pulse-glow 2s ease-in-out infinite !important;
}

/* Rotating Border Layer */
.custom-contact-fab .fab-main::before {
    content: '';
    position: absolute;
    top: -50%; left: -50%;
    width: 200%; height: 200%;
    background: conic-gradient(transparent, #0d6efd, #00ff88, transparent 30%);
    animation: rotate-border 3s linear infinite;
    z-index: -2;
}

/* Inner Mask (Prevents gradient from filling button center) */
.custom-contact-fab .fab-main::after {
    content: '';
    position: absolute;
    inset: 2px;
    background: #1a1a1a;
    border-radius: 16px;
    z-index: -1;
    transition: background 0.3s ease;
}

.custom-contact-fab .fab-main:hover {
    transform: scale(1.05) translateY(-2px);
    color: #fff;
}

.custom-contact-fab .fab-main:hover::after {
    background: #000;
}

/* 4. Dropdown Menu - Anti-Shutter Fix */
.custom-contact-fab .dropdown-menu {
    display: block !important;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    margin: 0 !important;
    padding: 10px;
    border-radius: 16px;
    min-width: 220px;
    /* Static positioning overrides Popper.js jitter */
    bottom: calc(100% + 2px) !important;
    top: auto !important;
    right: 0 !important;
    left: auto !important;
    transform: translateY(15px) scale(0.95);
    transition: all 0.25s cubic-bezier(0.165, 0.84, 0.44, 1);
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    border: none;
    background: #fff;
}

.custom-contact-fab .dropdown-menu.show {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

/* 5. Item Hover & Typography Fixes */
.custom-contact-fab .dropdown-item {
    border-radius: 10px;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: #333 !important;
    font-weight: 500;
    transition: all 0.2s ease;
}

.custom-contact-fab .dropdown-menu .dropdown-item:hover {
    background-color: #f8f9fa !important;
    color: #1a1a1a !important; /* Prevents text turning white on light bg */
}

.custom-contact-fab .dropdown-item:hover .icon-box {
    transform: scale(1.1);
}

/* 6. Animations & Helpers */
@keyframes rotate-border {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulse-glow {
    0% { box-shadow: 0 0 0 0px rgba(13, 110, 253, 0.4), 0 4px 15px rgba(0,0,0,0.2); }
    70% { box-shadow: 0 0 0 15px rgba(13, 110, 253, 0), 0 4px 25px rgba(13, 110, 253, 0.3); }
    100% { box-shadow: 0 0 0 0px rgba(13, 110, 253, 0), 0 4px 15px rgba(0,0,0,0.2); }
}

.custom-contact-fab .icon-box { 
    width: 32px; height: 32px; 
    display: flex; align-items: center; justify-content: center; 
    border-radius: 8px; 
}

.custom-contact-fab .fab-icon { transition: transform 0.4s ease; }
.custom-contact-fab .show .fab-icon { transform: rotate(135deg); }
.custom-contact-fab .dropdown-toggle::after { display: none; }

/* 7. Mobile Responsive Adjustments */
@media (max-width: 767px) {
    .custom-contact-fab .fab-wrapper { bottom: 20px !important; right: 20px !important; }
    .custom-contact-fab .fab-main { width: 65px !important; height: 65px !important; }
    .custom-contact-fab .dropdown-menu { min-width: 250px; padding: 12px; }
    .custom-contact-fab .dropdown-item { padding: 14px 18px !important; font-size: 1rem !important; }
    .custom-contact-fab .icon-box { width: 38px !important; height: 38px !important; }
}