/* ==========================================================================
   MJB Category Filter — Sidebar Widget
   ========================================================================== */

#mjb-cat-filter,
.mjb-cat-filter {
    font-size: 0.9rem;
    color: inherit;
}

/* --------------------------------------------------------------------------
   Search box
   -------------------------------------------------------------------------- */
.mjb-cat-search-wrap {
    position: relative;
    margin-bottom: 14px;
}

.mjb-cat-search {
    width: 100%;
    padding: 8px 34px 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.85rem;
    outline: none;
    background: #fff;
    color: #333;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.mjb-cat-search:focus {
    border-color: #a0a0a0;
    box-shadow: 0 0 0 2px rgba(0,0,0,.06);
}

.mjb-cat-search-icon {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    pointer-events: none;
    display: flex;
    align-items: center;
}

/* --------------------------------------------------------------------------
   Category list
   -------------------------------------------------------------------------- */
.mjb-cat-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.mjb-cat-list--children {
    margin: 4px 0 6px 14px;
    border-left: 2px solid #eee;
    padding-left: 10px;
}

/* --------------------------------------------------------------------------
   Category item
   -------------------------------------------------------------------------- */
.mjb-cat-item {
    margin: 0;
    padding: 0;
}

.mjb-cat-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.mjb-cat-label {
    flex: 1;
    display: block;
    padding: 7px 4px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.15s, color 0.15s;
    line-height: 1.3;
    user-select: none;
}

.mjb-cat-label:hover {
    background: #f5f5f5;
    color: #000;
}

/* Active state */
.mjb-cat-item--active > .mjb-cat-label,
.mjb-cat-item--active > .mjb-cat-row > .mjb-cat-label {
    font-weight: 600;
    color: #000;
}

/* --------------------------------------------------------------------------
   Accordion toggle button
   -------------------------------------------------------------------------- */
.mjb-cat-toggle {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #888;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s, transform 0.2s;
}

.mjb-cat-toggle:hover {
    background: #f0f0f0;
    color: #333;
}

.mjb-cat-toggle--open {
    transform: rotate(180deg);
}

/* --------------------------------------------------------------------------
   Children list slide animation
   -------------------------------------------------------------------------- */
.mjb-cat-list--children {
    overflow: hidden;
    transition: max-height 0.25s ease;
}

/* --------------------------------------------------------------------------
   "All Products" special item
   -------------------------------------------------------------------------- */
.mjb-cat-all .mjb-cat-label {
    font-weight: 500;
}

/* --------------------------------------------------------------------------
   No products message
   -------------------------------------------------------------------------- */
.mjb-no-products {
    padding: 20px 0;
    text-align: center;
    color: #888;
    font-size: 0.9rem;
}

/* --------------------------------------------------------------------------
   Loading overlay on product grid
   -------------------------------------------------------------------------- */
.mjb-products-loading {
    opacity: 0.4;
    pointer-events: none;
    transition: opacity 0.2s;
}

/* --------------------------------------------------------------------------
   Hidden utility (search filtering)
   -------------------------------------------------------------------------- */
.mjb-cat-item--hidden {
    display: none;
}

/* ==========================================================================
   MOBILE — Collapsible drawer
   ========================================================================== */
@media (max-width: 768px) {

    /* Floating "Filters" trigger button injected by JS above product grid */
    .mjb-mobile-trigger-wrap {
        display: flex;
        align-items: center;
        margin-bottom: 16px;
    }

    .mjb-mobile-trigger {
        display: inline-flex;
        align-items: center;
        gap: 7px;
        padding: 9px 18px;
        background: #fff;
        border: 1.5px solid #333;
        border-radius: 6px;
        font-size: 0.875rem;
        font-weight: 600;
        cursor: pointer;
        color: #333;
        transition: background 0.15s, color 0.15s;
        line-height: 1;
    }

    .mjb-mobile-trigger:hover,
    .mjb-mobile-trigger--open {
        background: #333;
        color: #fff;
    }

    .mjb-mobile-trigger svg {
        flex-shrink: 0;
    }

    /* Active category label badge next to button */
    .mjb-mobile-active-label {
        margin-left: 10px;
        font-size: 0.8rem;
        color: #666;
        font-style: italic;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 160px;
    }

    /* Drawer panel — slides down from above products */
    .mjb-mobile-drawer {
        display: none;
        background: #fff;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        padding: 16px;
        margin-bottom: 20px;
        box-shadow: 0 4px 16px rgba(0,0,0,0.08);
    }

    .mjb-mobile-drawer--open {
        display: block;
        animation: mjbSlideDown 0.22s ease;
    }

    @keyframes mjbSlideDown {
        from { opacity: 0; transform: translateY(-8px); }
        to   { opacity: 1; transform: translateY(0); }
    }

    /* Drawer close row */
    .mjb-drawer-close-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 14px;
        padding-bottom: 10px;
        border-bottom: 1px solid #eee;
    }

    .mjb-drawer-title {
        font-weight: 700;
        font-size: 0.95rem;
        color: #111;
    }

    .mjb-drawer-close {
        background: none;
        border: none;
        cursor: pointer;
        color: #666;
        padding: 4px;
        line-height: 1;
        border-radius: 4px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: background 0.15s;
    }

    .mjb-drawer-close:hover {
        background: #f0f0f0;
        color: #000;
    }

    /* Hide the original sidebar widget on mobile — drawer takes over */
    .widget_mjb_category_filter {
        display: none !important;
    }
}
