/**
 * GlobaRank Core - Buscador AJAX en vivo
 * v2.5.2 - Fix de bordes residuales del navegador y esquinas
 *
 * @since 2.5.0
 */

/* ===================================================================
   WRAPPER (respeta ancho del container de Elementor)
   =================================================================== */
.globarank-search-wrapper {
    position: relative;
    width: 100%;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ===================================================================
   INPUT GROUP - Una sola caja redondeada con input+botón integrados
   =================================================================== */
.globarank-search-input-group {
    display: flex;
    align-items: stretch;
    gap: 0;
    background: #FFFFFF;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 4px 12px rgba(0,0,0,0.04);
    border: 1px solid #E2E8F0;
    transition: box-shadow 0.2s, border-color 0.2s;
    isolation: isolate;
}

.globarank-search-wrapper:focus-within .globarank-search-input-group {
    border-color: #2563EB;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1), 0 4px 16px rgba(0,0,0,0.06);
}

/* ===================================================================
   INPUT - reset agresivo de estilos del navegador
   =================================================================== */
.globarank-search-wrapper .globarank-search-input {
    flex: 1;
    border: none !important;
    outline: none !important;
    padding: 18px 24px;
    font-size: 16px;
    color: #0F172A;
    background: transparent;
    font-family: inherit;
    line-height: 1.5;
    min-width: 0;
    box-shadow: none !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    margin: 0;
}

.globarank-search-wrapper .globarank-search-input:focus,
.globarank-search-wrapper .globarank-search-input:active,
.globarank-search-wrapper .globarank-search-input:hover {
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.globarank-search-wrapper .globarank-search-input::placeholder {
    color: #94A3B8;
    opacity: 1;
}

/* ===================================================================
   BOTÓN SEARCH - reset agresivo de estilos del navegador
   =================================================================== */
.globarank-search-wrapper .globarank-search-btn {
    background: #2563EB !important;
    color: #FFFFFF !important;
    border: none !important;
    outline: none !important;
    padding: 0 36px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    position: relative;
    letter-spacing: 0.2px;
    box-shadow: none !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    border-style: none !important;
    border-width: 0 !important;
    border-color: transparent !important;
    margin: 0;
    border-radius: 0;
}

.globarank-search-wrapper .globarank-search-btn:hover {
    background: #1D4ED8 !important;
}

.globarank-search-wrapper .globarank-search-btn:active,
.globarank-search-wrapper .globarank-search-btn:focus {
    background: #1E40AF !important;
    border: none !important;
    outline: none !important;
    box-shadow: none !important;
}

/* Firefox: eliminar borde interno del button */
.globarank-search-wrapper .globarank-search-btn::-moz-focus-inner {
    border: 0 !important;
    padding: 0;
}

.globarank-search-btn-loader {
    display: none;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: globarank-spin 0.8s linear infinite;
}

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

.globarank-search-wrapper.is-loading .globarank-search-btn-text {
    display: none;
}
.globarank-search-wrapper.is-loading .globarank-search-btn-loader {
    display: inline-block;
}

/* ===================================================================
   STATUS BAR (flotante, tipo tooltip)
   =================================================================== */
.globarank-search-status {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: #0F172A;
    color: #FFFFFF;
    font-size: 12px;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 8px;
    z-index: 998;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.globarank-search-wrapper.has-results .globarank-search-status {
    display: none !important;
}

/* ===================================================================
   DROPDOWN DE RESULTADOS (floating, no empuja contenido)
   =================================================================== */
.globarank-search-results {
    display: none;
    position: absolute;
    top: calc(100% + 12px);
    left: 0;
    right: 0;
    z-index: 999;
    background: #FFFFFF;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.12), 0 4px 16px rgba(0,0,0,0.06);
    border: 1px solid #E2E8F0;
    overflow: hidden;
    max-height: 540px;
    overflow-y: auto;
}

.globarank-search-results::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 32px;
    width: 12px;
    height: 12px;
    background: #FFFFFF;
    border-top: 1px solid #E2E8F0;
    border-left: 1px solid #E2E8F0;
    transform: rotate(45deg);
}

.globarank-search-results::-webkit-scrollbar {
    width: 6px;
}
.globarank-search-results::-webkit-scrollbar-track {
    background: #F8FAFC;
}
.globarank-search-results::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 3px;
}

/* ===================================================================
   CARD DE RESULTADO INDIVIDUAL
   =================================================================== */
.globarank-search-result {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 24px;
    border-bottom: 1px solid #F1F5F9;
    text-decoration: none !important;
    color: inherit !important;
    transition: background 0.15s;
    position: relative;
}

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

.globarank-search-result:hover {
    background: #F8FAFC;
}

.globarank-search-result:focus {
    outline: none;
    background: #EFF6FF;
}

.globarank-search-result-thumb {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 10px;
    overflow: hidden;
    background: #F1F5F9;
}

.globarank-search-result-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.globarank-search-result-body {
    flex: 1;
    min-width: 0;
}

.globarank-search-result-title {
    font-family: 'Plus Jakarta Sans', 'DM Sans', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: #0F172A;
    margin: 0 0 8px 0;
    line-height: 1.35;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.globarank-search-result-title mark {
    background: rgba(37, 99, 235, 0.15);
    color: #2563EB;
    font-weight: 700;
    padding: 0 3px;
    border-radius: 3px;
}

.globarank-search-result-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.globarank-search-result-category {
    display: inline-block;
    background: #EFF6FF;
    color: #2563EB;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    letter-spacing: 0.3px;
}

.globarank-search-result-score {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 60px;
    text-align: center;
    padding-left: 12px;
    border-left: 1px solid #F1F5F9;
}

.globarank-search-result-score strong {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 24px;
    font-weight: 800;
    color: #2563EB;
    line-height: 1;
}

.globarank-search-result-score span {
    font-size: 10px;
    color: #94A3B8;
    font-weight: 600;
    margin-top: 4px;
    letter-spacing: 0.3px;
}

/* ===================================================================
   ESTADO VACÍO / NO RESULTADOS
   =================================================================== */
.globarank-search-empty {
    padding: 32px 24px;
    text-align: center;
    color: #64748B;
    font-size: 14px;
}

.globarank-search-empty-icon {
    font-size: 32px;
    margin-bottom: 8px;
    display: block;
}

/* ===================================================================
   RESPONSIVE
   =================================================================== */
@media (max-width: 768px) {
    .globarank-search-wrapper .globarank-search-input {
        padding: 16px 20px;
        font-size: 15px;
    }

    .globarank-search-wrapper .globarank-search-btn {
        padding: 0 20px;
        min-width: 80px;
        font-size: 14px;
    }

    .globarank-search-result {
        padding: 14px 18px;
        gap: 12px;
    }

    .globarank-search-result-thumb {
        width: 48px;
        height: 48px;
    }

    .globarank-search-result-title {
        font-size: 14px;
    }

    .globarank-search-result-score {
        min-width: 50px;
        padding-left: 8px;
    }

    .globarank-search-result-score strong {
        font-size: 20px;
    }

    .globarank-search-results::before {
        left: 20px;
    }
}

/* ===================================================================
   ANIMACIONES
   =================================================================== */
.globarank-search-results {
    animation: globarank-dropdown-in 0.2s ease forwards;
}

@keyframes globarank-dropdown-in {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.globarank-search-results .globarank-search-result {
    opacity: 0;
    animation: globarank-fade-in 0.25s ease forwards;
}

.globarank-search-results .globarank-search-result:nth-child(1) { animation-delay: 0.04s; }
.globarank-search-results .globarank-search-result:nth-child(2) { animation-delay: 0.08s; }
.globarank-search-results .globarank-search-result:nth-child(3) { animation-delay: 0.12s; }
.globarank-search-results .globarank-search-result:nth-child(4) { animation-delay: 0.16s; }
.globarank-search-results .globarank-search-result:nth-child(5) { animation-delay: 0.20s; }
.globarank-search-results .globarank-search-result:nth-child(6) { animation-delay: 0.24s; }
.globarank-search-results .globarank-search-result:nth-child(7) { animation-delay: 0.28s; }
.globarank-search-results .globarank-search-result:nth-child(8) { animation-delay: 0.32s; }

@keyframes globarank-fade-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
