/* =============================================================
 *  BFM Live Search — Modal & Resultados
 *  Estilado con los design tokens del child theme (tokens.css):
 *  --bfm-*, --font-display (Orbitron), --font-body (Roboto), --r-*, --sh-*.
 *  Cada var() lleva fallback por si el modal aparece en una página sin tokens.
 * ============================================================= */

/* ---------------------------------------------------------------
 *  Botón disparador (icono del header)
 *  Hereda el color del contenedor del header (color: inherit) para
 *  adaptarse a cualquier fondo de header que se configure en Elementor/HFE.
 * ------------------------------------------------------------- */

.bfm-search-trigger {
    background: none !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    cursor: pointer;
    color: inherit;
    padding: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s ease;
}

.bfm-search-trigger:hover,
.bfm-search-trigger:focus,
.bfm-search-trigger:active {
    opacity: 0.65;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* ---------------------------------------------------------------
 *  Wrapper y backdrop
 * ------------------------------------------------------------- */

.bfm-search-modal-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 30px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.bfm-search-modal-wrapper.is-open {
    opacity: 1;
    visibility: visible;
}

.bfm-search-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(3, 23, 71, 0.55); /* tinte --bfm-deep */
    backdrop-filter: blur(2px);
}

body.bfm-search-open {
    overflow: hidden;
}

/* ---------------------------------------------------------------
 *  Contenedor del modal
 * ------------------------------------------------------------- */

.bfm-search-modal {
    position: relative;
    background: var(--bfm-white, #fff);
    width: 100%;
    max-width: 640px;
    margin-top: 50px;
    border: 1px solid var(--bfm-line, #E5E7EE);
    border-radius: var(--r-lg, 10px);
    box-shadow: var(--sh-3, 0 18px 40px rgba(3, 23, 71, 0.14), 0 6px 14px rgba(3, 23, 71, 0.08));
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 100px);
    transform: translateY(-16px) scale(0.97);
    transition: transform 0.25s ease;
    overflow: hidden;
}

.bfm-search-modal-wrapper.is-open .bfm-search-modal {
    transform: translateY(0) scale(1);
}

/* ---------------------------------------------------------------
 *  Botón cerrar
 * ------------------------------------------------------------- */

.bfm-search-close {
    position: absolute;
    top: 8px;
    right: 16px;
    background: none !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
    font-size: 1.75rem !important;
    line-height: 1;
    cursor: pointer;
    color: var(--bfm-muted, #6B7388) !important;
    padding: 0;
    z-index: 1;
    transition: color 0.15s ease;
}

.bfm-search-close:hover,
.bfm-search-close:focus,
.bfm-search-close:active {
    color: var(--bfm-deep, #031747) !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* ---------------------------------------------------------------
 *  Header (hint + input + botón)
 * ------------------------------------------------------------- */

.bfm-search-header {
    padding: 24px 24px 16px;
}

.bfm-search-hint {
    display: block;
    font-family: var(--font-display, 'Orbitron', sans-serif);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--bfm-muted, #6B7388);
    margin-bottom: 10px;
}

.bfm-search-form {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bfm-search-input {
    flex: 1;
    border: 1px solid var(--bfm-line-strong, #C9CDDB) !important;
    border-radius: var(--r-sm, 4px) !important;
    background: var(--bfm-soft, #F7F7F8) !important;
    font-family: var(--font-body, 'Roboto', sans-serif);
    font-size: 1.05rem;
    color: var(--bfm-ink, #0B1431) !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 12px 14px !important;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.bfm-search-input:focus {
    border-color: var(--bfm-deep, #031747) !important;
    background: var(--bfm-white, #fff) !important;
}

.bfm-search-input::placeholder {
    color: var(--bfm-muted, #6B7388);
    font-weight: 400;
}

.bfm-search-submit {
    background: var(--bfm-deep, #031747) !important;
    color: var(--bfm-white, #fff) !important;
    border: 1px solid var(--bfm-deep, #031747) !important;
    padding: 12px 22px !important;
    border-radius: var(--r-sm, 4px) !important;
    font-family: var(--font-body, 'Roboto', sans-serif);
    font-size: 13px;
    font-weight: 500 !important;
    letter-spacing: 0.04em;
    cursor: pointer !important;
    white-space: nowrap !important;
    transition: background 0.15s ease !important;
}

.bfm-search-submit:hover {
    background: var(--bfm-deep-2, #0A2461) !important;
    border-color: var(--bfm-deep-2, #0A2461) !important;
}

/* ---------------------------------------------------------------
 *  Body (status + lista de resultados)
 * ------------------------------------------------------------- */

.bfm-search-body {
    flex: 1;
    overflow-y: auto;
    border-top: 1px solid var(--bfm-line, #E5E7EE);
}

.bfm-search-status {
    padding: 16px 24px;
    font-family: var(--font-body, 'Roboto', sans-serif);
    font-size: 0.875rem;
    color: var(--bfm-muted, #6B7388);
    text-align: center;
}

.bfm-search-status:empty {
    display: none;
}

.bfm-search-results-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 480px;
    overflow-y: auto;
}

/* ---------------------------------------------------------------
 *  Ítem de resultado
 * ------------------------------------------------------------- */

.bfm-search-result-item {
    border-bottom: 1px solid var(--bfm-line, #E5E7EE);
}

.bfm-search-result-item:last-child {
    border-bottom: none;
}

.bfm-search-result-link {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 24px;
    text-decoration: none !important;
    color: inherit;
    transition: background 0.12s ease;
}

.bfm-search-result-link:hover {
    background: var(--bfm-soft, #F7F7F8);
}

/* Portada: matte de marca + contain para no recortar revistas (3:4) ni libros cuadrados. */
.bfm-search-result-img {
    width: 46px;
    height: 60px;
    object-fit: contain;
    background: var(--bfm-soft, #F7F7F8);
    border: 1px solid var(--bfm-line, #E5E7EE);
    border-radius: var(--r-xs, 2px);
    padding: 3px;
    flex-shrink: 0;
}

.bfm-search-result-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bfm-search-result-name {
    font-family: var(--font-display, 'Orbitron', sans-serif);
    font-weight: 700;
    font-size: 0.9rem;
    line-height: 1.25;
    letter-spacing: 0.01em;
    color: var(--bfm-deep, #031747);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bfm-search-result-meta {
    font-family: var(--font-display, 'Orbitron', sans-serif);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--bfm-muted, #6B7388);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bfm-search-result-price {
    flex-shrink: 0;
    font-family: var(--font-display, 'Orbitron', sans-serif);
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--bfm-deep, #031747);
    text-align: right;
    white-space: nowrap;
}

.bfm-search-result-price del {
    color: var(--bfm-muted, #6B7388);
    font-weight: 400;
    font-size: 0.8rem;
    margin-right: 4px;
}

.bfm-search-result-price ins {
    text-decoration: none;
}

.bfm-search-no-price {
    color: var(--bfm-muted, #6B7388);
}

/* Sin stock */
.bfm-search-result-item.is-out-of-stock .bfm-search-result-img {
    opacity: 0.5;
}

.bfm-search-result-item.is-out-of-stock .bfm-search-result-name {
    color: var(--bfm-muted, #6B7388);
}

/* ---------------------------------------------------------------
 *  Footer (conteo + ver todos)
 * ------------------------------------------------------------- */

.bfm-search-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 24px;
    border-top: 1px solid var(--bfm-line, #E5E7EE);
}

.bfm-search-count {
    font-family: var(--font-display, 'Orbitron', sans-serif);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--bfm-muted, #6B7388);
}

.bfm-search-show-all {
    font-family: var(--font-body, 'Roboto', sans-serif);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0.04em;
    color: var(--bfm-white, #fff);
    text-decoration: none !important;
    padding: 9px 18px;
    background: var(--bfm-deep, #031747);
    border: 1px solid var(--bfm-deep, #031747);
    border-radius: var(--r-sm, 4px);
    transition: background 0.15s ease;
}

.bfm-search-show-all:hover {
    background: var(--bfm-deep-2, #0A2461);
    color: var(--bfm-white, #fff);
}

/* ---------------------------------------------------------------
 *  Responsive
 * ------------------------------------------------------------- */

@media (max-width: 768px) {
    .bfm-search-modal-wrapper {
        padding: 12px;
    }

    .bfm-search-modal {
        margin-top: 16px;
        max-height: calc(100vh - 40px);
    }

    .bfm-search-header {
        padding: 20px 16px 12px;
    }

    .bfm-search-form {
        flex-direction: column;
        gap: 10px;
    }

    .bfm-search-input {
        font-size: 1rem;
        text-align: center;
    }

    .bfm-search-submit {
        width: 100%;
        text-align: center;
    }

    .bfm-search-result-link {
        padding: 10px 16px;
        gap: 10px;
    }

    .bfm-search-result-img {
        width: 40px;
        height: 52px;
    }

    .bfm-search-footer {
        padding: 12px 16px;
    }

    .bfm-search-results-list {
        max-height: 50vh;
    }
}
