/* ═══════════════════════════════════════════════════════════
   Product catalog — filters & sort (desktop + mobile)
   ═══════════════════════════════════════════════════════════ */

/* ── Desktop filter sidebar ─────────────────────────────── */
.km-filter-sidebar {
    border-radius: 16px;
    padding-bottom: 8px;
}

.km-filter-sidebar .sidebar-header {
    padding: 16px 18px 12px;
    border-bottom: none;
}

.km-filter-sidebar .sidebar-header h3 {
    font-size: 16px;
    font-weight: 800;
}

.km-filter-sidebar .clear-filters {
    color: #ef4444;
    font-weight: 700;
}

.km-filter-sidebar .clear-filters:hover {
    color: #dc2626;
}

.km-filter-search-wrap {
    position: relative;
    margin: 0 16px 14px;
}

.km-filter-search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: #94a3b8;
    pointer-events: none;
}

.km-filter-search {
    width: 100%;
    padding: 11px 40px 11px 12px;
    border: none;
    border-radius: 12px;
    background: #f1f5f9;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}

.km-filter-search:focus {
    background: #e8edf3;
    box-shadow: 0 0 0 2px rgba(249, 115, 22, 0.25);
}

.km-filter-sidebar .filter-group {
    border-bottom: 1px solid var(--border, #e2e8f0);
}

.km-filter-sidebar .filter-title {
    width: 100%;
    border: none;
    background: transparent;
    font-family: inherit;
    text-align: right;
}

.km-filter-sidebar .filter-body {
    padding: 4px 16px 16px;
}

/* ── Price range ──────────────────────────────────────── */
.km-price-filter {
    padding: 4px 0 0;
}

.km-price-slider-labels {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 3px;
    direction: rtl;
}

.km-price-slider-ticks {
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin: 0 10px;
    min-height: 10px;
    padding: 0 4px;
}

.km-price-slider-ticks i {
    display: block;
    width: 1px;
    height: 8px;
    background: #cbd5e1;
    flex: 0 0 1px;
}

.price-slider-wrap {
    position: relative;
    height: 22px;
    margin: 0 4px 18px;
    direction: rtl;
}

.price-slider-bg,
.price-slider-fill,
.km-price-slider-fill {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 4px;
    border-radius: 4px;
    pointer-events: none;
}

.price-slider-bg {
    left: 0;
    right: 0;
    background: #e2e8f0;
}

.price-slider-fill,
.km-price-slider-fill {
    background: var(--primary, #f97316);
    left: 0%;
    right: 0%;
}

.price-range-input {
    position: absolute;
    width: 100%;
    height: 22px;
    top: 0;
    left: 0;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
    pointer-events: none;
    outline: none;
    margin: 0;
    padding: 0;
}

/* RTL slider: min thumb on the right needs higher stacking */
.price-slider-wrap .km-price-range-min {
    z-index: 4;
}

.price-slider-wrap .km-price-range-max {
    z-index: 3;
}

.price-range-input::-webkit-slider-runnable-track {
    height: 4px;
    background: transparent;
}

.price-range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--primary, #f97316);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.18);
    pointer-events: all;
    cursor: pointer;
    margin-top: -8px;
}

.price-range-input::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    border: 3px solid var(--primary, #f97316);
    box-shadow: 0 1px 6px rgba(0, 0, 0, 0.18);
    pointer-events: all;
    cursor: pointer;
}

.price-range-input::-moz-range-track {
    height: 4px;
    background: transparent;
}

.km-price-fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.km-price-field-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 6px;
}

.km-price-input-wrap {
    position: relative;
    display: block;
    direction: ltr;
}

.km-price-min-input,
.km-price-max-input {
    width: 100%;
    padding: 10px 12px 10px 52px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 12px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
    direction: ltr;
    text-align: right;
}

.km-price-min-input:focus,
.km-price-max-input:focus {
    border-color: var(--primary, #f97316);
}

.km-price-unit {
    position: absolute;
    left: 12px;
    right: auto;
    top: 50%;
    transform: translateY(-50%);
    font-size: 11px;
    color: #94a3b8;
    pointer-events: none;
    white-space: nowrap;
}

/* ── Multiselect (brand / category) ───────────────────── */
.km-multiselect--filter {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.km-multiselect--filter .km-ms-empty {
    padding: 16px 4px;
    text-align: center;
    font-size: 13px;
    color: #94a3b8;
}

.km-multiselect--filter .km-ms-search-wrap {
    position: relative;
}

.km-multiselect--filter .km-ms-search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    color: #94a3b8;
    pointer-events: none;
}

.km-multiselect--filter .km-ms-search {
    padding: 10px 12px 10px 36px;
    border: 1.5px solid #e2e8f0;
    border-radius: 10px;
    font-size: 13px;
    background: #fff;
}

.km-multiselect--filter .km-ms-summary {
    display: none;
}

.km-multiselect--filter .km-ms-list {
    max-height: 260px;
    border: none;
    border-radius: 0;
    background: transparent;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.km-multiselect--filter .km-ms-opt {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 11px 2px;
    margin: 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.45;
    cursor: pointer;
    direction: rtl;
}

.km-multiselect--filter .km-ms-opt:last-child {
    border-bottom: none;
}

.km-multiselect--filter .km-ms-opt:hover {
    background: #f8fafc;
}

.km-multiselect--filter .km-ms-opt input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0;
    flex: 0 0 20px;
    accent-color: var(--primary, #f97316);
    border-radius: 4px;
    cursor: pointer;
}

.km-multiselect--filter .km-ms-opt-text {
    flex: 1;
    min-width: 0;
    text-align: right;
    word-break: break-word;
}

.km-multiselect--filter .km-ms-opt-text--sub {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: #94a3b8;
    margin-top: 2px;
}

.km-multiselect--filter .km-ms-opt--depth-1 { padding-inline-start: 12px; }
.km-multiselect--filter .km-ms-opt--depth-2 { padding-inline-start: 24px; }
.km-multiselect--filter .km-ms-opt--depth-3 { padding-inline-start: 36px; }
.km-multiselect--filter .km-ms-opt--depth-4 { padding-inline-start: 48px; }

/* Override legacy row-reverse in filter sheet */
.km-filter-sheet .km-multiselect--filter .km-ms-opt,
#km-brand-sheet .km-multiselect--filter .km-ms-opt {
    flex-direction: row;
    direction: rtl;
}

/* ── Desktop sort bar v2 ──────────────────────────────── */
.km-sort-bar-v2 {
    background: transparent;
    border: none;
    padding: 0 0 16px;
    margin-bottom: 8px;
}

.km-sort-bar-v2 .result-count {
    font-size: 14px;
    color: #64748b;
}

.km-sort-bar-v2 .result-count strong {
    color: #0f172a;
    font-weight: 800;
}

.sort-options-v2 {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 16px;
}

.sort-by-label {
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
    margin-left: 4px;
}

.km-sort-bar-v2 .sort-opt {
    font-size: 13px;
    padding: 4px 0;
    border-radius: 0;
    background: transparent;
    color: #64748b;
    font-weight: 600;
    border: none;
    border-bottom: 2px solid transparent;
}

.km-sort-bar-v2 .sort-opt:hover {
    color: var(--primary, #f97316);
    background: transparent;
}

.km-sort-bar-v2 .sort-opt.active {
    color: var(--primary, #f97316);
    background: transparent;
    font-weight: 800;
    border-bottom-color: var(--primary, #f97316);
}

/* ── Mobile catalog meta ────────────────────────────────── */
.mob-catalog-meta {
    display: none;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px 6px;
    background: #fff;
}

.mob-catalog-title {
    font-size: 14px;
    font-weight: 800;
    color: #0f172a;
}

.mob-catalog-count {
    font-size: 13px;
    color: #64748b;
}

.mob-catalog-count strong {
    color: #0f172a;
    font-weight: 800;
}

/* ── Mobile panel sheets (price / brand / sort) ─────────── */
.km-panel-sheet {
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.km-panel-sheet.is-open {
    transform: translateY(0);
}

.km-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 18px 14px;
    flex-shrink: 0;
}

.km-panel-title {
    font-size: 16px;
    font-weight: 800;
    margin: 0;
    flex: 1;
    text-align: right;
}

.km-panel-close {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    font-size: 26px;
    line-height: 1;
    color: #64748b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.km-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 0 18px 16px;
}

.km-panel-body .km-price-filter {
    padding-top: 4px;
}

.km-panel-footer {
    flex-shrink: 0;
    display: flex;
    gap: 10px;
    padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #e2e8f0;
    background: #fff;
}

.km-panel-btn {
    flex: 1;
    padding: 14px 16px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    border: none;
    transition: background 0.15s, color 0.15s;
}

.km-panel-btn--ghost {
    background: #fff7ed;
    color: var(--primary, #f97316);
}

.km-panel-btn--ghost:hover {
    background: #ffedd5;
}

.km-panel-btn--primary {
    background: var(--primary, #f97316);
    color: #fff;
}

.km-panel-btn--primary:hover {
    background: var(--primary-d, #ea580c);
}

.km-sort-options {
    display: flex;
    flex-direction: column;
    padding: 0;
}

.km-sort-options .km-bs-option {
    width: 100%;
    border: none;
    background: transparent;
    font-family: inherit;
    text-align: right;
    border-bottom: 1px solid #f1f5f9;
}

#km-price-overlay,
#km-brand-overlay {
    z-index: 499;
}

#km-price-sheet,
#km-brand-sheet {
    z-index: 500;
}

.km-filter-sidebar .filter-group--open .filter-body {
    display: block;
}

/* ── Mobile filter sheet refresh ──────────────────────── */
.km-filter-sheet .km-fs-header-spacer {
    width: 36px;
}

.km-filter-sheet .km-fs-clear {
    background: #fff7ed;
    color: var(--primary, #f97316);
    border: none;
    font-weight: 700;
}

.km-filter-sheet .km-fs-apply {
    flex: 1.4;
}

.km-fs-section-header {
    width: 100%;
    border: none;
    background: transparent;
    font-family: inherit;
}

/* ── Dynamic attribute filters in sidebar ───────────────── */
.km-filter-sidebar .filter-group .check-item {
    flex-direction: row-reverse;
    justify-content: space-between;
    padding: 10px 0;
    font-size: 14px;
}

.km-filter-sidebar .filter-group .check-item input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary, #f97316);
}

/* ── Catalog infinite-scroll sentinel ───────────────────── */
.catalog-scroll-sentinel {
    width: 100%;
    height: 4px;
    margin: 0;
    padding: 0;
    border: 0;
    flex-shrink: 0;
    pointer-events: none;
    opacity: 0;
}

@media (min-width: 769px) {
    #mob-scroll-sentinel {
        display: none !important;
    }

    /* Active filter chips — mobile only */
    .mob-active-filters,
    .mob-active-filters.has-filters {
        display: none !important;
    }
}

@media (max-width: 768px) {
    #desktop-scroll-sentinel {
        display: none !important;
    }

    .mob-catalog-meta {
        display: flex;
    }
}

/* ── Skeletons ──────────────────────────────────────────── */
@keyframes km-catalog-skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.km-skel-block {
    background: linear-gradient(90deg, #f1f5f9 0%, #e8edf3 40%, #f1f5f9 80%);
    background-size: 200% 100%;
    animation: km-catalog-skeleton-shimmer 1.15s ease-in-out infinite;
    border-radius: 8px;
}

.product-card--skeleton {
    pointer-events: none;
    cursor: default;
}

.product-card--skeleton .pc-img-wrap {
    padding: 12px;
}

.product-card--skeleton .km-skel-img {
    width: 100%;
    height: 100%;
    min-height: 140px;
    border-radius: 10px;
}

.product-card--skeleton .km-skel-title {
    height: 14px;
    width: 92%;
    margin-bottom: 10px;
}

.product-card--skeleton .km-skel-line {
    height: 12px;
    width: 55%;
    margin-bottom: 14px;
}

.product-card--skeleton .km-skel-price {
    height: 18px;
    width: 70%;
}

.mob-product-card--skeleton {
    pointer-events: none;
    cursor: default;
}

.mob-product-card--skeleton .km-skel-mob-img {
    width: 120px;
    height: 120px;
    flex-shrink: 0;
    border-radius: 8px;
}

.mob-product-card--skeleton .km-skel-mob-title {
    height: 14px;
    width: 85%;
    margin-bottom: 12px;
}

.mob-product-card--skeleton .km-skel-mob-price {
    height: 16px;
    width: 60%;
}

.catalog-append-error {
    grid-column: 1 / -1;
    padding: 16px;
    text-align: center;
    font-size: 13px;
    color: var(--primary, #f97316);
}
