/**
 * Custom Product Search Widget Styles
 * File: custom-product-search.css
 * Author: Ángel Parada
 */

/* -----------------------------------------------------------------
   1. Base & Layout Containers
----------------------------------------------------------------- */
.custom-product-search {
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.custom-product-search__form {
    margin: 0;
    padding: 0;
    width: 100%;
}

.custom-product-search__container {
    display: flex;
    align-items: center;
    position: relative;
    width: 100%;
}

/* -----------------------------------------------------------------
   2. Input Field Styles
----------------------------------------------------------------- */
.custom-product-search__input {
    flex: 1;
    width: 100%;
    height: 48px;
    padding: 0 16px;
    font-size: 14px;
    line-height: 1.5;
    color: #333333;
    background-color: #ffffff;
    border: 1px solid #cccccc;
    border-radius: 4px 0 0 4px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.custom-product-search__input:focus {
    border-color: #0073aa;
}

/* Hide native search decoration buttons */
.custom-product-search__input::-webkit-search-decoration,
.custom-product-search__input::-webkit-search-cancel-button,
.custom-product-search__input::-webkit-search-results-button,
.custom-product-search__input::-webkit-search-results-decoration {
    display: none;
}

/* -----------------------------------------------------------------
   3. Button & Icon Styles
----------------------------------------------------------------- */
.custom-product-search__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    padding: 0 20px;
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    background-color: #0073aa;
    border: 1px solid #0073aa;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    white-space: nowrap;
    text-decoration: none;
    box-sizing: border-box;
    transition: background-color 0.2s ease-in-out, border-color 0.2s ease-in-out, color 0.2s ease-in-out;
}

.custom-product-search__btn:hover {
    background-color: #005177;
    border-color: #005177;
}

.custom-product-search__btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.custom-product-search__btn-icon svg {
    display: block;
    width: 1em;
    height: 1em;
    fill: currentColor;
}

/* -----------------------------------------------------------------
   4. Live Search Results Dropdown
----------------------------------------------------------------- */
.custom-product-search__results-container {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%; /* Ajuste para coincidir con el ancho exacto del buscador */
    z-index: 9999;
    margin-top: 8px;
    background-color: #ffffff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    max-height: 420px;
    overflow-y: auto;
    overflow-x: hidden; /* Garantiza evitar scrollbars horizontales no deseados */
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
    box-sizing: border-box;
}

.custom-product-search__results-container.is-active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Scrollbar estilizado para el panel desplegable */
.custom-product-search__results-container::-webkit-scrollbar {
    width: 6px;
}

.custom-product-search__results-container::-webkit-scrollbar-thumb {
    background-color: #cccccc;
    border-radius: 3px;
}

/* -----------------------------------------------------------------
   5. Grid & Item Cards Layout
----------------------------------------------------------------- */
.custom-product-search__grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    background-color: #e5e7eb; /* Color de las líneas divisoras */
    gap: 1px;
}

.custom-product-search__item {
    display: flex;
    align-items: center;
    padding: 16px;
    background-color: #ffffff;
    text-decoration: none;
    color: inherit;
    box-sizing: border-box;
    transition: background-color 0.15s ease-in-out;
}

.custom-product-search__item:hover {
    background-color: #f9fafb;
}

.custom-product-search__item-thumb-wrapper {
    width: 70px;
    height: 70px;
    margin-right: 14px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.custom-product-search__item-thumb {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.custom-product-search__item-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    min-width: 0; /* Permite el truncado de texto sin forzar el ancho */
}

.custom-product-search__item-title {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.35;
    color: #1f2937;
    margin: 0 0 4px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.custom-product-search__item-excerpt {
    font-size: 11px;
    line-height: 1.3;
    color: #6b7280;
    margin: 0 0 6px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

mark.search-highlight {
    background-color: #f3f4f6;
    color: #111827;
    font-weight: 700;
    padding: 1px 3px;
    border-radius: 3px;
}

/* -----------------------------------------------------------------
   6. Price Styles (WooCommerce Format)
----------------------------------------------------------------- */
.custom-product-search__item-price {
    font-size: 13px;
    font-weight: 700;
    color: #2563eb;
    margin-top: auto;
}

.custom-product-search__item-price del {
    color: #dc2626;
    font-size: 12px;
    font-weight: 500;
    text-decoration: line-through;
    margin-right: 6px;
}

.custom-product-search__item-price ins {
    text-decoration: none;
    color: #2563eb;
}

.custom-product-search__message {
    padding: 16px;
    font-size: 13px;
    color: #666666;
    text-align: center;
}

/* -----------------------------------------------------------------
   7. Responsive Adaptability
----------------------------------------------------------------- */
@media (max-width: 640px) {
    .custom-product-search__grid {
        grid-template-columns: 1fr;
    }
}