/* Leo Product Search Modal CSS */
.lps-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 99999;
    font-family: inherit;
}

.lps-modal.open {
    display: block;
}

.lps-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.lps-modal__dialog {
    position: relative;
    margin: 10px auto;
    width: calc(100% - 20px);
    max-width: 900px;
    max-height: calc(100vh - 20px);
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Close button: anchored top-right, never overlaps the submit button */
.lps-modal__close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid #ddd;
    border-radius: 50%;
    background: #fff;
    color: #333;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.lps-modal__close:hover {
    background: #f2f2f2;
}

/* Reserve room on the right so the search button is not hidden under the close button */
.lps-modal__form {
    padding: 16px 58px 16px 16px;
    border-bottom: 1px solid #eee;
    flex: 0 0 auto;
}

.lps-modal__form-row {
    display: flex;
    gap: 8px;
}

.lps-modal__input {
    flex: 1;
    min-width: 0;
    padding: 9px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.lps-modal__submit {
    padding: 9px 18px;
    border: 1px solid #333;
    background: #333;
    color: #fff;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.lps-modal__submit:hover {
    background: #111;
}

/* Search results (when typing) */
.lps-modal__results {
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
    overflow: auto;
    max-height: 45vh;
    flex: 0 0 auto;
}

.lps-results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: 600;
}

.lps-viewall {
    font-weight: 400;
    font-size: 13px;
}

.lps-results-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Three stacked rows: recentes / populares / categorias */
.lps-modal__sections {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    overflow: auto;
    flex: 1 1 auto;
}

.lps-modal__sections section h3 {
    margin: 0 0 8px;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: #555;
}

/* Row 1: recent searches in a single line */
.lps-recentes-list {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    margin: 0 0 6px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.lps-recentes-chip {
    flex: 0 0 auto;
    border: 1px solid #ddd;
    background: #f7f7f7;
    padding: 5px 10px;
    border-radius: 14px;
    cursor: pointer;
    white-space: nowrap;
}

.lps-recentes-chip:hover {
    background: #efefef;
}

.lps-recentes-clear {
    border: none;
    background: transparent;
    color: #888;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    font-size: 13px;
}

/* Rows: popular products AND search results as cards */
.lps-populares-list,
.lps-results-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.lps-populares-list .lps-prod,
.lps-results-list .lps-prod {
    display: flex;
    flex-direction: column;
    gap: 8px;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 10px;
    text-decoration: none;
    color: inherit;
    text-align: center;
    align-items: stretch;
    transition: box-shadow .15s ease, transform .15s ease;
}

.lps-populares-list .lps-prod:hover,
.lps-results-list .lps-prod:hover {
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

.lps-populares-list .lps-prod-img,
.lps-results-list .lps-prod-img {
    display: flex;
    justify-content: center;
    align-items: center;
}

.lps-populares-list .lps-prod-img img,
.lps-results-list .lps-prod-img img {
    width: 100%;
    max-width: 120px;
    height: auto;
    aspect-ratio: 1 / 1;
    object-fit: contain;
    border-radius: 4px;
}

.lps-populares-list .lps-prod-title,
.lps-results-list .lps-prod-title {
    font-weight: 600;
    font-size: 13px;
    line-height: 1.25;
}

.lps-populares-list .lps-prod-price,
.lps-results-list .lps-prod-price {
    color: #666;
    font-size: 13px;
}

.lps-prod-title {
    font-weight: 600;
}

.lps-prod-price {
    color: #666;
    font-size: 14px;
}

/* Row 3: categories as cards */
.lps-categorias-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 10px;
}

.lps-cat {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    padding: 12px 14px;
    border: 1px solid #eee;
    border-radius: 8px;
    background: #fafafa;
    transition: border-color .15s ease, background .15s ease;
}

.lps-cat:hover {
    border-color: #ccc;
    background: #f3f3f3;
}

.lps-cat-name {
    font-weight: 600;
}

.lps-cat-count {
    color: #888;
    font-size: 13px;
    white-space: nowrap;
}

@media (max-width: 600px) {
    .lps-modal__dialog {
        margin: 6px auto;
        max-height: calc(100vh - 12px);
    }
    .lps-populares-list,
    .lps-results-list {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }
    .lps-categorias-list {
        grid-template-columns: 1fr 1fr;
    }
}

/* Mobile: keep only the theme's search icon (#leo_search_block_top .title_block),
   which opens the modal (see leosearch-modal.js). The classic form/dropdown is
   hidden so tapping the icon never reveals the legacy dropdown. */
@media (max-width: 767px) {
    #leo_search_block_top .title_block {
        display: block;
    }
    #leo_search_block_top #leosearchtopbox {
        display: none !important;
    }
}
