/**
 * Alza-style Search Autocomplete Styles
 */

/* Search Container */
.search-container {
    position: relative;
    width: 100%;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-field-shell {
    position: relative;
    flex: 1 1 auto;
    min-width: 0;
}

.search-field-icon {
    display: none;
}

#search-input {
    width: 100%;
    padding: 12px 15px;
    font-size: 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.3s ease;
}

#search-input:focus {
    outline: none;
    border-color: #000;
    box-shadow: 0 0 0 0.2rem rgba(0, 0, 0, 0.15);
}

.search-clear-btn {
    display: none;
}

.search-clear-btn {
    position: absolute;
    top: 50%;
    right: 8px;
    width: 30px;
    height: 30px;
    transform: translateY(-50%);
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 999px;
    background: #f1f3f5;
    color: #495057;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.search-clear-btn:hover {
    background: #e9ecef;
    color: #212529;
}

.catalog-search-inline-controls {
    align-items: flex-end;
    gap: 8px;
    margin-top: 8px;
    padding: 8px 10px;
    border: 1px solid #edf0f2;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
    min-width: 0;
}

.catalog-search-control {
    display: flex;
    flex: 1 1 130px;
    flex-direction: column;
    gap: 3px;
    margin: 0;
    min-width: 120px;
}

.catalog-search-control > span {
    color: #6c757d;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1;
    text-transform: uppercase;
}

.catalog-search-control .form-select,
.catalog-search-control .form-control {
    min-height: 32px;
    font-size: 13px;
}

.catalog-search-price-control {
    flex: 0 0 92px;
    min-width: 92px;
}

.catalog-search-history-control {
    flex: 0 1 176px;
    min-width: 150px;
}

.catalog-history-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 32px;
    padding: 5px 8px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    background: #fff;
    color: #212529;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.05;
    max-width: 100%;
    overflow: hidden;
}

.catalog-history-toggle input {
    flex: 0 0 auto;
    margin: 0;
}

.catalog-history-toggle span {
    min-width: 0;
    overflow-wrap: anywhere;
}

.catalog-price-slider-control {
    flex: 2 1 300px;
    min-width: 260px;
}

.catalog-price-slider-values {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    color: #212529;
    font-size: 12px;
    line-height: 1;
}

.catalog-price-slider {
    position: relative;
    height: 30px;
    margin-top: 2px;
    cursor: pointer;
}

.catalog-price-slider-track,
.catalog-price-slider-range {
    position: absolute;
    top: 14px;
    right: 0;
    left: 0;
    height: 5px;
    border-radius: 999px;
}

.catalog-price-slider-track {
    background: #dee2e6;
}

.catalog-price-slider-range {
    background: #ef233c;
}

.catalog-price-slider input[type="range"] {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 30px;
    margin: 0;
    background: transparent;
    pointer-events: none;
    opacity: 0;
    appearance: none;
    -webkit-appearance: none;
    accent-color: #ef233c;
}

.catalog-price-slider input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.catalog-price-slider input[type="range"]::-moz-range-track,
.catalog-price-slider input[type="range"]::-moz-range-progress {
    height: 4px;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.catalog-price-slider input[type="range"]::-webkit-slider-thumb {
    width: 1px;
    height: 1px;
    border: 0;
    background: transparent;
    appearance: none;
    -webkit-appearance: none;
}

.catalog-price-slider input[type="range"]::-moz-range-thumb {
    width: 1px;
    height: 1px;
    border: 0;
    background: transparent;
}

.catalog-price-slider input[type="range"]:focus {
    outline: none;
}

.catalog-price-slider-handle {
    position: absolute;
    top: 16px;
    z-index: 5;
    width: 16px;
    height: 16px;
    border: 2px solid #ef233c;
    border-radius: 50%;
    background: #fff;
    cursor: grab;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 8px rgba(239, 35, 60, 0.28);
    touch-action: none;
}

.catalog-price-slider-handle:active {
    cursor: grabbing;
}

.catalog-price-slider-handle:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(239, 35, 60, 0.18), 0 2px 8px rgba(239, 35, 60, 0.28);
}

.catalog-search-clear {
    flex: 0 0 auto;
    min-height: 32px;
    white-space: nowrap;
}

@media (min-width: 768px) {
    .search-container[data-catalog-live-filter="1"] #search-results,
    .search-container[data-catalog-live-filter="1"] #search-results.show {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }
}

.catalog-matched-categories {
    border: 1px solid #e9ecef;
    border-radius: 12px;
    background: #fff;
    padding: 12px;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.04);
}

.catalog-filter-summary {
    border: 1px solid #d7e7ff;
    border-left: 4px solid #0d6efd;
    background: #f8fbff;
}

.catalog-filter-summary-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-weight: 800;
}

.catalog-filter-summary-title > span {
    flex: 1 1 auto;
    min-width: 0;
}

.catalog-filter-summary-clear {
    flex: 0 0 auto;
    margin-left: auto;
}

.catalog-filter-summary-list {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.catalog-filter-summary-chip {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 4px 9px;
    border-radius: 999px;
    background: #fff;
    color: #0b5ed7;
    font-size: 12px;
    font-weight: 700;
    box-shadow: inset 0 0 0 1px rgba(13, 110, 253, 0.18);
}

#catalog-results-content {
    position: relative;
}

#catalog-results-content.catalog-results-loading {
    opacity: 0.55;
    pointer-events: none;
    transition: opacity 0.16s ease;
}

.catalog-matched-categories-title {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 10px;
    color: #495057;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
}

.catalog-matched-categories-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.catalog-matched-category-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 34px;
    padding: 6px 11px;
    border: 1px solid #dee2e6;
    border-radius: 999px;
    background: #f8f9fa;
    color: #212529;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none;
    transition: border-color 0.18s ease, color 0.18s ease, background-color 0.18s ease;
}

.catalog-matched-category-chip:hover {
    border-color: #ef233c;
    background: #fff5f6;
    color: #ef233c;
}

.catalog-matched-category-chip img {
    width: 18px;
    height: 18px;
    object-fit: contain;
}

/* Results Container */
#search-results {
    position: absolute;
    top: calc(100% + 5px);
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    max-height: var(--search-results-max-height, calc(100dvh - 200px));
    overflow: hidden;
    overscroll-behavior: contain;
    z-index: 1050;
    display: none;
    flex-direction: column;
}

#search-results.show {
    display: flex;
}

.search-source-switcher {
    display: flex;
    gap: 6px;
    padding: 10px 12px;
    border-bottom: 1px solid #e9ecef;
    background: #fff;
    flex-wrap: wrap;
}

.search-source-btn {
    border: 1px solid #dee2e6;
    background: #f8f9fa;
    color: #495057;
    border-radius: 999px;
    padding: 5px 11px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: all 0.2s ease;
}

.search-source-btn:hover {
    border-color: #ef233c;
    color: #ef233c;
    background: #fff5f6;
}

.search-source-btn.active {
    border-color: #ef233c;
    background: #ef233c;
    color: #fff;
}

.search-source-select-wrapper {
    display: none;
}

.search-toolbar {
    background: #fff;
    border-bottom: 1px solid #e9ecef;
    flex-shrink: 0;
}

.search-mobile-summary {
    display: none;
}

.search-filter-backdrop,
.search-filter-modal-header {
    display: none;
}

.search-mobile-filter-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 34px;
    padding: 6px 12px;
    border: 1px solid #ef233c;
    border-radius: 999px;
    background: #ef233c;
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    line-height: 1;
}

.search-mobile-filter-toggle.is-active {
    background: #198754;
    border-color: #198754;
}

.search-mobile-summary-text {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.1;
}

.search-mobile-summary-label {
    color: #6c757d;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
}

.search-mobile-summary-text strong {
    overflow: hidden;
    color: #212529;
    font-size: 13px;
    line-height: 1.15;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-toolbar .search-source-switcher {
    border-bottom: 0;
    padding-bottom: 7px;
}

.search-refine-controls {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 8px 10px;
    padding: 0 12px 10px;
}

.search-filter-row {
    display: flex;
    align-items: flex-end;
    gap: 8px 10px;
    width: 100%;
}

.search-filter-row-main {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(150px, 1fr);
}

.search-filter-row-secondary {
    flex-wrap: wrap;
}

.search-control-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
}

.search-control-group > span {
    color: #6c757d;
    font-size: 11px;
    font-weight: 700;
    line-height: 1;
    text-transform: uppercase;
}

.search-source-select,
.search-sort-select,
.search-availability-select,
.search-price-input {
    height: 32px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    background: #fff;
    color: #212529;
    font-size: 13px;
}

.search-source-select,
.search-sort-select,
.search-availability-select {
    min-width: 155px;
    padding: 0 30px 0 10px;
}

.search-price-range {
    display: flex;
    align-items: center;
    gap: 5px;
}

.search-price-input {
    width: 82px;
    padding: 0 8px;
}

.search-price-apply,
.search-price-reset {
    height: 32px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.search-price-apply {
    border: 1px solid #ef233c;
    background: #ef233c;
    color: #fff;
    padding: 0 10px;
}

.search-price-reset {
    width: 32px;
    border: 1px solid #dee2e6;
    background: #f8f9fa;
    color: #6c757d;
    font-size: 18px;
    line-height: 1;
}

.search-price-reset:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.search-history-toggle {
    display: inline-flex;
    align-items: center;
    align-self: flex-end;
    gap: 7px;
    min-height: 32px;
    margin: 0;
    padding: 6px 10px;
    border: 1px solid #d1e7dd;
    border-radius: 999px;
    background: #f0fdf4;
    color: #0f5132;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.search-history-toggle input {
    margin: 0;
}

/* Results Grid - Two Columns */
.search-results-grid {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 0;
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Full width when no categories */
.search-results-grid.no-categories {
    grid-template-columns: 1fr;
}

@media (max-width: 768px) {
    .search-field-shell #search-input {
        padding-right: 44px;
    }

    .search-clear-btn.is-visible {
        display: flex;
    }

    .search-results-grid {
        grid-template-columns: 1fr;
    }
    
    .search-categories {
        border-bottom: 1px solid #e0e0e0;
        border-right: none !important;
    }

    html.search-mobile-overlay-open,
    body.search-mobile-overlay-open,
    html.search-mobile-page-locked,
    body.search-mobile-page-locked {
        overflow: auto !important;
    }

    .sticky-header.search-mobile-overlay-host {
        height: auto !important;
        min-height: 0 !important;
        margin-bottom: 0.35rem !important;
        border-bottom: 1px solid #e9ecef !important;
        background: #fff !important;
        box-shadow: none !important;
        overflow: visible !important;
        z-index: 1045 !important;
    }

    .sticky-header.search-mobile-overlay-host::before {
        display: block !important;
    }

    .sticky-header.search-mobile-overlay-host > .container,
    .sticky-header.search-mobile-overlay-host .row {
        height: auto !important;
        min-height: 0 !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        overflow: visible !important;
    }

    .search-container.mobile-search-active {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        z-index: auto !important;
        min-height: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    #search-results.show {
        position: fixed !important;
        top: var(--search-results-mobile-top, calc(var(--app-sticky-navbar-offset, 64px) + 46px)) !important;
        left: var(--search-results-mobile-left, 10px) !important;
        right: var(--search-results-mobile-right, 10px) !important;
        bottom: var(--search-results-mobile-bottom, calc(var(--app-sticky-footer-height, 82px) + 8px)) !important;
        z-index: 1058;
        max-height: var(--search-results-max-height, calc(100vh - var(--app-sticky-navbar-offset, 64px) - var(--app-sticky-footer-height, 82px) - 70px)) !important;
        overflow: hidden;
        overscroll-behavior: contain;
    }

    #search-results.show .search-results-grid {
        min-height: 0;
        max-height: none;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
    }
}

/* Categories Section (Left) */
.search-categories {
    padding: 15px;
    background: #f8f9fa;
    border-right: 1px solid #e0e0e0;
}

.search-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: #6c757d;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.search-category-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.search-category-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    color: #212529;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 14px;
}

.search-category-item:hover {
    background: white;
    color: #000;
    transform: translateX(3px);
}

.search-category-item i {
    font-size: 12px;
    color: #6c757d;
}

/* Products Section (Right) */
.search-products {
    padding: 15px;
}

.search-product-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.search-product-list-item {
    margin-bottom: 8px;
}

.search-product-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
    border: 1px solid #e0e0e0;
    background: white;
}

/* Expanded view - when no categories */
.search-product-item.expanded {
    padding: 16px;
    gap: 12px;
}

.search-product-item:hover {
    border-color: #000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.search-product-item.disabled {
    opacity: 0.6;
    background: #f8f9fa;
}

.search-product-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #212529;
    text-decoration: none;
    gap: 15px;
    min-width: 0;
}

.search-product-media {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

/* Product Image */
.search-product-image {
    width: 60px;
    height: 60px;
    object-fit: contain;
    border-radius: 6px;
    background: #f8f9fa;
    flex-shrink: 0;
}

.search-product-image-placeholder {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 6px;
    color: #6c757d;
    flex-shrink: 0;
}

.search-product-image-placeholder i {
    font-size: 24px;
}

.search-product-link:hover {
    color: #000;
}

.search-product-info {
    flex: 1;
    min-width: 0;
}

.search-product-name {
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* Expanded view - larger name */
.search-product-item.expanded .search-product-name {
    font-size: 15px;
    margin-bottom: 8px;
}

/* Product meta info (SKU, brand, category) */
.search-product-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
    font-size: 12px;
}

.search-product-meta-mobile {
    display: none;
}

.search-product-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: #f8f9fa;
    border-radius: 4px;
    color: #6c757d;
    line-height: 1.2;
}

.search-product-meta span i {
    font-size: 12px;
}

.search-product-sku {
    font-family: 'Courier New', monospace;
    background: #e9ecef !important;
    font-weight: 500;
}

.search-product-brand {
    color: #000 !important;
    background: #e9ecef !important;
}

.search-product-category {
    color: #198754 !important;
    background: #d1e7dd !important;
}

.search-product-history {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-top: 5px;
    padding: 3px 8px;
    border-radius: 999px;
    background: #e7f1ff;
    color: #084298;
    font-size: 11px;
    font-weight: 700;
    line-height: 1.2;
}

/* Product description */
.search-product-description {
    margin-top: 8px;
    font-size: 13px;
    color: #6c757d;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-product-price {
    text-align: right;
    flex-shrink: 0;
}

.search-product-price .price {
    font-size: 16px;
    font-weight: 600;
    color: #198754;
    margin-bottom: 5px;
}

.search-product-price .price-label {
    font-size: 11px;
    color: #6c757d;
    margin-top: -3px;
    margin-bottom: 5px;
}

.search-unit-price-after-discount {
    font-size: 11px;
    color: #495057;
    line-height: 1.25;
    margin: -2px 0 5px;
    white-space: nowrap;
}

.search-unit-price-after-discount strong {
    color: #198754;
    font-weight: 700;
}

/* Expanded view - larger price */
.search-product-item.expanded .search-product-price .price {
    font-size: 18px;
}

.search-product-price .badge {
    font-size: 11px;
    padding: 3px 8px;
}

/* Product Actions */
.search-product-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 8px;
    border-top: 1px solid #e9ecef;
    flex-wrap: wrap;
}

/* Unit Selector */
.unit-selector {
    display: flex;
    gap: 4px;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    overflow: hidden;
    background: white;
}

.unit-btn {
    background: #f8f9fa;
    border: none;
    padding: 6px 12px;
    cursor: pointer;
    transition: all 0.2s;
    color: #495057;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.unit-btn:hover:not(.active) {
    background: #e9ecef;
}

.unit-btn.active {
    background: #000;
    color: white;
}

.unit-btn:first-child {
    border-right: 1px solid #dee2e6;
}

/* Quantity Input */
.quantity-with-conversion {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.search-quantity-price-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.search-discount-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 4px 9px;
    border: 1px solid #dee2e6;
    border-radius: 999px;
    background: #f8f9fa;
    color: #6c757d;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.search-product-price .search-discount-badge {
    margin: 0 0 5px auto;
}

.search-discount-badge.is-active {
    border-color: rgba(25, 135, 84, 0.22);
    background: #e9f7ef;
    color: #198754;
}

.search-discount-badge.is-review {
    border-color: rgba(25, 135, 84, 0.22);
    background: #e9f7ef;
    color: #198754;
}

.quantity-input {
    display: flex;
    align-items: center;
    border: 1px solid #dee2e6;
    border-radius: 6px;
    overflow: hidden;
    background: white;
}

.quantity-input .search-unit-switcher {
    flex: 0 0 82px;
    width: 82px;
    max-width: 82px;
    align-self: stretch;
    min-height: 32px;
    border: 0;
    border-left: 1px solid #dee2e6;
    border-radius: 0;
    background-color: #f8f9fa;
    color: #495057;
    font-size: 12px;
    font-weight: 600;
    padding-top: 6px;
    padding-bottom: 6px;
    padding-left: 8px;
}

.qty-btn {
    background: #f8f9fa;
    border: none;
    padding: 6px 10px;
    cursor: pointer;
    transition: all 0.2s;
    color: #495057;
    display: flex;
    align-items: center;
    justify-content: center;
}

.qty-btn:hover:not(:disabled) {
    background: #e9ecef;
    color: #000;
}

.qty-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.qty-btn i {
    font-size: 14px;
}

.qty-value {
    border: none;
    width: 50px;
    text-align: center;
    padding: 6px 4px;
    font-weight: 500;
    font-size: 14px;
    -moz-appearance: textfield;
}

.qty-value::-webkit-outer-spin-button,
.qty-value::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.qty-value:focus {
    outline: none;
    background: #f8f9fa;
}

.qty-value:disabled {
    background: #e9ecef;
    cursor: not-allowed;
}

.quantity-unit-label {
    align-self: stretch;
    display: inline-flex;
    align-items: center;
    padding: 0 8px;
    border-left: 1px solid #dee2e6;
    border-right: 1px solid #dee2e6;
    background: #f8f9fa;
    color: #495057;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.required-secondary-conversion {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #6c757d;
    font-size: 11px;
    line-height: 1.2;
    white-space: nowrap;
}

/* Add to Cart Button */
.add-to-cart-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.add-to-cart-btn i {
    font-size: 16px;
}

.add-to-cart-btn .spinner-border-sm {
    width: 14px;
    height: 14px;
    border-width: 2px;
}

/* Highlight matched text */
mark {
    background-color: #fff3cd;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 600;
}

/* No Results */
.search-no-results {
    padding: 40px 20px;
    text-align: center;
    color: #6c757d;
}

.search-no-results i {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.search-no-results p {
    margin: 0;
    font-size: 16px;
}

/* Footer - Sticky na spodu */
.search-footer {
    padding: 12px 15px;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
    position: sticky;
    bottom: 0;
    z-index: 10;
    flex-shrink: 0;
}

.search-footer .btn {
    font-size: 14px;
    padding: 8px 16px;
}

/* Scrollbar Styling */
#search-results::-webkit-scrollbar,
.search-results-grid::-webkit-scrollbar {
    width: 8px;
}

#search-results::-webkit-scrollbar-track,
.search-results-grid::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#search-results::-webkit-scrollbar-thumb,
.search-results-grid::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

#search-results::-webkit-scrollbar-thumb:hover,
.search-results-grid::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Loading State */
.search-loading {
    padding: 40px 20px;
    text-align: center;
}

.search-loading .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Toast Notifications */
.search-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 9999;
    opacity: 0;
    transform: translateX(100px);
    transition: all 0.3s ease;
    min-width: 300px;
}

.search-toast.show {
    opacity: 1;
    transform: translateX(0);
}

.search-toast-success {
    border-left: 4px solid #198754;
}

.search-toast-success i {
    color: #198754;
    font-size: 20px;
}

.search-toast-error {
    border-left: 4px solid #dc3545;
}

.search-toast-error i {
    color: #dc3545;
    font-size: 20px;
}

.search-toast span {
    flex: 1;
    font-size: 14px;
    color: #212529;
}

/* Animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#search-results.show {
    animation: fadeIn 0.2s ease;
}

/* Expanded products section */
.search-products.expanded {
    padding: 20px;
}

/* Responsive */
@media (max-width: 768px) {
    html.search-mobile-page-locked,
    body.search-mobile-page-locked {
        overflow: hidden;
        overscroll-behavior: none;
    }

    .sticky-header.search-mobile-overlay-host {
        height: 0 !important;
        min-height: 0 !important;
        margin-bottom: 0 !important;
        border: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
        overflow: visible !important;
        z-index: 8999 !important;
    }

    .sticky-header.search-mobile-overlay-host::before {
        display: none !important;
    }

    .sticky-header.search-mobile-overlay-host > .container,
    .sticky-header.search-mobile-overlay-host .row {
        height: 0 !important;
        min-height: 0 !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        padding-top: 0 !important;
        padding-bottom: 0 !important;
        overflow: visible !important;
    }

    .sticky-header.search-mobile-overlay-host ~ .catalog-content-container {
        position: relative;
        z-index: 1020;
        padding-top: 0;
        transform: none;
    }

    .search-container.mobile-search-active {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 9000;
        min-height: calc(var(--app-sticky-navbar-offset, 64px) + 5px);
        padding: calc(env(safe-area-inset-top, 0px) + 7px) 10px 0;
        background: #fff;
        box-shadow: 0 10px 26px rgba(15, 23, 42, 0.16);
    }

    .search-container.mobile-search-active .search-input-wrapper {
        display: flex;
        align-items: center;
        width: 100%;
    }

    .search-container.mobile-search-active .search-field-shell {
        position: relative;
        display: flex;
        align-items: center;
        width: 100%;
        min-width: 0;
    }

    .search-container.mobile-search-active #search-results {
        position: fixed;
        top: calc(var(--app-sticky-navbar-offset, 64px) + 5px);
        left: 10px;
        right: 10px;
        z-index: 9002;
        touch-action: pan-y;
        overscroll-behavior: contain;
    }

    .search-container.mobile-search-active .search-results-grid {
        touch-action: pan-y;
        overscroll-behavior: contain;
    }

    .search-container.mobile-search-active .search-field-shell #search-input {
        position: relative;
        z-index: 1;
        width: 100%;
        padding-left: 44px !important;
        padding-right: 46px !important;
    }

    .search-container.mobile-search-active .search-field-icon {
        position: absolute;
        top: 50%;
        left: 14px;
        z-index: 3;
        display: inline-flex;
        width: 22px;
        height: 22px;
        transform: translateY(-50%);
        align-items: center;
        justify-content: center;
        color: #495057;
        font-size: 18px;
        line-height: 1;
        pointer-events: none;
    }

    .search-container.mobile-search-active .search-clear-btn.is-visible {
        z-index: 4;
        display: flex;
    }

    .search-container.mobile-search-active .search-mobile-summary {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 8px 10px;
        border-bottom: 1px solid #edf0f2;
        background: #fff;
    }

    .search-container.mobile-search-active #search-results:not(.mobile-filters-open) .search-source-switcher,
    .search-container.mobile-search-active #search-results:not(.mobile-filters-open) .search-refine-controls {
        display: none;
    }

    .search-container.mobile-search-active .search-products > .search-section-title,
    .search-container.mobile-search-active .search-footer {
        display: none;
    }

    .search-container.mobile-search-active #search-results.mobile-filters-open .search-toolbar {
        box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
    }

    .search-toolbar .search-source-switcher {
        padding: 10px;
        border-bottom: 0;
    }

    .search-source-switcher .search-source-btn {
        display: none;
    }

    .search-source-select-wrapper {
        display: flex;
        flex-direction: column;
        gap: 4px;
        width: 100%;
        margin: 0;
    }

    .search-source-select-wrapper > span {
        color: #6c757d;
        font-size: 11px;
        font-weight: 700;
        line-height: 1;
        text-transform: uppercase;
    }

    .search-source-select {
        width: 100%;
        font-size: 16px;
    }

    .search-refine-controls {
        align-items: stretch;
        padding: 0 10px 10px;
    }

    .search-filter-row {
        width: 100%;
    }

    .search-filter-row-main {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .search-control-group,
    .search-price-group {
        width: 100%;
    }

    .search-price-group {
        display: none;
    }

    .search-source-select,
    .search-sort-select,
    .search-availability-select,
    .search-price-input {
        width: 100%;
        font-size: 16px;
    }

    .search-price-range {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto auto;
        width: 100%;
    }

    .search-price-apply {
        padding: 0 9px;
    }

    .search-history-toggle {
        width: 100%;
        justify-content: center;
    }

    .search-product-item {
        min-width: 0;
    }

    .search-product-link {
        display: grid;
        grid-template-columns: 72px minmax(0, 1fr);
        grid-template-areas:
            "media price"
            "info info";
        align-items: start;
        gap: 10px 12px;
        width: 100%;
        min-width: 0;
    }

    .search-product-media {
        grid-area: media;
        width: 72px;
        min-width: 0;
    }

    .search-product-image,
    .search-product-image-placeholder {
        width: 72px;
        height: 72px;
    }

    .search-product-info {
        grid-area: info;
        width: 100%;
        min-width: 0;
    }

    .search-product-price {
        grid-area: price;
        min-width: 0;
        text-align: right;
    }

    .search-product-name {
        width: 100%;
        max-width: 100%;
        -webkit-line-clamp: 3;
    }

    .search-product-description {
        width: 100%;
        max-width: 100%;
        -webkit-line-clamp: 3;
    }

    .search-product-meta-desktop {
        display: none;
    }

    .search-product-meta-mobile {
        display: flex;
        flex-direction: column;
        gap: 4px;
        width: 72px;
        margin-top: 0;
        font-size: 10px;
    }

    .search-product-meta-mobile span {
        width: 100%;
        justify-content: center;
        padding: 3px 4px;
        text-align: center;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .search-unit-price-after-discount {
        white-space: normal;
    }

    .search-product-actions {
        flex-direction: column;
    }

    .search-quantity-price-row {
        width: 100%;
    }
    
    .quantity-input {
        width: 100%;
        flex: 1 1 auto;
    }

    .quantity-input .search-unit-switcher {
        flex-basis: 84px;
        width: 84px;
        max-width: 84px;
        min-height: 46px;
        font-size: 14px;
        font-weight: 800;
        padding-left: 10px;
    }

    .search-discount-badge {
        flex: 0 0 auto;
    }

    .add-to-cart-btn {
        width: 100%;
    }
    
    .search-toast {
        right: 10px;
        left: 10px;
        min-width: auto;
    }
    
}

@media (max-width: 768px) {
    html.search-mobile-page-locked,
    body.search-mobile-page-locked,
    html.search-mobile-overlay-open,
    body.search-mobile-overlay-open {
        overflow: auto !important;
        overscroll-behavior: auto !important;
    }

    .sticky-header.search-mobile-overlay-host {
        position: sticky !important;
        top: var(--app-sticky-navbar-offset, 54px) !important;
        transform: translate3d(0, var(--app-visual-viewport-offset-top, 0px), 0) !important;
        height: auto !important;
        min-height: 0 !important;
        margin-bottom: 0.35rem !important;
        border-bottom: 1px solid #e9ecef !important;
        background: #fff !important;
        box-shadow: none !important;
        overflow: visible !important;
        z-index: 1045 !important;
    }

    .sticky-header.search-mobile-overlay-host::before {
        display: block !important;
    }

    .sticky-header.search-mobile-overlay-host > .container,
    .sticky-header.search-mobile-overlay-host .row {
        height: auto !important;
        min-height: 0 !important;
        margin-top: 0 !important;
        margin-bottom: 0 !important;
        overflow: visible !important;
    }

    .sticky-header.search-mobile-overlay-host ~ .catalog-content-container {
        z-index: 1020 !important;
        padding-top: 0 !important;
        transform: none !important;
    }

    .search-container.mobile-search-active {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        z-index: auto !important;
        min-height: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
    }
}
