/* Final Optimized Category Styling - Fixed Visibility & Contrast */

.custom-category-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 20px;
    padding: 40px 10px;
    max-width: 1300px;
    margin: 0 auto;
}

/* Base Category Item - High Quality Card */
.category-item {
    position: relative;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.06) !important;
    border-radius: 20px;
    padding: 24px 12px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    text-align: center;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    min-height: 150px;
    height: 100%;
    z-index: 1;
}

.category-item:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 74, 173, 0.1);
    border-color: #007aff !important;
}

/* Icon Container (Pastel / Light Tint Background) */
.category-image-wrapper {
    width: 64px;
    height: 64px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    transition: all 0.3s ease;
    flex-shrink: 0;
    /* Default fallback colors */
    background-color: #f0f4ff;
    color: #007aff;
}

.category-item:hover .category-image-wrapper {
    transform: scale(1.1) rotate(4deg);
}

/* Icon Styling - Force Visibility */
.category-icon-large {
    font-size: 28px;
    /* Slightly larger */
    margin: 0 !important;
    line-height: 1;
    color: inherit !important;
    /* Take color from parent wrapper */
}

.category-icon-large i {
    color: inherit !important;
    display: block;
}

/* Text Container */
.category-overlay {
    position: static !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100%;
}

/* Category Name - Deep Contrast */
.category-name {
    color: #111111 !important;
    /* Deep black for maximum visibility */
    font-size: 14px !important;
    /* Increased for readability */
    font-weight: 800 !important;
    margin: 0 0 4px 0 !important;
    line-height: 1.25 !important;
    text-shadow: none !important;
    text-transform: capitalize;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Listing Count Label */
.category-count {
    display: block;
    color: #666666 !important;
    /* Medium gray */
    font-size: 11px !important;
    font-weight: 500;
}

/* Vibrant + Pastel Theme Rotation (8 Colors) */
.grid-item:nth-child(8n+1) .category-image-wrapper {
    background-color: #fff0f0;
    color: #ff3b30;
}

/* Red */
.grid-item:nth-child(8n+2) .category-image-wrapper {
    background-color: #eaf6ff;
    color: #007aff;
}

/* Blue */
.grid-item:nth-child(8n+3) .category-image-wrapper {
    background-color: #f2fcf5;
    color: #34c759;
}

/* Green */
.grid-item:nth-child(8n+4) .category-image-wrapper {
    background-color: #fff9e6;
    color: #ff9500;
}

/* Orange */
.grid-item:nth-child(8n+5) .category-image-wrapper {
    background-color: #f6f0ff;
    color: #af52de;
}

/* Purple */
.grid-item:nth-child(8n+6) .category-image-wrapper {
    background-color: #e6fcfc;
    color: #5ac8fa;
}

/* Cyan */
.grid-item:nth-child(8n+7) .category-image-wrapper {
    background-color: #fff0f5;
    color: #ff2d55;
}

/* Pink */
.grid-item:nth-child(8n+8) .category-image-wrapper {
    background-color: #f0f1ff;
    color: #5856d6;
}

/* Indigo */

/* Responsiveness Optimization */
@media (max-width: 1200px) {
    .custom-category-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 15px;
    }

    .category-item {
        min-height: 140px;
    }
}

@media (max-width: 992px) {
    .custom-category-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .custom-category-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
        padding: 20px 8px;
    }

    .category-item {
        min-height: 120px;
        padding: 15px 8px !important;
        border-radius: 16px;
    }

    .category-image-wrapper {
        width: 48px;
        height: 48px;
        margin-bottom: 10px;
    }

    .category-icon-large {
        font-size: 22px;
    }

    .category-name {
        font-size: 11px !important;
    }
}

@media (max-width: 480px) {
    .custom-category-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

/* Cleanup */
.category-area {
    padding-top: 50px;
    padding-bottom: 70px;
    background: #fafafa;
}

.category-area .section-title .title {
    font-size: 28px !important;
    color: #000 !important;
}

.category-area .category-icon,
.category-area .category-title,
.category-area .category-qty {
    display: none !important;
}

/* --- Homepage Search Bar Styles --- */
.banner-filter-form {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    position: relative;
    z-index: 100;
}

.banner-search-wrapper {
    min-height: 80px;
    /* Reserves space to prevent 'jump' when search bar becomes fixed */
}

.banner-filter-form .form-wrapper {
    background: #fff;
    border-radius: 60px !important;
    padding: 8px 10px 8px 25px !important;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.15) !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
}

/* Ensure nice-select works with our custom sizing */
.banner-filter-form .nice-select {
    border: none !important;
    background: transparent !important;
    height: 50px !important;
    line-height: 50px !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    width: 100% !important;
}

.banner-filter-form label {
    margin-right: 12px;
    font-size: 20px;
    color: #ff5e62;
}

.banner-filter-form input.form-control {
    border: none !important;
    background: transparent !important;
    height: 50px !important;
    font-size: 15px !important;
    font-weight: 500 !important;
    color: #333 !important;
    padding-left: 5px !important;
    box-shadow: none !important;
}

/* Dividers */
.banner-filter-form .border-end {
    border-right: 1px solid #ebebeb !important;
}

/* Location Selector refinement */
.banner-filter-form .location-input-wrapper {
    width: 100%;
}

.banner-filter-form .location-input-wrapper .input-group {
    flex-wrap: nowrap !important;
}

.banner-filter-form .location-input-wrapper input {
    min-width: 140px;
}

.banner-filter-form .location-input-wrapper .btn-outline-secondary {
    border: none !important;
    color: #888;
    background: transparent !important;
}

/* Search Button */
#searchBtn2 {
    border-radius: 50px !important;
    height: 54px;
    padding: 0 35px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, #ff5e62, #ff9966);
    border: none !important;
    color: #fff !important;
    transition: all 0.3s ease;
}

#searchBtn2:hover {
    transform: scale(1.05);
    box-shadow: 0 8px 25px rgba(255, 94, 98, 0.4);
}

/* --- Sticky Mode (JS toggled) --- */
.banner-filter-form.is-sticky {
    position: fixed;
    /* top is set by JS dynamically to match header height */
    left: 0;
    width: 100% !important;
    padding: 8px 0 !important;
    background: #ffffff;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    animation: slideInDown 0.4s both !important;
    z-index: 998;
    /* Just below main navbar which is typically 999+ */
    display: flex;
    justify-content: center;
}

.banner-filter-form.is-sticky .container {
    max-width: 1200px;
    width: 100%;
}

.banner-filter-form.is-sticky .form-wrapper {
    width: 95%;
    margin: 0 auto;
    box-shadow: none !important;
    background: #f1f3f6;
    border-radius: 40px !important;
    padding: 2px 5px 2px 20px !important;
    border: 1px solid rgba(0, 0, 0, 0.05) !important;
}

.banner-filter-form.is-sticky input,
.banner-filter-form.is-sticky .nice-select {
    height: 38px !important;
    line-height: 38px !important;
    font-size: 13px !important;
}

.banner-filter-form.is-sticky #searchBtn2 {
    height: 38px;
    padding: 0 20px;
    font-size: 12px;
    border-radius: 30px !important;
}

.banner-filter-form.is-sticky label {
    font-size: 16px;
    margin-right: 8px;
}

.banner-filter-form.is-sticky .location-input-wrapper input {
    min-width: 100px;
}

/* Optimization for Mobile/Tablet Sticky */
@media (max-width: 991px) {
    .banner-filter-form.is-sticky .form-wrapper {
        border-radius: 12px !important;
        padding: 5px !important;
    }
}

@media (max-width: 768px) {
    .banner-filter-form.is-sticky {
        padding: 5px 0 !important;
        /* Mobile: Sticky to TOP (or below mobile header) */
    }

    .banner-filter-form.is-sticky .form-wrapper {
        border-radius: 8px !important;
        background: #fff;
        border: 1px solid #eee;
    }

    .banner-filter-form.is-sticky label {
        display: none !important;
        /* Compact: Hide icons */
    }

    .banner-filter-form.is-sticky .border-end {
        border-right: none !important;
    }

    .banner-filter-form.is-sticky .row {
        flex-direction: row !important;
        flex-wrap: nowrap !important;
    }

    .banner-filter-form.is-sticky .col-md-6 {
        flex: 1 1 auto !important;
        width: auto !important;
        padding: 0 4px !important;
    }
}

/* Animations */
@keyframes slideInDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* --- Navbar Integrated Search Bar --- */
.nav-search-container {
    flex: 1;
    max-width: 650px;
    /* Increased from 550px */
    margin: 0 20px;
    display: flex;
    align-items: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.is-home .nav-search-container {
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    width: 0;
    margin: 0;
    pointer-events: none;
}

.is-home .nav-search-container.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
    width: auto;
    margin: 0 20px;
    pointer-events: auto;
}

@media (max-width: 1199px) {
    .nav-search-container {
        display: none !important;
        /* Hide in header on tablet/mobile */
    }
}

.nav-filter-form {
    width: 100%;
}

.nav-form-wrapper {
    background: #f1f3f6;
    border-radius: 40px;
    padding: 0 5px 0 15px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    height: 42px;
    /* Increased slightly */
    display: flex;
    align-items: center;
    width: 100%;
    overflow: visible !important;
    /* CRITICAL: Allow dropdown to show */
}

.nav-form-wrapper form {
    width: 100%;
    margin: 0;
    overflow: visible !important;
}

.nav-form-wrapper .row {
    width: 100%;
    margin: 0;
    overflow: visible !important;
}

.nav-input-group {
    display: flex;
    align-items: center;
    padding: 0 10px;
    height: 100%;
    overflow: visible !important;
}

.nav-input-group label {
    margin: 0 8px 0 0 !important;
    color: #ff5e62;
    font-size: 15px;
    display: flex;
    align-items: center;
}

.nav-input-group input.form-control {
    border: none !important;
    background: transparent !important;
    height: 100% !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    color: #333 !important;
    padding: 0 !important;
    box-shadow: none !important;
}

.nav-filter-form .border-start {
    border-left: 1px solid #d0d5dd !important;
    margin-left: 5px;
    padding-left: 10px;
}

.nav-btn-search {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff5e62, #ff9966);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(255, 94, 98, 0.3);
}

.nav-btn-search:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(255, 94, 98, 0.4);
}

/* Location Selector refinement inside navbar */
.nav-input-group .location-input-wrapper {
    width: 100%;
    position: relative;
}

.nav-input-group .location-input-wrapper .list-group {
    width: 350px !important;
    /* Fixed width to prevent narrow/wrapped text */
    min-width: 300px;
    left: auto !important;
    right: 0 !important;
    margin-top: 5px;
    border-radius: 12px !important;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
}

.nav-input-group .location-input-wrapper .list-group-item {
    font-size: 13px !important;
    padding: 10px 15px !important;
    border: none !important;
    border-bottom: 1px solid #f0f0f0 !important;
}

.nav-input-group .location-input-wrapper .list-group-item:last-child {
    border-bottom: none !important;
}

.nav-input-group .location-input-wrapper .list-group-item:hover {
    background-color: #f8f9fa !important;
    color: #ff5e62 !important;
}

.nav-input-group .location-input-wrapper .input-group {
    border: none !important;
    background: transparent !important;
}

.nav-input-group .location-input-wrapper .btn-outline-secondary {
    display: none !important;
    /* Hide 'Detect' text/button to save space */
}

/* Adjust navbar components */
.navbar-brand img {
    max-height: 45px !important;
}

.navbar {
    width: 100% !important;
    display: flex !important;
    justify-content: space-between !important;
    align-items: center !important;
}