/* Modern Category Cards - Inspired by App Design */
.categories-section {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    padding: 40px 20px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
}

.categories-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(45deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
    pointer-events: none;
}

.categories-section h2 {
    font-size: 1.8rem;
    color: #2c3e50;
    margin-bottom: 30px;
    text-align: center;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: relative;
    z-index: 1;
}

.categories-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 15px 0 25px 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    position: relative;
    z-index: 1;
}

.categories-scroll::-webkit-scrollbar {
    display: none;
}

.categories-grid {
    display: flex;
    gap: 24px;
    min-width: max-content;
    padding: 0 10px;
    align-items: center;
}

/* Modern Category Card Design */
.category-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 140px;
    width: 140px;
    height: 140px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 28px;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-align: center;
    padding: 20px 16px;
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.12),
        0 2px 8px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
    transform-origin: center;
    will-change: transform, box-shadow;
}

/* Gradient overlay for category cards */
.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--category-color, #667eea) 0%, rgba(118, 75, 162, 0.1) 100%);
    opacity: 0;
    transition: opacity 0.4s ease;
    border-radius: 28px;
    z-index: 1;
}

.category-card:hover::before {
    opacity: 0.08;
}

.category-card.selected::before {
    opacity: 0.12;
}

/* Hover and interaction states */
.category-card:hover {
    box-shadow: 
        0 20px 48px rgba(0, 0, 0, 0.18),
        0 8px 24px rgba(0, 0, 0, 0.12);
    background: rgba(255, 255, 255, 1);
}

.category-card.selected {
    background: white;
    box-shadow: 
        0 16px 40px rgba(0, 0, 0, 0.15),
        0 4px 16px rgba(0, 0, 0, 0.1),
        inset 0 0 0 2px var(--category-color, #667eea);
}

/* Category Icon Container */
.category-image {
    width: 110px;
    height: 110px;
    margin-bottom: 8px;
    position: relative;
    z-index: 2;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    border-radius: 20px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.category-image::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, rgba(255,255,255,0.05) 100%);
    border-radius: 20px;
    z-index: 1;
}

.category-image img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 16px;
    transition: all 0.4s ease;
    position: relative;
    z-index: 2;
    filter: brightness(1.1) contrast(1.1);
}

.category-card:hover .category-image {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.category-card:hover .category-image img {
    filter: brightness(1.2) contrast(1.2);
}

.category-card.selected .category-image {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* Category Name */
.category-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: #2c3e50;
    position: relative;
    z-index: 2;
    transition: all 0.3s ease;
    line-height: 1.3;
    max-width: 100%;
    word-wrap: break-word;
    letter-spacing: -0.2px;
}

.category-card:hover .category-name {
    color: var(--category-color, #667eea);
    font-weight: 700;
}

.category-card.selected .category-name {
    color: var(--category-color, #667eea);
    font-weight: 700;
}

/* Selection indicator badge */
.category-card.selected::after {
    content: '✓';
    position: absolute;
    top: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    background: var(--category-color, #667eea);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    z-index: 3;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    animation: checkmarkPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes checkmarkPop {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    60% {
        transform: scale(1.2) rotate(0deg);
        opacity: 0.9;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Pulse animation for selected state - REMOVED */
/* .category-card.selected {
    animation: selectedPulse 2s infinite alternate;
} */

/* @keyframes selectedPulse {
    0% {
        box-shadow: 
            0 16px 40px rgba(0, 0, 0, 0.15),
            0 4px 16px rgba(0, 0, 0, 0.1),
            inset 0 0 0 2px var(--category-color, #667eea);
    }
    100% {
        box-shadow: 
            0 16px 40px rgba(0, 0, 0, 0.15),
            0 4px 16px rgba(0, 0, 0, 0.1),
            inset 0 0 0 2px var(--category-color, #667eea),
            0 0 20px rgba(102, 126, 234, 0.4);
    }
} */

/* Active/Click state */
.category-card:active {
    transition: all 0.1s ease;
}

/* Loading state */
.category-card.loading {
    opacity: 0.7;
    pointer-events: none;
}

.category-card.loading .category-image {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Mobile Responsive Design */
@media (max-width: 768px) {
    .categories-section {
        padding: 30px 15px;
        margin-bottom: 15px;
    }

    .categories-section h2 {
        font-size: 1.5rem;
        margin-bottom: 25px;
    }

    .categories-grid {
        gap: 18px;
        padding: 0 8px;
    }

    .category-card {
        min-width: 120px;
        width: 120px;
        height: 120px;
        padding: 12px 8px;
        border-radius: 24px;
    }

    .category-image {
        width: 90px;
        height: 90px;
        margin-bottom: 6px;
        border-radius: 16px;
    }

    .category-image img {
        width: 65px;
        height: 65px;
        border-radius: 12px;
    }

    .category-name {
        font-size: 0.85rem;
    }

    .category-card.selected::after {
        width: 20px;
        height: 20px;
        top: 8px;
        right: 8px;
        font-size: 10px;
    }
}

@media (max-width: 480px) {
    .categories-section {
        padding: 25px 0;
        width: 100vw;
        margin-left: calc(-50vw + 50%);
    }

    .categories-section h2 {
        font-size: 1.3rem;
        margin-bottom: 20px;
        padding: 0 10px;
    }

    .categories-scroll {
        padding: 15px 10px 25px 10px;
    }

    .categories-grid {
        gap: 15px;
        padding: 0 5px;
    }

    .category-card {
        min-width: 100px;
        width: 100px;
        height: 100px;
        padding: 8px 6px;
        border-radius: 20px;
    }

    .category-image {
        width: 75px;
        height: 75px;
        margin-bottom: 4px;
        border-radius: 14px;
    }

    .category-image img {
        width: 55px;
        height: 55px;
        border-radius: 10px;
    }

    .category-name {
        font-size: 0.8rem;
        line-height: 1.2;
    }

    .category-card:hover {
        box-shadow: 
            0 20px 48px rgba(0, 0, 0, 0.18),
            0 8px 24px rgba(0, 0, 0, 0.12);
    }
}

/* Focus states for accessibility */
.category-card:focus {
    outline: none;
    box-shadow: 
        0 16px 40px rgba(0, 0, 0, 0.15),
        0 4px 16px rgba(0, 0, 0, 0.1),
        0 0 0 3px rgba(102, 126, 234, 0.4);
}

/* Admin specific enhancements */
.category-admin-actions {
    position: absolute;
    top: 8px;
    left: 8px;
    display: none;
    gap: 4px;
    z-index: 4;
}

.category-card:hover .category-admin-actions {
    display: flex;
}

.category-admin-btn {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.3s ease;
    color: #666;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.category-admin-btn:hover {
    background: white;
    color: #333;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.category-admin-btn.edit {
    color: #007bff;
}

.category-admin-btn.delete {
    color: #dc3545;
}

/* Count badge for products */
.category-card .count-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    padding: 3px 7px;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.4);
    z-index: 4;
    animation: bounce 0.5s ease;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-8px);
    }
    60% {
        transform: translateY(-4px);
    }
}

/* Special styling for Today's Offers category card */
.special-offer-card {
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%) !important;
    color: white !important;
    position: relative;
    overflow: hidden;
    animation: pulse-glow 2s infinite;
    border: 2px solid #fff !important;
    box-shadow: 0 8px 25px rgba(108, 117, 125, 0.4) !important;
}

.special-offer-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shine 3s infinite;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 8px 25px rgba(108, 117, 125, 0.4);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 8px 35px rgba(108, 117, 125, 0.6);
        transform: scale(1.02);
    }
}

@keyframes shine {
    0% { left: -100%; }
    100% { left: 100%; }
}

.special-offer-card .category-image {
    background: rgba(255, 255, 255, 0.2) !important;
    border: 2px solid rgba(255, 255, 255, 0.3) !important;
}

.special-offer-card .offer-icon {
    font-size: 2rem;
    line-height: 1;
    animation: bounce-fire 1.5s infinite;
}

@keyframes bounce-fire {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.special-offer-card .category-name {
    color: white !important;
    font-weight: 700 !important;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.special-offer-card .offer-badge {
    position: absolute;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.9);
    color: #495057;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    animation: blink-badge 2s infinite;
}

@keyframes blink-badge {
    0%, 50% { opacity: 1; }
    25%, 75% { opacity: 0.7; }
}

.special-offer-card:hover {
    transform: translateY(-8px) scale(1.05) !important;
    box-shadow: 0 15px 40px rgba(108, 117, 125, 0.6) !important;
}

.special-offer-card.selected {
    background: linear-gradient(135deg, #495057 0%, #343a40 100%) !important;
    box-shadow: 0 8px 25px rgba(73, 80, 87, 0.6) !important;
}