/* ── Almasabih Filter Popup — filter-popup.css ───────────────────────────── */

/* ── Filter Button ─────────────────────────────────────────────────────── */

.almasabih-filter-btn-wrap {
    display: block;
    margin-bottom: 12px;
}

#almasabih-filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 18px;
    background: transparent;
    border: 1px solid #E1E1E1;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
    color: inherit;
    cursor: pointer;
    line-height: 1.2;
    transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease;
    vertical-align: middle;
}

#almasabih-filter-btn svg {
    width: 13px;
    height: 13px;
    fill: currentColor;
    flex-shrink: 0;
    transition: fill 0.25s ease;
}

#almasabih-filter-btn:hover,
#almasabih-filter-btn:focus-visible {
    background: var(--theme-accent-color, #e63329);
    border-color: var(--theme-accent-color, #e63329);
    color: #fff;
    outline: none;
}

/* ── Overlay ────────────────────────────────────────────────────────────── */

#almasabih-filter-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.52);
    z-index: 100000;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}

#almasabih-filter-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity 0.3s ease, visibility 0s linear 0s;
}

/* ── Popup Panel ─────────────────────────────────────────────────────────── */

#almasabih-filter-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, calc(-50% + 16px));
    width: min(520px, 94vw);
    max-height: 90vh;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.18);
    z-index: 100001;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s linear 0.25s;
}

#almasabih-filter-popup.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translate(-50%, -50%);
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0s linear 0s;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

.almasabih-fp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid #efefef;
    flex-shrink: 0;
}

.almasabih-fp-header h3 {
    margin: 0;
    padding: 0;
    font-size: 18px;
    font-weight: 700;
    color: var(--theme-primary-color, #1a1a1a);
    line-height: 1.25;
    border: none;
}

#almasabih-fp-close {
    background: none;
    border: none;
    padding: 5px;
    cursor: pointer;
    color: #999;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s;
    line-height: 1;
    flex-shrink: 0;
}

#almasabih-fp-close:hover {
    color: var(--theme-accent-color, #e63329);
    background: #f5f5f5;
}

#almasabih-fp-close svg {
    width: 20px;
    height: 20px;
    fill: none;
}

/* ── Body (scrollable) ───────────────────────────────────────────────────── */

.almasabih-fp-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 4px 24px;
    scrollbar-width: thin;
    scrollbar-color: #d0d0d0 #f5f5f5;
}

.almasabih-fp-body::-webkit-scrollbar { width: 5px; }
.almasabih-fp-body::-webkit-scrollbar-track { background: #f5f5f5; }
.almasabih-fp-body::-webkit-scrollbar-thumb { background: #d0d0d0; border-radius: 3px; }

/* ── Sections ────────────────────────────────────────────────────────────── */

.almasabih-fp-section {
    padding: 18px 0;
    border-bottom: 1px solid #f2f2f2;
}

.almasabih-fp-section:last-child {
    border-bottom: none;
}

.almasabih-fp-section-title {
    margin: 0 0 12px;
    padding: 0;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #999;
    border: none;
}

/* ── Category Dropdowns ──────────────────────────────────────────────────── */

.almasabih-cat-wrap {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.almasabih-cat-select {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    color: #333;
    background: #fafafa;
    cursor: pointer;
    appearance: auto;
    transition: border-color 0.2s;
    font-family: inherit;
}

.almasabih-cat-select:focus {
    outline: none;
    border-color: var(--theme-accent-color, #e63329);
    background: #fff;
}

/* ── Price Range ─────────────────────────────────────────────────────────── */

.almasabih-price-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.almasabih-price-row label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    white-space: nowrap;
    flex-shrink: 0;
}

.almasabih-price-field {
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 0 10px;
    background: #fafafa;
    flex: 1;
    min-width: 110px;
    transition: border-color 0.2s;
}

.almasabih-price-field:focus-within {
    border-color: var(--theme-accent-color, #e63329);
    background: #fff;
}

.almasabih-currency {
    font-size: 11px;
    font-weight: 700;
    color: #aaa;
    white-space: nowrap;
    flex-shrink: 0;
}

.almasabih-price-field input[type="number"] {
    border: none;
    background: transparent;
    padding: 9px 0;
    font-size: 14px;
    width: 100%;
    min-width: 0;
    outline: none;
    font-family: inherit;
    color: #333;
    -moz-appearance: textfield;
}

.almasabih-price-field input[type="number"]::-webkit-inner-spin-button,
.almasabih-price-field input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
}

.almasabih-price-dash {
    color: #bbb;
    font-weight: 700;
    font-size: 16px;
    flex-shrink: 0;
}

/* ── Customer Rating ─────────────────────────────────────────────────────── */

.almasabih-rating-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.almasabih-rating-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 5px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease;
    border: 1px solid transparent;
}

.almasabih-rating-row:hover {
    background: #f7f7f7;
}

.almasabih-rating-row:focus-visible {
    outline: 2px solid var(--theme-accent-color, #e63329);
    outline-offset: 1px;
}

.almasabih-rating-row.selected {
    background: var(--theme-accent-color, #e63329);
    border-color: var(--theme-accent-color, #e63329);
}

.almasabih-stars {
    font-size: 18px;
    line-height: 1;
    letter-spacing: 1px;
}

.star-on  { color: #f5a623; }
.star-off { color: #ddd; }

.almasabih-rating-row.selected .star-on  { color: rgba(255,255,255,0.95); }
.almasabih-rating-row.selected .star-off { color: rgba(255,255,255,0.35); }

.almasabih-rating-label {
    font-size: 13px;
    color: #555;
    font-weight: 500;
}

.almasabih-rating-row.selected .almasabih-rating-label {
    color: #fff;
}

.almasabih-rating-count {
    margin-left: auto;
    font-size: 12px;
    color: #bbb;
}

.almasabih-rating-row.selected .almasabih-rating-count {
    color: rgba(255,255,255,0.7);
}

.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0,0,0,0);
    white-space: nowrap;
    border: 0;
}

/* ── Brand Grid ──────────────────────────────────────────────────────────── */

.almasabih-brand-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 10px;
}

.almasabih-brand-item {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 8px 6px;
    border: 2px solid #eee;
    border-radius: 6px;
    cursor: pointer;
    min-height: 64px;
    text-align: center;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.almasabih-brand-item:hover {
    border-color: var(--theme-accent-color, #e63329);
}

.almasabih-brand-item:focus-visible {
    outline: 2px solid var(--theme-accent-color, #e63329);
    outline-offset: 2px;
}

.almasabih-brand-item.selected {
    border-color: var(--theme-accent-color, #e63329);
    box-shadow: 0 0 0 3px rgba(230,51,41,0.12);
}

.almasabih-brand-item img {
    max-width: 100%;
    max-height: 48px;
    object-fit: contain;
    display: block;
}

.almasabih-brand-name {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    line-height: 1.3;
    word-break: break-word;
}

/* ── Footer ──────────────────────────────────────────────────────────────── */

.almasabih-fp-footer {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    border-top: 1px solid #efefef;
    flex-shrink: 0;
}

#almasabih-fp-apply {
    flex: 1;
    padding: 12px 20px;
    background: var(--theme-accent-color, #e63329);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: opacity 0.2s;
    line-height: 1.2;
}

#almasabih-fp-apply:hover {
    opacity: 0.87;
}

#almasabih-fp-reset {
    font-size: 14px;
    color: #999;
    text-decoration: underline;
    white-space: nowrap;
    transition: color 0.2s;
    flex-shrink: 0;
}

#almasabih-fp-reset:hover {
    color: var(--theme-accent-color, #e63329);
    text-decoration: underline;
}

/* ── Mobile: full-screen ─────────────────────────────────────────────────── */

@media (max-width: 540px) {
    #almasabih-filter-popup {
        width: 100%;
        max-height: 100%;
        height: 100%;
        top: 0 !important;
        left: 0 !important;
        border-radius: 0;
        transform: translateY(8px) !important;
    }

    #almasabih-filter-popup.active {
        transform: translateY(0) !important;
    }
}

/* ── Prevent body scroll when popup is open ──────────────────────────────── */

body.almasabih-fp-open {
    overflow: hidden;
}

/* ── Hide old sidebar filter, expand content area ───────────────────────── */

.post-type-archive-product #secondary.widget-area,
.tax-product_cat #secondary.widget-area {
    display: none !important;
}

.post-type-archive-product .page-wrap.sidebar-left #primary.content-area,
.post-type-archive-product .page-wrap.sidebar-right #primary.content-area,
.tax-product_cat .page-wrap.sidebar-left #primary.content-area,
.tax-product_cat .page-wrap.sidebar-right #primary.content-area {
    width: 100% !important;
    float: none !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}
