/* ============================================
   MurliGanj Local Store - UI Restoration Fix
   Fixes all CSS, icon, layout, and asset issues
   ============================================ */

/* === ICON FIXES === */
/* CRITICAL: Ensure Font Awesome font-family is never overridden */
.fa, .fas, .far, .fal, .fab, .fa-solid, .fa-regular, .fa-light, .fa-brands,
[class^="fa-"], [class*=" fa-"] {
    font-family: var(--fa-style-family, "Font Awesome 6 Free") !important;
}
.fas, .fa-solid, [class^="fas"], [class*=" fas"] {
    font-weight: 900 !important;
}
.far, .fa-regular {
    font-family: "Font Awesome 6 Free" !important;
    font-weight: 400 !important;
}
.fab, .fa-brands {
    font-family: "Font Awesome 6 Brands" !important;
    font-weight: 400 !important;
}

/* Ensure FA pseudo-elements are never hidden */
.fa::before, .fas::before, .far::before, .fab::before,
.fa-solid::before, .fa-regular::before, .fa-brands::before {
    display: inline-block !important;
    font-style: normal !important;
    font-variant: normal !important;
    text-rendering: auto !important;
    -webkit-font-smoothing: antialiased !important;
}

/* Ensure Font Awesome renders everywhere */
.fa, .fas, .far, .fal, .fab, .fa-solid, .fa-regular, .fa-brands {
    display: inline-block !important;
    font-style: normal !important;
    font-variant: normal !important;
    text-rendering: auto !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
    visibility: visible !important;
    opacity: 1 !important;
    line-height: 1 !important;
}

/* Fix icon sizing in all contexts */
.sidebar-link i,
.sidebar-link .fa,
.sidebar-link .fas,
.sidebar-link .far {
    width: 20px !important;
    text-align: center !important;
    font-size: 14px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.sidebar-section-label i,
.sidebar-section-label .fa {
    margin-right: 6px;
}

/* Fix category icons */
.category-icon i,
.category-icon .fa,
.category-icon .fas {
    font-size: inherit !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* Fix all icon containers */
[class*="bg-"] i,
[class*="bg-"] .fa,
[class*="bg-"] .fas {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
}

/* === WHITE TEXT ON WHITE BACKGROUND FIX === */
/* Ensure text is always visible on white/light backgrounds */
.bg-white .text-white,
.bg-white.text-white,
.bg-gray-50 .text-white,
.bg-gray-50.text-white {
    color: #111827 !important;
}

/* Dark text on light backgrounds */
.bg-white .text-white:not(.btn):not(.badge):not(.navbar):not(header):not(footer):not(.sidebar):not(.gradient-primary):not(.gradient-accent),
.bg-gray-50 .text-white:not(.btn):not(.badge):not(.navbar):not(header):not(footer):not(.sidebar):not(.gradient-primary):not(.gradient-accent) {
    color: #111827 !important;
}

/* Light text on dark backgrounds */
.bg-gray-800 .text-gray-900,
.bg-gray-900 .text-gray-900,
.bg-gray-950 .text-gray-900,
.bg-gray-800 .text-black,
.bg-gray-900 .text-black,
.bg-gray-950 .text-black,
.bg-dark .text-gray-900,
.bg-dark .text-black {
    color: #f3f4f6 !important;
}

/* Fix footer text visibility */
footer .text-gray-400,
footer .text-gray-500,
footer .text-gray-600 {
    color: #9ca3af !important;
}

footer a.text-gray-500:hover {
    color: #4ade80 !important;
}

footer .text-white {
    color: #fff !important;
}

/* === SPACING & PADDING FIXES === */
/* Ensure consistent card spacing */
.product-card {
    transition: all 0.3s ease;
    position: relative;
}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

/* Fix card body overflow */
.product-card .p-3 {
    padding: 0.75rem;
}

/* Fix ADD button alignment */
.product-card button,
.product-card .btn {
    white-space: nowrap;
    flex-shrink: 0;
}

/* === TEXT ALIGNMENT FIXES === */
/* Ensure consistent text alignment */
.text-center {
    text-align: center !important;
}

.text-left {
    text-align: left !important;
}

.text-right {
    text-align: right !important;
}

/* Fix truncation */
.truncate,
.text-truncate {
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

/* === ADMIN PANEL FIXES === */
/* Admin sidebar icons - ensure visibility */
.admin-sidebar .sidebar-link i {
    width: 20px !important;
    text-align: center !important;
    font-size: 14px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #9ca3af;
}

/* Only override color for active/hover if no inline style is set */
.admin-sidebar .sidebar-link i[style*="color"] {
    /* Preserve inline colors set on specific icons */
}

.admin-sidebar .sidebar-link.active i:not([style*="color"]) {
    color: #34d399 !important;
}

.admin-sidebar .sidebar-link:hover i:not([style*="color"]) {
    color: #f3f4f6 !important;
}

/* Admin stat cards */
.admin-content .rounded-xl.border.border-gray-100 {
    background: #fff !important;
}

/* Admin dashboard card text */
.admin-content .text-gray-900 {
    color: #111827 !important;
}

.admin-content .text-gray-500 {
    color: #6b7280 !important;
}

/* Admin tables */
.admin-content .table-wrap table {
    width: 100%;
    border-collapse: collapse;
}

.admin-content .table-wrap th {
    background: #f9fafb;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 2px solid #e5e7eb;
}

.admin-content .table-wrap td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f3f4f6;
    color: #374151;
    font-size: 0.875rem;
}

.admin-content .table-wrap tr:hover td {
    background: #f9fafb;
}

/* Admin form elements */
.admin-content .form-control {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: #374151;
    background: #fff;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    transition: border-color 0.15s ease-in-out;
}

.admin-content .form-control:focus {
    border-color: #22c55e;
    outline: 0;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}

.admin-content .form-label {
    display: block;
    margin-bottom: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: #374151;
}

.admin-content .btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #16a34a;
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.admin-content .btn-primary:hover {
    background: #15803d;
}

.admin-content .btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #6b7280;
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.admin-content .btn-secondary:hover {
    background: #4b5563;
}

.admin-content .btn-danger {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: #ef4444;
    color: #fff;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.admin-content .btn-danger:hover {
    background: #dc2626;
}

/* Admin page titles */
.admin-content h1,
.admin-content h2,
.admin-content h3 {
    color: #111827 !important;
}

.admin-content .page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 1.5rem;
}

/* Admin card styling */
.admin-content .card {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    overflow: hidden;
}

.admin-content .card-header {
    padding: 1rem 1.25rem;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 600;
    font-size: 0.9375rem;
    color: #111827;
}

.admin-content .card-body {
    padding: 1.25rem;
}

/* === IMAGE FIXES === */
/* Ensure images don't break layout */
img {
    max-width: 100%;
    height: auto;
}

img[src=""],
img:not([src]) {
    opacity: 0;
}

/* Category icon images */
.category-icon img,
.w-16 img,
.w-20 img,
.w-24 img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* === FOOTER FIXES === */
footer .gradient-primary {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%) !important;
}

footer .social-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

footer ul li a i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
}

/* === CATEGORY SECTION FIXES === */
.category-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.category-grid-item .icon-wrapper {
    width: 4rem;
    height: 4rem;
    border-radius: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.category-grid-item:hover .icon-wrapper {
    transform: scale(1.05);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

@media (min-width: 640px) {
    .category-grid-item .icon-wrapper {
        width: 5rem;
        height: 5rem;
    }
}

/* === PRODUCT CARD FIXES === */
.product-card .aspect-square {
    aspect-ratio: 1/1;
    overflow: hidden;
    background: #f9fafb;
}

.product-card img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-card:hover img {
    transform: scale(1.05);
}

/* === NAVIGATION FIXES === */
/* Desktop nav active states */
.nav-active {
    color: #16a34a !important;
    font-weight: 600 !important;
}

/* Mobile bottom nav */
.fixed.bottom-0.left-0.right-0.bg-white {
    z-index: 30 !important;
}

/* === RESPONSIVE FIXES === */
@media (max-width: 640px) {
    .product-card .text-sm {
        font-size: 0.8125rem;
    }
    
    .category-grid-item .icon-wrapper {
        width: 3.5rem;
        height: 3.5rem;
    }
    
    .category-grid-item .icon-wrapper i {
        font-size: 1.25rem !important;
    }
}

/* === MISSING UTILITY CLASSES === */
.object-cover { object-fit: cover !important; }
.object-contain { object-fit: contain !important; }
.object-fill { object-fit: fill !important; }
.aspect-square { aspect-ratio: 1/1 !important; }
.aspect-video { aspect-ratio: 16/9 !important; }

/* Gap utilities not in framework */
.gap-x-2 { column-gap: 0.5rem; }
.gap-y-2 { row-gap: 0.5rem; }
.gap-x-3 { column-gap: 0.75rem; }
.gap-y-3 { row-gap: 0.75rem; }

/* Opacity */
.opacity-0 { opacity: 0; }
.opacity-60 { opacity: 0.6; }
.opacity-80 { opacity: 0.8; }
.opacity-100 { opacity: 1; }

/* Additional responsive */
@media (min-width: 640px) {
    .sm\:gap-2 { gap: 0.5rem; }
    .sm\:gap-3 { gap: 0.75rem; }
    .sm\:gap-4 { gap: 1rem; }
    .sm\:gap-6 { gap: 1.5rem; }
}

@media (min-width: 768px) {
    .md\:gap-3 { gap: 0.75rem; }
    .md\:gap-4 { gap: 1rem; }
    .md\:gap-6 { gap: 1.5rem; }
}

/* === CARD GLASS EFFECT === */
.glass-card {
    background: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
}

/* === GRADIENT FIX === */
.gradient-primary {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%) !important;
}

.gradient-accent {
    background: linear-gradient(135deg, #f97316 0%, #ea580c 100%) !important;
}

/* === STORE CARD FIXES === */
.store-card {
    transition: all 0.3s ease;
}

.store-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.1);
}

/* === BANNER FIXES === */
.banner-container {
    width: 100%;
    overflow: hidden;
}

.banner-container img {
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* === CHAT BOT WIDGET FIX === */
#mls-chat-widget .chat-fab {
    z-index: 9990 !important;
    pointer-events: auto !important;
}

#mls-chat-widget .chat-panel {
    z-index: 9989 !important;
}

/* === WHATSAPP BUTTON FIX === */
#whatsapp-float-btn {
    z-index: 95 !important;
    pointer-events: auto !important;
    -webkit-tap-highlight-color: transparent;
}

@media (max-width: 1023px) {
    #whatsapp-float-btn {
        bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

@media (min-width: 1024px) {
    #whatsapp-float-btn {
        bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* === FLOATING CART BAR FIX === */
#floating-cart-bar {
    transition: transform 0.3s ease-out;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

#floating-cart-bar.translate-y-0 {
    transform: translateY(0);
}

#floating-cart-bar.translate-y-full {
    transform: translateY(100%);
}

/* === MOBILE BOTTOM NAV SAFE AREA === */
@media (max-width: 1023px) {
    nav.lg\:hidden.fixed.bottom-0 {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}

/* === CHATBOT SAFE AREA === */
@media (max-width: 1023px) {
    #mls-chat-widget .chat-fab {
        bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* === RIDER LAYOUT FIX === */
body:has(.rider-layout) {
    background: #f9fafb;
}

/* === SUPPORT/HELPDESK FIXES === */
.support-container {
    max-width: 72rem;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* === AUTH PAGES FIX === */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #111827 0%, #1f2937 50%, #111827 100%);
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 28rem;
    background: #fff;
    border-radius: 1rem;
    padding: 2rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

/* === SECTION HEADER FIXES === */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
}

/* === BADGE FIXES === */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
}

.badge-green {
    background: #dcfce7;
    color: #15803d;
}

.badge-red {
    background: #fee2e2;
    color: #dc2626;
}

.badge-yellow {
    background: #fef9c3;
    color: #a16207;
}

.badge-blue {
    background: #dbeafe;
    color: #1d4ed8;
}

/* === RESPONSIVE GRID FIXES === */
.grid-responsive {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)) !important;
    gap: 1rem !important;
}

/* === TOAST FIX === */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    transform: translateX(120%);
    transition: transform 0.3s ease;
}

.toast.show {
    transform: translateX(0);
}

/* === CART FLOATING BAR FIX === */
#floating-cart-bar {
    transition: transform 0.3s ease-out;
}

#floating-cart-bar.translate-y-0 {
    transform: translateY(0);
}

/* === CONTAINER FIX === */
.max-w-7xl {
    max-width: 80rem;
    margin-left: auto;
    margin-right: auto;
}

/* === FLEX HELPERS NOT IN FRAMEWORK === */
@media (min-width: 640px) {
    .sm\:flex-row { flex-direction: row !important; }
    .sm\:flex-col { flex-direction: column !important; }
}

@media (min-width: 768px) {
    .md\:flex-row { flex-direction: row !important; }
    .md\:flex-col { flex-direction: column !important; }
}

/* === GAS BOOKING FIXES === */
.gas-booking-card {
    background: linear-gradient(135deg, #fff7ed 0%, #ffedd5 100%);
    border: 1px solid #fed7aa;
    border-radius: 0.75rem;
    padding: 1.25rem;
}

/* === CUSTOMER SECTION FIX === */
/* Fix the "What's on your mind" horizontal scroll */
.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

/* === ANIMATION FIXES === */
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-slide-up {
    animation: slideUp 0.3s ease-out forwards;
}

/* === IMPORTANT NOTICE POPUP FIX === */
.important-notice-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

/* === SEARCH PAGE FIXES === */
.search-result-card {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    background: #fff;
    border-radius: 0.75rem;
    border: 1px solid #f3f4f6;
    transition: all 0.2s;
}

.search-result-card:hover {
    border-color: #bbf7d0;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

/* === COMPLAINT PAGE FIXES === */
.complaint-card {
    background: #fff;
    border: 1px solid #f3f4f6;
    border-radius: 0.75rem;
    padding: 1rem;
    transition: all 0.2s;
}

.complaint-card:hover {
    border-color: #fde68a;
}

/* === ORDER STATUS COLORS === */
.text-pending { color: #f59e0b; }
.text-confirmed { color: #3b82f6; }
.text-preparing { color: #8b5cf6; }
.text-out-for-delivery { color: #f97316; }
.text-delivered { color: #22c55e; }
.text-cancelled { color: #ef4444; }

.bg-pending { background: #fef3c7; }
.bg-confirmed { background: #dbeafe; }
.bg-preparing { background: #ede9fe; }
.bg-out-for-delivery { background: #ffedd5; }
.bg-delivered { background: #dcfce7; }
.bg-cancelled { background: #fee2e2; }

/* === MOBILE SAFE AREA & FLOATING ELEMENT FIXES === */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .safe-area-pb {
        padding-bottom: env(safe-area-inset-bottom, 0px) !important;
    }
}

/* Prevent floating elements from overlapping on mobile */
@media (max-width: 1023px) {
    /* Bottom nav spacing */
    nav.lg\:hidden.fixed.bottom-0 {
        padding-bottom: max(0px, env(safe-area-inset-bottom, 0px));
    }
    
    /* Floating cart bar above bottom nav */
    #floating-cart-bar {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
    
    /* WhatsApp above bottom nav */
    #whatsapp-float-btn {
        bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
    }
    
    /* Chatbot FAB above bottom nav */
    #mls-chat-widget .chat-fab {
        bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* Desktop spacing */
@media (min-width: 1024px) {
    #whatsapp-float-btn {
        bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
    }
}

/* Touch-friendly tap targets on mobile */
@media (max-width: 768px) {
    button, a[role="button"], .cursor-pointer {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Location button touch target */
    #location-btn-mobile {
        min-height: 44px;
    }
    
    /* Bottom nav items */
    nav.lg\:hidden.fixed.bottom-0 a {
        min-height: 44px;
    }
}

/* Prevent horizontal scroll from floating elements */
body {
    overflow-x: hidden;
}

/* Ensure floating elements don't cause horizontal scroll */
#whatsapp-float-btn,
#floating-cart-bar,
#mls-chat-widget {
    max-width: calc(100vw - 16px);
}

/* Fix for iOS Safari bottom bar overlap */
@supports (-webkit-touch-callout: none) {
    @media (max-width: 1023px) {
        #whatsapp-float-btn {
            bottom: calc(88px + env(safe-area-inset-bottom, 0px)) !important;
        }
        
        #floating-cart-bar {
            padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
        }
    }
}


