/* Tactical Real Estate — Buscador Global */

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Hero layout con buscador — sin display:contents (evita que el texto quede bajo el overlay) */
.hero[data-global-search] .hero-content {
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
}

.hero[data-global-search] .hero-content .global-search {
    width: 100%;
    max-width: 420px;
}

.hero[data-global-search] .hero-toolbar {
    position: relative;
    z-index: 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    width: 100%;
    max-width: 720px;
    padding: 0 2rem;
    margin-top: 0.5rem;
    margin-left: auto;
    margin-right: auto;
}

@media (min-width: 1024px) {
    .hero[data-global-search] .hero-toolbar {
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 1rem;
        width: 100%;
        max-width: none;
        margin-top: 1.5rem;
        padding: 0 2rem;
    }

    .hero[data-global-search] .hero-toolbar .global-search:not(.global-search--header) {
        width: clamp(280px, 32vw, 420px);
        flex: 0 0 auto;
    }

    .hero[data-global-search] .hero-toolbar .hero-badge {
        flex: 0 0 auto;
        margin: 0;
    }
}

/* Componente de búsqueda */
.global-search {
    position: relative;
    width: 100%;
}

.global-search__field {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.65rem 1.2rem;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.22);
    transition: all 0.2s ease;
}

.global-search__field:focus-within {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
}

.global-search__icon {
    flex-shrink: 0;
    color: rgba(255, 255, 255, 0.7);
}

.global-search__input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--white);
    font-family: 'Open Sans', sans-serif;
    font-size: 0.95rem;
    line-height: 1.4;
    outline: none;
}

.global-search__input::placeholder {
    color: rgba(255, 255, 255, 0.55);
}

.global-search__input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

/* Panel de resultados — position:fixed vía JS (portal a body) para quedar sobre todo */
.global-search__panel {
    position: fixed;
    top: 0;
    left: 0;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.18);
    overflow: hidden;
    z-index: 10005;
    max-height: min(70vh, 480px);
    overflow-y: auto;
}

.global-search__list {
    list-style: none;
    margin: 0;
    padding: 0.35rem 0;
}

.global-search__result {
    margin: 0;
}

.global-search__result-link {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    text-decoration: none;
    color: var(--black);
    transition: background 0.15s ease;
}

.global-search__result-link:hover,
.global-search__result--active .global-search__result-link {
    background: var(--light-grey);
}

.global-search__result--active .global-search__result-link {
    outline: 2px solid var(--red);
    outline-offset: -2px;
}

.global-search__thumb {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--light-grey);
}

.global-search__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.global-search__thumb--empty {
    background: linear-gradient(135deg, var(--light-grey), var(--grafito-light));
    opacity: 0.4;
}

/* Miniatura por tipo (sin foto propia o imagen rota) */
.global-search__thumb--type {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--light-grey);
    border: 1px solid rgba(173, 2, 3, 0.15);
}

.global-search__thumb-type {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--grey);
    line-height: 1;
}

.global-search__thumb--type-propiedad { background: rgba(173, 2, 3, 0.1); }
.global-search__thumb--type-servicio { background: rgba(255, 140, 0, 0.12); }
.global-search__thumb--type-faq { background: rgba(100, 103, 102, 0.1); }
.global-search__thumb--type-inversion { background: rgba(74, 74, 74, 0.1); }
.global-search__thumb--type-categoria { background: rgba(173, 2, 3, 0.08); }
.global-search__thumb--type-pagina,
.global-search__thumb--type-equipo,
.global-search__thumb--type-contacto { background: var(--light-grey); }

.global-search__result-body {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
    text-align: left;
}

.global-search__result-type {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--red);
}

.global-search__result-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--black);
    line-height: 1.3;
}

.global-search__result-location {
    font-size: 0.78rem;
    color: var(--grey);
}

.global-search__result-desc {
    font-size: 0.78rem;
    color: var(--texto-grey);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.global-search__highlight {
    background: rgba(173, 2, 3, 0.12);
    color: var(--red-oscuro);
    font-weight: 600;
    padding: 0 0.1em;
    border-radius: 2px;
}

.global-search__empty {
    padding: 1.25rem 1rem;
    margin: 0;
    text-align: center;
    font-size: 0.9rem;
    color: var(--grey);
    line-height: 1.5;
}

/* Focus visible */
.global-search__input:focus-visible {
    outline: none;
}

.global-search__field:focus-within {
    outline: 2px solid rgba(255, 255, 255, 0.5);
    outline-offset: 2px;
}

.global-search__result-link:focus-visible {
    outline: 2px solid var(--red);
    outline-offset: -2px;
}

@media (max-width: 480px) {
    .global-search__input {
        font-size: 0.88rem;
    }

    .global-search__field {
        padding: 0.6rem 1rem;
    }

    .hero[data-global-search] {
        padding-bottom: clamp(4rem, 8vh, 6rem);
    }
}

@media (prefers-reduced-motion: reduce) {
    .global-search__field,
    .global-search__result-link {
        transition: none;
    }
}

/* ── Buscador en hero de propiedad individual ── */
.propiedad-meta--search {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
}

.propiedad-meta__items {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
}

.propiedad-hero-toolbar {
    display: flex;
    justify-content: center;
    width: 100%;
    position: relative;
    z-index: 4;
}

.propiedad-hero-toolbar .global-search--propiedad {
    width: 100%;
    max-width: 420px;
}

.propiedad-meta__badge {
    display: flex;
    justify-content: center;
    width: 100%;
}

.propiedad-meta__badge .hero-badge {
    margin: 0;
}

@media (min-width: 768px) {
    .propiedad-hero-toolbar .global-search--propiedad {
        max-width: 480px;
    }
}

/* ── Variante compacta en header ── */
.nav-container:has(.global-search--header) {
    gap: 0.75rem;
}

.nav-container:has(.global-search--header) .nav-links {
    flex-shrink: 0;
}

.global-search--header {
    position: relative;
    flex-shrink: 0;
    margin-left: auto;
    margin-right: 0.75rem;
}

.global-search--header .global-search__toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid var(--light-grey);
    border-radius: 50%;
    background: var(--white);
    color: var(--grey);
    cursor: pointer;
    transition: all 0.2s ease;
}

.global-search--header .global-search__toggle:hover {
    color: var(--red);
    border-color: var(--red);
}

.global-search--header .global-search__field {
    background: var(--light-grey);
    border: 1px solid transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    padding: 0.45rem 0.85rem;
    border-radius: 20px;
    min-width: 0;
}

.global-search--header .global-search__field:focus-within {
    background: var(--white);
    border-color: rgba(173, 2, 3, 0.25);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
    outline: none;
}

.global-search--header .global-search__icon {
    color: var(--grey);
    width: 16px;
    height: 16px;
}

.global-search--header .global-search__input {
    color: var(--black);
    font-size: 0.85rem;
}

.global-search--header .global-search__input::placeholder {
    color: var(--texto-grey);
}

.global-search--header .global-search__close {
    display: none;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--grey);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.global-search--header .global-search__close:hover {
    color: var(--red);
}

.global-search--header .global-search__panel {
    min-width: 320px;
}

@media (min-width: 1024px) {
    .global-search--header {
        width: clamp(180px, 18vw, 260px);
        margin-right: 1.25rem;
    }

    .global-search--header .global-search__toggle {
        display: none !important;
    }

    .global-search--header .global-search__field {
        display: flex;
    }

    .global-search--header .global-search__close {
        display: none !important;
    }
}

@media (max-width: 1023px) {
    .global-search--header {
        margin-left: 0;
        margin-right: 0.5rem;
    }

    .global-search--header .global-search__toggle {
        display: flex;
    }

    .global-search--header .global-search__field {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 10001;
        padding: 0.85rem 1rem;
        border-radius: 0;
        border: none;
        border-bottom: 1px solid var(--light-grey);
        background: var(--white);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    }

    .global-search--header.global-search--expanded .global-search__field {
        display: flex;
    }

    .global-search--header.global-search--expanded .global-search__toggle {
        display: none;
    }

    .global-search--header .global-search__close {
        display: flex;
    }

    .global-search--header .global-search__panel {
        position: fixed;
        top: 58px;
        left: 0;
        right: 0;
        min-width: 0;
        border-radius: 0;
        max-height: calc(100vh - 58px);
    }
}
