/* ============================================
   TARJETA DE PRODUCTO - LISTA VIEW
   ============================================ */
.search-content-wrapper {
    background: var(--search-background);
}

.offline-catalog-notice {
    position: sticky;
    top: 88px;
    z-index: 1010;
}

.search-scroll-sentinel {
    height: 2px;
}

.search-load-more {
    display: flex;
    justify-content: center;
    margin: 1.25rem 0;
    color: #65705f;
    font-size: .9rem;
}

#searchLoadMoreStatus {
    display: inline-flex;
    align-items: center;
}

.search-load-more .btn {
    min-height: 44px;
    padding: .65rem 1.25rem;
    border: 1px solid var(--search-action);
    border-radius: .6rem;
    color: var(--search-action);
    background: #fff;
    box-shadow: none;
}

.search-load-more .btn:hover:not(:disabled) {
    border-color: var(--search-action-hover);
    color: var(--search-action-hover);
    background: #eef5e3;
}

.search-results-status {
    display: flex;
    align-items: center;
    gap: .5rem;
    min-height: 1.5rem;
    margin-bottom: .75rem;
    color: #65705f;
    font-size: .85rem;
}

.search-empty-state {
    padding: 1.5rem;
    border: 1px solid var(--search-border);
    border-radius: .75rem;
    background: #fff;
}

.search-empty-state h2 {
    margin-bottom: .75rem;
    color: #42533d;
    font-size: 1.15rem;
}

.search-empty-state p {
    color: #65705f;
    line-height: 1.6;
    overflow-wrap: anywhere;
}

.search-empty-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

.search-empty-actions .btn {
    min-height: 44px;
    font-size: .85rem;
}

.search-content-wrapper .end-pagination-message {
    padding: 1rem;
    color: #65705f;
    font-size: .85rem;
    text-align: center;
}

.search-layout {
    display: grid;
    gap: 1.5rem;
}

.search-results {
    min-width: 0;
}

.search-results,
#product-container > :first-child,
.search-empty-state {
    scroll-margin-top: calc(var(--search-header-height, 230px) + 1rem);
}

.search-filters-panel {
    z-index: 1050;
    width: min(360px, calc(100vw - 1rem));
    height: 100vh;
    height: 100dvh;
    border: 0;
    background: #fff;
}

/* Bridge the bundled Bootstrap 5.3 offcanvas behavior and the existing 5.0 CSS. */
.search-filters-panel.showing,
.search-filters-panel.hiding,
.search-filters-panel.show {
    visibility: visible;
}

.search-filters-panel.showing,
.search-filters-panel.show:not(.hiding) {
    transform: none;
}

.search-filters-panel.hiding {
    transform: translateX(-100%);
}

.search-layout > .offcanvas-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1040;
    background: #000;
    opacity: 0;
}

.search-layout > .offcanvas-backdrop.show {
    opacity: .5;
}

.search-filters-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: max(1rem, env(safe-area-inset-top)) 1rem 1rem;
    border-bottom: 1px solid var(--search-border);
}

.search-filters-heading h2 {
    margin: 0;
    color: #42533d;
    font-size: 1rem;
    font-weight: 700;
}

.search-filters-heading .btn-close {
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.search-filters-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0 1rem;
}

.search-filter-group {
    border-bottom: 1px solid var(--search-border);
}

.search-filter-group:last-child {
    border-bottom: 0;
}

.search-filter-group summary {
    padding: 1rem 0;
    color: #42533d;
    cursor: pointer;
    font-size: .9rem;
    font-weight: 700;
}

.search-filter-group-content {
    padding: 0 0 1rem;
}

.search-filter-group .form-label {
    font-size: .85rem;
}

.search-filter-group .form-select {
    min-height: 44px;
    border-radius: .6rem;
    font-size: .9rem;
}

.search-filter-group .form-check {
    display: flex;
    align-items: center;
    gap: .5rem;
    min-height: 44px;
    margin: 0;
}

.search-filter-group .form-check-input {
    flex-shrink: 0;
    margin-top: 0;
}

.search-content-wrapper .form-check-input:checked {
    border-color: var(--search-action);
    background-color: var(--search-action);
}

.search-content-wrapper .form-check-input:checked + .form-check-label {
    font-weight: 700;
}

.search-content-wrapper :is(button, input, select, summary):focus-visible,
.search-filters-heading h2:focus-visible,
.search-filters-panel .select2-selection:focus-visible,
.search-filters-panel .select2-container--focus .select2-selection {
    outline: 2px solid var(--search-action);
    outline-offset: 2px;
}

.search-filter-group summary:focus-visible {
    outline-offset: -2px;
}

.product-quantity-control:has(:focus-visible) {
    outline: 2px solid var(--search-action);
    outline-offset: 2px;
}

@media (forced-colors: active) {
    .search-content-wrapper .form-check-input {
        appearance: auto;
    }

    .search-content-wrapper :is(button, input, select, summary):focus-visible,
    .search-filters-heading h2:focus-visible,
    .search-filters-panel .select2-selection:focus-visible,
    .search-filters-panel .select2-container--focus .select2-selection,
    .product-quantity-control:has(:focus-visible) {
        outline-color: Highlight;
    }
}

.search-filter-group .form-check-label {
    flex: 1;
    padding: .65rem 0;
    cursor: pointer;
    font-size: .9rem;
}

.search-filters-panel .select2-container .select2-selection--multiple {
    min-height: 44px;
    padding-top: 7px;
    border-color: #ced4da;
    border-radius: .6rem;
}

.search-filters-panel .select2-selection--multiple .select2-selection__choice {
    max-width: calc(100% - 5px);
    white-space: normal;
    overflow-wrap: anywhere;
}

.search-filters-footer {
    padding: 1rem 1rem max(1rem, env(safe-area-inset-bottom));
    border-top: 1px solid var(--search-border);
}

.search-filters-footer .btn,
.search-open-filters {
    min-height: 44px;
}

@media (min-width: 992px) {
    .search-layout {
        grid-template-columns: 250px minmax(0, 1fr);
        align-items: start;
        padding-top: 1rem;
    }

    .search-filters-panel {
        position: sticky;
        top: calc(var(--search-header-height, 230px) + 1rem);
        z-index: auto;
        width: 100%;
        height: auto;
        max-height: calc(100vh - var(--search-header-height, 230px) - 2rem);
        max-height: calc(100dvh - var(--search-header-height, 230px) - 2rem);
        border: 1px solid var(--search-border);
        border-radius: .75rem;
        visibility: visible !important;
        transform: none !important;
    }

    .search-layout .search-results-toolbar {
        margin-top: 0;
    }
}

.search-results-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem 1rem;
    align-items: flex-start;
    margin: 1rem 0 1.25rem;
    padding: .85rem;
    border: 1px solid var(--search-border);
    border-radius: .75rem;
    background: #fff;
}

.search-toolbar-group {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.search-toolbar-group legend {
    float: none;
    width: auto;
    margin-bottom: .5rem;
    color: #42533d;
    font-size: .85rem;
    font-weight: 700;
}

.search-order-controls {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: .5rem;
}

.search-order-controls .form-select,
.search-presentation-options summary,
.search-presentation-group #toggle-view {
    min-height: var(--store-tool-height);
    border-radius: var(--store-tool-radius);
}

.search-order-group {
    flex: 1 1 280px;
}

.search-presentation-group {
    flex: 1 1 260px;
}

.search-visualization-controls {
    display: flex;
    align-items: flex-start;
    gap: var(--store-tool-gap);
}

.search-presentation-options {
    flex: 1;
    min-width: 0;
}

.search-presentation-options summary {
    padding: .65rem .75rem;
    border: 1px solid var(--search-border);
    color: #42533d;
    background: #fff;
    cursor: pointer;
    font-size: .85rem;
    font-weight: 700;
}

.search-presentation-controls {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem 1rem;
    align-items: center;
    min-height: 44px;
    padding-top: .5rem;
}

.search-presentation-options:not([open]) > .search-presentation-controls {
    display: none;
}

.search-presentation-controls .form-check {
    display: flex;
    gap: .5rem;
    align-items: center;
    min-height: 44px;
    margin-bottom: 0;
}

.search-presentation-controls .form-check-label {
    cursor: pointer;
    font-size: .9rem;
}

.search-presentation-group #toggle-view {
    min-width: var(--store-tool-height);
    margin-left: auto;
}

.search-presentation-group #toggle-view[aria-pressed="true"] {
    border: 2px solid var(--search-action);
    color: var(--search-action);
    background: var(--search-background);
}

@media (max-width: 767.98px) {
    .search-results-toolbar {
        gap: 1rem;
        padding: .85rem;
    }

    .search-toolbar-group {
        flex-basis: 100%;
    }

    .search-presentation-group {
        padding-top: .75rem;
        border-top: 1px solid #edf1eb;
    }
}

.search-active-filters,
.search-active-filter-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .5rem;
}

.search-active-filters {
    margin-bottom: 1.25rem;
}

.search-active-filters-label {
    color: #42533d;
    font-size: .85rem;
    font-weight: 700;
}

.search-active-filter-list {
    flex: 1;
    min-width: 0;
}

.search-filter-chip {
    display: inline-flex;
    gap: .65rem;
    align-items: center;
    min-height: 44px;
    max-width: 100%;
    padding: .4rem .75rem;
    border: 1px solid #c7dca9;
    border-radius: 1.25rem;
    color: #36531b;
    background: #f1f7e9;
    font-size: .85rem;
    text-align: left;
    overflow-wrap: anywhere;
}

.search-filter-chip span {
    font-size: 1.2rem;
    line-height: 1;
}

.search-filter-chip:hover {
    border-color: var(--primary-dark);
    background: #e6f0d8;
}

.search-clear-filters {
    min-height: 44px;
    color: #42533d;
    font-size: .85rem;
    text-decoration: underline;
}

.search-clear-filters:hover {
    color: #36531b;
    background: #f1f7e9;
}

.search-filter-chip:focus-visible,
.search-clear-filters:focus-visible {
    outline: 2px solid var(--primary-dark);
    outline-offset: 3px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
#product-container {
    width: 100%;
    margin-right: 0;
    margin-left: 0;
    padding-right: 0;
    padding-left: 0;
    display: flex;
    flex-wrap: wrap;
}

.offline-sync-card {
    position: fixed;
    left: .65rem;
    bottom: .65rem;
    z-index: 1080;
    width: min(280px, calc(100vw - 1.3rem));
    gap: .5rem;
    align-items: center;
    padding: .5rem .65rem;
    color: #243746;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid #dce9e8;
    border-left: 3px solid #0d8f87;
    border-radius: 9px;
    box-shadow: 0 5px 16px rgba(25, 55, 70, 0.14);
    backdrop-filter: blur(8px);
}

#offlineCatalogSyncStatus {
    top: auto !important;
    right: auto !important;
    bottom: .65rem !important;
    left: .65rem !important;
    margin: 0 !important;
    transform: none;
}

.offline-sync-icon {
    display: grid;
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    place-items: center;
    color: #fff;
    background: #0d8f87;
    border-radius: 7px;
    font-size: .75rem;
}

.offline-sync-content {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    gap: 0.15rem;
}

.offline-sync-content .sync-title {
    font-size: .76rem;
    line-height: 1.15;
}

.offline-sync-content .sync-message {
    color: #65757f;
    font-size: .68rem;
    line-height: 1.2;
}

.offline-sync-progress {
    height: 2px;
    margin-top: .2rem;
    overflow: hidden;
    background: #e5efee;
    border-radius: 999px;
}

.offline-sync-progress span {
    display: block;
    width: 35%;
    height: 100%;
    background: #0d8f87;
    border-radius: inherit;
    animation: offline-sync-progress 1.2s ease-in-out infinite;
}

.offline-sync-card[data-state="warning"] {
    border-left-color: #e3a008;
}

.offline-sync-card[data-state="warning"] .offline-sync-icon {
    background: #e3a008;
}

.offline-sync-card[data-state="success"] {
    border-left-color: #36a269;
}

.offline-sync-card[data-state="success"] .offline-sync-icon {
    background: #36a269;
}

.similar-product-card {
    background: linear-gradient(180deg, #fff 0%, #f8fbfb 100%);
    box-shadow: 0 7px 22px rgba(30, 65, 75, 0.11);
    transition: transform .2s ease, box-shadow .2s ease;
}

.similar-product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(30, 65, 75, 0.17);
}

.similar-product-info {
    width: 100%;
    color: inherit;
}

.similar-product-image {
    display: grid;
    width: 132px;
    height: 132px;
    margin: 0 auto .65rem;
    place-items: center;
    background: #fff;
    border: 1px solid #edf2f2;
    border-radius: 14px;
}

.similar-product-image img {
    width: 94%;
    height: 94%;
    object-fit: contain;
}

.similar-product-code {
    color: #78858c;
    font-weight: 600;
}

.similar-product-name {
    display: block;
    min-height: 2.6em;
    margin-top: .2rem;
    font-weight: 700;
    line-height: 1.3;
}

.similar-product-price {
    display: block;
    margin-top: .45rem;
    color: #263b45;
    font-size: 1.15rem;
}

.similar-stock {
    display: inline-block;
    margin-top: .45rem;
    padding: .3rem .6rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
}

.similar-stock.is-available {
    color: #17653d;
    background: #e7f7ee;
}

.similar-stock.is-empty {
    color: #885c08;
    background: #fff3d7;
}

.similar-quantity-control {
    display: grid;
    grid-template-columns: 42px 1fr 42px;
    align-items: stretch;
    overflow: hidden;
    background: #f0f7f6;
    border: 1px solid #cfe3e1;
    border-radius: 12px;
}

.similar-quantity-control button {
    border: 0;
    color: #087f78;
    background: transparent;
    font-size: .9rem;
}

.similar-quantity-control button:hover {
    color: #fff;
    background: #0d8f87;
}

.similar-quantity-control label {
    margin: 0;
    padding: .3rem .2rem;
    border-right: 1px solid #cfe3e1;
    border-left: 1px solid #cfe3e1;
}

.similar-quantity-control label span {
    display: block;
    color: #77868c;
    font-size: .65rem;
    font-weight: 600;
    text-transform: uppercase;
}

.similar-quantity {
    width: 100%;
    padding: 0;
    color: #263b45;
    background: transparent;
    border: 0;
    outline: 0;
    text-align: center;
    font-size: 1.05rem;
    font-weight: 700;
}

#similarProductsModal {
    z-index: 1070;
}

#reduceQuantityModal {
    z-index: 1120 !important;
}

.similar-quantity-control button:disabled { color: #a9b5af; background: #e8eeeb; cursor: not-allowed; }

.similar-products-modal { overflow: hidden; box-shadow: 0 18px 55px rgba(26, 55, 45, .2); }
.similar-products-modal .modal-body { position: relative; }
.similar-products-loading { position: absolute; z-index: 10; inset: 0; align-items: center; justify-content: center; flex-direction: column; gap: .75rem; color: var(--primary-dark); background: rgba(255, 255, 255, .82); backdrop-filter: blur(2px); }
.similar-products-loading:not(.d-none) { display: flex; }
.similar-products-swiper { padding-top: .5rem !important; }
.similar-products-nav { display: grid; width: 2.35rem; height: 2.35rem; padding: 0; place-items: center; border: 1px solid rgba(255, 255, 255, .5); border-radius: 50%; color: #fff; background: rgba(255, 255, 255, .14); transition: background .2s ease, opacity .2s ease; }
.similar-products-nav:hover { background: rgba(255, 255, 255, .28); }
.similar-products-nav.swiper-button-disabled { opacity: .35; }
.similar-products-nav.swiper-button-lock { display: none; }
.similar-products-swiper .swiper-pagination-bullet-active { background: var(--primary); }
.similar-cart-status { justify-content: space-between; }
.similar-cart-status .badge { margin-left: auto; }

#articleInfoModal {
    z-index: 1090 !important;
}

@keyframes offline-sync-progress {
    from {
        transform: translateX(-110%);
    }

    to {
        transform: translateX(300%);
    }
}

@media (max-width: 768px) {
    .search-filter-group .form-select,
    .search-order-controls .form-select,
    .search-filters-panel .select2-search__field {
        font-size: 1rem;
    }

    .product-list-view .search-product-shell {
        margin-right: 0;
        margin-left: 0;
    }

}

@media (max-width: 576px) {
    .offline-sync-card {
        right: auto;
        bottom: .5rem;
        left: .5rem;
        width: min(250px, calc(100vw - 1rem));
    }

    #offlineCatalogSyncStatus {
        right: auto !important;
        bottom: .5rem !important;
        left: .5rem !important;
    }

    .search-content-wrapper>.container {
        padding-right: 0.65rem;
        padding-left: 0.65rem;
    }

    #product-container {
        --bs-gutter-x: 0.75rem;
        --bs-gutter-y: 0.9rem;
    }

    .product-list-view .product-image-wrapper {
        min-height: 135px;
        border-right: 0 !important;
    }

    .product-list-view .search-product-shell>.col-12 {
        border-top: 1px solid #edf0f3;
    }

}
