/* ─── YP Smart Search — Frontend CSS v1.0.3 ──────────────────────────────── */

.yps-wrap {
    position: relative;
    width: 100%;
    font-family: inherit;
}

/* ── Input wrap ──────────────────────────────────────────────────────────── */

.yps-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.yps-icon-search {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #a0aec0;
    pointer-events: none;
    display: flex;
    align-items: center;
    z-index: 1;
}

/* Alta especificidad para ganar al tema */
.yps-wrap .yps-input-wrap input.yps-input,
.yps-wrap .yps-input-wrap input[type="text"].yps-input,
.yps-wrap .yps-input-wrap input[type="search"].yps-input {
    width: 100% !important;
    padding: 12px 44px 12px 46px !important;
    border: 1.5px solid #dde1ee !important;
    border-radius: 999px !important;
    font-size: 14px !important;
    color: #1A1F36 !important;
    background: #fff !important;
    outline: none !important;
    box-shadow: none !important;
    transition: border-color .2s, box-shadow .2s !important;
    box-sizing: border-box !important;
    -webkit-appearance: none !important;
    appearance: none !important;
}

.yps-wrap .yps-input-wrap input.yps-input:focus,
.yps-wrap .yps-input-wrap input[type="text"].yps-input:focus {
    border-color: #334F9D !important;
    box-shadow: 0 0 0 3px rgba(51, 79, 157, .10) !important;
    outline: none !important;
}

.yps-wrap .yps-input-wrap input.yps-input::placeholder {
    color: #a0aec0 !important;
}

/* ── Botón X ─────────────────────────────────────────────────────────────── */

.yps-clear {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: #eef1fb !important;
    border: none !important;
    cursor: pointer;
    color: #334F9D;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    transition: background .15s;
    z-index: 1;
}

.yps-clear:hover {
    background: #334F9D !important;
    color: #fff;
}

/* ── Dropdown resultados ─────────────────────────────────────────────────── */

.yps-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e0e4f0;
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .13);
    z-index: 9999;
    max-height: 420px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.yps-results::-webkit-scrollbar { width: 4px; }
.yps-results::-webkit-scrollbar-track { background: transparent; }
.yps-results::-webkit-scrollbar-thumb { background: #d0d6e8; border-radius: 4px; }

/* ── Item ────────────────────────────────────────────────────────────────── */

.yps-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px 14px;
    text-decoration: none !important;
    color: inherit !important;
    border-bottom: 1px solid #f0f3fa;
    transition: background .12s;
    position: relative;
}

.yps-item:last-child {
    border-bottom: none;
}

.yps-item:hover {
    background: #f5f7fe;
    text-decoration: none !important;
}

/* ── Badge recompensa — siempre arriba a la derecha ──────────────────────── */

.yps-reward-badge {
    display: inline-flex;
    align-self: flex-end;
    align-items: center;
    gap: 5px;
    background: #0f7a5a;
    color: #fff !important;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 9px 3px 7px;
    border-radius: 20px;
    white-space: nowrap;
    line-height: 1.4;
    text-decoration: none !important;
    margin-bottom: -2px;
}

/* ── Fila principal: imagen + texto ──────────────────────────────────────── */

.yps-item-main {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

/* ── Imagen ──────────────────────────────────────────────────────────────── */

.yps-item-media {
    flex-shrink: 0;
}

.yps-thumb {
    width: 54px;
    height: 54px;
    object-fit: cover;
    border-radius: 9px !important;
    display: block;
}

.yps-thumb-placeholder {
    width: 54px;
    height: 54px;
    background: #eef1fb;
    border-radius: 9px !important;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #c8d0e7;
}

/* ── Texto ───────────────────────────────────────────────────────────────── */

.yps-item-body {
    flex: 1;
    min-width: 0;
}

.yps-title-row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 3px;
}

.yps-title {
    font-weight: 600;
    font-size: 14px;
    color: #1A1F36 !important;
    line-height: 1.4;
    word-break: break-word;
}

.yps-subtitle {
    font-size: 12px;
    color: #334F9D !important;
    font-weight: 500;
    word-break: break-word;
}

.yps-desc {
    font-size: 12px;
    color: #52607A !important;
    line-height: 1.5;
    margin-top: 2px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

/* ── Estados ─────────────────────────────────────────────────────────────── */

.yps-loading,
.yps-empty {
    padding: 20px 16px;
    text-align: center;
    color: #52607A;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.yps-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #e0e4f0;
    border-top-color: #334F9D;
    border-radius: 50%;
    animation: yps-spin .7s linear infinite;
    flex-shrink: 0;
}

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

/* ── Botón de filtros ────────────────────────────────────────────────────── */

/* ── Row que contiene input + botón filtros ───────────────────────────────── */

.yps-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

.yps-input-row .yps-input-wrap {
    flex: 1;
    min-width: 0;
}

/* ── Botón de filtros ────────────────────────────────────────────────────── */

.yps-filter-btn {
    flex-shrink: 0;
    width: 36px !important;
    height: 36px !important;
    padding: 0 !important;
    margin: 0 !important;
    background: #f0f2f8 !important;
    border: 1.5px solid #e0e4f0 !important;
    border-radius: 10px !important;
    cursor: pointer;
    color: #52607A !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: opacity .15s;
    position: relative;
    box-shadow: none !important;
    outline: none !important;
}

.yps-filter-btn:hover {
    opacity: 0.85;
}

.yps-filter-btn--active {
    opacity: 0.85;
}

/* Punto indicador de filtros activos */
.yps-filter-btn--has-filters::after {
    content: '';
    position: absolute;
    top: 5px;
    right: 5px;
    width: 7px;
    height: 7px;
    background: #fff;
    border-radius: 50%;
    border: 1.5px solid #334F9D;
}

/* Sin ajustes de posición del X — ya no hay conflicto */
.yps-wrap:has(.yps-filter-btn) .yps-clear {
    right: 14px;
}

.yps-wrap:has(.yps-filter-btn) .yps-input-wrap input.yps-input {
    padding-right: 44px !important;
}

.yps-filter-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e0e4f0;
    border-radius: 14px;
    box-shadow: 0 10px 40px rgba(0,0,0,.13);
    z-index: 9998;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.yps-filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.yps-filter-label {
    font-size: 11px;
    font-weight: 700;
    color: #52607A;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.yps-filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.yps-chip {
    padding: 5px 12px;
    border: 1.5px solid #e0e4f0 !important;
    border-radius: 20px !important;
    background: #f8f9fc !important;
    color: #52607A !important;
    font-size: 12px !important;
    font-weight: 500;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
    line-height: 1.4;
}

.yps-chip:hover {
    border-color: #334F9D !important;
    color: #334F9D !important;
    background: #eef1fb !important;
}

.yps-chip--active {
    background: #334F9D !important;
    border-color: #334F9D !important;
    color: #fff !important;
    font-weight: 600;
}

.yps-filter-clear-all {
    align-self: flex-end;
    background: none !important;
    border: none !important;
    color: #334F9D;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    padding: 4px 0 !important;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.yps-filter-clear-all:hover {
    color: #c00;
}
