/* ICON DUPLICATE FIX - แก้ไขไอคอนซ้ำกันทั้งระบบ */
/* Force single icon display only */

/* ===== HIDE DUPLICATE ICONS GLOBALLY ===== */
/* Hide any duplicate FontAwesome icons */
.fas + .fas,
.far + .far,
.fab + .fab,
[class*="fa-"] + [class*="fa-"] {
    display: none !important;
}

/* Hide duplicate icons within same container */
.mobile-nav-item i + i,
.nav-link i + i,
.contact-item i + i,
.social-icons i + i,
.product-card i + i {
    display: none !important;
}

/* ===== SPECIFIC DUPLICATE REMOVALS ===== */
/* Remove duplicate shopping cart icons */
.fa-shopping-cart + .fa-shopping-cart,
.fas.fa-shopping-cart + .fas.fa-shopping-cart {
    display: none !important;
}

/* Remove duplicate phone icons */
.fa-phone + .fa-phone,
.fas.fa-phone + .fas.fa-phone {
    display: none !important;
}

/* Remove duplicate home icons */
.fa-home + .fa-home,
.fas.fa-home + .fas.fa-home {
    display: none !important;
}

/* Remove duplicate user icons */
.fa-user + .fa-user,
.fas.fa-user + .fas.fa-user {
    display: none !important;
}

/* Remove duplicate envelope icons */
.fa-envelope + .fa-envelope,
.fas.fa-envelope + .fas.fa-envelope {
    display: none !important;
}

/* Remove duplicate location icons */
.fa-map-marker-alt + .fa-map-marker-alt,
.fas.fa-map-marker-alt + .fas.fa-map-marker-alt {
    display: none !important;
}

/* Remove duplicate star icons (but allow star ratings) */
.fa-star + .fa-star + .fa-star + .fa-star + .fa-star + .fa-star,
.fas.fa-star:nth-child(n+6) {
    display: none !important;
}

/* ===== CONTAINER-SPECIFIC FIXES ===== */
/* Mobile Navigation - Only first icon */
.mobile-nav-item i:not(:first-child) {
    display: none !important;
}

.mobile-bottom-nav i:not(:first-child) {
    display: none !important;
}

/* Desktop Navigation - Only first icon */
.desktop-header i:not(:first-child),
.nav-link i:not(:first-child) {
    display: none !important;
}

/* Contact Section - Only first icon */
.contact-item i:not(:first-child),
.contact-info i:not(:first-child) {
    display: none !important;
}

/* Social Media - Only first icon per link */
.social-icons a i:not(:first-child) {
    display: none !important;
}

/* Product Cards - Only first icon per element */
.product-card i:not(:first-child),
.group i:not(:first-child) {
    display: none !important;
}

/* ===== PREVENT ICON MULTIPLICATION ===== */
/* Prevent CSS from creating multiple icons */
.fas::before + .fas::before,
.far::before + .far::before,
.fab::before + .fab::before {
    display: none !important;
}

/* Hide pseudo-element duplicates */
[class*="fa-"]::after {
    display: none !important;
}

/* Override any duplicate content */
.fas::after,
.far::after,
.fab::after {
    content: none !important;
    display: none !important;
}

/* ===== FORCE SINGLE ICON DISPLAY ===== */
/* Ensure only one icon shows per element */
i[class*="fa-"] {
    position: relative !important;
}

i[class*="fa-"]::before {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    z-index: 1 !important;
}

/* Hide any additional pseudo-elements */
i[class*="fa-"]::after {
    display: none !important;
    content: none !important;
}

/* ===== SPECIFIC ELEMENT TARGETING ===== */
/* Mobile Top Bar - Single icons only */
.mobile-top-bar i:not(:first-of-type) {
    display: none !important;
}

/* Top Contact Bar - Single icons only */
.top-contact-bar i:not(:first-of-type) {
    display: none !important;
}

/* Footer - Single icons only */
.footer i:not(:first-of-type),
footer i:not(:first-of-type) {
    display: none !important;
}

/* ===== CART BADGE SPECIFIC ===== */
/* Prevent duplicate cart badges */
.cart-count + .cart-count,
.mobile-cart-badge + .mobile-cart-badge {
    display: none !important;
}

/* Only show first cart badge */
.cart-count:not(:first-of-type),
.mobile-cart-badge:not(:first-of-type) {
    display: none !important;
}

/* ===== BUTTON ICONS ===== */
/* Single icon per button */
button i:not(:first-child),
.btn i:not(:first-child) {
    display: none !important;
}

/* Link icons */
a i:not(:first-child) {
    display: none !important;
}

/* ===== GRID AND FLEX CONTAINERS ===== */
/* Grid containers - single icon per cell */
.grid > * i:not(:first-child),
.flex > * i:not(:first-child) {
    display: none !important;
}

/* ===== JAVASCRIPT GENERATED ICONS ===== */
/* Hide dynamically added duplicate icons */
.fa-loaded + .fa-loaded {
    display: none !important;
}

.icon-success + .icon-success,
.icon-error + .icon-error,
.icon-loading + .icon-loading {
    display: none !important;
}

/* ===== EMOJI FALLBACK PREVENTION ===== */
/* Prevent emoji + icon duplication */
.emoji-fallback + [class*="fa-"],
[class*="fa-"] + .emoji-fallback {
    display: none !important;
}

/* Hide emoji when FontAwesome loads */
.fa-loaded .emoji-fallback {
    display: none !important;
}

/* ===== RESPONSIVE DUPLICATE PREVENTION ===== */
@media (max-width: 768px) {
    /* Mobile specific duplicate prevention */
    .mobile-only i:not(:first-child) {
        display: none !important;
    }
    
    /* Hide desktop duplicates on mobile */
    .desktop-only i {
        display: none !important;
    }
}

@media (min-width: 769px) {
    /* Desktop specific duplicate prevention */
    .desktop-only i:not(:first-child) {
        display: none !important;
    }
    
    /* Hide mobile duplicates on desktop */
    .mobile-only i {
        display: none !important;
    }
}

/* ===== FORCE CLEAN DISPLAY ===== */
/* Reset any conflicting styles that might cause duplication */
[class*="fa-"] {
    text-decoration: none !important;
    text-shadow: none !important;
    background: none !important;
    border: none !important;
}

/* Prevent text content interference */
[class*="fa-"]:not(:empty) {
    font-size: 0 !important;
}

[class*="fa-"]:not(:empty)::before {
    font-size: 1em !important;
}

/* ===== DEBUG MODE FOR DUPLICATES ===== */
.debug-duplicates [class*="fa-"] + [class*="fa-"] {
    border: 2px solid red !important;
    background: rgba(255, 0, 0, 0.1) !important;
}

.debug-duplicates [class*="fa-"] + [class*="fa-"]::before {
    content: "DUPLICATE!" !important;
    color: red !important;
    font-family: monospace !important;
    font-size: 10px !important;
}

/* ===== PERFORMANCE OPTIMIZATION ===== */
/* Hide elements that are definitely duplicates */
[class*="fa-"][style*="display: none"] + [class*="fa-"],
[class*="fa-"][hidden] + [class*="fa-"],
[class*="fa-"][class*="hidden"] + [class*="fa-"] {
    display: none !important;
}

/* ===== FINAL CLEANUP ===== */
/* Catch-all rule for any remaining duplicates */
* [class*="fa-"]:nth-of-type(n+2) {
    display: none !important;
}

/* Exception for star ratings (allow up to 5 stars) */
.rating [class*="fa-star"]:nth-of-type(-n+5),
.stars [class*="fa-star"]:nth-of-type(-n+5),
[class*="star-rating"] [class*="fa-star"]:nth-of-type(-n+5) {
    display: inline-block !important;
}

/* ===== IMPORTANT OVERRIDES ===== */
/* Force hide duplicates even with important declarations */
[class*="fa-"] + [class*="fa-"] {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    position: absolute !important;
    left: -9999px !important;
    width: 0 !important;
    height: 0 !important;
    overflow: hidden !important;
}

