/*
 * Shell del buscador: contenedor, campos de estación, fila de opciones y botón de búsqueda.
 *
 * Estas reglas replican lo que antes aportaba public/css/home/ofertren-design.css (selectores
 * #form ...) para que el widget no dependa del CSS del sitio anfitrión. El markup usa clases
 * propias con prefijo sw- en lugar de las del tema (bloque-estaciones, form-control,
 * input_buscador, btn-buscar...), que colisionaban con nombres genéricos de frameworks como
 * Bootstrap en páginas de terceros.
 *
 * Personalización: sobrescribe las variables --sw-* sobre .sw-root desde la página anfitriona.
 */

.sw-root {
    /* Colores */
    --sw-color-borde: #464646;
    --sw-color-texto: #000000;
    --sw-color-placeholder: #000000;
    --sw-color-campo-fondo: #ffffff;
    --sw-color-primario: #8bc53e;
    --sw-color-primario-compacto: #1e6fa8;
    --sw-color-primario-texto: #ffffff;
    --sw-color-desactivado-fondo: rgba(0, 0, 0, 0.12);
    --sw-color-desactivado-texto: rgba(0, 0, 0, 0.37);

    /* Modo destino: paleta que aportaba ofertren-rutas.css en las páginas T1/T3 */
    --sw-color-acento: #3998db;
    --sw-color-acento-oscuro: #2478b5;
    --sw-color-marca: #9dc44d;
    --sw-color-etiqueta: #6b6c6d;
    --sw-color-nota: #9a9b9c;
    --sw-color-campo-borde: #e8e8e8;
    --sw-color-campo-suave: #fafafa;
    --sw-color-tinta: #1a1a1a;
    --sw-panel-redondeo: 20px;
    --sw-panel-redondeo-compacto: 12px;

    /* Contenedor */
    --sw-shell-fondo: rgba(255, 255, 255, 0.5);
    --sw-shell-redondeo: 40px;
    --sw-shell-padding: 20px;
    --sw-shell-sombra: 0 0 20px 6px rgba(0, 0, 0, 0.07);

    /* Campos */
    --sw-campo-redondeo: 50px;
    /* Alto común de todos los campos de la barra: estaciones, fechas, pasajeros y botón. */
    --sw-campo-alto: 55px;
    --sw-campo-alto-compacto: 40px;

    /*
     * Tipografía: stack propio en lugar de `inherit`. Heredar deja el buscador en la serif por
     * defecto del navegador en cualquier landing que no declare tipografía. Para que herede la de
     * la página anfitriona, sobrescribe con `--sw-fuente: inherit`.
     */
    --sw-fuente: 'Poppins', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --sw-fuente-tamano: 16px;
    --sw-fuente-tamano-compacto: 14px;

    --sw-color-titulo: #2c3e50;

    /* Se aplica en el propio root para que la hereden también calendario y modales */
    font-family: var(--sw-fuente);

    /*
     * ofertren.com declara `body { line-height: 1 }` en su reset y todo el widget lo hereda; sin
     * él los textos de los modales y del calendario se separan (`normal` ≈ 1.2) y no coinciden con
     * lo que se ve en el sitio. Los elementos que necesitan más interlineado lo declaran aparte.
     */
    line-height: 1;
}

/*
 * Los controles solo heredan la familia, no el tamaño.
 *
 * El navegador da a `button` un tamaño propio (13,3 px), menor que los 16 px de los campos de
 * estación y fecha. Se deja así a propósito: es exactamente como se ve el botón de pasajeros en
 * ofertren.com, y el objetivo es que el buscador embebido sea indistinguible del de la portada.
 * Si algún día se quiere igualar, el sitio de la campaña puede subir el tamaño desde su propio CSS.
 */
.sw-root button,
.sw-root input,
.sw-root select,
.sw-root textarea {
    font-family: inherit;
}

/* ── Contenedor exterior ── */
.sw-root.sw-shell {
    margin: auto;
    width: 100%;
    max-width: 100%;
    padding: var(--sw-shell-padding);
    border-radius: var(--sw-shell-redondeo);
    background-color: var(--sw-shell-fondo);
    z-index: 5;
    box-shadow: var(--sw-shell-sombra);
}

.sw-root .sw-content {
    transition: height 0.5s;
    font-size: var(--sw-fuente-tamano);
    font-family: var(--sw-fuente);
    padding: 0;
}

/* ── Fila de estaciones ── */
.sw-root .sw-estaciones {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
}

/*
 * Todos los campos de la barra comparten el alto de referencia de ofertren.com (55 px medidos a
 * 1440 px). En el sitio esa medida sale porque su reset aplica `box-sizing: border-box` a todo; el
 * widget aislado no hereda ese reset, así que sin declararlo el padding y los bordes se sumaban al
 * alto y cada campo quedaba distinto (estaciones 49 px, fechas 65 px, pasajeros 45 px, botón 55 px).
 */
.sw-root .sw-estacion,
.sw-root .sw-datepicker-inputs,
.sw-root .sw-estacion-label,
.sw-root .sw-opciones .sw-menu button.sw-btn-menu,
.sw-root .sw-opciones button.sw-btn-buscar {
    box-sizing: border-box;
}

.sw-root .sw-estacion,
.sw-root .sw-datepicker-inputs,
.sw-root .sw-opciones .sw-menu button.sw-btn-menu,
.sw-root .sw-opciones button.sw-btn-buscar {
    height: var(--sw-campo-alto);
}

.sw-root .sw-estaciones .sw-estacion {
    border: 1px solid var(--sw-color-borde);
    padding: 4px 0;
    width: 50%;
    display: flex;
    align-items: center;
    background-color: var(--sw-color-campo-fondo);
}

.sw-root .sw-estacion-label {
    width: 100%;
    display: flex;
    align-items: center;
    border-radius: 6px;
    padding: 10px 40px;
    margin-bottom: 0;
}

.sw-root .sw-estacion:first-of-type .sw-estacion-label {
    border-radius: 0;
    border-right: 1px solid var(--sw-color-borde);
}

.sw-root .sw-estaciones label .sw-typeahead {
    flex-grow: 1;
    display: flex;
    align-items: center;
    width: 100%;
    transition: border-left-color 0.5s;
}

.sw-root .sw-estaciones label .sw-typeahead .sw-input {
    width: 100%;
    margin: 0;
    padding: 0;
    box-shadow: none;
    border: none;
    border-radius: 0;
    height: unset;
    font-weight: normal;
    font-size: 1em;
    font-family: var(--sw-fuente);
    background-color: transparent;
    line-height: normal;
    color: var(--sw-color-texto);
}

.sw-root .sw-estaciones label .sw-typeahead .sw-input::placeholder {
    color: var(--sw-color-placeholder);
}

.sw-root .sw-input:focus,
.sw-root .sw-input:active {
    outline: none;
    box-shadow: none;
}

/* ── Fila de opciones: fechas, pasajeros y botón ── */
.sw-root .sw-opciones {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: unset;
    position: relative;
    margin-top: 15px;
}

.sw-root .sw-opciones .sw-datepicker {
    width: 49.5%;
}

.sw-root .sw-opciones .sw-menu {
    position: relative;
}

.sw-root .sw-opciones .sw-menu:first-of-type {
    margin-right: 20px;
}

.sw-root .sw-opciones .sw-menu--pasajeros {
    width: 24%;
}

.sw-root .sw-opciones .sw-menu button.sw-btn-menu {
    display: flex;
    align-items: center;
    background-color: var(--sw-color-campo-fondo);
    border: 1px solid var(--sw-color-borde);
    border-radius: var(--sw-campo-redondeo);
    padding: 14px 0 14px 40px;
    position: relative;
    white-space: nowrap;
    width: 100%;
    font-family: var(--sw-fuente);
    color: var(--sw-color-texto);
    cursor: pointer;
}

.sw-root .sw-opciones .sw-menu button.sw-btn-menu > span {
    font-size: 1em;
    display: flex;
    align-items: center;
    line-height: normal;
}

.sw-root .sw-datepicker-inputs {
    display: flex;
    background-color: var(--sw-color-campo-fondo);
    border: 1px solid var(--sw-color-borde);
    border-radius: var(--sw-campo-redondeo);
    padding: 4px 0;
}

/* ── Botón de búsqueda ── */
.sw-root .sw-opciones button.sw-btn-buscar {
    position: unset;
    display: flex;
    background-color: var(--sw-color-primario);
    color: var(--sw-color-primario-texto);
    width: 24%;
    height: 55px;
    align-items: center;
    justify-content: center;
    font-size: 1.4em;
    font-family: var(--sw-fuente);
    transition: background-color 0.2s linear;
    border: none;
    border-radius: var(--sw-campo-redondeo);
    line-height: normal;
    cursor: pointer;
}

.sw-root .sw-opciones button.sw-btn-buscar:disabled {
    background-color: var(--sw-color-desactivado-fondo);
    color: var(--sw-color-desactivado-texto);
    cursor: default;
}

/* ── Separador central entre origen y destino (pantallas anchas) ── */
@media screen and (min-width: 769px) {
    .sw-root .sw-estaciones .sw-estacion:first-of-type {
        position: relative;
        border-right: none;
        border-radius: var(--sw-campo-redondeo) 0 0 var(--sw-campo-redondeo);
    }

    .sw-root .sw-estaciones .sw-estacion:last-of-type {
        border-left: none;
        border-radius: 0 var(--sw-campo-redondeo) var(--sw-campo-redondeo) 0;
    }

    .sw-root .sw-estaciones .sw-estacion:first-of-type::after {
        content: '';
        position: absolute;
        right: 0;
        top: 6px;
        bottom: 6px;
        width: 1px;
        background-color: var(--sw-color-borde);
        z-index: 1;
    }
}

/* ── Apilado en pantallas estrechas ── */
@media screen and (max-width: 768px) {
    .sw-root .sw-content {
        font-size: var(--sw-fuente-tamano-compacto);
    }

    .sw-root .sw-estaciones {
        flex-direction: column;
    }

    .sw-root .sw-estaciones .sw-estacion,
    .sw-root .sw-datepicker-inputs,
    .sw-root .sw-opciones .sw-menu button.sw-btn-menu {
        height: var(--sw-campo-alto-compacto);
    }

    .sw-root .sw-estaciones .sw-estacion {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: var(--sw-campo-redondeo);
        padding: 0 6px;
    }

    .sw-root .sw-opciones .sw-menu button.sw-btn-menu {
        padding: 0 0 0 20px;
    }

    .sw-root .sw-estaciones .sw-estacion:first-of-type {
        margin-bottom: 10px;
    }

    .sw-root .sw-estacion:first-of-type .sw-estacion-label {
        border-right: none;
    }

    .sw-root .sw-estacion-label {
        padding: 0 20px;
    }

    .sw-root .sw-estaciones label .sw-typeahead {
        border-left: none;
        margin: 0;
    }

    .sw-root .sw-opciones {
        padding-bottom: 0;
        margin-top: 10px;
        flex-direction: column;
    }

    .sw-root .sw-opciones .sw-datepicker,
    .sw-root .sw-opciones .sw-menu--pasajeros {
        width: 100%;
        margin-bottom: 10px;
        margin-right: 0;
        margin-left: 0;
    }

    .sw-root .sw-opciones button.sw-btn-buscar {
        position: relative;
        height: var(--sw-campo-alto-compacto);
        width: 100%;
        right: unset;
        bottom: unset;
        margin-left: auto;
        font-size: 1.1em;
    }
}

@media screen and (max-width: 576px) {
    .sw-root .sw-opciones button.sw-btn-buscar {
        background-color: var(--sw-color-primario-compacto);
    }
}

/*
 * ── Modo destino (origen o destino prefijado) ──────────────────────────────
 *
 * Replica lo que aportaba frontend/src/ofertren-rutas/ofertren-rutas.css en las páginas T1, T3 y
 * T5b. Sin estas reglas el buscador en modo destino se renderiza sin estilos en cualquier página
 * que no cargue ese fichero, que es justo el caso de una landing externa.
 */
.sw-root.sw-panel {
    background: var(--sw-color-campo-fondo);
    border-radius: var(--sw-panel-redondeo);
    padding: 28px 24px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 3;
    margin-bottom: -40px;
}

.sw-root .sw-panel-head {
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--sw-color-acento);
    margin: 0 0 18px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.sw-root .sw-panel-head::before {
    content: '';
    display: block;
    width: 3px;
    height: 16px;
    background: var(--sw-color-marca);
    border-radius: 2px;
}

.sw-root .sw-panel-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.sw-root .s-field label {
    display: block;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--sw-color-etiqueta);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 5px;
}

.sw-root.sw-panel .s-field input,
.sw-root.sw-panel .s-field select {
    width: 100%;
    border: 1.5px solid var(--sw-color-campo-borde);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 0.9rem;
    font-family: var(--sw-fuente);
    color: var(--sw-color-tinta);
    outline: none;
    transition: border 0.2s;
    background: var(--sw-color-campo-suave);
}

.sw-root.sw-panel .s-field input:focus,
.sw-root.sw-panel .s-field select:focus {
    border-color: var(--sw-color-acento);
    background: var(--sw-color-campo-fondo);
}

.sw-root .sw-btn-search {
    width: 100%;
    background: var(--sw-color-acento);
    color: var(--sw-color-primario-texto);
    border: none;
    border-radius: 10px;
    padding: 14px;
    font-size: 0.95rem;
    font-family: var(--sw-fuente);
    font-weight: 800;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.sw-root .sw-btn-search:hover {
    background: var(--sw-color-acento-oscuro);
}

.sw-root .sw-panel-note {
    text-align: center;
    font-size: 0.72rem;
    color: var(--sw-color-nota);
    margin-top: 10px;
}

@media screen and (max-width: 820px) {
    .sw-root.sw-panel {
        margin: 20px;
        border-radius: var(--sw-panel-redondeo-compacto);
        margin-bottom: -30px;
    }
}

@media screen and (max-width: 480px) {
    .sw-root .sw-panel-row {
        grid-template-columns: 1fr;
    }

    .sw-root.sw-panel {
        margin-bottom: 20px;
        padding-top: 20px;
    }
}
