/* Mobile Sticky Footer Menu Styles */

/* Hide on desktop */
@media (min-width: 1024px) {
    .mobile-footer-menu {
        display: none !important;
    }
}

/* Mobile Footer Menu Container */
.mobile-footer-menu {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.1), 0 -2px 4px -1px rgba(0, 0, 0, 0.06);
    z-index: 9999;
    padding: 8px 0;
    transition: transform 0.3s ease;
}

/* Hide footer menu when scrolling down */
.mobile-footer-menu.hidden {
    transform: translateY(100%);
}

/* Menu Items Container */
.mobile-footer-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    max-width: 100%;
    margin: 0 auto;
}

/* Individual Menu Item */
.mobile-footer-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 60px;
    padding: 8px 4px;
    text-decoration: none;
    color: #6b7280;
    transition: all 0.2s ease;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.mobile-footer-item:hover,
.mobile-footer-item.active {
    color: #3b82f6;
}

.mobile-footer-item:active {
    transform: scale(0.95);
}

/* Menu Item Icon */
.mobile-footer-icon {
    width: 24px;
    height: 24px;
    margin-bottom: 4px;
    fill: currentColor;
    transition: all 0.2s ease;
}

.mobile-footer-item:hover .mobile-footer-icon,
.mobile-footer-item.active .mobile-footer-icon {
    transform: scale(1.1);
}

/* Menu Item Text */
.mobile-footer-text {
    font-size: 10px;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Active State */
.mobile-footer-item.active {
    color: #3b82f6;
}

.mobile-footer-item.active .mobile-footer-icon {
    color: #3b82f6;
}

/* Categories Popup - Mobile Optimized */
.categories-popup {
    position: fixed;
    bottom: 76px;
    left: 0;
    right: 0;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    border-radius: 20px 20px 0 0;
    box-shadow: 0 -8px 25px -5px rgba(0, 0, 0, 0.15);
    z-index: 9998;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    height: 70vh;
    max-height: 70vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* Ensure popup is hidden by default */
    visibility: hidden;
    opacity: 0;
}

.categories-popup.show {
    transform: translateY(0);
    visibility: visible;
    opacity: 1;
}

.categories-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    flex-shrink: 0;
    position: relative;
}

.categories-popup-header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
}

.categories-popup-title {
    font-size: 18px;
    font-weight: 600;
    color: #111827;
    margin: 0;
}

.categories-popup-close {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #6b7280;
    border-radius: 50%;
    transition: all 0.2s ease;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.categories-popup-close:hover {
    background: #e5e7eb;
    color: #374151;
}

.categories-popup-close:active {
    transform: scale(0.95);
}

.categories-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    padding: 16px;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #d1d5db #f3f4f6;
}

.categories-grid::-webkit-scrollbar {
    width: 4px;
}

.categories-grid::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 2px;
}

.categories-grid::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 2px;
}

.categories-grid::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

.category-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: #374151;
    transition: all 0.2s ease;
    padding: 12px 6px;
    border-radius: 10px;
    text-align: center;
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    -webkit-tap-highlight-color: transparent;
    min-width: 0;
    width: 100%;
}

.category-item:hover {
    background: #f3f4f6;
    color: #3b82f6;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.category-item:active {
    transform: translateY(0);
    background: #e5e7eb;
}

.category-icon {
    width: 28px;
    height: 28px;
    margin-bottom: 6px;
    fill: currentColor;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.category-name {
    font-size: 10px;
    font-weight: 500;
    line-height: 1.2;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    word-wrap: break-word;
}

/* Overlay for popup */
.categories-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9997;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    backdrop-filter: blur(2px);
}

.categories-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Responsive adjustments for better mobile experience */
@media (max-width: 480px) {
    .categories-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        padding: 12px;
    }
    
    .category-item {
        padding: 10px 4px;
        border-radius: 8px;
        min-height: 60px;
    }
    
    .category-icon {
        width: 24px;
        height: 24px;
        margin-bottom: 4px;
    }
    
    .category-name {
        font-size: 9px;
    }
}

@media (max-width: 400px) {
    .categories-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
        padding: 10px;
    }
    
    .category-item {
        padding: 8px 3px;
    }
    
    .category-icon {
        width: 22px;
        height: 22px;
    }
    
    .category-name {
        font-size: 8px;
    }
}

@media (max-width: 360px) {
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
        padding: 8px;
    }
    
    .category-item {
        padding: 10px 4px;
        border-radius: 8px;
    }
    
    .category-icon {
        width: 24px;
        height: 24px;
        margin-bottom: 4px;
    }
    
    .category-name {
        font-size: 9px;
    }
}

@media (max-width: 320px) {
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        padding: 6px;
    }
    
    .category-item {
        padding: 8px 3px;
        min-height: 50px;
    }
    
    .category-icon {
        width: 20px;
        height: 20px;
        margin-bottom: 3px;
    }
    
    .category-name {
        font-size: 8px;
    }
}

/* Extra small mobile devices */
@media (max-width: 280px) {
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
        padding: 4px;
    }
    
    .category-item {
        padding: 6px 2px;
        min-height: 45px;
    }
    
    .category-icon {
        width: 18px;
        height: 18px;
        margin-bottom: 2px;
    }
    
    .category-name {
        font-size: 7px;
    }
}

/* Ensure proper spacing for content above footer */
body {
    padding-bottom: 76px;
}

@media (min-width: 1024px) {
    body {
        padding-bottom: 0;
    }
}

/* Focus states for accessibility */
.mobile-footer-item:focus,
.category-item:focus,
.categories-popup-close:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .mobile-footer-menu {
        border-top-width: 2px;
    }
    
    .categories-popup {
        border-top-width: 2px;
    }
    
    .category-item {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .mobile-footer-menu,
    .categories-popup,
    .mobile-footer-item,
    .category-item {
        transition: none !important;
        transform: none !important;
    }
    
    .mobile-footer-item:hover,
    .category-item:hover {
        transform: none !important;
    }
}

/* Mobile touch improvements */
@media (hover: none) and (pointer: coarse) {
    .category-item:hover {
        transform: none;
        background: #f9fafb;
    }
    
    .mobile-footer-item:hover {
        transform: none;
    }
}
