/* MOBILE ICON CRITICAL FIX - สำหรับแก้ไขปัญหา Mobile Icons แบบครอบคลุม */
/* Based on diagnostic analysis and FontAwesome 5.15.4 Classic */
/* Priority: CRITICAL - Load this CSS first */

/* ===== CRITICAL FONTAWESOME 5 OVERRIDE ===== */
/* Force FontAwesome 5.15.4 Classic for all icons */
.fas, .far, .fab, .fal, .fat, .fad, .fass,
[class*="fa-"],
i[class*="fa-"] {
    /* Font Family - FontAwesome 5 Classic */
    font-family: 'Font Awesome 5 Free', 'Font Awesome 5 Brands', 'Font Awesome 5 Regular', 'FontAwesome', Arial, sans-serif !important;
    font-weight: 900 !important;
    font-style: normal !important;
    font-variant: normal !important;
    
    /* Display Properties */
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    
    /* Font Rendering */
    text-rendering: auto !important;
    line-height: 1 !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
    
    /* Reset conflicting properties */
    text-decoration: none !important;
    text-transform: none !important;
    vertical-align: baseline !important;
    speak: none !important;
}

/* Brand icons specific override */
.fab, .fa-brands,
.fab[class*="fa-"], .fa-brands[class*="fa-"] {
    font-family: 'Font Awesome 5 Brands' !important;
    font-weight: 400 !important;
}

/* Regular icons specific override */
.far, .fa-regular,
.far[class*="fa-"], .fa-regular[class*="fa-"] {
    font-family: 'Font Awesome 5 Regular' !important;
    font-weight: 400 !important;
}

/* ===== MOBILE NAVIGATION CRITICAL FIX ===== */
@media (max-width: 768px) {
    
    /* Mobile Bottom Navigation Icons */
    .mobile-bottom-nav i,
    .mobile-nav-item i,
    nav[class*="bottom"] i,
    nav.fixed.bottom-0 i,
    .bottom-nav i {
        /* Font Properties */
        font-family: 'Font Awesome 5 Free' !important;
        font-weight: 900 !important;
        font-style: normal !important;
        
        /* Size and Display */
        font-size: 1.5rem !important; /* 24px - Better visibility */
        line-height: 1 !important;
        display: inline-block !important;
        text-align: center !important;
        
        /* Visibility */
        visibility: visible !important;
        opacity: 1 !important;
        
        /* Color - White for better contrast */
        color: white !important;
        
        /* Spacing */
        margin: 0 !important;
        padding: 0 !important;
        margin-bottom: 0.25rem !important;
        
        /* Reset conflicting properties */
        width: auto !important;
        height: auto !important;
        min-width: 24px !important;
        min-height: 24px !important;
        border: none !important;
        background: none !important;
        text-decoration: none !important;
        text-shadow: none !important;
        box-shadow: none !important;
        transform: none !important;
        
        /* Ensure proper rendering */
        -webkit-font-smoothing: antialiased !important;
        -moz-osx-font-smoothing: grayscale !important;
    }
    
    /* Mobile Navigation Item Container */
    .mobile-nav-item,
    .mobile-bottom-nav a,
    nav[class*="bottom"] a {
        /* Touch Target Size - Apple HIG recommendation */
        min-width: 44px !important;
        min-height: 44px !important;
        
        /* Layout */
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        
        /* Spacing */
        padding: 8px 4px !important;
        margin: 0 !important;
        
        /* Visual */
        text-decoration: none !important;
        border-radius: 8px !important;
        
        /* Interaction */
        transition: all 0.2s ease !important;
        cursor: pointer !important;
        
        /* Ensure visibility */
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    /* Mobile Navigation Text */
    .mobile-nav-item span,
    .mobile-bottom-nav span {
        font-size: 0.75rem !important; /* 12px */
        font-weight: 500 !important;
        color: white !important;
        margin-top: 2px !important;
        text-align: center !important;
        line-height: 1.2 !important;
        white-space: nowrap !important;
    }
    
    /* Active State */
    .mobile-nav-item.active i,
    .mobile-bottom-nav .active i,
    .mobile-nav-item:hover i {
        color: #fbbf24 !important; /* Yellow highlight */
        transform: scale(1.1) !important;
        transition: all 0.2s ease !important;
    }
    
    .mobile-nav-item.active span,
    .mobile-bottom-nav .active span,
    .mobile-nav-item:hover span {
        color: #fbbf24 !important; /* Yellow highlight */
    }
    
    /* Hover Effects */
    .mobile-nav-item:hover {
        background-color: rgba(255, 255, 255, 0.1) !important;
        transform: translateY(-2px) !important;
    }
    
    /* ===== MOBILE TOP NAVIGATION ===== */
    /* Mobile Hamburger Menu */
    .mobile-menu-button i,
    #mobile-menu-button i,
    button[aria-expanded] i,
    .navbar-toggler i {
        font-family: 'Font Awesome 5 Free' !important;
        font-weight: 900 !important;
        font-size: 1.5rem !important; /* 24px */
        color: white !important;
        display: inline-block !important;
        visibility: visible !important;
        opacity: 1 !important;
        line-height: 1 !important;
        text-align: center !important;
    }
    
    /* Mobile Top Bar Icons */
    .mobile-top-bar i,
    .mobile-header i {
        font-family: 'Font Awesome 5 Free' !important;
        font-weight: 900 !important;
        font-size: 1.25rem !important; /* 20px */
        color: white !important;
        display: inline-block !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    /* ===== MOBILE CART BADGE ===== */
    /* Cart Badge Styling */
    .cart-badge,
    .cart-count,
    .mobile-cart-badge {
        position: absolute !important;
        top: -8px !important;
        right: -8px !important;
        background: #ef4444 !important; /* Red background */
        color: white !important;
        border-radius: 50% !important;
        width: 20px !important;
        height: 20px !important;
        font-size: 0.75rem !important; /* 12px */
        font-weight: 700 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        line-height: 1 !important;
        min-width: 20px !important;
        padding: 0 !important;
        border: 2px solid white !important;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2) !important;
        z-index: 10 !important;
    }
    
    /* Cart Icon with Badge Container */
    .mobile-nav-item[href*="cart"],
    .mobile-nav-item:has(.fa-shopping-cart) {
        position: relative !important;
    }
    
    /* ===== SPECIFIC MOBILE ICON FIXES ===== */
    /* Home Icon */
    .fa-home:before { content: "\f015" !important; }
    .mobile-nav-item .fa-home {
        color: white !important;
        font-size: 1.5rem !important;
    }
    
    /* Shopping Cart Icon */
    .fa-shopping-cart:before { content: "\f07a" !important; }
    .mobile-nav-item .fa-shopping-cart {
        color: white !important;
        font-size: 1.5rem !important;
    }
    
    /* User Icon */
    .fa-user:before { content: "\f007" !important; }
    .mobile-nav-item .fa-user {
        color: white !important;
        font-size: 1.5rem !important;
    }
    
    /* Heart Icon */
    .fa-heart:before { content: "\f004" !important; }
    .mobile-nav-item .fa-heart {
        color: white !important;
        font-size: 1.5rem !important;
    }
    
    /* Category/Grid Icon */
    .fa-th-large:before { content: "\f009" !important; }
    .mobile-nav-item .fa-th-large {
        color: white !important;
        font-size: 1.5rem !important;
    }
    
    /* Menu/Bars Icon */
    .fa-bars:before { content: "\f0c9" !important; }
    .mobile-nav-item .fa-bars {
        color: white !important;
        font-size: 1.5rem !important;
    }
    
    /* Search Icon */
    .fa-search:before { content: "\f002" !important; }
    .mobile-nav-item .fa-search {
        color: white !important;
        font-size: 1.5rem !important;
    }
    
    /* ===== MOBILE NAVIGATION CONTAINER ===== */
    /* Bottom Navigation Container */
    .mobile-bottom-nav,
    nav[class*="bottom"],
    .bottom-nav {
        /* Position */
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 1000 !important;
        
        /* Background */
        background: #22c55e !important; /* Green background */
        background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%) !important;
        
        /* Layout */
        display: flex !important;
        justify-content: space-around !important;
        align-items: center !important;
        
        /* Spacing */
        padding: 0.75rem 1rem !important;
        margin: 0 !important;
        
        /* Visual */
        box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.1) !important;
        border-top: 1px solid rgba(255, 255, 255, 0.1) !important;
        
        /* Ensure visibility */
        visibility: visible !important;
        opacity: 1 !important;
        
        /* Safe area for notched devices */
        padding-bottom: max(0.75rem, env(safe-area-inset-bottom)) !important;
    }
    
    /* Navigation Items Container */
    .mobile-nav-items,
    .mobile-bottom-nav > * {
        display: flex !important;
        justify-content: space-around !important;
        align-items: center !important;
        width: 100% !important;
        max-width: 480px !important;
        margin: 0 auto !important;
    }
    
    /* ===== ACCESSIBILITY IMPROVEMENTS ===== */
    /* Focus states for keyboard navigation */
    .mobile-nav-item:focus,
    .mobile-nav-item:focus-visible {
        outline: 2px solid #fbbf24 !important;
        outline-offset: 2px !important;
        border-radius: 8px !important;
    }
    
    /* High contrast mode support */
    @media (prefers-contrast: high) {
        .mobile-nav-item i {
            color: white !important;
            text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.8) !important;
        }
    }
    
    /* Reduced motion support */
    @media (prefers-reduced-motion: reduce) {
        .mobile-nav-item,
        .mobile-nav-item i {
            transition: none !important;
            transform: none !important;
        }
    }
    
    /* ===== FALLBACK EMOJI SYSTEM ===== */
    /* If FontAwesome fails to load, show emojis */
    .fa-home:empty:after { content: "🏠" !important; font-family: system-ui !important; }
    .fa-shopping-cart:empty:after { content: "🛒" !important; font-family: system-ui !important; }
    .fa-user:empty:after { content: "👤" !important; font-family: system-ui !important; }
    .fa-heart:empty:after { content: "❤️" !important; font-family: system-ui !important; }
    .fa-th-large:empty:after { content: "⊞" !important; font-family: system-ui !important; }
    .fa-bars:empty:after { content: "☰" !important; font-family: system-ui !important; }
    .fa-search:empty:after { content: "🔍" !important; font-family: system-ui !important; }
    
    /* ===== PREVENT DUPLICATE NAVIGATION ===== */
    /* Hide duplicate mobile navigations */
    .mobile-bottom-nav + .mobile-bottom-nav,
    nav[class*="bottom"] + nav[class*="bottom"] {
        display: none !important;
    }
    
    /* Ensure only first mobile nav is visible */
    .mobile-bottom-nav:not(:first-of-type) {
        display: none !important;
    }
    
    /* ===== BODY PADDING FOR FIXED NAVIGATION ===== */
    /* Add bottom padding to body to prevent content overlap */
    body {
        padding-bottom: 80px !important;
        padding-bottom: max(80px, calc(80px + env(safe-area-inset-bottom))) !important;
    }
}

/* ===== DESKTOP COMPATIBILITY ===== */
@media (min-width: 769px) {
    /* Hide mobile navigation on desktop */
    .mobile-bottom-nav,
    nav[class*="bottom"] {
        display: none !important;
    }
    
    /* Remove body padding on desktop */
    body {
        padding-bottom: 0 !important;
    }
    
    /* Desktop navigation icons */
    .desktop-nav i,
    .navbar i {
        font-family: 'Font Awesome 5 Free' !important;
        font-weight: 900 !important;
        font-size: 1.125rem !important;
        color: inherit !important;
        display: inline-block !important;
        margin-right: 0.5rem !important;
    }
}

/* ===== HIGH PRIORITY OVERRIDE ===== */
/* Ensure this CSS takes precedence over other icon fixes */
html body * [class*="fa-"],
html body * .fas,
html body * .far,
html body * .fab {
    font-family: 'Font Awesome 5 Free', 'Font Awesome 5 Brands', 'Font Awesome 5 Regular', 'FontAwesome', Arial, sans-serif !important;
    display: inline-block !important;
    visibility: visible !important;
    opacity: 1 !important;
    font-style: normal !important;
    font-variant: normal !important;
    text-rendering: auto !important;
    line-height: 1 !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

/* Brand icons final override */
html body * .fab {
    font-family: 'Font Awesome 5 Brands' !important;
    font-weight: 400 !important;
}

/* Regular icons final override */
html body * .far {
    font-family: 'Font Awesome 5 Regular' !important;
    font-weight: 400 !important;
}

/* ===== DEBUG HELPER ===== */
/* Uncomment for debugging icon issues */
/*
[class*="fa-"]:after {
    content: " [FA]";
    font-size: 0.5em;
    color: red;
    font-family: Arial;
}
*/


