/* ICON SYSTEM FIX - COMPREHENSIVE SOLUTION */
/* แก้ไขปัญหาไอคอนทั้งระบบ */

/* ===== FORCE FONTAWESOME LOADING ===== */
/* Primary FontAwesome 6 Loading */
@import url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css');

/* Backup FontAwesome Sources */
@import url('https://use.fontawesome.com/releases/v6.4.0/css/all.css');

/* Local Font Face Definitions */
@font-face {
    font-family: 'Font Awesome 6 Free';
    font-style: normal;
    font-weight: 900;
    font-display: swap;
    src: url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/webfonts/fa-solid-900.woff2') format('woff2'),
         url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/webfonts/fa-solid-900.woff') format('woff'),
         url('https://use.fontawesome.com/releases/v6.4.0/webfonts/fa-solid-900.woff2') format('woff2');
}

@font-face {
    font-family: 'Font Awesome 6 Brands';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/webfonts/fa-brands-400.woff2') format('woff2'),
         url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/webfonts/fa-brands-400.woff') format('woff'),
         url('https://use.fontawesome.com/releases/v6.4.0/webfonts/fa-brands-400.woff2') format('woff2');
}

@font-face {
    font-family: 'Font Awesome 6 Regular';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/webfonts/fa-regular-400.woff2') format('woff2'),
         url('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/webfonts/fa-regular-400.woff') format('woff');
}

/* ===== UNIVERSAL ICON FIXES ===== */
/* Force all FontAwesome icons to display properly */
.fas, .fa-solid,
.far, .fa-regular,
.fab, .fa-brands,
.fal, .fa-light,
.fat, .fa-thin,
.fad, .fa-duotone,
.fass, .fa-sharp,
[class*="fa-"],
i[class*="fa-"] {
    /* Font Properties */
    font-family: 'Font Awesome 6 Free', 'Font Awesome 6 Brands', 'Font Awesome 6 Regular', 'FontAwesome', 'Font Awesome 5 Free', 'Font Awesome 5 Brands' !important;
    font-weight: 900 !important;
    font-style: normal !important;
    font-variant: normal !important;
    text-transform: none !important;
    line-height: 1 !important;
    
    /* Rendering Properties */
    text-rendering: auto !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
    
    /* Display Properties */
    display: inline-block !important;
    vertical-align: baseline !important;
    
    /* Size Properties */
    width: auto !important;
    height: auto !important;
    min-width: 1em !important;
    min-height: 1em !important;
    
    /* Visibility */
    opacity: 1 !important;
    visibility: visible !important;
    
    /* Text Properties */
    speak: never !important;
    text-decoration: none !important;
    
    /* Box Model */
    box-sizing: content-box !important;
}

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

/* Regular Icons Specific */
.far, .fa-regular,
.far[class*="fa-"], .fa-regular[class*="fa-"] {
    font-family: 'Font Awesome 6 Regular' !important;
    font-weight: 400 !important;
}

/* ===== ICON CONTENT DEFINITIONS ===== */
/* Ensure proper icon content display */
.fas::before, .fa-solid::before,
.far::before, .fa-regular::before,
.fab::before, .fa-brands::before,
[class*="fa-"]::before {
    display: inline-block !important;
    font-family: inherit !important;
    font-weight: inherit !important;
    font-style: normal !important;
    text-decoration: none !important;
    text-transform: none !important;
    vertical-align: baseline !important;
    line-height: 1 !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
}

/* ===== SPECIFIC ICON UNICODE ===== */
/* Navigation Icons */
.fa-home::before { content: "\f015" !important; }
.fa-box::before { content: "\f466" !important; }
.fa-shopping-cart::before { content: "\f07a" !important; }
.fa-user::before { content: "\f007" !important; }
.fa-user-circle::before { content: "\f2bd" !important; }
.fa-bars::before { content: "\f0c9" !important; }
.fa-times::before { content: "\f00d" !important; }
.fa-search::before { content: "\f002" !important; }

/* Contact Icons */
.fa-phone::before { content: "\f095" !important; }
.fa-phone-alt::before { content: "\f879" !important; }
.fa-envelope::before { content: "\f0e0" !important; }
.fa-map-marker-alt::before { content: "\f3c5" !important; }
.fa-clock::before { content: "\f017" !important; }

/* Store/Business Icons */
.fa-store::before { content: "\f54e" !important; }
.fa-building::before { content: "\f1ad" !important; }
.fa-handshake::before { content: "\f2b5" !important; }

/* Product Icons */
.fa-star::before { content: "\f005" !important; }
.fa-heart::before { content: "\f004" !important; }
.fa-cart-plus::before { content: "\f217" !important; }
.fa-truck::before { content: "\f0d1" !important; }
.fa-shipping-fast::before { content: "\f48b" !important; }
.fa-leaf::before { content: "\f06c" !important; }

/* Feature Icons */
.fa-crown::before { content: "\f521" !important; }
.fa-award::before { content: "\f559" !important; }
.fa-certificate::before { content: "\f0a3" !important; }
.fa-gift::before { content: "\f06b" !important; }
.fa-shield-alt::before { content: "\f3ed" !important; }

/* Navigation Arrows */
.fa-chevron-left::before { content: "\f053" !important; }
.fa-chevron-right::before { content: "\f054" !important; }
.fa-chevron-up::before { content: "\f077" !important; }
.fa-chevron-down::before { content: "\f078" !important; }
.fa-arrow-right::before { content: "\f061" !important; }

/* Social Media Icons */
.fa-facebook-f::before { content: "\f39e" !important; }
.fa-line::before { content: "\f3c0" !important; }
.fa-tiktok::before { content: "\e07b" !important; }
.fa-youtube::before { content: "\f167" !important; }
.fa-facebook-messenger::before { content: "\f39f" !important; }
.fa-instagram::before { content: "\f16d" !important; }

/* Utility Icons */
.fa-check::before { content: "\f00c" !important; }
.fa-check-circle::before { content: "\f058" !important; }
.fa-exclamation-triangle::before { content: "\f071" !important; }
.fa-info-circle::before { content: "\f05a" !important; }
.fa-question-circle::before { content: "\f059" !important; }

/* ===== FALLBACK EMOJI SYSTEM ===== */
/* If FontAwesome fails to load, show emoji */
.fa-home:not(.fa-loaded):empty::after { content: "🏠"; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif !important; }
.fa-box:not(.fa-loaded):empty::after { content: "📦"; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif !important; }
.fa-shopping-cart:not(.fa-loaded):empty::after { content: "🛒"; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif !important; }
.fa-user:not(.fa-loaded):empty::after { content: "👤"; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif !important; }
.fa-phone:not(.fa-loaded):empty::after { content: "📞"; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif !important; }
.fa-envelope:not(.fa-loaded):empty::after { content: "✉️"; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif !important; }
.fa-map-marker-alt:not(.fa-loaded):empty::after { content: "📍"; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif !important; }
.fa-clock:not(.fa-loaded):empty::after { content: "🕐"; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif !important; }
.fa-store:not(.fa-loaded):empty::after { content: "🏪"; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif !important; }
.fa-star:not(.fa-loaded):empty::after { content: "⭐"; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif !important; }
.fa-heart:not(.fa-loaded):empty::after { content: "💚"; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif !important; }
.fa-truck:not(.fa-loaded):empty::after { content: "🚚"; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif !important; }
.fa-leaf:not(.fa-loaded):empty::after { content: "🍃"; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif !important; }
.fa-crown:not(.fa-loaded):empty::after { content: "👑"; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif !important; }
.fa-bars:not(.fa-loaded):empty::after { content: "☰"; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif !important; }
.fa-search:not(.fa-loaded):empty::after { content: "🔍"; font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif !important; }

/* ===== MOBILE RESPONSIVE FIXES ===== */
@media (max-width: 768px) {
    /* Mobile icon sizing */
    .mobile-nav-item i,
    .mobile-bottom-nav i {
        font-size: 1.25rem !important;
        min-width: 44px !important;
        min-height: 44px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    /* Mobile touch targets */
    .fas, .fab, .far, [class*="fa-"] {
        min-width: 1.25em !important;
        text-align: center !important;
    }
    
    /* Contact section mobile */
    .contact-item i {
        font-size: 2rem !important;
        margin-bottom: 0.5rem !important;
    }
}

/* ===== COLOR SYSTEM ===== */
/* Default icon colors - no black icons */
.fas, .far, .fab, [class*="fa-"] {
    color: #22c55e !important; /* Default green */
}

/* Navigation specific colors */
.mobile-nav-item i,
.mobile-bottom-nav i,
.desktop-header i,
.nav-link i {
    color: white !important;
}

/* Contact colors */
.fa-phone, .fa-phone-alt { color: #10b981 !important; }
.fa-envelope { color: #3b82f6 !important; }
.fa-map-marker-alt { color: #ef4444 !important; }
.fa-clock { color: #f59e0b !important; }

/* Product colors */
.fa-star { color: #f59e0b !important; }
.fa-heart { color: #ef4444 !important; }
.fa-cart-plus, .fa-shopping-cart { color: #22c55e !important; }
.fa-truck, .fa-shipping-fast { color: #3b82f6 !important; }

/* Social media brand colors */
.fab.fa-facebook-f { color: #1877f2 !important; }
.fab.fa-line { color: #00b900 !important; }
.fab.fa-tiktok { color: #000000 !important; }
.fab.fa-youtube { color: #ff0000 !important; }
.fab.fa-facebook-messenger { color: #0084ff !important; }
.fab.fa-instagram { color: #e4405f !important; }

/* ===== LOADING STATES ===== */
/* Show loading indicator while fonts load */
.icon-loading {
    position: relative;
}

.icon-loading::before {
    content: "⏳";
    font-family: 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji', sans-serif;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== BROWSER SPECIFIC FIXES ===== */
/* Safari specific fixes */
@supports (-webkit-appearance: none) {
    .fas, .far, .fab, [class*="fa-"] {
        -webkit-font-feature-settings: normal !important;
        -webkit-text-stroke: 0 !important;
    }
}

/* Firefox specific fixes */
@-moz-document url-prefix() {
    .fas, .far, .fab, [class*="fa-"] {
        -moz-font-feature-settings: normal !important;
    }
}

/* Edge/IE specific fixes */
@supports (-ms-ime-align: auto) {
    .fas, .far, .fab, [class*="fa-"] {
        font-feature-settings: normal !important;
    }
}

/* ===== HIGH PRIORITY OVERRIDES ===== */
/* Force display for hidden icons */
.fas[style*="display: none"],
.far[style*="display: none"],
.fab[style*="display: none"],
[class*="fa-"][style*="display: none"] {
    display: inline-block !important;
}

/* Force visibility for invisible icons */
.fas[style*="visibility: hidden"],
.far[style*="visibility: hidden"],
.fab[style*="visibility: hidden"],
[class*="fa-"][style*="visibility: hidden"] {
    visibility: visible !important;
}

/* Force opacity for transparent icons */
.fas[style*="opacity: 0"],
.far[style*="opacity: 0"],
.fab[style*="opacity: 0"],
[class*="fa-"][style*="opacity: 0"] {
    opacity: 1 !important;
}

/* ===== ACCESSIBILITY ===== */
/* Screen reader support */
.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: 0 !important;
}

/* Focus indicators */
.fas:focus, .far:focus, .fab:focus,
[class*="fa-"]:focus {
    outline: 2px solid #22c55e !important;
    outline-offset: 2px !important;
}

/* ===== PERFORMANCE OPTIMIZATIONS ===== */
/* GPU acceleration for smooth animations */
.fas, .far, .fab, [class*="fa-"] {
    will-change: transform !important;
    backface-visibility: hidden !important;
    transform: translateZ(0) !important;
}

/* Preload critical icons */
.critical-icon {
    font-display: block !important;
}

/* ===== DEBUG MODE ===== */
/* Add debug class to see icon loading issues */
.debug-icons .fas::after,
.debug-icons .far::after,
.debug-icons .fab::after,
.debug-icons [class*="fa-"]::after {
    content: " [" attr(class) "]";
    font-size: 0.5em;
    color: red;
    font-family: monospace;
}

