/**
 * LM Responsive Search - style.css v3.9
 * Cambios: dropdown posicionado y dimensionado 100% por CSS (no por JS).
 * El JS solo gestiona `top` (basado en el input) y display/visibility.
 */

/* ── Wrapper del widget ─────────────────────────────────── */
.lm-search-widget--isolated {
    position: relative;
    width: 100%;
}

/* ── Formulario ─────────────────────────────────────────── */
.lm-search-form {
    width: 100%;
}

.lm-search-field-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.lm-search-widget--isolated .lm-search-input,
.lm-search-widget--isolated input.lm-search-input,
.lm-search-widget--isolated input[type="search"].lm-search-input {
    width: 100%;
    height: 48px !important;
    padding: 0 52px 0 18px !important;
    border: 2px solid #e5e7eb !important;
    border-radius: 50px !important;
    font-size: 15px !important;
    outline: none !important;
    background: #fff !important;
    box-sizing: border-box !important;
    transition: border-color .2s;
    /* Cross-browser normalization: unify iOS Safari vs Android Chrome */
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    font-family: inherit !important;
    line-height: normal !important;
    color: inherit !important;
    -webkit-text-size-adjust: 100%;
    /* Prevent Samsung/Android Chrome from applying theme input styles */
    box-shadow: none !important;
    -webkit-box-shadow: none !important;
}
.lm-search-widget--isolated .lm-search-input:focus,
.lm-search-widget--isolated input.lm-search-input:focus {
    border-color: #2563eb !important;
    outline: none !important;
}

/* Reduce placeholder size on mobile so it fits the search bar width */
@media (max-width: 599px) {
    .lm-search-widget--isolated .lm-search-input::placeholder,
    .lm-search-widget--isolated input.lm-search-input::placeholder {
        font-size: 13px;
    }
}

.lm-search-widget--isolated .lm-search-btn {
    position: absolute;
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    width: 38px !important;
    height: 38px !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 50% !important;
    background: #2563eb !important;
    cursor: pointer;
    padding: 0 !important;
    border: none !important;
    /* Prevent theme from overriding button appearance */
    -webkit-appearance: none !important;
    appearance: none !important;
    box-shadow: none !important;
    outline: none;
}
/* SVG lupa: el icono está sobre fondo azul, debe ser BLANCO y visible.
   Forzamos con !important para ganar al tema en Android Chrome. */
/* SVG lupa SIEMPRE negra */
.lm-search-widget--isolated .lm-search-icon,
.lm-search-widget--isolated .lm-search-icon svg {
    width: 20px !important;
    height: 20px !important;
    color: #000 !important;
    stroke: #000 !important;
    fill: none !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.lm-search-widget--isolated .lm-search-icon path,
.lm-search-widget--isolated .lm-search-icon circle,
.lm-search-widget--isolated .lm-search-icon line {
    stroke: #000 !important;
    fill: none !important;
}

/* evitar que hover del tema cambie el color */
.lm-search-widget--isolated .lm-search-btn:hover .lm-search-icon,
.lm-search-widget--isolated .lm-search-btn:focus .lm-search-icon {
    color: #000 !important;
    stroke: #000 !important;
}

/* ── Loader ─────────────────────────────────────────────── */
.lm-search-loader {
    display: none;
    position: absolute;
    right: 56px;
    top: 50%;
    transform: translateY(-50%);
    gap: 4px;
}
.lm-search-loader.lmrs-loading {
    display: flex;
}
.lm-search-loader span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #2563eb;
    animation: lmrsBounce 0.6s infinite alternate;
}
.lm-search-loader span:nth-child(2) { animation-delay: .15s; }
.lm-search-loader span:nth-child(3) { animation-delay: .30s; }
@keyframes lmrsBounce {
    from { opacity: .3; transform: scale(.7); }
    to   { opacity: 1;  transform: scale(1.1); }
}

/* ═══════════════════════════════════════════════════════════
   DROPDOWN DE SUGERENCIAS
   El dropdown se inserta en <body> (portal pattern) con
   position: fixed. El JS SOLO calcula el `top` desde el input.
   El ANCHO y el CENTRADO son responsabilidad exclusiva de CSS.
═══════════════════════════════════════════════════════════ */
.lm-search-suggestions {
    position: fixed !important;
    left: 50% !important;
    transform: translateX(-50%) !important;
    right: auto !important;
    z-index: 999999 !important;
    box-sizing: border-box !important;

    /* Estilos visuales */
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,.13);
    overflow-y: auto;
    max-height: 70vh;
    padding: 6px 0;

    /* Ancho base — móvil */
    width: 90vw;
    max-width: 90vw;
}

/* Tablet (≥ 600px) */
@media (min-width: 600px) {
    .lm-search-suggestions {
        width: 70vw;
        max-width: 700px;
    }
}

/* Escritorio (≥ 1025px) */
@media (min-width: 1025px) {
    .lm-search-suggestions {
        width: 60vw;
        max-width: 900px;
    }
}

/* Oculto por defecto */
.lm-search-suggestions[hidden] {
    display: none !important;
}
.lm-search-suggestions.lm-suggestions-visible {
    display: block !important;
}

/* ── Items del dropdown ─────────────────────────────────── */
.lm-suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background .15s;
    text-decoration: none;
    color: #1e293b;
    outline: none;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
}
.lm-suggestion-item:hover,
.lm-suggestion-item:focus {
    background: #f1f5f9;
}

/* Imagen miniatura */
.lmrs-item-img {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    background: #f3f4f6;
}
.lmrs-img-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
}
.lmrs-img-placeholder svg {
    width: 52px;
    height: 52px;
}

/* Cuerpo del item */
.lmrs-item-body {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}

/* Título */
.lmrs-item-title {
    font-size: 14px;
    font-weight: 500;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    min-width: 0;
}
.lmrs-item-title mark {
    background: transparent;
    color: #2563eb;
    font-weight: 700;
}

/* Metadatos */
.lmrs-item-meta {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
}
.lmrs-cat {
    font-size: 11px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: .04em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    flex: 1 1 0;
}
.lmrs-price {
    font-size: 13px;
    font-weight: 700;
    color: #111827;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Badge */
.lmrs-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 2px 8px;
    border-radius: 20px;
    background: #e0e7ff;
    color: #3730a3;
    white-space: nowrap;
    flex-shrink: 0;
    align-self: center;
}
@media (max-width: 380px) {
    .lmrs-badge { display: none; }
}

/* ── Historial ──────────────────────────────────────────── */
.lmrs-section-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #9ca3af;
    padding: 8px 16px 4px;
}
.lmrs-history-item {
    color: #374151;
}
.lmrs-hist-icon {
    width: 20px;
    height: 20px;
    color: #9ca3af;
    flex-shrink: 0;
    display: flex;
}
.lmrs-hist-icon svg {
    width: 20px;
    height: 20px;
}
.lmrs-hist-remove {
    background: none;
    border: none;
    padding: 0 4px;
    font-size: 16px;
    line-height: 1;
    color: #9ca3af;
    cursor: pointer;
    flex-shrink: 0;
    transition: color .15s;
}
.lmrs-hist-remove:hover {
    color: #ef4444;
}

/* ── Ver todos ──────────────────────────────────────────── */
.lmrs-view-all {
    display: block;
    padding: 10px 16px;
    font-size: 13px;
    color: #2563eb;
    text-decoration: none;
    border-top: 1px solid #f1f5f9;
    margin-top: 4px;
    transition: background .15s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lmrs-view-all:hover {
    background: #eff6ff;
}
.lmrs-view-all strong {
    font-weight: 700;
}

/* ── Sin resultados ─────────────────────────────────────── */
.lmrs-no-results {
    padding: 32px 20px;
    text-align: center;
    color: #6b7280;
}
.lmrs-no-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    display: block;
}
.lmrs-no-results p {
    font-size: 14px;
    margin: 0 0 4px;
    color: #374151;
}
.lmrs-no-results small {
    font-size: 12px;
    color: #9ca3af;
}
