/* ==========================================================================
   Mac-Tech Brand Filter  –  styles matching WPCode snippet 29215
   ========================================================================== */

/* ---------- Hidden until JS positions it ---------- */
#mtbf-brand-filter {
    display: none;          /* hidden until JS positions it */
}

#mtbf-brand-filter.mtbf-visible {
    display: block;         /* revealed by JS after positioning */
}

/* ---------- Flex row wrapping both dropdowns ---------- */
.mtbf-filters-row {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    gap: 12px;
    max-width: 1100px;
    margin: 0 auto 2em;
    padding: 0 20px;
    flex-wrap: wrap;
    position: relative;     /* positioning context for both dropdown panels */
}

/* Both wrappers must be static so dropdowns position against .mtbf-filters-row */
.mtbf-filters-row .all-pro-cat-wrapper {
    margin: 0 !important;
    padding: 0 !important;
    position: static !important;
}

.mtbf-filters-row #mtbf-brand-filter {
    position: static !important;
}

/* Category dropdown panel – position relative to the flex row */
body .mtbf-filters-row ul.all-pro-cat {
    width: calc(100% - 40px);
    left: 50%;
    transform: translateX(-50%);
}

/* ---------- Trigger button (matches .all-pro-cat-trigger exactly) ---------- */
.mtbf-brand-trigger {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 24px;
    background: #336b35;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
    font-family: inherit;
    line-height: 1.4;
    white-space: nowrap;
}

.mtbf-brand-trigger:hover {
    background: #2a5a2c;
}

/* Chevron arrow */
.mtbf-chevron {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(45deg);
    transition: transform 0.25s ease;
    margin-top: -3px;
}

.mtbf-brand-trigger.open .mtbf-chevron {
    transform: rotate(-135deg);
    margin-top: 3px;
}

/* ---------- Dropdown list (matches body ul.all-pro-cat exactly) ---------- */
body ul.mtbf-brand-list {
    display: none;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px 16px;
    max-width: 1100px;
    margin: 12px auto 0;
    padding: 24px;
    list-style: none;
    text-align: center;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    z-index: 999;
    width: calc(100% - 40px);
    box-sizing: border-box;
}

body ul.mtbf-brand-list.open {
    display: grid;
}

body ul.mtbf-brand-list li {
    list-style-type: none;
    text-align: center;
}

body ul.mtbf-brand-list li a {
    display: block;
    padding: 10px 18px;
    background: #f0f0f0;
    border-radius: 8px;
    color: #333 !important;
    text-decoration: none !important;
    font-size: 15px;
    font-weight: 500;
    line-height: 1.4;
    transition: background 0.2s ease, color 0.2s ease;
    white-space: normal;
}

body ul.mtbf-brand-list li a:hover {
    background: #e2e2e2;
    color: #111 !important;
}

body ul.mtbf-brand-list li.active a {
    background: #336b35;
    color: #fff !important;
    font-weight: 600;
}

body ul.mtbf-brand-list li.active a:hover {
    background: #2a5a2c;
    color: #fff !important;
}

/* ---------- Overlay (click-outside-to-close) ---------- */
.mtbf-brand-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 998;
}

.mtbf-brand-overlay.open {
    display: block;
}

/* ---------- AJAX loading overlay ---------- */
.mtbf-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.mtbf-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e0e0e0;
    border-top-color: #336b35;
    border-radius: 50%;
    animation: mtbf-spin 0.7s linear infinite;
}

@keyframes mtbf-spin {
    to { transform: rotate(360deg); }
}

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
    body ul.mtbf-brand-list {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 768px) {
    .mtbf-filters-row {
        flex-direction: column;
        align-items: center;
        gap: 8px;
    }

    body ul.mtbf-brand-list {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px 12px;
        padding: 16px;
    }

    body ul.mtbf-brand-list li a {
        padding: 8px 14px;
        font-size: 14px;
    }

    body .mtbf-filters-row ul.all-pro-cat {
        width: calc(100vw - 40px);
        max-width: 1100px;
    }
}

@media (max-width: 480px) {
    body ul.mtbf-brand-list {
        grid-template-columns: 1fr;
        width: calc(100vw - 40px);
    }

    .mtbf-brand-trigger {
        font-size: 15px;
        padding: 10px 20px;
    }
}
