/* ==========================================================================
   La ficha de busqueda.

   Es el instrumento principal del directorio: dos compartimentos separados
   por un filete, cada uno rotulado como el campo de una ficha escolar, y un
   boton de accion al final. En la portada vuela sobre el borde del panel
   oscuro; en el listado se apoya en la cabecera.
   ========================================================================== */

.ficha {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr) auto;
    align-items: stretch;
    gap: 0;
    padding: var(--space-2);
    background: var(--surface);
    border-radius: var(--r-2xl);
    box-shadow: var(--shadow-lg);
    z-index: 10;
}

.ficha__field {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.15rem;
    min-width: 0;
    padding: 0.85rem 1.25rem;
    border-radius: var(--r-xl);
    transition: background-color var(--dur) var(--ease);
}

.ficha__field:first-child {
    padding-left: 1.75rem;
}

/* Filete entre compartimentos, del alto del contenido y no del contenedor. */
.ficha__field + .ficha__field::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    translate: 0 -50%;
    width: 1px;
    height: 2.4rem;
    background: var(--rule);
    transition: opacity var(--dur) var(--ease);
}

.ficha__field:hover,
.ficha__field:focus-within {
    background: var(--teal-tint);
}

.ficha__field:hover + .ficha__field::before,
.ficha__field:focus-within + .ficha__field::before,
.ficha__field:hover::before,
.ficha__field:focus-within::before {
    opacity: 0;
}

.ficha__label {
    display: block;
    color: var(--teal);
    pointer-events: none;
}

.ficha__input {
    width: 100%;
    border: 0;
    padding: 0;
    background: transparent;
    font-size: var(--fs-body);
    font-weight: 600;
    color: var(--ink);
}

.ficha__input::placeholder {
    color: var(--ink-faint);
    font-weight: 500;
}

.ficha__input:focus {
    outline: none;
}

/* Disparador de los desplegables: se comporta como el input de al lado. */
.ficha__trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    width: 100%;
    padding: 0;
    font-size: var(--fs-body);
    font-weight: 600;
    color: var(--ink);
    text-align: left;
}

.ficha__trigger-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ficha__trigger-caret {
    flex-shrink: 0;
    width: 0.75rem;
    height: 0.75rem;
    color: var(--ink-faint);
    transition: transform var(--dur) var(--ease);
}

.ficha__trigger[aria-expanded='true'] .ficha__trigger-caret {
    transform: rotate(180deg);
}

.ficha__submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    align-self: center;
    margin-right: 0.4rem;
    padding: 0 1.6rem;
    height: 3.5rem;
    border-radius: var(--r-pill);
    background: var(--brand);
    color: #fff;
    font-size: var(--fs-sm);
    font-weight: 800;
    transition: background-color var(--dur) var(--ease), transform var(--dur-fast) var(--ease);
}

.ficha__submit:hover {
    background: var(--brand-dark);
}

.ficha__submit:active {
    transform: scale(0.98);
}

.ficha__submit svg {
    width: 1.1rem;
    height: 1.1rem;
}

.ficha__submit-text {
    display: inline;
}

/* --- Autocompletado ---------------------------------------------------- */

.ficha__suggestions {
    position: absolute;
    top: calc(100% + 0.6rem);
    left: 0.5rem;
    right: -0.5rem;
    max-height: 22rem;
    overflow-y: auto;
    padding: var(--space-2);
    background: var(--surface);
    border: 1px solid var(--rule);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    z-index: 40;
}

.suggestion {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: 0.6rem 0.7rem;
    border-radius: var(--r-md);
    text-align: left;
    cursor: pointer;
}

.suggestion:hover,
.suggestion[aria-selected='true'] {
    background: var(--teal-tint);
}

.suggestion__icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 2.1rem;
    height: 2.1rem;
    border-radius: var(--r-sm);
    background: var(--teal-soft);
    color: var(--teal);
}

.suggestion__icon svg {
    width: 1rem;
    height: 1rem;
}

.suggestion[data-type='city'] .suggestion__icon {
    background: var(--brand-soft);
    color: var(--brand-deep);
}

.suggestion__text {
    min-width: 0;
}

.suggestion__label {
    display: block;
    font-size: var(--fs-sm);
    font-weight: 700;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.suggestion__sublabel {
    display: block;
    font-size: var(--fs-xs);
    color: var(--ink-faint);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ficha__status {
    padding: var(--space-4) var(--space-3);
    font-size: var(--fs-sm);
    color: var(--ink-soft);
    text-align: center;
}

/* --- Recuento bajo la ficha -------------------------------------------- */

.ficha-note {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-top: var(--space-4);
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--ink-faint);
}

.ficha-note__dot {
    width: 0.4rem;
    height: 0.4rem;
    border-radius: 50%;
    background: var(--brand);
}

/* --- Adaptacion a pantallas estrechas ---------------------------------- */

@media (max-width: 64rem) {
    .ficha {
        grid-template-columns: minmax(0, 1fr);
        border-radius: var(--r-xl);
        padding: var(--space-3);
        gap: var(--space-1);
    }

    .ficha__field {
        border-radius: var(--r-lg);
        padding: 0.7rem 1rem;
    }

    .ficha__field:first-child {
        padding-left: 1rem;
    }

    .ficha__field + .ficha__field::before {
        display: none;
    }

    .ficha__field--query {
        border-bottom: 1px solid var(--rule);
        border-radius: var(--r-lg) var(--r-lg) 0 0;
    }

    .ficha__submit {
        width: 100%;
        margin: var(--space-2) 0 0;
    }

    .ficha__suggestions {
        left: 0;
        right: 0;
    }
}
