/*
* Component: jmg:search.title (rkd-header-search-v5)
* Structure:
* 1. General Styles
* 2. Desktop Styles (min-width: 768px)
* 3. Mobile Styles (max-width: 767px)
*/

/* --- 1. General Styles --- */

.jmg-search-hl {
    /* font-weight: 1000;
    font-size: large; */
}

.rkd-header-search {
    position: relative;
    border: 1px solid #E8DFC5;
    border-radius: 21px;
    background-color: #fff;
    line-height: 28px;
}

.rkd-mobile-header__search-container.js-mobile-header-search-container {
    border: 1px solid #E8DFC5;
    border-radius: 21px;
    background-color: #fff;
    line-height: 28px;
}

.jmg-input-slot {
    position: relative;
}

.rkd-header-search .jmg-search-input {
    width: 100%;
    height: 44px;
    padding: 8px 28px 8px 52px;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 14px;
}

/* Icons: Search lens & AJAX spinner */
.jmg-search-icon {
    position: absolute;
    top: 50%;
    left: 14px;
    width: 18px;
    height: 18px;
    margin-top: -9px;
    background-image: url("data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 18 18' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M17.8 16.7L13.1 12C14.2 10.7 14.8 9 14.8 7.4C14.8 3.3 11.5 0 7.4 0C3.3 0 0 3.3 0 7.4C0 11.5 3.3 14.8 7.4 14.8C9 14.8 10.7 14.2 12 13.1L16.7 17.8L17.8 16.7ZM1.5 7.4C1.5 4.1 4.1 1.5 7.4 1.5C10.7 1.5 13.3 4.1 13.3 7.4C13.3 10.7 10.7 13.3 7.4 13.3C4.1 13.3 1.5 10.7 1.5 7.4Z' fill='%23B37836'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 18px 18px;
}

.rkd-header-search .jmg-ajax-icon {
    position: absolute;
    top: 50%;
    left: 14px;
    width: 18px;
    height: 18px;
    margin-top: -9px;
    background: none;
    display: none;
}

.rkd-header-search.--loading .jmg-search-icon {
    display: none;
}

.rkd-header-search .jmg-ajax-icon:after {
    content: "";
    position: absolute;
    inset: 0;
    border: 2px solid #b37836;
    border-top-color: transparent;
    border-radius: 50%;
    animation: rkd-spin .7s linear infinite;
}

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

/* Close button */
.jmg-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 18px;
    background: rgba(0, 0, 0, .06);
    border: 0;
    color: #4f3335;
    font-size: 24px;
    line-height: 36px;
    text-align: center;
    cursor: pointer;
    flex-shrink: 0;
}

.jmg-close-btn:hover {
    background: rgba(0, 0, 0, .1);
}

/* Dropdown structure */
.jmg-search-dropdown {
    display: flex;
    flex-direction: column;
    visibility: hidden;
}

.jmg-sheet-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    flex-shrink: 0;
    justify-content: space-between;
}

.jmg-sheet-header__content {
    flex: 1 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.jmg-sheet-header__title {
    display: block;
    margin: 0;
    font-weight: 600;
    font-size: 15px;
    color: #4f3335;
    text-decoration: none;
    transition: opacity .2s;
}

.jmg-sheet-header__title:hover {
    opacity: .8;
}

/* Search results general styling */
.jmg-search-result {
    padding: 10px 14px 6px;
    display: grid;
    grid-template-rows: 1fr auto;
    min-height: 100%;
}

.jmg-item-link {
    display: flex !important;
    gap: 12px;
    align-items: flex-start;
    width: 100%;
}

.jmg-item {
    padding: 10px 6px;
    border-radius: 8px;
}

.jmg-item:hover {
    background: #f8f8f8;
}

.jmg-item.--not-available {
    filter: grayscale(1);
    opacity: 0.6;
}

.jmg-item-picture {
    width: 56px;
    flex: 0 0 56px;
    text-align: center;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

.jmg-item-picture img {
    max-width: 56px;
    max-height: 56px;
    object-fit: contain;
}

.jmg-item-info {
    display: flex;
    flex-direction: column;
    /* gap: 6px; */
    align-items: flex-start;
    flex: 1 1 auto;
}

.jmg-item-name {
    margin: 0;
    width: 100%;
    align-self: flex-start;
    font-size: 15px;
    font-weight: 600;
    color: #4f3335;
}

.jmg-item-props {
    width: 100%;
    font-size: 13px;
    color: #4d3336;
    opacity: .85;
    line-height: 1.25;
}

.jmg-item-prop-value {
    font-weight: 400;
}

.jmg-item-prices {
    display: flex;
    gap: 10px;
    align-items: baseline;
    justify-content: flex-start;
    width: 100%;
    flex-wrap: nowrap;
    white-space: nowrap;
    float: none !important;
}

.jmg-search-result .jmg-item-prices>* {
    display: inline-block;
    margin: 0;
}

.jmg-item-discount {
    color: #999;
    text-decoration: line-through;
    font-weight: 400;
    font-size: 15px;
}

.jmg-item-price {
    color: #dd2645;
    font-weight: 700;
    font-size: 15px;
}

.jmg-search-tech-info {
    font-size: 8px;
    color: #9e9e9e;
    text-align: right;
    padding: 8px 6px 0;
    display: block;
}

/* --- 2. Desktop Styles (min-width: 768px) --- */

@media (min-width: 768px) {
    .jmg-search-dropdown {
        position: absolute !important;
        top: calc(100% + 8px);
        left: 0;
        width: clamp(520px, 62vw, 760px);
        min-width: 420px;
        background: #fff;
        border: 1px solid #eee;
        border-radius: 12px;
        box-shadow: 0 20px 40px rgba(0, 0, 0, .12);
        visibility: hidden;
    }

    .jmg-search-dropdown .jmg-search-result {
        overflow-y: auto;
        max-height: 60vh;
    }
}

/* --- 3. Mobile Styles (max-width: 767px) --- */

/* Mimic real component on placeholder for seamless replacement */
.rkd-mobile-header__search-container:not(.--mobile-search-active) input[name="search"] {
    height: 44px;
    padding: 8px 28px 8px 52px;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    font-size: 14px;
    width: 100%;
}

.rkd-mobile-header__search-container:not(.--mobile-search-active)::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 14px;
    width: 18px;
    height: 18px;
    margin-top: -9px;
    background-image: url("data:image/svg+xml,%3Csvg width='18' height='18' viewBox='0 0 18 18' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M17.8 16.7L13.1 12C14.2 10.7 14.8 9 14.8 7.4C14.8 3.3 11.5 0 7.4 0C3.3 0 0 3.3 0 7.4C0 11.5 3.3 14.8 7.4 14.8C9 14.8 10.7 14.2 12 13.1L16.7 17.8L17.8 16.7ZM1.5 7.4C1.5 4.1 4.1 1.5 7.4 1.5C10.7 1.5 13.3 4.1 13.3 7.4C13.3 10.7 10.7 13.3 7.4 13.3C4.1 13.3 1.5 10.7 1.5 7.4Z' fill='%23B37836'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 18px 18px;
    z-index: 1;
}

/* Hide placeholder once real component is active */
.rkd-mobile-header__search-container.--mobile-search-active input[data-jmg-placeholder="1"] {
    display: none !important;
}

@media (max-width: 767px) {

    /* Header transformations when search is active */
    .rkd-mobile-header.--search-active {
        position: relative;
        z-index: 100000;
    }

    .rkd-mobile-header.--search-active>div:not(.rkd-mobile-header__search) {
        display: none;
    }

    .rkd-mobile-header.--search-active .rkd-mobile-header__search {
        width: 100%;
        padding-left: 12px;
        padding-right: 12px;
    }

    .rkd-mobile-header__search-container .jmg-search-input {
        padding-left: 40px !important;
    }

    /* Fullscreen dropdown / sheet */
    .jmg-search-dropdown {
        position: fixed !important;
        top: var(--rkd-mh, 56px);
        left: 0;
        right: 0;
        bottom: 0;
        /* width: 100vw; */
        width: 100%;
        background: #fff;
        max-height: none;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    /* Scroller for results */
    .jmg-search-dropdown .jmg-search-result {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .jmg-overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(30, 30, 30, .1);
        z-index: 3999;
    }

    /* Mobile dropdown header */
    .jmg-sheet-header {
        position: sticky;
        top: 0;
        background: #fff;
    }

    /* Styles for portalized elements (appended to body) */
.jmg-overlay-portal {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: var(--rkd-mh, 56px);
    background: rgba(30, 30, 30, .1);
    z-index: 1000;
}

.jmg-search-dropdown.jmg-portal {
    position: fixed !important;
    top: var(--rkd-mh, 56px);
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    max-height: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    }
}