.clerk-search-container {
    position: relative;
}

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

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

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

img.clerk-product-badges {
    aspect-ratio: auto;
}

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

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

.clerk-product-badge {
    max-width: 42px;
    height: 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: 80px;
    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 #333;
    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;
}

.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 {
    .products-grid .products.list .product-item {
        border: 0px !important;
        border-right: 0px !important;
        border-left: 0px !important;
        border-bottom: 0px !important;
    }

    .products.list .product-item {
        border: 0px !important;
        border-right: 0px !important;
        border-left: 0px !important;
        border-bottom: 0px !important;
    }

    .products-grid .products.list .product-item:nth-child(2n) {
        border: 0px !important;
        border-right: 0px !important;
        border-left: 0px !important;
        border-bottom: 0px !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 img {
    max-height: 120px;
    width: 100%;
    height: auto;
    object-fit: contain;
}

.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: #333;
    text-decoration: none;
}

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

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

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

.clerk-product-extra span {
    font-weight: 600;
}

.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: #417505;
}

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

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

.clerk-product-availability .availability-text {
    font-style: italic;
}

.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-qty.control {
    display: flex;
    align-items: center;
    justify-content: center;
}

.clerk-product-qty .product-item-qty__minus,
.clerk-product-qty .product-item-qty__plus,
.clerk-product-qty .product-item-add-to-box__minus,
.clerk-product-qty .product-item-add-to-box__plus {
    text-decoration: none;
    box-shadow: none;
    background: none;
    border: 0;
    display: block;
    padding: 0 10px;
    cursor: pointer;
    opacity: 1;
}

.clerk-product-qty .product-item-qty__minus:after,
.clerk-product-qty .product-item-qty__plus:after,
.clerk-product-qty .product-item-add-to-box__minus:after,
.clerk-product-qty .product-item-add-to-box__plus:after {
    font-size: 12px;
    font-weight: 700;
    color: #2d473a;
    font-family: 'Royal_Unibrew_Icons';
    text-align: center;
}

.clerk-product-qty .product-item-qty__plus:after,
.clerk-product-qty .product-item-add-to-box__plus:after {
    content: '\e9d6';
}

.clerk-product-qty .product-item-qty__minus:after,
.clerk-product-qty .product-item-add-to-box__minus:after {
    content: '\e9c0';
}

.clerk-product-qty .product-item-qty__minus span,
.clerk-product-qty .product-item-qty__plus span,
.clerk-product-qty .product-item-add-to-box__minus span,
.clerk-product-qty .product-item-add-to-box__plus span {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.clerk-product-qty .product-item-qty__input.input-text.qty {
    border: 1px solid #2d473a;
    border-radius: 1px;
    font-family: 'Dinot', 'Dinot';
    font-size: 14px;
    width: 45px;
    padding: 0;
    text-align: center;
    background: transparent;
    height: 28px;
}

.clerk-add-to-cart {
    width: 100%;
    padding: 8px 12px;
    background: #e8e0ca;
    color: #2a2928;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 400;
    transition: opacity 0.2s ease, background 0.2s ease;
}

.clerk-add-to-cart:hover {
    background: #ede3c7;
    color: #2a2928;
}

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

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

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

.clerk-show-all-btn:hover {
    background-color: #8a7b50;
}

/* 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: #8b7332;
    box-shadow: 0 2px 8px rgba(123, 117, 0, 0.19);
}

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

.clerk-story-image img {
    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: #8b7332;
}

.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;
    text-decoration: none;
    cursor: pointer;
}

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

.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;
    text-decoration: none;
}

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

.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: 1200px) {
    .clerk-search-products__grid .products.list.product-items {
        grid-template-columns: repeat(4, 1fr);
    }

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

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

    .clerk-search-overlay__content {
        top: 130px;
        width: 95%;
        max-height: calc(100vh - 100px);
    }
}

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

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

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

    .clerk-search-category-list {
        max-height: 70px;
        list-style: none;
        margin: 0;
        padding: 0;
        overflow-y: auto;
    }

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

    .clerk-search-products {
        padding: 8px;
    }
}

/* --- 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 #A39260;
        border-radius: 4px;
        font-size: 16px;
        outline: none;
        box-sizing: border-box;
        font-family: inherit;
    }

    .clerk-search-overlay__input:focus {
        border-color: #8a7b4f;
        box-shadow: 0 0 0 3px rgba(163, 146, 96, 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;
    }
}
