/* ============================================
   NOTIFICATION BADGE STYLES - CONFLICT-FREE VERSION
   ============================================ 
   
   Design Philosophy:
   - Keranjang (Cart): Orange - Items BELUM BAYAR (show on navbar icon)
   - Belanja (Orders): Blue - Items SUDAH BAYAR (show in dropdown menu)
   
   CRITICAL FIX:
   - Cart badge position: top: -3px, right: -10px (proper position on icon)
   - Belanja badge: Only shows when order is PAID
   - All selectors are highly specific to avoid conflicts
*/

/* ========================================
   1. KERANJANG BADGE (Cart - Belum Bayar)
   ======================================== */

.cart-badge,
.notification-badge.cart-badge,
.nav-item .cart-badge,
.nav-link .cart-badge {
    /* ✅ FINAL POSITIONING - Perfect on shopping cart icon */
    position: absolute !important;
    top: -3px !important;
    right: -10px !important; /* Changed from 20px to -10px for proper icon positioning */
    
    /* Orange gradient */
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
    color: white !important;
    
    /* Compact sizing */
    font-size: 10px !important;
    font-weight: 700 !important;
    padding: 2px 6px !important;
    border-radius: 10px !important;
    
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    
    /* ✅ FIXED: Prevent pointer events on badge to avoid hover space issue */
    pointer-events: none !important;
    
    /* Prevent text decoration from parent links */
    text-decoration: none !important;
    
    /* Prevent inheritance from other badge styles */
    min-width: 18px !important;
    height: 18px !important;
    line-height: 14px !important;
    
    /* Subtle shadow */
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.5),
                0 0 0 2px rgba(255, 255, 255, 0.25) !important;
    
    border: 1.5px solid rgba(255, 255, 255, 0.4) !important;
    
    z-index: 10 !important;
    animation: cartBadgePulse 2s infinite !important;
    transition: all 0.3s ease !important;
    
    /* Prevent layout issues */
    white-space: nowrap !important;
    overflow: visible !important;
}

.cart-badge:hover,
.notification-badge.cart-badge:hover,
.nav-item .cart-badge:hover,
.nav-link .cart-badge:hover {
    transform: scale(1.1) !important;
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.6),
                0 0 0 3px rgba(255, 255, 255, 0.35) !important;
}

@keyframes cartBadgePulse {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 2px 6px rgba(245, 158, 11, 0.5),
                    0 0 0 2px rgba(255, 255, 255, 0.25);
    }
    50% {
        opacity: 0.9;
        box-shadow: 0 4px 10px rgba(245, 158, 11, 0.6),
                    0 0 0 3px rgba(255, 255, 255, 0.3);
    }
}

/* ========================================
   2. BELANJA BADGE (Orders - Sudah Bayar)
   ======================================== */

.belanja-badge,
.notification-badge-dropdown,
.dropdown-item .belanja-badge,
.dropdown-item .notification-badge-dropdown {
    position: absolute !important;
    right: 10px !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    
    /* Blue gradient */
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
    color: white !important;
    
    font-size: 10px !important;
    font-weight: 700 !important;
    padding: 2px 6px !important;
    border-radius: 10px !important;
    min-width: 18px !important;
    height: 18px !important;
    line-height: 14px !important;
    
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    
    /* ✅ FIXED: Prevent pointer events on badge to avoid hover space issue */
    pointer-events: none !important;
    
    /* Prevent text decoration from parent links */
    text-decoration: none !important;
    
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.5),
                0 0 0 2px rgba(255, 255, 255, 0.25) !important;
    
    border: 1.5px solid rgba(255, 255, 255, 0.4) !important;
    
    transition: all 0.3s ease !important;
    animation: belanjaBadgePulse 2.5s infinite !important;
    
    /* Prevent layout issues */
    white-space: nowrap !important;
    overflow: visible !important;
    z-index: 5 !important;
}

.belanja-badge:hover,
.notification-badge-dropdown:hover,
.dropdown-item .belanja-badge:hover,
.dropdown-item .notification-badge-dropdown:hover {
    transform: translateY(-50%) scale(1.1) !important;
    box-shadow: 0 4px 10px rgba(59, 130, 246, 0.6),
                0 0 0 3px rgba(255, 255, 255, 0.35) !important;
}

@keyframes belanjaBadgePulse {
    0%, 100% {
        opacity: 1;
        box-shadow: 0 2px 6px rgba(59, 130, 246, 0.5),
                    0 0 0 2px rgba(255, 255, 255, 0.25);
    }
    50% {
        opacity: 0.9;
        box-shadow: 0 4px 10px rgba(59, 130, 246, 0.6),
                    0 0 0 3px rgba(255, 255, 255, 0.3);
    }
}

/* ========================================
   3. NAVIGATION POSITIONING
   ======================================== */

.nav-item.position-relative {
    position: relative !important;
}

.nav-item.position-relative .nav-link {
    position: relative !important;
    /* ✅ FIXED: Remove extra padding that causes empty space on hover */
    padding-right: 0.5rem !important; /* Reset to default, badge is absolutely positioned */
}

.dropdown-item.position-relative {
    position: relative !important;
    padding-right: 50px !important;
    display: flex !important;
    align-items: center !important;
    min-height: 44px !important;
}

.dropdown-item.position-relative i {
    margin-right: 12px !important;
    width: 20px !important;
    text-align: center !important;
}

/* ========================================
   4. HIDE BADGE WHEN COUNT IS 0
   ======================================== */

.cart-badge[data-count="0"],
.belanja-badge[data-count="0"],
.notification-badge-dropdown[data-count="0"],
.nav-item .cart-badge[data-count="0"],
.dropdown-item .belanja-badge[data-count="0"] {
    display: none !important;
}

/* ========================================
   5. ANIMATION ON UPDATE
   ======================================== */

@keyframes badgeBounce {
    0%, 100% { transform: scale(1); }
    25% { transform: scale(1.2); }
    50% { transform: scale(0.95); }
    75% { transform: scale(1.1); }
}

.cart-badge.updated,
.nav-item .cart-badge.updated { 
    animation: badgeBounce 0.6s ease !important; 
}

@keyframes badgeBounceDropdown {
    0%, 100% { transform: translateY(-50%) scale(1); }
    25% { transform: translateY(-50%) scale(1.2); }
    50% { transform: translateY(-50%) scale(0.95); }
    75% { transform: translateY(-50%) scale(1.1); }
}

.belanja-badge.updated,
.notification-badge-dropdown.updated,
.dropdown-item .belanja-badge.updated {
    animation: badgeBounceDropdown 0.6s ease !important;
}

/* ========================================
   6. HOVER ON PARENT
   ======================================== */

.nav-item:hover .cart-badge {
    transform: scale(1.15) !important;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.7),
                0 0 0 3px rgba(255, 255, 255, 0.4) !important;
}

.dropdown-item:hover .belanja-badge,
.dropdown-item:hover .notification-badge-dropdown {
    transform: translateY(-50%) scale(1.15) !important;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.7),
                0 0 0 3px rgba(255, 255, 255, 0.4) !important;
}

/* ========================================
   7. OVERRIDE CONFLICTING BADGE STYLES
   ======================================== */

/* Override general .badge styles from other CSS files */
.cart-badge.badge,
.belanja-badge.badge,
.notification-badge-dropdown.badge {
    /* Reset Bootstrap/other badge styles */
    vertical-align: unset !important;
    letter-spacing: normal !important;
}

/* Prevent belanja.css badge styles from affecting notification badges */
.nav-item .cart-badge,
.dropdown-item .belanja-badge {
    /* Override any inherited styles */
    background: none !important;
    background-image: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
}

.dropdown-item .belanja-badge,
.dropdown-item .notification-badge-dropdown {
    background: none !important;
    background-image: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
}

/* ========================================
   8. RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 768px) {
    .cart-badge,
    .notification-badge.cart-badge,
    .nav-item .cart-badge {
        top: -2px !important;
        right: -8px !important;
        font-size: 9px !important;
        min-width: 16px !important;
        height: 16px !important;
        line-height: 12px !important;
        padding: 2px 5px !important;
    }
    
    .belanja-badge,
    .notification-badge-dropdown,
    .dropdown-item .belanja-badge {
        right: 8px !important;
        font-size: 9px !important;
        min-width: 16px !important;
        height: 16px !important;
        line-height: 12px !important;
        padding: 2px 5px !important;
    }
}

@media (max-width: 480px) {
    .cart-badge,
    .notification-badge.cart-badge,
    .nav-item .cart-badge {
        top: -2px !important;
        right: -6px !important;
        font-size: 8px !important;
        min-width: 14px !important;
        height: 14px !important;
        line-height: 10px !important;
        padding: 2px 4px !important;
    }
}

/* ========================================
   9. ACCESSIBILITY
   ======================================== */

.badge-sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border-width: 0 !important;
}

@media (prefers-reduced-motion: reduce) {
    .cart-badge,
    .belanja-badge,
    .notification-badge-dropdown,
    .nav-item .cart-badge,
    .dropdown-item .belanja-badge {
        animation: none !important;
    }
}

@media print {
    .cart-badge,
    .belanja-badge,
    .notification-badge-dropdown,
    .nav-item .cart-badge,
    .dropdown-item .belanja-badge {
        display: none !important;
    }
}

/* ========================================
   10. SPECIFICITY OVERRIDES FOR CONFLICTS
   ======================================== */

/* Ensure notification badges don't inherit from belanja.css .badge styles */
.belanja-container .cart-badge,
.belanja-container .belanja-badge {
    /* Restore notification badge styles even inside belanja container */
    padding: 2px 6px !important;
    border-radius: 10px !important;
    font-size: 10px !important;
}

/* Ensure notification badges don't inherit from detail.css styles */
.product-main-container .cart-badge,
.product-info .cart-badge {
    /* Keep notification badge styles in product pages */
    position: absolute !important;
    top: -3px !important;
    right: 20px !important;
}

/* Prevent any discount-badge or variant-discount-badge styles from affecting notifications */
.cart-badge:not(.discount-badge):not(.variant-discount-badge),
.belanja-badge:not(.discount-badge):not(.variant-discount-badge) {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%) !important;
}

.notification-badge-dropdown:not(.discount-badge):not(.variant-discount-badge),
.dropdown-item .belanja-badge:not(.discount-badge):not(.variant-discount-badge) {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
}