/* ==========================================================================
   SHOWROOM 3D — MOBILE
   ==========================================================================
   Este archivo se carga siempre, pero TODA regla vive dentro de
   @media (max-width: 900px). En escritorio no aplica absolutamente nada.

   Las tres hojas de escritorio (style, style_compras, uistyle) siguen
   gateadas a min-width: 769px, asi que en pantalla angosta mobile.css es la
   unica fuente de estilo. Por eso el archivo es autonomo: define tambien el
   header del sitio, el canvas y la pantalla de carga, que en movil venian
   directamente sin estilo.

   Landscape es la orientacion objetivo. El mismo cutoff lo usa MOBILE_BP en
   source/device.js: los dos tienen que ver el mismo numero o el layout y la
   interaccion se contradicen.

   El diseno es uno solo, en columnas:
       header
       #ui_header   -> titulo + carrusel de vehiculos
       3D           -> franja libre en el medio
       #equipDock   -> tipos de equipamiento, productos y resumen
   Los @media que siguen solo ajustan escala para pantallas muy bajas; no
   cambian la estructura ni ocultan contenido.
   ========================================================================== */

@media (max-width: 900px) {

    :root {
        --mob-h: 34px;
        --mob-orange: #ff5100;
    }

    /* ==================================================================
       Base
       ================================================================== */

    html,
    body {
        margin: 0;
        height: 100%;
        overflow: hidden;
        background: #0b0b0b;
        color: #ffffff;
        font-family: Arial, sans-serif;
    }

    body {
        /* El 3D maneja su propio touch; esto solo frena el rebote de la pagina. */
        overscroll-behavior: none;
    }

    /* El canvas lo crea three.js y lo cuelga de body sin estilos. */
    body>canvas {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 0;
        display: block;
    }

    button {
        font-family: inherit;
        cursor: pointer;
    }

    /* Los <p> del showroom traen el margen por defecto del navegador (1em
       arriba y abajo). En escritorio eso lo resetea uistyle.css, pero en
       pantalla angosta esta hoja es la unica, asi que hay que hacerlo aca o
       cada renglon de las tarjetas mide el doble. Con width explicito y
       padding, ademas, content-box se desborda. */
    #ui_header,
    #ui_header *,
    #equipDock,
    #equipDock *,
    .header,
    .header *,
    #loadingAnim,
    #rotateHint {
        box-sizing: border-box;
    }

    #ui_header p,
    #equipDock p,
    .header p,
    #equipDock hr {
        margin: 0;
    }

    /* Los carruseles scrollean con el dedo, no con la barra. */
    .brands_cont,
    .parts_ui,
    .equip_ui,
    #hide {
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .brands_cont::-webkit-scrollbar,
    .parts_ui::-webkit-scrollbar,
    .equip_ui::-webkit-scrollbar,
    #hide::-webkit-scrollbar {
        width: 0 !important;
        height: 0 !important;
        display: none !important;
    }

    /* ==================================================================
       Header del sitio
       ================================================================== */

    .header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 30;
        width: auto;
        /* uistyle.css lleva height con !important y :hover que lo agranda;
           sin hover en touch, pero el !important hay que ganarlo igual. */
        height: var(--mob-h) !important;
        padding: 0 8px !important;
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        background: #262626f2;
        backdrop-filter: blur(8px);
        box-shadow: 0 1px 0 #ffffff1f;
    }

    .header:hover {
        height: var(--mob-h) !important;
    }

    .logo {
        width: auto;
        height: 22px;
    }

    #headerR {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 10px;
    }

    nav {
        height: auto;
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 10px;
    }

    /* Sin lugar para los links ni el buscador: se va a Inicio por el logo. */
    nav a:not(#user) {
        display: none;
    }

    #user {
        width: 24px;
        height: 24px;
        font-size: 10px;
        font-weight: 600;
        color: #ffffff;
        text-decoration: none;
        background: #7ff3fc81;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        line-height: 1;
    }

    #buscador {
        display: none;
    }

    /* ==================================================================
       Carrito
       En celular compra.js manda a carrito.html al tocar el icono, asi que
       el desplegable no se abre: queda collapsed igual, solo por si acaso.
       ================================================================== */

    #compras {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 30px;
        height: 30px;
    }

    .icono-carrito {
        width: 22px;
        height: 22px;
        margin-left: 0;
        fill: currentColor;
        color: #ffffff;
    }

    #tituloCarrito {
        display: none;
    }

    #bloque_compras {
        position: fixed;
        top: var(--mob-h);
        right: 0;
        z-index: 40;
        width: 260px;
        max-height: 0;
        overflow: hidden;
        flex-direction: column;
        background: #d3d3d38c;
        backdrop-filter: blur(8px);
    }

    #art_container {
        height: 190px;
        overflow-y: auto;
    }

    #finalizar_compra {
        font-size: 14px;
        padding: 8px;
    }

    /* ==================================================================
       Pantalla de carga
       ================================================================== */

    #loadingAnim {
        position: fixed;
        inset: 0;
        z-index: 60;
        display: flex;
        align-items: center;
        justify-content: center;
        background: #0b0b0be6;
    }

    #loadingAnimGif {
        width: 90px;
        height: auto;
    }

    /* ==================================================================
       Tutorial
       Los textos de mouse no sirven sin mouse y el panel no entra en una
       franja de 140px, asi que en celular no se muestra.
       ================================================================== */

    .tutorial_ui {
        display: none;
    }

    /* ==================================================================
       Arriba: titulo + carrusel de vehiculos
       ================================================================== */

    #ui_header {
        position: absolute;
        top: var(--mob-h);
        left: 0;
        z-index: 10;
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 3px;
    }

    #title {
        width: calc(100% - 8px);
        height: 22px;
        min-height: 22px;
        margin: 0;
        padding: 0 7px;
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 6px;
        background: #000000c4;
        border-radius: 7px;
    }

    #title_txt {
        margin: 0;
        color: var(--mob-orange);
        font-size: 12px;
        font-style: italic;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #title_txt::first-letter {
        text-transform: uppercase;
    }

    /* Pantalla completa no entra en un celular en horizontal. */
    #btnFullscreen {
        display: none;
    }

    #brand_container {
        width: calc(100% - 8px);
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 2px;
        padding: 2px;
        border-radius: 8px;
        background: #dcdcdc85;
        backdrop-filter: blur(12px);
    }

    #btn_prev,
    #btn_next {
        flex: 0 0 auto;
        width: 30px;
        height: 30px;
        margin: 0;
        padding: 0;
        border: none;
        border-radius: 50%;
        background: #0000004d;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #btn_prev[hidden],
    #btn_next[hidden] {
        display: none !important;
    }

    #btn_prev svg,
    #btn_next svg {
        width: 22px;
        height: 22px;
    }

    .brands_cont {
        /* mobile.js deja el carrusel siempre visible: main.js lo oculta al
           elegir modelo (comportamiento de escritorio) y el modelo nuevo
           pide los vehiculos arriba. El !important gana al estilo inline. */
        display: flex !important;
        flex: 1 1 auto;
        flex-direction: row !important;
        align-items: center;
        gap: 5px;
        width: auto;
        min-width: 0;
        padding: 2px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-mask-image: none;
        mask-image: none;
    }

    .brand_center_container {
        flex: 0 0 auto;
        opacity: 0.75;
        border-radius: 5px;
    }

    .brand_center_container.selected {
        box-shadow: 0px 0px 0px 2px var(--mob-orange);
        opacity: 1;
    }

    #brand_logo_container {
        padding: 2px;
        background: #00000042;
    }

    #brand_desc {
        gap: 3px;
        padding-right: 3px;
        margin-bottom: 2px;
    }

    #brand_logo {
        height: 22px;
        padding: 2px 3px;
        margin-right: 3px;
    }

    #main_desc_img {
        width: 64px;
        height: 18px;
    }

    #sec_desc_txt {
        font-size: 8px;
    }

    /* En movil el carrusel nunca se oculta, asi que no hay nada a que volver. */
    #goBack {
        display: none !important;
    }

    /* ==================================================================
       Abajo: dock de equipamiento
       Lo arma mobile.js moviendo .parts_ui, .equip_ui y #equipResumen
       adentro de #equipDock. En escritorio el dock no existe.
       ================================================================== */

    #equipDock {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 20;
        display: flex;
        flex-direction: column;
        gap: 4px;
        padding: 4px 6px 6px;
        background: linear-gradient(to top, #0b0b0bf2 55%, #0b0b0b00);
        pointer-events: none;
    }

    #equipDock>* {
        pointer-events: auto;
    }

    /* ---- Tipos de equipamiento ---- */

    .parts_ui {
        display: flex;
        flex: 0 0 auto;
        flex-direction: row !important;
        align-items: center;
        gap: 4px;
        padding: 2px;
        border-radius: 8px;
        background: #000000a6;
        backdrop-filter: blur(6px);
        overflow-x: auto;
        overflow-y: hidden;
    }

    #part_logo_container {
        flex: 0 0 auto;
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 4px;
        padding: 2px 8px 2px 2px;
        border: 1px solid #ffffff1f;
        border-radius: 999px;
        background: #00000078;
    }

    #part_logo {
        width: 22px;
        height: 22px;
        padding: 1px;
        border-radius: 6px;
    }

    #part_txt {
        width: auto;
        font-size: 10px;
        line-height: 1.1;
    }

    /* ---- Slider de productos ---- */

    .equip_ui {
        /* uistyle.css lo pone absoluto a 14vw del tope y en columna; en
           movil va al pie, en fila, scrolleando con el dedo. */
        position: static;
        display: flex;
        flex: 0 0 auto;
        flex-direction: row;
        align-items: stretch;
        gap: 4px;
        width: auto;
        max-height: none;
        margin: 0;
        padding: 3px;
        border-radius: 8px;
        background: #0000007a;
        backdrop-filter: blur(6px);
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x proximity;
    }

    /* ---- Tarjeta ---- */

    #equip_logo_container {
        flex: 0 0 auto;
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 6px;
        width: 234px;
        padding: 4px 6px 4px 4px;
        border: 1px solid #ffffff14;
        border-radius: 10px;
        background: #141414e0;
        scroll-snap-align: start;
        user-select: none;
        -webkit-user-select: none;
    }

    #equip_logo_container.equipado {
        border-color: var(--mob-orange);
    }

    #leftPart2 {
        display: flex;
        flex: 0 0 auto;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        width: 40px !important;
        height: auto;
        margin: 0;
    }

    #equip_logo {
        width: 40px;
        height: 40px;
        border-radius: 6px;
    }

    #detalles {
        font-size: 7px;
        line-height: 1;
        color: var(--mob-orange);
    }

    #rightPart2 {
        display: flex;
        flex: 1 1 auto;
        /* Envuelve: el nombre con Equipar ocupa el primer renglon y abajo, en
           el segundo, entran el stock y los dos precios en fila. Sin esto la
           tarjeta mide tres renglones y el dock se come la franja del 3D. */
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 2px 6px !important;
        height: auto;
        min-width: 0;
        margin: 0;
    }

    #rightTopPart {
        display: flex;
        flex: 1 1 100%;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 6px;
        width: auto;
    }

    #equip_txt {
        flex: 1 1 auto;
        width: auto !important;
        font-size: 10px;
        line-height: 1.1;
    }

    #equip_btn {
        flex: 0 0 auto;
        width: auto !important;
        min-width: 52px;
        height: 20px !important;
        margin: 0;
        font-size: 10px;
        font-weight: 600;
        border: 1px solid #ff8c42;
        border-radius: 5px;
        background: #ff8c421f;
        color: #ffffff;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #equip_btn.equipado {
        background: var(--mob-orange);
        border-color: var(--mob-orange);
    }

    #stockContainer {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 3px;
    }

    #stockContainer svg {
        width: 11px;
        height: 11px;
    }

    #stockTxtLabel,
    #stockCantTxt {
        font-size: 9px;
    }

    #precioContainer {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 4px;
    }

    #precioCont {
        display: flex;
        flex: 0 0 auto;
        flex-direction: column;
        align-items: center;
        width: auto;
        padding: 1px 5px;
        border-radius: 5px;
        box-shadow: 0px 0px 0px 1px #b45e00;
    }

    #precioLabel {
        font-size: 7px;
        line-height: 1.1;
    }

    #equip_precio_txt,
    #equip_precio_eff_txt {
        font-size: 11px !important;
        line-height: 1.1;
    }

    #precioCont:last-child {
        box-shadow: 0px 0px 0px 1px var(--mob-orange);
    }

    #equip_precio_eff_txt {
        color: var(--mob-orange) !important;
    }

    /* ==================================================================
       Resumen — una sola fila, envuelve sola si no entra
       ================================================================== */

    #equipResumen {
        display: flex;
        flex: 0 0 auto;
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 5px;
        width: auto;
        margin: 0;
        padding: 3px 5px;
        color: #ffffff;
        background: #000000b3;
        border-radius: 8px;
        backdrop-filter: blur(6px);
        user-select: none;
    }

    .resumenHeaderCont {
        display: flex;
        flex: 0 0 auto;
        flex-direction: row;
        align-items: center;
        gap: 6px;
        margin: 0;
    }

    #itemTitulo {
        font-size: 11px;
    }

    #showHide {
        width: auto !important;
        height: 18px !important;
        margin: 0;
        font-size: 9px;
        font-weight: 600;
        border: 1px solid #ff8c42;
        border-radius: 5px;
        background: #ff8c421f;
        color: #ffffff;
    }

    /* La lista scrollea adentro. Con flex-basis se acomoda a una sola linea
       en pantalla ancha y se cae a su propia linea cuando no entra. */
    #hide {
        flex: 1 1 150px;
        min-width: 0;
        max-height: 30px;
        overflow-y: auto;
    }

    #hide hr {
        margin: 1px 0;
        border: 0;
        border-top: 1px solid #ffffff26;
    }

    #noProdTxt {
        font-size: 10px;
        margin: 0;
    }

    .equipResumenItem {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 6px;
        font-size: 9px;
    }

    #itemNombre {
        flex: 1 1 auto;
        min-width: 0;
        font-size: 9px;
        overflow: hidden;
        white-space: nowrap;
    }

    .total {
        display: flex;
        flex: 0 0 auto;
        flex-direction: row;
        align-items: center;
        gap: 5px;
        margin: 0;
    }

    /* La palabra "Total" se muestra: main.js le pone display inline 'block'
       cuando hay productos y eso le gana a la hoja, asi que esconderla
       habria que pelear con un !important. Sale chica y al lado de las dos
       cajas, que ya traen su propio titulo. */
    #totalLabel {
        font-size: 9px;
        line-height: 1;
        white-space: nowrap;
    }

    #equipResumenTotal {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 4px;
    }

    .ResumenTotal {
        display: flex;
        flex-direction: column;
        padding: 1px 5px;
        font-size: 8px;
        border-radius: 5px;
        box-shadow: 0px 0px 0px 1px #b45e00;
    }

    #resumenPrecio,
    #resumenPrecioEfect {
        font-size: 11px !important;
        font-weight: bold !important;
    }

    #resumenPrecio {
        color: #b9b9b9 !important;
    }

    #resumenPrecioEfect {
        color: var(--mob-orange) !important;
    }

    #sumarCarrito {
        width: auto !important;
        height: 20px !important;
        margin: 0 !important;
        align-self: center;
        font-size: 9px;
        font-weight: 600;
        padding: 0 7px;
        border: 1px solid #ff8c42;
        border-radius: 5px;
        background: #ff8c421f;
        color: #ffffff;
    }

    /* ==================================================================
       Aviso de girar
       ================================================================== */

    #rotateHint {
        position: fixed;
        inset: 0;
        z-index: 55;
        display: none;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 10px;
        padding: 16px;
        text-align: center;
        background: #0b0b0bf2;
        color: #ffffff;
        font-size: 13px;
        pointer-events: none;
    }

    body.mostrarGiro #rotateHint {
        display: flex;
    }

    #rotateHint svg {
        width: 46px;
        height: 46px;
        stroke: var(--mob-orange);
        fill: none;
        stroke-width: 2.5;
        stroke-linecap: round;
        stroke-linejoin: round;
        animation: girar 2.4s ease-in-out infinite;
    }

    @keyframes girar {

        0%,
        35% {
            transform: rotate(0deg);
        }

        65%,
        100% {
            transform: rotate(-90deg);
        }
    }

    /* ==================================================================
       Pantallas muy bajas (celulares en horizontal Chico)
       Solo escala: no cambia la estructura ni oculta contenido.
       ================================================================== */

    @media (max-height: 400px) {

        :root {
            --mob-h: 28px;
        }

        .logo {
            height: 18px;
        }

        #user {
            width: 20px;
            height: 20px;
            font-size: 9px;
        }

        #compras {
            width: 26px;
            height: 26px;
        }

        .icono-carrito {
            width: 19px;
            height: 19px;
        }

        #title {
            height: 19px;
            min-height: 19px;
        }

        #title_txt {
            font-size: 11px;
        }

        #btn_prev,
        #btn_next {
            width: 26px;
            height: 26px;
        }

        #btn_prev svg,
        #btn_next svg {
            width: 19px;
            height: 19px;
        }

        #brand_logo {
            height: 18px;
        }

        #main_desc_img {
            width: 56px;
            height: 15px;
        }

        #part_logo {
            width: 18px;
            height: 18px;
        }

        #part_txt {
            font-size: 9px;
        }

        #equip_logo {
            width: 36px;
            height: 36px;
        }

        #leftPart2 {
            width: 36px !important;
        }

        #equip_txt {
            font-size: 9px;
        }

        #equip_btn {
            height: 18px !important;
            min-width: 46px;
        }

        #stockTxtLabel,
        #stockCantTxt {
            font-size: 8px;
        }

        #precioLabel {
            font-size: 6px;
        }

        #equip_precio_txt,
        #equip_precio_eff_txt,
        #resumenPrecio,
        #resumenPrecioEfect {
            font-size: 10px !important;
        }

        #hide {
            max-height: 26px;
        }

        #itemTitulo {
            font-size: 10px;
        }
    }
}
