/* ============================================================
   KSHATRIYA EXIM - Products Filter Panel
   Premium filter sidebar + responsive layout
   Version: 2.0.0
   ============================================================ */

.ks-shop-layout {
    display: grid;
    grid-template-columns: 290px 1fr;
    gap: 30px;
    align-items: start;
}

.ks-filter-mobile-toggle { padding: 0 0 20px; }

.ks-filter-toggle-btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 12px 24px; border-radius: 14px;
    border: 1.5px solid var(--border-color);
    background: var(--white-color); color: var(--title-color);
    font-family: var(--body-font); font-size: 14px; font-weight: 600;
    cursor: pointer; box-shadow: 0 4px 16px rgba(0,0,0,0.06);
    transition: all 250ms ease;
}
.ks-filter-toggle-btn:hover { border-color: var(--secondary-color); color: var(--secondary-color); }

/* ── Sidebar ──────────────────────────────────────────────── */
.ks-filter-sidebar {
    position: sticky; top: 100px;
    background: var(--white-color);
    border: 1px solid var(--border-color);
    border-radius: 18px; padding: 24px 20px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.06);
    max-height: calc(100vh - 120px); overflow-y: auto;
    scrollbar-width: thin; scrollbar-color: var(--secondary-color) transparent;
}
.ks-filter-sidebar::-webkit-scrollbar { width: 5px; }
.ks-filter-sidebar::-webkit-scrollbar-track { background: transparent; }
.ks-filter-sidebar::-webkit-scrollbar-thumb { background: var(--secondary-color); border-radius: 10px; }

/* ── Header ───────────────────────────────────────────────── */
.ks-filter-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}
.ks-filter-header h3 {
    display: flex; align-items: center; gap: 10px; margin: 0;
    font-family: var(--title-font); font-size: 18px; font-weight: 700; color: var(--title-color);
}
.ks-filter-header h3 i { color: var(--secondary-color); font-size: 16px; }
.ks-filter-close {
    display: none; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 10px;
    border: 1px solid var(--border-color); background: transparent;
    color: var(--body-color); font-size: 20px; cursor: pointer;
}
.ks-filter-close:hover { background: var(--error-color); color: #fff; border-color: var(--error-color); }

/* ── Active Filter Chips ──────────────────────────────────── */
.ks-active-filters { margin-bottom: 16px; padding-bottom: 16px; border-bottom: 1px solid var(--border-color); }
.ks-active-filters__list { display: flex; flex-wrap: wrap; gap: 8px; }
.ks-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px; border-radius: 99px;
    background: rgba(228,95,43,0.08); border: 1px solid rgba(228,95,43,0.2);
    color: var(--secondary-color); font-family: var(--body-font);
    font-size: 12px; font-weight: 600; white-space: nowrap;
}
.ks-chip__remove {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; border-radius: 50%; border: none;
    background: rgba(228,95,43,0.15); color: var(--secondary-color);
    font-size: 12px; line-height: 1; cursor: pointer; padding: 0;
}
.ks-chip__remove:hover { background: var(--secondary-color); color: #fff; }

/* ── Filter Groups ────────────────────────────────────────── */
.ks-filter-group {
    padding: 16px 0;
    border-bottom: 1px solid rgba(0,0,0,0.06);
}
.ks-filter-group:last-of-type { border-bottom: none; padding-bottom: 0; }
.ks-filter-group:first-of-type { padding-top: 0; }
.ks-filter-group__title {
    font-family: var(--title-font); font-size: 13px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.08em;
    color: var(--body-color); margin: 0 0 12px;
}

/* ── Category Buttons ─────────────────────────────────────── */
.ks-filter-cats { list-style: none; margin: 0; padding: 0; }
.ks-filter-cat {
    display: flex; align-items: center; justify-content: space-between;
    width: 100%; padding: 10px 14px; border-radius: 12px;
    border: 1px solid transparent; background: transparent;
    font-family: var(--body-font); font-size: 13.5px; font-weight: 500;
    color: var(--body-color); cursor: pointer; text-align: left;
    margin-bottom: 2px; transition: all 200ms ease;
}
.ks-filter-cat:hover { background: rgba(228,95,43,0.05); color: var(--title-color); }
.ks-filter-cat--active {
    background: rgba(228,95,43,0.08); border-color: rgba(228,95,43,0.25);
    color: var(--secondary-color); font-weight: 700;
}
.ks-filter-cat__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ks-filter-cat__count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 26px; height: 22px; padding: 0 7px; border-radius: 99px;
    background: rgba(0,0,0,0.06); font-size: 11px; font-weight: 700;
    color: var(--body-color); flex-shrink: 0; margin-left: 8px;
    font-variant-numeric: tabular-nums; letter-spacing: 0.02em;
}
.ks-filter-cat--active .ks-filter-cat__count { background: rgba(228,95,43,0.15); color: var(--secondary-color); }

/* ── Price Range ──────────────────────────────────────────── */
.ks-filter-price { padding-top: 4px; }

.ks-filter-price__inputs {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}
.ks-filter-price__field { position: relative; min-width: 0; }
.ks-filter-price__symbol {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    font-size: 13px; font-weight: 700; color: var(--body-color);
    pointer-events: none; z-index: 1; line-height: 1;
}
.ks-filter-price__sep {
    color: var(--border-color); font-weight: 600; font-size: 16px;
    text-align: center; line-height: 1; user-select: none;
}

.ks-filter-input {
    width: 100%; height: 40px; padding: 0 12px 0 30px;
    border-radius: 10px; border: 1.5px solid var(--border-color);
    background: var(--white-color); font-family: var(--body-font);
    font-size: 13px; font-weight: 500; color: var(--title-color);
    box-sizing: border-box;
    transition: border-color 200ms ease, box-shadow 200ms ease;
    -moz-appearance: textfield;
}
.ks-filter-input::-webkit-outer-spin-button,
.ks-filter-input::-webkit-inner-spin-button {
    -webkit-appearance: none; margin: 0;
}
.ks-filter-input:focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(228,95,43,0.1);
    outline: none;
}
.ks-filter-input::placeholder { color: #b0b0b0; font-weight: 400; }
.ks-filter-input--search { padding-left: 36px; }

/* Override global input rule (style.css:215) — specificity boost via :not() */
.ks-filter-input:not([type="checkbox"]):not([type="radio"]) {
    width: 100%;
    height: 40px;
    padding: 0 12px 0 30px;
    background-color: var(--white-color);
    border: 1.5px solid var(--border-color);
    border-radius: 10px;
    box-shadow: none;
    transition: border-color 200ms ease, box-shadow 200ms ease;
    font-family: var(--body-font);
    font-size: 13px;
    font-weight: 500;
    color: var(--title-color);
}
.ks-filter-input:not([type="checkbox"]):not([type="radio"]):focus {
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(228,95,43,0.1);
    outline: none;
}
.ks-filter-input--search:not([type="checkbox"]):not([type="radio"]) {
    padding-left: 36px;
}

/* ── Dual Range Slider ────────────────────────────────────── */
.ks-filter-price__slider {
    position: relative;
    height: 28px;
    padding: 0;
    margin: 4px 0 8px;
}

/* Both range inputs are stacked on top of each other */
.ks-range {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 28px;
    margin: 0; padding: 0;
    background: none;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    border: none;
    border-radius: 0;
    outline: none;
    box-shadow: none;
}

/* ── WebKit (Chrome, Edge, Safari) ────────────────────────── */
.ks-range::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 2px;
    background: #e2e2e2;
    border: none;
}

.ks-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--secondary-color);
    border: 3px solid var(--white-color);
    box-shadow: 0 1px 4px rgba(0,0,0,0.18), 0 0 0 1px rgba(228,95,43,0.15);
    cursor: pointer;
    pointer-events: auto;
    margin-top: -8px;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}
.ks-range::-webkit-slider-thumb:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.22), 0 0 0 1px rgba(228,95,43,0.25);
    transform: scale(1.1);
}
.ks-range::-webkit-slider-thumb:active {
    transform: scale(1.05);
}

/* ── Firefox ──────────────────────────────────────────────── */
.ks-range::-moz-range-track {
    height: 4px;
    border-radius: 2px;
    background: #e2e2e2;
    border: none;
}

.ks-range::-moz-range-thumb {
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--secondary-color);
    border: 3px solid var(--white-color);
    box-shadow: 0 1px 4px rgba(0,0,0,0.18), 0 0 0 1px rgba(228,95,43,0.15);
    cursor: pointer;
    pointer-events: auto;
}

/* ── Active range highlight (applied via JS on parent) ────── */
.ks-filter-price__slider--active .ks-range::-webkit-slider-runnable-track {
    background: linear-gradient(to right, #e2e2e2 0%, #e2e2e2 var(--range-from, 0%), var(--secondary-color) var(--range-from, 0%), var(--secondary-color) var(--range-to, 100%), #e2e2e2 var(--range-to, 100%), #e2e2e2 100%);
}
.ks-filter-price__slider--active .ks-range::-moz-range-track {
    background: linear-gradient(to right, #e2e2e2 0%, #e2e2e2 var(--range-from, 0%), var(--secondary-color) var(--range-from, 0%), var(--secondary-color) var(--range-to, 100%), #e2e2e2 var(--range-to, 100%), #e2e2e2 100%);
}

/* ── Price Labels ─────────────────────────────────────────── */
.ks-filter-price__labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--body-color);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    margin-top: 2px;
    line-height: 1;
}

/* ── Checkboxes ───────────────────────────────────────────── */
.ks-filter-check {
    display: flex; align-items: center; gap: 10px; padding: 8px 0;
    cursor: pointer; font-family: var(--body-font); font-size: 13.5px;
    color: var(--body-color); transition: color 200ms ease;
    border-radius: 6px;
}
.ks-filter-check:hover { color: var(--title-color); }
.ks-filter-check:hover input[type="checkbox"] { border-color: var(--secondary-color); }
.ks-filter-check input[type="checkbox"] {
    appearance: none; -webkit-appearance: none; width: 18px; height: 18px;
    border: 2px solid var(--border-color); border-radius: 6px; cursor: pointer;
    position: relative; flex-shrink: 0; transition: all 200ms ease;
}
.ks-filter-check input[type="checkbox"]:focus-visible {
    outline: 2px solid var(--secondary-color); outline-offset: 2px;
}
.ks-filter-check input[type="checkbox"]:checked {
    background: var(--secondary-color); border-color: var(--secondary-color);
}
.ks-filter-check input[type="checkbox"]:checked::after {
    content: ''; position: absolute; left: 4px; top: 1px;
    width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}
.ks-filter-check__box { display: none; }
.ks-filter-check__label { user-select: none; }

/* ── Product Types ────────────────────────────────────────── */
.ks-filter-types { display: flex; flex-direction: column; gap: 0; }

/* ── Sort Select ──────────────────────────────────────────── */
.ks-filter-select {
    width: 100%; height: 40px; padding: 0 36px 0 14px;
    border-radius: 10px; border: 1.5px solid var(--border-color);
    background: var(--white-color) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23e45f2b' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 12px center;
    font-family: var(--body-font); font-size: 13px; font-weight: 500;
    color: var(--title-color); cursor: pointer; appearance: none; -webkit-appearance: none;
    box-sizing: border-box;
    transition: border-color 200ms ease, box-shadow 200ms ease;
}
.ks-filter-select:focus { border-color: var(--secondary-color); outline: none; box-shadow: 0 0 0 3px rgba(228,95,43,0.1); }

/* ── Search ───────────────────────────────────────────────── */
.ks-filter-search { position: relative; }
.ks-filter-search__icon {
    position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
    font-size: 13px; color: var(--border-color); pointer-events: none;
    transition: color 200ms ease;
}
.ks-filter-search:focus-within .ks-filter-search__icon { color: var(--secondary-color); }
.ks-filter-search:focus-within .ks-filter-input--search {
    border-color: var(--secondary-color); box-shadow: 0 0 0 3px rgba(228,95,43,0.1);
}

/* ── Action Buttons ───────────────────────────────────────── */
.ks-filter-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border-color); }

.ks-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 12px 20px; border-radius: 13px; border: none;
    font-family: var(--body-font); font-size: 14px; font-weight: 700;
    cursor: pointer; transition: all 250ms ease; text-decoration: none;
}
.ks-btn:hover { transform: translateY(-2px); }
.ks-btn:active { transform: translateY(0) scale(0.98); }
.ks-btn:focus-visible { outline: 2px solid var(--secondary-color); outline-offset: 2px; }
.ks-btn--primary {
    background: linear-gradient(135deg, var(--secondary-color), #ff8a47);
    color: #fff; box-shadow: 0 8px 22px rgba(228,95,43,0.3);
}
.ks-btn--primary:hover { box-shadow: 0 12px 28px rgba(228,95,43,0.4); }
.ks-btn--ghost {
    background: transparent; color: var(--body-color);
    border: 1.5px solid var(--border-color);
}
.ks-btn--ghost:hover { border-color: var(--secondary-color); color: var(--secondary-color); }
.ks-btn--full { width: 100%; }

/* ── Main Content ─────────────────────────────────────────── */
.ks-shop-main { min-width: 0; }

/* ── Quantity stepper (defensive reset of generic input padding) ── */
.ks-qty-stepper { display: inline-flex; align-items: center; }

/* Override global input rule (style.css:215) — specificity boost via :not() */
.ks-qty-input:not([type="checkbox"]):not([type="radio"]) {
    width: 48px;
    height: 36px;
    padding: 0;
    background-color: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    transition: none;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
}

/* ── Toolbar ──────────────────────────────────────────────── */
.ks-shop-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.ks-shop-toolbar__count {
    font-family: var(--body-font); font-size: 14px; font-weight: 600; color: var(--body-color);
    padding: 8px 16px; background: rgba(228,95,43,0.04); border-radius: 10px;
    border: 1px solid rgba(228,95,43,0.1);
}
.ks-shop-toolbar__count strong {
    color: var(--secondary-color); font-weight: 700;
}

/* ── Empty State ──────────────────────────────────────────── */
.ks-empty-state {
    text-align: center; padding: 60px 20px;
    background: rgba(255,255,255,0.7); border-radius: 18px;
    border: 1px dashed rgba(0,0,0,0.12);
}
.ks-empty-state__icon { font-size: 48px; display: block; margin-bottom: 12px; }
.ks-empty-state h3 { font-family: var(--title-font); font-size: 1.3rem; color: var(--title-color); margin: 0 0 6px; }
.ks-empty-state p { font-family: var(--body-font); font-size: 14px; color: var(--body-color); margin: 0 0 18px; }

/* ── Loading ──────────────────────────────────────────────── */
.ks-loading-overlay {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.7); border-radius: 12px; z-index: 10;
    backdrop-filter: blur(2px); transition: opacity 200ms ease;
}
.ks-loading-spinner {
    width: 36px; height: 36px; border: 3px solid var(--border-color);
    border-top-color: var(--secondary-color); border-radius: 50%;
    animation: ks-spin 0.7s linear infinite;
}
@keyframes ks-spin { to { transform: rotate(360deg); } }

/* ── Pagination ───────────────────────────────────────────── */
.vs-pagination { text-align: center; margin: 30px 0 10px; }
.vs-pagination ul { list-style: none; margin: 0; padding: 0; display: inline-flex; gap: 6px; align-items: center; }
.vs-pagination ul li span,
.vs-pagination ul li button {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 38px; height: 38px; padding: 0 10px; border-radius: 10px;
    font-family: var(--body-font); font-size: 13px; font-weight: 600;
    border: 1px solid var(--border-color); background: var(--white-color);
    color: var(--body-color); cursor: pointer; transition: all 200ms ease;
}
.vs-pagination ul li button:hover {
    border-color: var(--secondary-color); color: var(--secondary-color);
    background: rgba(228,95,43,0.05);
}
.vs-pagination ul li.arrow span { opacity: 0.4; cursor: default; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1023px) {
    .ks-shop-layout { grid-template-columns: 1fr; }

    .ks-filter-sidebar {
        position: fixed; top: 0; left: 0; bottom: 0;
        width: 320px; max-width: 85vw; max-height: none;
        border-radius: 0 18px 18px 0;
        z-index: 9999; transform: translateX(-100%);
        transition: transform 300ms ease;
    }
    .ks-filter-sidebar.is-open { transform: translateX(0); }
    .ks-filter-close { display: flex; }
    .ks-filter-mobile-toggle { display: block; }

    .ks-filter-sidebar::before {
        content: ''; position: fixed; inset: 0;
        background: rgba(0,0,0,0.4); z-index: -1;
        opacity: 0; pointer-events: none;
        transition: opacity 300ms ease;
    }
    .ks-filter-sidebar.is-open::before { opacity: 1; pointer-events: auto; }
}

@media (min-width: 1024px) {
    .ks-filter-mobile-toggle { display: none; }
}

@media (max-width: 767px) {
    .ks-shop-layout { gap: 0; }
    .ks-filter-sidebar { width: 100%; max-width: 100%; border-radius: 0; }
    .ks-filter-actions { flex-direction: column; }
    .ks-filter-price__inputs { gap: 8px; }
}
