.clerk-search-container {
    position: relative;

    .products-grid .product-item {
        padding: 0 !important;
    }
}

.clerk-search-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 121;
    display: none;
    pointer-events: none;
}

.clerk-search-overlay .product-item .stock-availability {
    display: initial !important;
    top: -2px;
}

.clerk-search-overlay.is-visible {
    display: block;
    pointer-events: auto;
}

.clerk-search-overlay__backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: transparent;
    pointer-events: auto;
}

.clerk-search-overlay__content {
    position: absolute;
    top: 120px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 1400px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    pointer-events: auto;
}

.clerk-search-loader {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 60px;
}

.clerk-search-loader__spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #003f7b;
    border-radius: 50%;
    animation: clerk-spin 1s linear infinite;
}

@keyframes clerk-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.clerk-search-results {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.clerk-search-sidebar {
    width: 25%;
    min-width: 200px;
    max-width: 300px;
    padding: 24px;
    border-left: 1px solid #e0e0e0;
    overflow-y: auto;
    background: #fff;
    flex-shrink: 0;
    align-self: stretch;
}

.clerk-search-products {
    flex: 1;
    padding: 24px 24px 10px;
    overflow-y: auto;

    .page-header a {
        color: unset !important;
    }
}

.clerk-search-products__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.clerk-search-products__count {
    font-size: 14px;
    color: #666;
}

.clerk-search-products__grid {
    overflow-y: auto;
    max-height: calc(100vh - 330px);
}

.clerk-search-products__grid .products.list.product-items {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.clerk-search-products__grid .product-item {
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

.clerk-search-products__grid .clerk-search-product {
    display: flex;
    flex-direction: column;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: #fff;
    height: 100%;
    box-sizing: border-box;
}

.clerk-product-row {
    margin-bottom: 8px;
    text-align: center;
}

.clerk-product-row:last-child {
    margin-bottom: 0;
}

.clerk-product-image {
    position: relative;
}

.clerk-product-image img {
    aspect-ratio: 1;
    width: 100%;
    height: auto;
    object-fit: contain;
}

.clerk-product-badges {
    position: absolute;
    top: 0;
    left: 0;
    max-width: 42px;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

img.clerk-product-badge {
    aspect-ratio: auto !important;
}

.clerk-product-badge {
    max-width: 35px;
    height: auto;
}

.clerk-product-badges--top-left {
    left: 0;
}

.clerk-product-badges--top-right {
    right: 0;
}

.clerk-product-name {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    min-height: 34px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.clerk-product-name a {
    color: #003f7b !important;
    text-decoration: none;
    text-transform: uppercase;
}

.clerk-product-name a:hover {
    color: #003f7b;
    text-decoration: underline;
}

.clerk-product-package {
    font-size: 11px;
    color: #666;
}

.clerk-product-availability {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

.clerk-product-availability .stock-availability {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.clerk-product-availability .stock-availability-g {
    background: #7ED321;
}

.clerk-product-availability .stock-availability-y {
    background: #FFCA33;
}

.clerk-product-availability .stock-availability-r {
    background: #D0021B;
}

.clerk-product-availability .availability-text {
    text-transform: uppercase;
}

.clerk-product-price {
    font-size: 14px;
    font-weight: 700;
}

.clerk-product-qty {
    display: flex;
    align-items: center;
    justify-content: center;
}

.clerk-product-qty .product-item-add-to-box__control {
    display: flex;
    align-items: center;
    justify-content: center;
}

.clerk-product-qty .product-item-add-to-box__minus,
.clerk-product-qty .product-item-add-to-box__plus {
    width: 30px;
    height: 30px;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #003f7b;
}

.clerk-product-qty .product-item-add-to-box__input .input-text.qty {
    font-size: 14px;
    width: 45px;
    padding: 0;
    text-align: center;
    background: transparent;
    height: 30px;
}

.clerk-add-to-cart {
    width: 100%;
    background: #003f7b;
    color: #fff;
    border: none;
    border-radius: 0;
    cursor: pointer;
    font-weight: 600;
    text-transform: uppercase;
    transition: opacity 0.2s ease, background 0.2s ease;
    padding: 10px !important;
    height: auto !important;
    font-size: 1.2rem !important;
}

.clerk-add-to-cart:hover {
    background: #002d5a;
}

.clerk-add-to-cart.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

/* Stories section */
.clerk-search-stories {
    margin-top: 24px;
    padding: 24px;
    border-top: 1px solid #e0e0e0;
}

.clerk-search-stories__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.clerk-search-stories__count {
    font-size: 14px;
    color: #666;
}

.clerk-search-stories__grid {
    overflow-y: auto;
}

.clerk-search-stories__grid .stories.list.story-items {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.clerk-search-stories__grid .story-item {
    width: 100%;
    margin: 0;
    padding: 0;
}

.clerk-search-stories__grid .clerk-search-story {
    display: flex;
    flex-direction: column;
    padding: 12px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    background: #fff;
    height: 100%;
    box-sizing: border-box;
    text-decoration: none;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.clerk-search-stories__grid .clerk-search-story:hover {
    border-color: #003f7b;
    box-shadow: 0 2px 8px rgba(0, 63, 123, 0.12);
}

.clerk-story-image {
    text-align: center;
    margin-bottom: 8px;
}

.clerk-story-image img {
    max-height: 120px;
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 4px;
}

.clerk-story-info {
    text-align: center;
}

.clerk-story-name {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.3;
    color: #333;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.clerk-search-story:hover .clerk-story-name {
    color: #003f7b;
}

.clerk-search-section {
    margin-bottom: 24px;
}

.clerk-search-section:last-child {
    margin-bottom: 0;
}

.clerk-search-section__title {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    color: #666;
    margin: 0 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid #e0e0e0;
}

.clerk-search-suggestion-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.clerk-search-suggestion-item {
    margin-bottom: 4px;
}

.clerk-search-suggestion-link {
    display: block;
    padding: 6px 0;
    color: #333 !important;
    text-decoration: none !important;
    text-transform: none !important;
    cursor: pointer;
}

.clerk-search-suggestion-link:hover {
    color: #000 !important;
    text-decoration: underline !important;
}

.clerk-search-category-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.clerk-search-category-item {
    margin-bottom: 8px;
}

.clerk-search-category-link {
    display: block;
    padding: 6px 0;
    color: #333 !important;
    text-decoration: none !important;
    text-transform: none !important;
}

.clerk-search-category-link:hover {
    color: #000 !important;
    text-decoration: underline !important;
}

.clerk-search-show-all {
    text-align: center;
    padding: 12px 0 5px;
}

.clerk-show-all-btn {
    background-color: #009EE0;
    color: #fff;
    border: none;
    padding: 10px 24px;
    cursor: pointer;
    font-size: 14px;
    border-radius: 3px;
}

.clerk-show-all-btn:hover {
    background-color: #0085be;
}

.clerk-search-no-results {
    padding: 60px;
    text-align: center;
    color: #666;
}

.clerk-search-no-results p {
    margin: 0;
    font-size: 16px;
}

body.clerk-search-active {
    overflow: hidden;
}

@media (max-width: 1440px) {
    .clerk-search-products__grid .products.list.product-items {
        grid-template-columns: repeat(4, 1fr);
    }
    .clerk-search-stories__grid .stories.list.story-items {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (max-width: 1200px) {
    .clerk-search-products__grid .products.list.product-items {
        grid-template-columns: repeat(3, 1fr);
    }
    .clerk-search-stories__grid .stories.list.story-items {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 992px) {
    .clerk-search-products__grid .products.list.product-items {
        grid-template-columns: repeat(2, 1fr);
    }
    .clerk-search-stories__grid .stories.list.story-items {
        grid-template-columns: repeat(2, 1fr);
    }
    .clerk-search-products {
        padding: 8px;
    }
    .clerk-search-products__grid .clerk-search-product {
        padding: 6px;
    }
    .clerk-search-products__grid {
        zoom: 0.9;
    }
    .clerk-search-stories {
        padding: 16px;
    }
}

@media (max-width: 768px) {
    .clerk-search-products__grid .products.list.product-items {
        grid-template-columns: repeat(2, 1fr);
    }

    .clerk-search-stories__grid .stories.list.story-items {
        grid-template-columns: repeat(2, 1fr);
    }
    .clerk-search-overlay__content {
        top: 170px;
        width: 95%;
        max-height: calc(100vh - 200px);
    }

    .clerk-search-products__grid {
        overflow-y: auto;
        max-height: calc(100vh - 420px);
    }

    .clerk-search-results {
        flex-direction: column;
    }

    .clerk-search-sidebar {
        display: none;
    }
}

@media (max-width: 500px) {
    .clerk-search-overlay__content {
        top: 170px;
        width: 95%;
        max-height: calc(100vh - 200px);
    }

    .clerk-search-products__grid {
        overflow-y: auto;
        max-height: calc(100vh - 420px);
    }

    .clerk-search-results {
        flex-direction: column;
    }

    .clerk-search-sidebar {
        display: none;
    }

    .clerk-search-products__grid .products.list.product-items {
        grid-template-columns: repeat(2, 1fr);
    }

    .clerk-search-stories__grid .stories.list.story-items {
        grid-template-columns: repeat(2, 1fr);
    }

    .clerk-search-container .products-grid .product-item-info .tocart {
        white-space: normal !important;
        padding: 8px 16px !important;
        padding-right: 8px !important;
        padding-left: 8px !important;
        height: auto !important;
    }
}

@media (max-width: 400px) {
    .clerk-search-overlay__content {
        top: 195px;
        width: 95%;
        max-height: calc(100vh - 200px);
    }

    .clerk-search-products__grid .products.list.product-items {
        grid-template-columns: repeat(2, 1fr);
        gap: 4px;
        zoom: 0.85;
    }

    .clerk-search-stories__grid .stories.list.story-items {
        grid-template-columns: repeat(1, 1fr);
    }
}

/* --- Mobile: full-screen popup overlay --- */

.clerk-search-overlay__header {
    display: none;
}

@media (max-width: 768px) {
    .clerk-search-overlay.is-visible .clerk-search-overlay__backdrop {
        background: rgba(0, 0, 0, 0.5);
    }

    .clerk-search-overlay__content {
        position: fixed;
        top: 12px;
        left: 12px;
        right: 12px;
        bottom: 12px;
        transform: none;
        width: auto;
        max-width: none;
        max-height: none;
        border-radius: 6px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .clerk-search-overlay__header {
        display: flex;
        align-items: center;
        padding: 12px;
        gap: 12px;
        border-bottom: 1px solid #e0e0e0;
        background: #fff;
        flex-shrink: 0;
        border-radius: 6px 6px 0 0;
    }

    .clerk-search-overlay__search-wrapper {
        flex: 1;
    }

    .clerk-search-overlay__input {
        width: 100%;
        padding: 10px 12px;
        border: 2px solid #009EE0;
        border-radius: 4px;
        font-size: 16px;
        outline: none;
        box-sizing: border-box;
        font-family: inherit;
    }

    .clerk-search-overlay__input:focus {
        border-color: #0080b8;
        box-shadow: 0 0 0 3px rgba(0, 158, 224, 0.2);
    }

    .clerk-search-overlay__close {
        background: none;
        border: none;
        font-size: 28px;
        color: #333;
        cursor: pointer;
        padding: 4px 8px;
        line-height: 1;
        flex-shrink: 0;
    }

    .clerk-search-results {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .clerk-search-products__grid {
        max-height: none;
        overflow-y: visible;
    }

    .clerk-search-show-all {
        flex-shrink: 0;
        border-top: 1px solid #e0e0e0;
        background: #fff;
    }

    .clerk-search-loader {
        flex: 1;
    }

    .clerk-search-no-results {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .clerk-product-badge {
        max-width: 35px;
        height: auto;
    }
}
