/* =============================================
   ALX Product Filters — Frontend Styles
   All visual properties use CSS custom properties
   for total admin-panel customization control
   ============================================= */

/* === WRAPPER === */
.alx-pf-wrapper {
    --alx-wrapper-bg: #ffffff;
    --alx-wrapper-padding: 20px;
    --alx-wrapper-border-color: #e5e7eb;
    --alx-wrapper-border-width: 1px;
    --alx-wrapper-border-radius: 8px;
    --alx-wrapper-shadow: 0 1px 3px rgba(0,0,0,0.1);
    --alx-wrapper-gap: 20px;
    --alx-btn-bg: #2563eb;
    --alx-btn-color: #ffffff;
    --alx-btn-radius: 6px;
    --alx-btn-font-size: 14px;
    --alx-btn-padding: 10px 20px;
    --alx-btn-hover-bg: #1d4ed8;
    --alx-reset-bg: transparent;
    --alx-reset-color: #ef4444;
    --alx-reset-border: 1px solid #ef4444;
    --alx-reset-hover-bg: #fef2f2;

    background: var(--alx-wrapper-bg);
    padding: var(--alx-wrapper-padding);
    border: var(--alx-wrapper-border-width) solid var(--alx-wrapper-border-color);
    border-radius: var(--alx-wrapper-border-radius);
    box-shadow: var(--alx-wrapper-shadow);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    box-sizing: border-box;
}
.alx-pf-wrapper *, .alx-pf-wrapper *::before, .alx-pf-wrapper *::after { box-sizing: border-box; }

/* === LAYOUTS === */
.alx-pf-facets-container { display: flex; flex-direction: column; gap: var(--alx-wrapper-gap); }
.alx-pf-layout-horizontal {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
}
.alx-pf-layout-horizontal .alx-pf-facet {
    flex: 1 1 calc(100% / var(--alx-columns, 3) - var(--alx-wrapper-gap));
    min-width: 180px;
}

/* === FACET === */
.alx-pf-facet {
    --alx-heading-ff: inherit;
    --alx-heading-fs: 15px;
    --alx-heading-fw: 600;
    --alx-heading-color: #333333;
    --alx-heading-margin: 0 0 12px 0;
    --alx-item-ff: inherit;
    --alx-item-fs: 14px;
    --alx-item-fw: 400;
    --alx-item-color: #555555;
    --alx-item-color-active: #ffffff;
    --alx-item-bg: transparent;
    --alx-item-bg-active: #2563eb;
    --alx-item-border-color: #d1d5db;
    --alx-item-border-active: #2563eb;
    --alx-item-border-width: 1px;
    --alx-item-border-radius: 4px;
    --alx-item-padding: 6px 10px;
    --alx-item-margin: 0 0 6px 0;
    --alx-item-gap: 8px;
    --alx-count-color: #999999;
    --alx-count-fs: 12px;
    --alx-slider-track: #e5e7eb;
    --alx-slider-range: #2563eb;
    --alx-slider-handle: #ffffff;
    --alx-slider-handle-border: #2563eb;
    --alx-slider-handle-size: 20px;
    --alx-slider-track-h: 6px;
    --alx-swatch-size: 32px;
    --alx-swatch-radius: 50%;
    --alx-swatch-bw: 2px;
    --alx-swatch-bc: #d1d5db;
    --alx-swatch-ba: #333333;
    --alx-star-size: 20px;
    --alx-star-color: #fbbf24;
    --alx-star-empty: #d1d5db;
    --alx-search-h: 40px;
    --alx-search-radius: 6px;
    --alx-width: 100%;

    width: var(--alx-width);
}

/* === HEADING (collapsible) === */
.alx-pf-facet-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: var(--alx-heading-margin);
}
.alx-pf-facet-label {
    font-family: var(--alx-heading-ff);
    font-size: var(--alx-heading-fs);
    font-weight: var(--alx-heading-fw);
    color: var(--alx-heading-color);
    line-height: 1.3;
}
.alx-pf-collapsible { cursor: pointer; user-select: none; }
.alx-pf-collapse-icon {
    width: 20px;
    height: 20px;
    position: relative;
    transition: transform 0.2s;
}
.alx-pf-collapse-icon::before, .alx-pf-collapse-icon::after {
    content: '';
    position: absolute;
    background: var(--alx-heading-color);
    border-radius: 1px;
}
.alx-pf-collapse-icon::before { top: 50%; left: 3px; right: 3px; height: 2px; transform: translateY(-50%); }
.alx-pf-collapse-icon::after { left: 50%; top: 3px; bottom: 3px; width: 2px; transform: translateX(-50%); transition: transform 0.2s; }
.alx-pf-collapsed .alx-pf-collapse-icon::after { transform: translateX(-50%) scaleY(0); }

/* Facet content scroll */
.alx-pf-facet-content {
    max-height: var(--alx-max-height, none);
    overflow-y: auto;
}
.alx-pf-facet-content::-webkit-scrollbar { width: 5px; }
.alx-pf-facet-content::-webkit-scrollbar-track { background: #f1f5f9; border-radius: 3px; }
.alx-pf-facet-content::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* Direction */
.alx-pf-dir-horizontal { display: flex; flex-wrap: wrap; gap: var(--alx-item-gap); }
.alx-pf-dir-horizontal .alx-pf-list { display: flex; flex-wrap: wrap; gap: var(--alx-item-gap); }

/* === CHECKBOX === */
.alx-pf-checkbox-list, .alx-pf-radio-list { list-style: none; margin: 0; padding: 0; }
.alx-pf-checkbox-list .alx-pf-item, .alx-pf-radio-list .alx-pf-item { margin: var(--alx-item-margin); }

.alx-pf-checkbox-label, .alx-pf-radio-label {
    display: flex;
    align-items: center;
    gap: var(--alx-item-gap);
    cursor: pointer;
    font-family: var(--alx-item-ff);
    font-size: var(--alx-item-fs);
    font-weight: var(--alx-item-fw);
    color: var(--alx-item-color);
    padding: var(--alx-item-padding);
    border-radius: var(--alx-item-border-radius);
    transition: background 0.15s, color 0.15s;
}
.alx-pf-checkbox-label:hover, .alx-pf-radio-label:hover { background: rgba(0,0,0,0.02); }

.alx-pf-checkbox-label input, .alx-pf-radio-label input { display: none; }

/* Checkmark */
.alx-pf-checkmark {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: var(--alx-item-border-width) solid var(--alx-item-border-color);
    border-radius: 3px;
    position: relative;
    transition: all 0.15s;
    background: var(--alx-item-bg);
}
.alx-pf-checkbox-label input:checked ~ .alx-pf-checkmark {
    background: var(--alx-item-bg-active);
    border-color: var(--alx-item-border-active);
}
.alx-pf-checkmark::after {
    content: '';
    position: absolute;
    display: none;
    left: 5px;
    top: 1px;
    width: 6px;
    height: 11px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.alx-pf-checkbox-label input:checked ~ .alx-pf-checkmark::after { display: block; }

/* Radio Mark */
.alx-pf-radio-mark {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: var(--alx-item-border-width) solid var(--alx-item-border-color);
    border-radius: 50%;
    position: relative;
    transition: all 0.15s;
    background: var(--alx-item-bg);
}
.alx-pf-radio-label input:checked ~ .alx-pf-radio-mark {
    border-color: var(--alx-item-border-active);
}
.alx-pf-radio-mark::after {
    content: '';
    position: absolute;
    display: none;
    top: 50%;
    left: 50%;
    width: 10px;
    height: 10px;
    background: var(--alx-item-bg-active);
    border-radius: 50%;
    transform: translate(-50%,-50%);
}
.alx-pf-radio-label input:checked ~ .alx-pf-radio-mark::after { display: block; }

.alx-pf-text { flex: 1; }
.alx-pf-count { font-size: var(--alx-count-fs); color: var(--alx-count-color); }
.alx-pf-sublist { list-style: none; margin: 0; padding: 0 0 0 24px; }

/* Item hidden by count=0 */
.alx-pf-item.alx-pf-disabled { opacity: 0.4; pointer-events: none; }

/* === SELECT / DROPDOWN === */
.alx-pf-select {
    width: 100%;
    padding: 8px 32px 8px 12px;
    border: var(--alx-item-border-width) solid var(--alx-item-border-color);
    border-radius: var(--alx-item-border-radius);
    font-family: var(--alx-item-ff);
    font-size: var(--alx-item-fs);
    color: var(--alx-item-color);
    background: var(--alx-item-bg);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23666' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    cursor: pointer;
    transition: border-color 0.15s;
}
.alx-pf-select:focus { border-color: var(--alx-item-border-active); outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }

/* === RANGE SLIDER === */
.alx-pf-range-slider { padding: 4px 0; }
.alx-pf-range-values {
    display: flex;
    justify-content: space-between;
    font-size: var(--alx-item-fs);
    color: var(--alx-item-color);
    font-weight: 600;
    margin-bottom: 12px;
}
.alx-pf-range-sep { color: var(--alx-count-color); }

.alx-pf-range-track {
    position: relative;
    height: var(--alx-slider-track-h);
    background: var(--alx-slider-track);
    border-radius: calc(var(--alx-slider-track-h) / 2);
    margin: calc(var(--alx-slider-handle-size) / 2) 0;
}
.alx-pf-range-fill {
    position: absolute;
    height: 100%;
    background: var(--alx-slider-range);
    border-radius: inherit;
    left: 0;
    right: 0;
}

.alx-pf-range-input {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    height: var(--alx-slider-handle-size);
    -webkit-appearance: none;
    appearance: none;
    background: none;
    pointer-events: none;
    margin: 0;
    padding: 0;
}
.alx-pf-range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: var(--alx-slider-handle-size);
    height: var(--alx-slider-handle-size);
    border-radius: 50%;
    background: var(--alx-slider-handle);
    border: 2px solid var(--alx-slider-handle-border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    cursor: pointer;
    pointer-events: all;
    transition: transform 0.1s;
}
.alx-pf-range-input::-webkit-slider-thumb:hover { transform: scale(1.15); }
.alx-pf-range-input::-moz-range-thumb {
    width: var(--alx-slider-handle-size);
    height: var(--alx-slider-handle-size);
    border-radius: 50%;
    background: var(--alx-slider-handle);
    border: 2px solid var(--alx-slider-handle-border);
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
    cursor: pointer;
    pointer-events: all;
}
.alx-pf-range-input::-moz-range-track { background: transparent; border: 0; }

.alx-pf-range-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}
.alx-pf-range-inputs input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--alx-item-border-color);
    border-radius: var(--alx-item-border-radius);
    font-size: 13px;
    text-align: center;
}
.alx-pf-range-input-sep { color: var(--alx-count-color); font-weight: 600; }

/* === COLOR SWATCHES === */
.alx-pf-swatches { display: flex; flex-wrap: wrap; gap: var(--alx-item-gap); }
.alx-pf-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    border: none;
    background: none;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--alx-item-border-radius);
    transition: all 0.15s;
}
.alx-pf-swatch:hover { background: rgba(0,0,0,0.04); }
.alx-pf-swatch.active { outline: 2px solid var(--alx-swatch-ba); outline-offset: 2px; }

.alx-pf-swatch-color {
    width: var(--alx-swatch-size);
    height: var(--alx-swatch-size);
    border-radius: var(--alx-swatch-radius);
    background: var(--swatch-color, #ccc);
    border: var(--alx-swatch-bw) solid var(--alx-swatch-bc);
    transition: border-color 0.15s, transform 0.15s;
}
.alx-pf-swatch.active .alx-pf-swatch-color { border-color: var(--alx-swatch-ba); transform: scale(1.1); }
.alx-pf-swatch-label { font-size: 11px; color: var(--alx-item-color); }

/* === RATING === */
.alx-pf-rating-list { display: flex; flex-direction: column; gap: 6px; }
.alx-pf-rating-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--alx-item-border-radius);
    transition: background 0.15s;
}
.alx-pf-rating-item:hover { background: rgba(0,0,0,0.02); }
.alx-pf-rating-item input { display: none; }
.alx-pf-rating-item.active { background: var(--alx-item-bg-active); }
.alx-pf-rating-item.active .alx-pf-rating-text { color: var(--alx-item-color-active); }

.alx-pf-stars { display: flex; gap: 1px; }
.alx-pf-star { font-size: var(--alx-star-size); line-height: 1; }
.alx-pf-star.filled { color: var(--alx-star-color); }
.alx-pf-star.empty { color: var(--alx-star-empty); }
.alx-pf-rating-text { font-size: var(--alx-item-fs); color: var(--alx-item-color); }

/* === SEARCH === */
.alx-pf-search-box { position: relative; }
.alx-pf-search-input {
    width: 100%;
    height: var(--alx-search-h);
    padding: 0 40px 0 14px;
    border: var(--alx-item-border-width) solid var(--alx-item-border-color);
    border-radius: var(--alx-search-radius);
    font-size: var(--alx-item-fs);
    font-family: var(--alx-item-ff);
    color: var(--alx-item-color);
    transition: border-color 0.15s;
}
.alx-pf-search-input:focus { border-color: var(--alx-item-border-active); outline: none; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
.alx-pf-search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--alx-count-color);
}

/* Facet-level search */
.alx-pf-facet-search { margin-bottom: 10px; }
.alx-pf-facet-search-input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--alx-item-border-color);
    border-radius: var(--alx-item-border-radius);
    font-size: 13px;
}

/* === TOGGLE === */
.alx-pf-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: var(--alx-item-padding);
}
.alx-pf-toggle-input { display: none; }
.alx-pf-toggle-slider {
    width: 44px;
    height: 24px;
    min-width: 44px;
    background: #d1d5db;
    border-radius: 12px;
    position: relative;
    transition: background 0.2s;
}
.alx-pf-toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.alx-pf-toggle-input:checked ~ .alx-pf-toggle-slider { background: var(--alx-item-bg-active); }
.alx-pf-toggle-input:checked ~ .alx-pf-toggle-slider::after { transform: translateX(20px); }
.alx-pf-toggle-text { font-size: var(--alx-item-fs); color: var(--alx-item-color); }

/* === LABEL CLOUD === */
.alx-pf-label-cloud { display: flex; flex-wrap: wrap; gap: var(--alx-item-gap); }
.alx-pf-label-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: var(--alx-item-padding);
    border: var(--alx-item-border-width) solid var(--alx-item-border-color);
    border-radius: var(--alx-item-border-radius);
    background: var(--alx-item-bg);
    color: var(--alx-item-color);
    font-size: var(--alx-item-fs);
    font-family: var(--alx-item-ff);
    cursor: pointer;
    transition: all 0.15s;
}
.alx-pf-label-tag:hover { border-color: var(--alx-item-border-active); }
.alx-pf-label-tag.active {
    background: var(--alx-item-bg-active);
    border-color: var(--alx-item-border-active);
    color: var(--alx-item-color-active);
}
.alx-pf-label-tag .alx-pf-count {
    font-size: 11px;
    background: rgba(0,0,0,0.08);
    padding: 1px 6px;
    border-radius: 8px;
}
.alx-pf-label-tag.active .alx-pf-count { background: rgba(255,255,255,0.2); color: inherit; }

/* === IMAGE GRID === */
.alx-pf-image-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: var(--alx-item-gap); }
.alx-pf-image-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px;
    border: var(--alx-item-border-width) solid var(--alx-item-border-color);
    border-radius: var(--alx-item-border-radius);
    background: var(--alx-item-bg);
    cursor: pointer;
    transition: all 0.15s;
}
.alx-pf-image-item:hover { border-color: var(--alx-item-border-active); }
.alx-pf-image-item.active { border-color: var(--alx-item-border-active); background: var(--alx-item-bg-active); }
.alx-pf-image-item.active .alx-pf-image-label { color: var(--alx-item-color-active); }
.alx-pf-image-item img { width: 100%; height: auto; border-radius: calc(var(--alx-item-border-radius) - 2px); }
.alx-pf-image-label { font-size: 11px; color: var(--alx-item-color); text-align: center; }

/* === NUMBER INPUT === */
.alx-pf-number-input-group { display: flex; align-items: flex-end; gap: 8px; }
.alx-pf-number-field { flex: 1; }
.alx-pf-number-field label { display: block; font-size: 12px; color: var(--alx-count-color); margin-bottom: 4px; }
.alx-pf-number-field input {
    width: 100%;
    padding: 8px 10px;
    border: var(--alx-item-border-width) solid var(--alx-item-border-color);
    border-radius: var(--alx-item-border-radius);
    font-size: var(--alx-item-fs);
    text-align: center;
}
.alx-pf-number-sep { color: var(--alx-count-color); font-weight: 600; margin-bottom: 8px; }

/* === SORT SELECT === */
.alx-pf-sort-select { width: 100%; }

/* === ACTION BUTTONS === */
.alx-pf-actions {
    display: flex;
    gap: 10px;
    margin-top: var(--alx-wrapper-gap);
    padding-top: var(--alx-wrapper-gap);
    border-top: 1px solid var(--alx-wrapper-border-color);
}
.alx-pf-apply-btn {
    padding: var(--alx-btn-padding);
    background: var(--alx-btn-bg);
    color: var(--alx-btn-color);
    border: none;
    border-radius: var(--alx-btn-radius);
    font-size: var(--alx-btn-font-size);
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
    flex: 1;
}
.alx-pf-apply-btn:hover { background: var(--alx-btn-hover-bg); }

.alx-pf-reset-btn {
    padding: var(--alx-btn-padding);
    background: var(--alx-reset-bg);
    color: var(--alx-reset-color);
    border: var(--alx-reset-border);
    border-radius: var(--alx-btn-radius);
    font-size: var(--alx-btn-font-size);
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.alx-pf-reset-btn:hover { background: var(--alx-reset-hover-bg); }

/* === ACTIVE FILTERS TAGS === */
.alx-pf-active-filters { margin-top: 12px; }
.alx-pf-active-filters:empty, .alx-pf-active-tags:empty { display: none !important; }
.alx-pf-active-filters, .alx-pf-active-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.alx-pf-active-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: #eff6ff;
    color: #2563eb;
    font-size: 13px;
    border-radius: 16px;
    cursor: default;
}
.alx-pf-active-tag-remove {
    cursor: pointer;
    font-weight: 700;
    line-height: 1;
    padding: 0 2px;
    border-radius: 50%;
    transition: background 0.15s;
}
.alx-pf-active-tag-remove:hover { background: rgba(37,99,235,0.15); }

/* === LOADER === */
.alx-pf-loading-overlay {
    position: relative;
}
.alx-pf-loading-overlay::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,0.7);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}
.alx-pf-loading-overlay .alx-pf-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
    z-index: 11;
    width: 36px;
    height: 36px;
    border: 3px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: alxSpin 0.6s linear infinite;
}
@keyframes alxSpin { to { transform: translate(-50%,-50%) rotate(360deg); } }

.alx-pf-loading-opacity { opacity: 0.4; transition: opacity 0.2s; pointer-events: none; }

/* === NO RESULTS === */
.alx-pf-no-results { text-align: center; padding: 40px 20px; }

/* === ANIMATIONS === */
.alx-pf-fade-in { animation: alxFadeIn 0.3s ease; }
@keyframes alxFadeIn { from { opacity: 0; } to { opacity: 1; } }

.alx-pf-slide-in { animation: alxSlideIn 0.3s ease; }
@keyframes alxSlideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .alx-pf-layout-horizontal { flex-direction: column; }
    .alx-pf-layout-horizontal .alx-pf-facet { flex: 1 1 100%; }
    .alx-pf-range-inputs { flex-direction: row; }
}

/* === EMPTY === */
.alx-pf-empty { color: var(--alx-count-color); font-size: 13px; font-style: italic; }

/* === ADMIN NOTICE (frontend) === */
.alx-pf-admin-notice {
    padding: 12px 16px;
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    border-radius: 4px;
    font-size: 14px;
}
.alx-pf-admin-notice a { color: #2563eb; font-weight: 600; }
