/* =========================================================
   Mobile Brand Filter — Frontend Styles
   ========================================================= */

/* ── Bar ── */
.mbf-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.mbf-open-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 22px;
    border: none;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease;
    box-shadow: 0 4px 14px rgba(0,0,0,.18);
    letter-spacing: .3px;
}
.mbf-open-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(0,0,0,.22);
}
.mbf-open-btn:active { transform: translateY(0); }
.mbf-open-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* ── Active filter pill ── */
.mbf-active-filter {
    display: flex;
    align-items: center;
    gap: 10px;
    animation: mbf-fade-in .2s ease;
}
.mbf-filter-pill {
    background: #f0f4ff;
    color: #2a3990;
    border: 1.5px solid #c5cff7;
    border-radius: 50px;
    padding: 6px 16px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .2px;
}
.mbf-clear-btn {
    background: none;
    border: 1.5px solid #ccc;
    border-radius: 50px;
    padding: 5px 14px;
    font-size: 13px;
    cursor: pointer;
    color: #555;
    transition: all .15s;
    font-weight: 500;
}
.mbf-clear-btn:hover { border-color:#e63946; color:#e63946; background:#fff5f5; }

/* ── Overlay ── */
.mbf-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 99998;
    backdrop-filter: blur(3px);
    animation: mbf-fade-in .2s ease;
}
.mbf-overlay.active { display: block; }

/* ── Popup ── */
.mbf-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(.95);
    width: min(92vw, 560px);
    max-height: 80vh;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 24px 80px rgba(0,0,0,.22);
    z-index: 99999;
    flex-direction: column;
    overflow: hidden;
    transition: transform .22s cubic-bezier(.34,1.56,.64,1), opacity .2s ease;
    opacity: 0;
}
.mbf-popup.active {
    display: flex;
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

/* ── Popup Header ── */
.mbf-popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px 16px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}
.mbf-popup-title {
    flex: 1;
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #111;
}
.mbf-back-btn,
.mbf-close-btn {
    background: #f5f5f5;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s;
    flex-shrink: 0;
}
.mbf-back-btn { border-radius: 50px; width: auto; padding: 0 12px; gap: 4px; font-size: 13px; font-weight: 600; color: #444; }
.mbf-back-btn svg { width: 16px; height: 16px; }
.mbf-back-btn:hover,
.mbf-close-btn:hover { background: #eaeaea; }
.mbf-close-btn svg { width: 18px; height: 18px; }

/* ── Search ── */
.mbf-search-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}
.mbf-search-wrap svg { width: 16px; height: 16px; color: #999; flex-shrink: 0; }
#mbf-search-input {
    border: none;
    outline: none;
    font-size: 14px;
    width: 100%;
    color: #222;
    background: transparent;
}
#mbf-search-input::placeholder { color: #aaa; }

/* ── Popup Body ── */
.mbf-popup-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px 20px;
    overscroll-behavior: contain;
}

/* ── Brands Grid ── */
.mbf-brands-grid {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.mbf-brand-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    background: #fafafa;
    border: 1.5px solid #efefef;
    border-radius: 14px;
    padding: 12px 14px;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .12s;
    text-align: left;
}
.mbf-brand-btn:hover {
    background: #f0f4ff;
    border-color: #c0cbf5;
    transform: translateX(3px);
}
.mbf-brand-logo {
    width: 52px;
    height: 52px;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #e8e8e8;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}
.mbf-brand-logo img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 6px;
}
.mbf-brand-initial {
    font-size: 22px;
    font-weight: 800;
    color: #888;
}
.mbf-brand-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.mbf-brand-name {
    font-size: 15px;
    font-weight: 700;
    color: #111;
    display: block;
}
.mbf-brand-count {
    font-size: 12px;
    color: #888;
    display: block;
}
.mbf-arrow {
    width: 18px;
    height: 18px;
    color: #ccc;
    flex-shrink: 0;
    transition: color .15s;
}
.mbf-brand-btn:hover .mbf-arrow { color: #5c6bc0; }

/* ── Models Grid ── */
.mbf-models-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}
.mbf-model-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: #fafafa;
    border: 1.5px solid #efefef;
    border-radius: 14px;
    padding: 16px 10px 12px;
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .12s, box-shadow .15s;
    text-align: center;
}
.mbf-model-btn:hover {
    background: #f0f4ff;
    border-color: #5c6bc0;
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(92,107,192,.15);
}
.mbf-model-img-wrap {
    width: 72px;
    height: 72px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid #e8e8e8;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}
.mbf-model-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 6px;
}
.mbf-model-placeholder {
    font-size: 28px;
    color: #ccc;
}
.mbf-model-name {
    font-size: 12px;
    font-weight: 600;
    color: #222;
    line-height: 1.3;
}

/* ── Loading spinner ── */
.mbf-spinner {
    display: flex;
    justify-content: center;
    padding: 40px;
}
.mbf-spinner::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid #eee;
    border-top-color: #5c6bc0;
    border-radius: 50%;
    animation: mbf-spin .7s linear infinite;
}

/* ── Empty / error ── */
.mbf-empty {
    text-align: center;
    color: #888;
    padding: 32px 16px;
    font-size: 14px;
}
.mbf-empty a { color: #5c6bc0; }

/* ── No results (below product list) ── */
.mbf-no-results {
    width: 100%;
    padding: 48px 16px;
}
.mbf-no-results-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    text-align: center;
    color: #888;
}
.mbf-no-results-inner svg {
    width: 48px;
    height: 48px;
    color: #ccc;
}
.mbf-no-results-inner p { margin: 0; font-size: 15px; }

/* ── Product list filter state ── */
.mbf-product-hidden { display: none !important; }
.mbf-filtering .products { transition: opacity .2s; }

/* ── Animations ── */
@keyframes mbf-fade-in { from { opacity: 0 } to { opacity: 1 } }
@keyframes mbf-spin { to { transform: rotate(360deg) } }

/* ── Scrollbar ── */
.mbf-popup-body::-webkit-scrollbar { width: 5px; }
.mbf-popup-body::-webkit-scrollbar-track { background: transparent; }
.mbf-popup-body::-webkit-scrollbar-thumb { background: #ddd; border-radius: 10px; }

/* ── Mobile ── */
@media (max-width: 480px) {
    .mbf-popup {
        width: 100vw;
        max-height: 90vh;
        border-radius: 20px 20px 0 0;
        top: auto;
        bottom: 0;
        left: 0;
        transform: translateY(20px);
    }
    .mbf-popup.active {
        transform: translateY(0);
    }
    .mbf-models-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
}

/* ==============================================
   ALL FILTERS BUTTON
   ============================================== */
.mbf-panel-open-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 11px 20px;
    border: 1.5px solid #ddd;
    border-radius: 50px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    background: #fff;
    color: #111;
    transition: transform .15s, box-shadow .15s, border-color .15s;
    box-shadow: 0 4px 14px rgba(0,0,0,.08);
}
.mbf-panel-open-btn:hover {
    border-color: #aaa;
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(0,0,0,.12);
}
.mbf-panel-open-btn svg { width: 17px; height: 17px; flex-shrink: 0; }

/* ==============================================
   PANEL OVERLAY
   ============================================== */
.mbf-panel-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 999996;
    animation: mbf-fade-in .2s ease;
}
.mbf-panel-overlay.active { display: block; }

/* ==============================================
   FILTER PANEL (slide in from right)
   ============================================== */
.mbf-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(100vw, 420px);
    background: #fff;
    z-index: 999997;
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 40px rgba(0,0,0,.15);
    transform: translateX(100%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.mbf-panel.active { transform: translateX(0); }

/* Header */
.mbf-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 24px 20px;
    border-bottom: 1px solid #f0f0f0;
    flex-shrink: 0;
}
.mbf-panel-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #111;
}
.mbf-panel-close {
    background: #f5f5f5;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s;
    flex-shrink: 0;
}
.mbf-panel-close:hover { background: #eaeaea; }
.mbf-panel-close svg { width: 17px; height: 17px; }

/* Body */
.mbf-panel-body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.mbf-panel-body::-webkit-scrollbar { width: 4px; }
.mbf-panel-body::-webkit-scrollbar-thumb { background: #e0e0e0; border-radius: 4px; }

/* Section */
.mbf-panel-section {
    border-bottom: 1px solid #f0f0f0;
}
.mbf-panel-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    cursor: pointer;
    user-select: none;
}
.mbf-panel-section-label {
    font-size: 16px;
    font-weight: 600;
    color: #111;
}
.mbf-panel-chevron {
    width: 20px;
    height: 20px;
    color: #999;
    transition: transform .2s;
    flex-shrink: 0;
}
.mbf-panel-section.open .mbf-panel-chevron { transform: rotate(180deg); }
.mbf-panel-section-content {
    display: none;
    padding: 0 24px 20px;
}
.mbf-panel-section.open .mbf-panel-section-content { display: block; }

/* Category buttons */
.mbf-panel-cats {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.mbf-panel-cat-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 11px 14px;
    background: #fafafa;
    border: 1.5px solid #efefef;
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    transition: background .15s, border-color .15s;
    font-size: 14px;
    font-weight: 500;
    color: #222;
}
.mbf-panel-cat-btn:hover { background: #f0f8ff; border-color: #b3d4f5; }
.mbf-panel-cat-btn.active {
    background: #f0f8ff;
    border-color: #2196f3;
    color: #1565c0;
    font-weight: 700;
}
.mbf-panel-cat-check {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all .15s;
}
.mbf-panel-cat-btn.active .mbf-panel-cat-check {
    background: #2196f3;
    border-color: #2196f3;
}
.mbf-panel-cat-check svg { width: 10px; height: 10px; color: #fff; display: none; }
.mbf-panel-cat-btn.active .mbf-panel-cat-check svg { display: block; }

/* Footer */
.mbf-panel-footer {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #f0f0f0;
    flex-shrink: 0;
    background: #fff;
}
.mbf-panel-btn-clear {
    flex: 1;
    padding: 13px;
    border-radius: 50px;
    border: 1.5px solid #ddd;
    background: #fff;
    font-size: 15px;
    font-weight: 600;
    color: #555;
    cursor: pointer;
    transition: all .15s;
}
.mbf-panel-btn-clear:hover { border-color: #e63946; color: #e63946; }
.mbf-panel-btn-apply {
    flex: 2;
    padding: 13px;
    border-radius: 50px;
    border: none;
    background: #e63946;
    color: #fff;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background .15s;
    box-shadow: 0 4px 14px rgba(230,57,70,.3);
}
.mbf-panel-btn-apply:hover { background: #c0303c; }

/* Active category row (shown below buttons) */
.mbf-active-cats-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    flex-wrap: wrap;
}
.mbf-active-cats-label {
    font-size: 13px;
    font-weight: 700;
    color: #2a9d8f;
}
.mbf-cat-active-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #e6f7f5;
    color: #2a9d8f;
    border: 1.5px solid #2a9d8f;
    border-radius: 50px;
    padding: 5px 12px 5px 14px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s;
}
.mbf-cat-active-pill:hover { background: #d0f0ec; color: #2a9d8f; }
.mbf-cat-active-pill svg { width: 10px; height: 10px; flex-shrink: 0; }

/* Device pill (teal with phone icon) */
.mbf-device-pill { background:#e6f7f5; color:#2a9d8f; border-color:#2a9d8f; }
.mbf-device-pill:hover { background:#d0f0ec; color:#2a9d8f; }

/* Clear all pill (dark outline) */
.mbf-clear-all-pill {
    background:#fff;
    color:#333;
    border-color:#333;
}
.mbf-clear-all-pill:hover { background:#f5f5f5; color:#000; border-color:#000; }
