/* =====================================================
   MDH CUSTOM FILTERS — base styles
   Elementor widget controls safely override these values.
===================================================== */

.mdh-product-filters {
    width: 100%;
    margin: 0 0 24px;
    padding: 0;
    font-family: Inter, sans-serif;
}

.mdh-product-filters .mdh-filter-toolbar {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin: 0;
    padding: 16px 0;
    overflow: visible;
    border-top: 1px solid #ded8ce;
    border-bottom: 1px solid #ded8ce;
}

.mdh-product-filters .mdh-sort-control,
.mdh-product-filters .mdh-filter-dropdown,
.mdh-product-filters .mdh-filter-apply,
.mdh-product-filters .mdh-filter-clear {
    margin: 0;
}

.mdh-product-filters .mdh-sort-control {
    display: block;
    flex: 0 0 auto;
}

.mdh-product-filters .mdh-sort-control select {
    width: auto;
    min-width: 150px;
    height: 41px;
    margin: 0;
    padding: 0 42px 0 17px;
    appearance: none;
    -webkit-appearance: none;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 20 20' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5 7.5L10 12.5L15 7.5' stroke='%2314284B' stroke-width='1.7' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    background-size: 14px;
    border: 1px solid #ded8ce;
    border-radius: 999px;
    box-shadow: none;
    color: #14284b;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
}

.mdh-product-filters .mdh-sort-control select:focus {
    outline: none;
    border-color: #14284b;
    box-shadow: 0 0 0 1px #14284b;
}

.mdh-product-filters .mdh-filter-dropdown {
    position: relative;
    flex: 0 0 auto;
    overflow: visible;
}

.mdh-product-filters .mdh-filter-dropdown > summary {
    list-style: none;
}

.mdh-product-filters .mdh-filter-dropdown > summary::-webkit-details-marker {
    display: none;
}

.mdh-product-filters .mdh-filter-summary {
    width: auto;
    min-width: 138px;
    height: 41px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 0;
    padding: 0 15px 0 17px;
    background: #fff;
    border: 1px solid #ded8ce;
    border-radius: 999px;
    box-shadow: none;
    color: #14284b;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    user-select: none;
}

.mdh-product-filters .mdh-filter-summary:hover,
.mdh-product-filters .mdh-filter-dropdown[open] .mdh-filter-summary {
    border-color: #14284b;
}

.mdh-product-filters .mdh-filter-summary-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mdh-product-filters .mdh-filter-count {
    min-width: 19px;
    height: 19px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    padding: 0 5px;
    background: #14284b;
    border-radius: 999px;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
}

.mdh-product-filters .mdh-filter-chevron {
    width: 7px;
    height: 7px;
    flex: 0 0 7px;
    border-right: 1.5px solid #14284b;
    border-bottom: 1.5px solid #14284b;
    transform: rotate(45deg) translateY(-2px);
    transition: transform 0.2s ease;
}

.mdh-product-filters .mdh-filter-dropdown[open] .mdh-filter-chevron {
    transform: rotate(225deg) translate(-1px, -1px);
}

.mdh-product-filters .mdh-filter-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: auto;
    bottom: auto;
    left: 0;
    z-index: 99999;
    width: max-content;
    min-width: 225px;
    max-width: 300px;
    max-height: 260px;
    margin: 0;
    padding: 15px;
    overflow-y: auto;
    background: #fff;
    border: 1px solid #ded8ce;
    border-radius: 14px;
    box-shadow: 0 14px 34px rgba(20, 40, 75, 0.13);
}

.mdh-product-filters .mdh-filter-menu-heading {
    margin: 0 0 12px;
    padding: 0 0 10px;
    border-bottom: 1px solid #eee9e1;
    color: #14284b;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.mdh-product-filters .mdh-filter-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 220px;
    overflow-y: auto;
}

.mdh-product-filters .mdh-filter-option {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0;
    color: #5f625f;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.35;
    cursor: pointer;
}

.mdh-product-filters .mdh-filter-option input {
    width: 17px;
    height: 17px;
    flex: 0 0 17px;
    margin: 0;
    accent-color: #14284b;
    cursor: pointer;
}

.mdh-product-filters .mdh-filter-apply,
.mdh-product-filters .mdh-filter-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 41px;
    font-weight: 600;
    line-height: 1;
    text-decoration: none;
}

.mdh-product-filters .mdh-filter-apply {
    min-width: 88px;
    padding: 0 19px;
    background: #14284b;
    border: 1px solid #14284b;
    border-radius: 999px;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
}

.mdh-product-filters .mdh-filter-apply:hover {
    background: #203b68;
    border-color: #203b68;
}

.mdh-product-filters .mdh-filter-clear {
    min-width: 76px;
    padding: 0 8px;
    background: transparent;
    border: 1px solid transparent;
    color: #b47d19;
    font-size: 13px;
}

.mdh-product-filters .mdh-filter-clear:hover {
    color: #8c5e0a;
    text-decoration: underline;
}

@media (max-width: 1024px) {
    .mdh-product-filters .mdh-filter-toolbar {
        gap: 9px;
    }
}

@media (max-width: 767px) {
    .mdh-product-filters {
        margin-bottom: 18px;
    }

    .mdh-product-filters .mdh-filter-toolbar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: stretch;
        gap: 7px;
        padding: 12px 0;
    }

    .mdh-product-filters .mdh-sort-control,
    .mdh-product-filters .mdh-filter-dropdown {
        width: 100%;
        min-width: 0;
        max-width: none;
        display: block;
    }

    .mdh-product-filters .mdh-sort-control select,
    .mdh-product-filters .mdh-filter-summary {
        width: 100%;
        min-width: 0;
        max-width: none;
        height: 36px;
        min-height: 36px;
        border-radius: 999px;
        font-size: 12px;
    }

    .mdh-product-filters .mdh-sort-control select {
        padding: 0 30px 0 12px;
        background-position: right 10px center;
        background-size: 12px;
    }

    .mdh-product-filters .mdh-filter-summary {
        gap: 7px;
        padding: 0 12px;
    }

    .mdh-product-filters .mdh-filter-dropdown:last-of-type {
        grid-column: 1 / -1;
    }

    .mdh-product-filters .mdh-filter-apply,
    .mdh-product-filters .mdh-filter-clear {
        width: 100%;
        min-width: 0;
        height: 36px;
        min-height: 36px;
        font-size: 12px;
        border-radius: 999px;
    }

    .mdh-product-filters .mdh-filter-clear {
        background: #fffaf2;
        border-color: #d9d2c4;
    }

    .mdh-product-filters .mdh-filter-menu {
        top: calc(100% + 6px);
        width: 100%;
        min-width: 0;
        max-width: none;
        padding: 14px;
    }

    .mdh-product-filters .mdh-filter-option,
    .mdh-product-filters .mdh-filter-menu-heading {
        font-size: 12px;
    }
}


/* =====================================================
   RESULTS COUNT + SELECTED FILTER CHIPS
===================================================== */
.mdh-product-filters .mdh-filter-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 0 0;
}

.mdh-product-filters .mdh-results-count {
    color: #14284b;
    font-size: 15px;
    line-height: 1.3;
}

.mdh-product-filters .mdh-results-count strong {
    font-weight: 700;
}

.mdh-product-filters .mdh-selected-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.mdh-product-filters .mdh-selected-chip,
.mdh-product-filters .mdh-selected-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 36px;
    padding: 8px 13px;
    background: #f2f0ed;
    border: 1px solid #d8d3cc;
    border-radius: 4px;
    color: #14284b;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    transition: background-color .2s ease, border-color .2s ease;
}

.mdh-product-filters .mdh-selected-chip:hover,
.mdh-product-filters .mdh-selected-clear:hover {
    background: #eae6e0;
    border-color: #bdb6ac;
    color: #14284b;
    text-decoration: none;
}

.mdh-product-filters .mdh-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    font-size: 20px;
    font-weight: 300;
    line-height: 1;
}

@media (max-width: 767px) {
    .mdh-product-filters .mdh-filter-meta {
        gap: 8px;
        padding-top: 12px;
    }

    .mdh-product-filters .mdh-results-count {
        font-size: 13px;
    }

    .mdh-product-filters .mdh-selected-filters {
        gap: 6px;
    }

    .mdh-product-filters .mdh-selected-chip,
    .mdh-product-filters .mdh-selected-clear {
        min-height: 32px;
        padding: 7px 10px;
        font-size: 12px;
    }
}

/* =====================================================
   4.5 STRUCTURE: CONTROLS + ACTIONS
===================================================== */
.mdh-product-filters .mdh-filter-controls,
.mdh-product-filters .mdh-filter-actions {
    display: contents;
}

/* =====================================================
   MOBILE LAYOUT OPTION
===================================================== */
@media (max-width: 767px) {
    /* Default: show all filters in a two-column grid. */
    .mdh-product-filters.mdh-mobile-layout-grid .mdh-filter-toolbar {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: stretch;
        gap: 7px;
    }

    .mdh-product-filters.mdh-mobile-layout-grid .mdh-filter-controls,
    .mdh-product-filters.mdh-mobile-layout-grid .mdh-filter-actions {
        display: contents;
    }

    .mdh-product-filters.mdh-mobile-layout-grid .mdh-filter-dropdown:last-child {
        grid-column: 1 / -1;
    }

    /* Horizontal Swipe: filters scroll on one row; actions stay below. */
    .mdh-product-filters.mdh-mobile-layout-horizontal .mdh-filter-toolbar {
        display: block;
        padding: 12px 0;
        overflow: visible;
    }

    .mdh-product-filters.mdh-mobile-layout-horizontal .mdh-filter-controls {
        display: flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: 8px;
        width: 100%;
        padding: 0 0 9px;
        overflow-x: auto;
        overflow-y: visible;
        scrollbar-width: none;
        -ms-overflow-style: none;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
    }

    .mdh-product-filters.mdh-mobile-layout-horizontal .mdh-filter-controls::-webkit-scrollbar {
        display: none;
    }

    .mdh-product-filters.mdh-mobile-layout-horizontal .mdh-sort-control,
    .mdh-product-filters.mdh-mobile-layout-horizontal .mdh-filter-dropdown {
        flex: 0 0 auto;
        width: auto;
        min-width: 0;
        max-width: none;
        scroll-snap-align: start;
    }

    .mdh-product-filters.mdh-mobile-layout-horizontal .mdh-sort-control select,
    .mdh-product-filters.mdh-mobile-layout-horizontal .mdh-filter-summary {
        width: auto;
        min-width: 132px;
        max-width: 190px;
        white-space: nowrap;
    }

    .mdh-product-filters.mdh-mobile-layout-horizontal .mdh-sort-control select {
        min-width: 148px;
    }

    .mdh-product-filters.mdh-mobile-layout-horizontal .mdh-filter-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        align-items: stretch;
        gap: 7px;
        width: 100%;
    }

    .mdh-product-filters.mdh-mobile-layout-horizontal .mdh-filter-apply,
    .mdh-product-filters.mdh-mobile-layout-horizontal .mdh-filter-clear {
        width: 100%;
        min-width: 0;
    }

    /* In horizontal mode the menu is moved into a body-level drawer by JS. */
    .mdh-product-filters.mdh-mobile-layout-horizontal .mdh-filter-dropdown > .mdh-filter-menu {
        display: none;
    }
}


/* =====================================================
   MOBILE DRAWER FOR HORIZONTAL FILTER MODE
   Body-level placement avoids iOS Safari overflow clipping.
===================================================== */
.mdh-mobile-drawer-backdrop,
.mdh-mobile-drawer {
    display: none;
}

@media (max-width: 767px) {
    html.mdh-drawer-open,
    body.mdh-drawer-open {
        overflow: hidden !important;
        overscroll-behavior: none;
    }

    .mdh-mobile-drawer-backdrop {
        position: fixed;
        inset: 0;
        z-index: 2147482000;
        display: block;
        background: rgba(10, 24, 49, 0.42);
        opacity: 0;
        transition: opacity .2s ease;
        -webkit-tap-highlight-color: transparent;
    }

    .mdh-mobile-drawer-backdrop[hidden],
    .mdh-mobile-drawer[hidden] {
        display: none !important;
    }

    .mdh-mobile-drawer-backdrop.is-open {
        opacity: 1;
    }

    .mdh-mobile-drawer {
        position: fixed;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 2147483000;
        display: flex;
        flex-direction: column;
        width: 100%;
        max-height: min(72vh, 620px);
        padding: 0;
        overflow: hidden;
        background: #fff;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -18px 48px rgba(10, 24, 49, .22);
        transform: translate3d(0, 102%, 0);
        transition: transform .24s ease;
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }

    .mdh-mobile-drawer.is-open {
        transform: translate3d(0, 0, 0);
    }

    .mdh-mobile-drawer-header {
        flex: 0 0 auto;
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        min-height: 58px;
        padding: 14px 18px;
        border-bottom: 1px solid #eee9e1;
    }

    .mdh-mobile-drawer-title {
        color: #14284b;
        font-family: Inter, sans-serif;
        font-size: 15px;
        font-weight: 700;
        line-height: 1.2;
    }

    .mdh-mobile-drawer-close {
        width: 34px;
        height: 34px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        background: #f6f3ee;
        border: 1px solid #ded8ce;
        border-radius: 999px;
        color: #14284b;
        font-size: 25px;
        font-weight: 300;
        line-height: 1;
        cursor: pointer;
        -webkit-appearance: none;
        appearance: none;
    }

    .mdh-mobile-drawer-body {
        flex: 1 1 auto;
        min-height: 0;
        padding: 6px 18px 12px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .mdh-mobile-drawer-body .mdh-filter-menu.mdh-menu-in-drawer {
        position: static !important;
        inset: auto !important;
        z-index: auto !important;
        display: block !important;
        visibility: visible !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 8px 0 0 !important;
        overflow: visible !important;
        opacity: 1 !important;
        transform: none !important;
        background: transparent !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        pointer-events: auto !important;
    }

    .mdh-mobile-drawer-body .mdh-filter-menu-heading {
        display: none;
    }

    .mdh-mobile-drawer-body .mdh-filter-options {
        gap: 0;
        max-height: none;
        overflow: visible;
    }

    .mdh-mobile-drawer-body .mdh-filter-option {
        min-height: 48px;
        padding: 11px 2px;
        border-bottom: 1px solid #f0ece6;
        color: #39445a;
        font-size: 14px;
    }

    .mdh-mobile-drawer-body .mdh-filter-option input {
        width: 19px;
        height: 19px;
        flex-basis: 19px;
    }

    .mdh-mobile-drawer-footer {
        flex: 0 0 auto;
        padding: 12px 18px 14px;
        border-top: 1px solid #eee9e1;
        background: #fff;
    }

    .mdh-mobile-drawer-done {
        width: 100%;
        min-height: 44px;
        padding: 0 18px;
        background: #14284b;
        border: 1px solid #14284b;
        border-radius: 999px;
        color: #fff;
        font-family: Inter, sans-serif;
        font-size: 13px;
        font-weight: 700;
        line-height: 1;
        cursor: pointer;
        -webkit-appearance: none;
        appearance: none;
    }
}

/* v4.9: anchor target spacing for sticky headers */
.mdh-product-filters {
    scroll-margin-top: 20px;
}

@media (max-width: 767px) {
    .mdh-product-filters {
        scroll-margin-top: 12px;
    }
}

/* =====================================================
   AJAX FILTERING
===================================================== */

.mdh-filters-is-loading {
    pointer-events: none;
    opacity: 0.72;
}

.elementor-widget-loop-grid.mdh-grid-is-loading,
[data-widget_type^="loop-grid"].mdh-grid-is-loading,
.elementor-widget-posts.mdh-grid-is-loading {
    position: relative;
    pointer-events: none;
}

.elementor-widget-loop-grid.mdh-grid-is-loading::before,
[data-widget_type^="loop-grid"].mdh-grid-is-loading::before,
.elementor-widget-posts.mdh-grid-is-loading::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 9998;
    background: rgba(248, 244, 236, 0.62);
    backdrop-filter: blur(1px);
    -webkit-backdrop-filter: blur(1px);
}

.elementor-widget-loop-grid.mdh-grid-is-loading::after,
[data-widget_type^="loop-grid"].mdh-grid-is-loading::after,
.elementor-widget-posts.mdh-grid-is-loading::after {
    content: "";
    position: absolute;
    top: 56px;
    left: 50%;
    z-index: 9999;
    width: 28px;
    height: 28px;
    margin-left: -14px;
    border: 3px solid rgba(20, 40, 75, 0.2);
    border-top-color: #14284b;
    border-radius: 50%;
    animation: mdh-filter-spin 0.72s linear infinite;
}

@keyframes mdh-filter-spin {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .elementor-widget-loop-grid.mdh-grid-is-loading::after,
    [data-widget_type^="loop-grid"].mdh-grid-is-loading::after,
    .elementor-widget-posts.mdh-grid-is-loading::after {
        animation-duration: 1.5s;
    }
}
