
.category-grid {
    margin-left: auto !important;
    margin-right: auto !important;
    overflow: hidden;
    box-sizing: border-box;
}
.categories-title {
    text-align: left;
    font-size: 3rem;
    font-weight: bold;
    background: linear-gradient(135deg, #764ba2 0%, #667eea 50%, #f093fb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    position: relative;
    padding: 20px 0;
    margin-bottom: 40px;
}

.categories-title::before {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    width: 100px;
    height: 4px;
    background: linear-gradient(135deg, #764ba2 100%, #667eea 100%);
    border-radius: 2px;
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4);
    animation: slideIn 1s ease-out;
}

.categories-title::after {
    content: '✦';
    position: absolute;
    bottom: -15px;
    right: 0;
    font-size: 1.5rem;
    color: #764ba2;
    animation: sparkle 2s infinite ease-in-out;
}

@keyframes slideIn {
    from {
        width: 0;
        opacity: 0;
    }
    to {
        width: 100px;
        opacity: 1;
    }
}

@keyframes sparkle {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        opacity: 0.7;
    }
    50% {
        transform: scale(1.2) rotate(180deg);
        opacity: 1;
    }
}

/* ===============================
   Responsive Title Adjustments
================================= */

/* Tablet screens and below */
@media (max-width: 768px) {
  .categories-title {
    font-size: 1.8rem;
    text-align: center;
    letter-spacing: 0.5px;
    margin-bottom: 15px;
  }

  .categories-title::before {
    left: 50%;
    transform: translateX(-50%);
    width: 70px;
    height: 3px;
    background-color: #D4AF37; /* gold underline */
    content: "";
    display: block;
    margin: 8px auto 0;
    border-radius: 2px;
  }
}

/* Mobile screens */
@media (max-width: 576px) {
  .categories-title {
    font-size: 1.5rem;
    padding: 10px 0;
    margin-bottom: 20px;
  }

  .categories-title::before {
    width: 60px;
    height: 3px;
  }

  .categories-title::after {
    content: "";
    display: none; /* remove any after element for clean compact look */
  }
}

/* Override Bootstrap flex to use grid for precise column control */
.category-grid {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr) !important;
    gap: 1rem !important; /* Matches gap-3 (1rem in Bootstrap) */
    justify-content: center !important; /* Centers all rows, including partial last row */
    margin-top: 40px !important;
    text-align: center;
    width: 100%;
    padding: 0 0.5rem; /* Small edge padding */
}

/* Base category card styles */
.category-card {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 1rem !important; /* Matches p-3 */
    text-decoration: none !important;
    color: inherit !important;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.3s ease;
    width: 100%;
    height: auto;
}

.category-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.category-logo {
    width: 100% !important; /* Override inline width */
    max-width: 200px;
    height: auto !important; /* Override inline height - auto for responsive */
    object-fit: contain; /* Shows full image without cropping/distortion */
    border-radius: 8px;
    margin-bottom: 0.5rem !important; /* Matches mb-2 */
    transition: transform 0.3s ease;
}

.category-card:hover .category-logo {
    transform: scale(1.05);
}

.category-card h2 {
    margin: 0.5rem 0 0 !important; /* Matches mt-2, text-center already on h2 */
    font-size: 1.1rem;
    font-weight: 600;
    text-align: center !important;
    line-height: 1.3;
}

/* Full responsive breakpoints for grid columns and sizing */
/* Mobile: 3 columns (up to 768px) */
@media (max-width: 768px) {
    .category-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 0.75rem !important;
        padding: 0 0.25rem !important;
        justify-content: center !important; /* Ensures last partial row (e.g., 1 item) is centered in the middle */
    }
    
    .category-card {
        padding: 0.75rem !important;
    }
    
    .category-logo {
        max-width: 100px !important; /* Adjusted smaller for 3-column mobile fit */
    }
    
    .category-card h2 {
        font-size: 0.9rem !important;
    }
    
    /* Tighter container on mobile */
    .container {
        padding-left: 0.25rem !important;
        padding-right: 0.25rem !important;
    }
    
    .container.py-3 {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }
}

/* Extra small mobile: Still 3 columns, but tighter if needed (optional) */
@media (max-width: 480px) {
    .category-logo {
        max-width: 80px !important;
    }
    
    .category-card h2 {
        font-size: 0.85rem !important;
    }
    
    .category-grid {
        gap: 0.5rem !important;
    }
}

/* Tablet: 4 columns */
@media (min-width: 769px) and (max-width: 992px) {
    .category-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 0.875rem !important;
        justify-content: center !important; /* Centers partial rows on tablet too */
    }
    
    .category-logo {
        max-width: 140px !important;
    }
    
    .category-card h2 {
        font-size: 1rem !important;
    }
}

/* Large desktop: 5 columns */
@media (min-width: 993px) {
    .category-grid {
        grid-template-columns: repeat(5, 1fr) !important;
        gap: 1.25rem !important;
        justify-content: center !important; /* Centers partial rows on desktop */
    }
    
    .category-card {
        padding: 1.25rem !important;
    }
    
    .category-logo {
        max-width: 200px !important;
    }
}