/* Taller Mackauto — fase 2 (navegacion). Solo móvil salvo que se diga. */

/* =====================================================================
   Variable compartida: alto de la barra de abajo del móvil.
   Quien tenga algo fijo abajo (p. ej. la barra de la orden) usa
   `bottom: var(--mack-barra-movil)` y queda justo encima.
   En el ordenador vale 0.
   ===================================================================== */
:root {
    --mack-barra-movil: 0px;
}

/* Cosas que solo existen en el móvil: fuera en el ordenador. */
.mack-barra-movil,
.mack-hoja-mas,
.mack-titulo-movil,
.mack-filtros-boton,
.mack-facturas-tarjetas,
.mack-vista-previa-boton,
.mack-cliente-acciones {
    display: none;
}

@media (min-width: 768px) {
    .mack-hoja-mas {
        display: none !important;
    }
}

@media print {
    .mack-barra-movil,
    .mack-hoja-mas {
        display: none !important;
    }
}

@media (max-width: 767px) {
    :root {
        --mack-barra-movil: calc(60px + env(safe-area-inset-bottom, 0px));
    }

    /* =================================================================
       F2-01 · Barra de arriba: título de la pantalla + avatar.
       La tira de pestañas recientes no se enseña en el móvil.
       ================================================================= */
    #ops-workspace-tabs,
    .ops-workspace-tabs {
        display: none !important;
    }

    .ops-main-shell,
    .ops-main-shell:has(.ops-workspace-tabs.is-visible) {
        --ops-sticky-workspace-tabs-height: 0rem;
    }

    .ops-shell-chrome {
        background: var(--mack-navy) !important;
    }

    .ops-topbar {
        position: relative !important;
        top: auto !important;
        right: auto !important;
        width: 100% !important;
        height: 3rem !important;
        min-height: 3rem !important;
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        padding: 0 1rem !important;
        background: var(--mack-navy) !important;
    }

    .mack-titulo-movil {
        display: block;
        flex: 1 1 auto;
        min-width: 0;
        margin: 0;
        overflow: hidden;
        color: #fff;
        font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;
        font-size: 1.0625rem;
        font-weight: 700;
        letter-spacing: -0.01em;
        line-height: 1.2;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .ops-topbar__account {
        flex: 0 0 auto;
        margin-left: 0 !important;
        border-left: 0 !important;
        background: transparent !important;
    }

    .ops-user-avatar--topbar {
        box-shadow: 0 0 0 2px rgb(255 255 255 / 0.9);
    }

    .ops-topbar-user-menu__trigger {
        min-width: 44px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* Que nada quede debajo de la barra de abajo. */
    .ops-main {
        padding-bottom: calc(var(--mack-barra-movil) + 1.25rem) !important;
    }

    /* =================================================================
       F2-01 · Barra de navegación de abajo (opaca, de una pieza).
       ================================================================= */
    .mack-barra-movil {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 60;
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: minmax(0, 1fr);
        align-items: stretch;
        height: var(--mack-barra-movil);
        padding: 0 0.25rem env(safe-area-inset-bottom, 0px);
        box-sizing: border-box;
        background: #fff;
        border-top: 1px solid var(--mack-borde, #dde1ea);
        box-shadow: 0 -2px 10px rgb(17 26 51 / 0.06);
        font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;
    }

    .mack-barra-movil__item {
        position: relative;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.1875rem;
        min-width: 0;
        min-height: 60px;
        height: 60px;
        margin: 0;
        padding: 0 0.125rem;
        border: 0;
        background: transparent;
        color: #5b6477;
        font: inherit;
        font-size: 0.6875rem;
        font-weight: 700;
        line-height: 1.1;
        letter-spacing: 0;
        text-decoration: none;
        white-space: nowrap;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .mack-barra-movil__item > span {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mack-barra-movil__icono {
        width: 1.5rem;
        height: 1.5rem;
        flex-shrink: 0;
    }

    .mack-barra-movil__item.is-activo {
        color: var(--mack-navy, #202f57);
    }

    .mack-barra-movil__item.is-activo::before {
        content: '';
        position: absolute;
        top: 0;
        left: 22%;
        right: 22%;
        height: 3px;
        border-radius: 0 0 3px 3px;
        background: var(--mack-red, #cb1824);
    }

    .mack-barra-movil__item:focus-visible {
        outline: 3px solid rgb(32 47 87 / 0.35);
        outline-offset: -3px;
        border-radius: 10px;
    }

    /* Recepción: el botón central, rojo y algo más grande. */
    .mack-barra-movil__item--recepcion {
        color: var(--mack-red, #cb1824);
        justify-content: flex-end;
        padding-bottom: 0.4375rem;
    }

    .mack-barra-movil__item--recepcion.is-activo {
        color: var(--mack-red, #cb1824);
    }

    .mack-barra-movil__item--recepcion.is-activo::before {
        display: none;
    }

    .mack-barra-movil__circulo {
        position: absolute;
        top: -1.125rem;
        left: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 3.5rem;
        height: 3.5rem;
        margin-left: -1.75rem;
        border: 4px solid #fff;
        border-radius: 999px;
        background: var(--mack-red, #cb1824);
        color: #fff;
        box-shadow: 0 4px 12px rgb(203 24 36 / 0.35);
    }

    .mack-barra-movil__circulo .mack-barra-movil__icono {
        width: 1.625rem;
        height: 1.625rem;
    }

    .mack-barra-movil__item--recepcion:active .mack-barra-movil__circulo {
        background: var(--mack-red-600, #b3141f);
    }

    /* =================================================================
       F2-01 · Hoja «Más».
       ================================================================= */
    .mack-hoja-mas {
        position: fixed;
        inset: 0;
        z-index: 90;
        display: block;
        font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;
    }

    .mack-hoja-mas[hidden] {
        display: none;
    }

    html.mack-hoja-abierta,
    html.mack-hoja-abierta body {
        overflow: hidden;
    }

    .mack-hoja-mas__fondo {
        position: absolute;
        inset: 0;
        background: rgb(17 26 51 / 0.5);
    }

    .mack-hoja-mas__panel {
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        max-height: calc(100% - 3rem);
        overflow-y: auto;
        box-sizing: border-box;
        padding: 0.5rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
        border-radius: 16px 16px 0 0;
        background: #fff;
        box-shadow: 0 -8px 24px rgb(17 26 51 / 0.2);
    }

    .mack-hoja-mas__cabeza {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 0.25rem 0 0.5rem;
    }

    .mack-hoja-mas__titulo {
        margin: 0;
        color: #5b6477;
        font-size: 0.75rem;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
    }

    .mack-hoja-mas__cerrar {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border: 0;
        border-radius: 10px;
        background: transparent;
        color: var(--mack-navy, #202f57);
        cursor: pointer;
    }

    .mack-hoja-mas__cerrar svg {
        width: 1.25rem;
        height: 1.25rem;
    }

    .mack-hoja-mas__lista {
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .mack-hoja-mas__lista li + li {
        border-top: 1px solid #eef0f5;
    }

    .mack-hoja-mas__form {
        margin: 0;
    }

    .mack-hoja-mas__enlace {
        display: flex;
        align-items: center;
        gap: 0.875rem;
        width: 100%;
        min-height: 3.25rem;
        padding: 0 0.5rem;
        border: 0;
        border-radius: 10px;
        background: transparent;
        color: var(--mack-navy-950, #111a33);
        font: inherit;
        font-size: 1rem;
        font-weight: 700;
        text-align: left;
        text-decoration: none;
        cursor: pointer;
    }

    .mack-hoja-mas__enlace svg {
        width: 1.375rem;
        height: 1.375rem;
        flex-shrink: 0;
        color: var(--mack-navy, #202f57);
    }

    .mack-hoja-mas__enlace.is-activo {
        background: #eef0f5;
    }

    .mack-hoja-mas__enlace--salir,
    .mack-hoja-mas__enlace--salir svg {
        color: var(--mack-red, #cb1824);
    }

    /* Buscador global (se abre con «Buscar»): arriba y sin zoom del iPhone. */
    .ops-global-search {
        padding: 0.75rem 0.75rem 1rem !important;
    }

    .ops-global-search__input {
        font-size: 16px !important;
        min-height: 3rem;
    }

    /* Modo oscuro */
    html.dark .mack-barra-movil {
        background: #111a33;
        border-top-color: #26314f;
    }

    html.dark .mack-barra-movil__item {
        color: #a3adc2;
    }

    html.dark .mack-barra-movil__item.is-activo {
        color: #fff;
    }

    html.dark .mack-barra-movil__item--recepcion,
    html.dark .mack-barra-movil__item--recepcion.is-activo {
        color: #ff8a92;
    }

    html.dark .mack-barra-movil__circulo {
        border-color: #111a33;
    }

    html.dark .mack-hoja-mas__panel {
        background: #111a33;
    }

    html.dark .mack-hoja-mas__enlace,
    html.dark .mack-hoja-mas__enlace svg,
    html.dark .mack-hoja-mas__cerrar {
        color: #e8ecf5;
    }

    html.dark .mack-hoja-mas__enlace.is-activo {
        background: #1c2745;
    }

    html.dark .mack-hoja-mas__lista li + li {
        border-top-color: #1c2745;
    }

    html.dark .mack-hoja-mas__enlace--salir,
    html.dark .mack-hoja-mas__enlace--salir svg {
        color: #ff8a92;
    }

    /* =================================================================
       F2-04 · Listas (Reparaciones, Vehículos, Clientes):
       solo la caja de búsqueda; el resto tras «Filtros».
       ================================================================= */
    .ops-index:has([data-mack-filtros]) .ops-page-toolbar-note,
    .ops-index:has([data-mack-filtros]) .ops-page-toolbar .ops-page-link--primary {
        display: none !important;
    }

    .ops-index:has([data-mack-filtros]) .ops-page-toolbar:not(:has(.ops-page-link:not(.ops-page-link--primary))) {
        display: none !important;
    }

    .ops-index-filters:has(> .mack-filtros-boton) {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: end;
        gap: 0.5rem;
    }

    .ops-index-filters:has(> .mack-filtros-boton) > .mack-filtro-extra {
        grid-column: 1 / -1;
    }

    .ops-index-filters:has(> .mack-filtros-boton) > div:first-of-type .ops-index-field-label {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    [data-mack-filtros] .ops-index-field {
        min-height: 2.75rem;
        font-size: 16px;
    }

    [data-mack-filtros]:not(.mack-filtros-abiertos) .mack-filtro-extra {
        display: none !important;
    }

    .mack-filtros-boton {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.375rem;
        min-height: 2.75rem;
        padding: 0 0.875rem;
        border: 1px solid var(--mack-borde, #dde1ea) !important;
        border-radius: 10px !important;
        background: #fff;
        color: var(--mack-navy, #202f57);
        font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;
        font-size: 0.9375rem;
        font-weight: 700;
        white-space: nowrap;
        cursor: pointer;
    }

    .mack-filtros-boton svg {
        width: 1.125rem;
        height: 1.125rem;
        flex-shrink: 0;
    }

    .mack-filtros-abiertos .mack-filtros-boton {
        border-color: var(--mack-navy, #202f57) !important;
        background: #eef0f5;
    }

    /* Mientras busca al escribir, los resultados viejos se atenúan. */
    [data-mack-bloque-filtros]:has(.mack-buscando) ~ * {
        opacity: 0.55;
        transition: opacity 120ms ease;
    }

    /* Botones de la lista: dedo de 44 px. */
    [data-mack-filtros] .ops-index-btn {
        min-height: 2.75rem;
    }

    /* =================================================================
       F2-04 · Facturas: filtros plegados, KPIs 2×2 y tarjetas.
       ================================================================= */
    .mack-facturas-filtros {
        padding: 0.75rem !important;
    }

    .mack-facturas-filtros .mack-filtros-boton {
        width: 100%;
        margin-bottom: 0.625rem;
    }

    .mack-facturas-filtros input,
    .mack-facturas-filtros select {
        min-height: 2.75rem;
        font-size: 16px !important;
    }

    .mack-facturas-filtros button[type='submit'] {
        min-height: 2.75rem;
        width: 100%;
    }

    .mack-facturas-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.5rem !important;
    }

    .mack-facturas-kpis > div {
        min-width: 0;
        padding: 0.5rem 0.625rem !important;
    }

    .mack-facturas-kpis > div > p:first-child {
        font-size: 0.625rem !important;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mack-facturas-kpis .text-2xl {
        margin-top: 0.125rem !important;
        font-size: 1.125rem !important;
        line-height: 1.3 !important;
        overflow-wrap: anywhere;
    }

    .mack-facturas-tabla {
        display: none !important;
    }

    .mack-facturas-tarjetas {
        display: grid;
        gap: 0.5rem;
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .mack-factura-tarjeta {
        display: grid;
        gap: 0.3125rem;
        padding: 0.75rem;
        border: 1px solid var(--mack-borde, #dde1ea);
        border-radius: var(--mack-radio, 12px);
        background: #fff;
        min-width: 0;
    }

    .mack-factura-tarjeta--rectificativa {
        background: #fff7f7;
    }

    .mack-factura-tarjeta--vacia {
        padding: 1.5rem 0.75rem;
        color: #64748b;
        font-size: 0.875rem;
        text-align: center;
    }

    .mack-factura-tarjeta__fila {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 0.75rem;
        min-width: 0;
    }

    .mack-factura-tarjeta__numero {
        color: var(--mack-navy-950, #111a33);
        font-size: 1rem;
        font-weight: 700;
        overflow-wrap: anywhere;
    }

    .mack-factura-tarjeta__total {
        flex-shrink: 0;
        color: var(--mack-navy-950, #111a33);
        font-size: 1.0625rem;
        font-weight: 800;
        white-space: nowrap;
    }

    .mack-factura-tarjeta__cliente {
        min-width: 0;
        overflow: hidden;
        color: #334155;
        font-size: 0.875rem;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mack-factura-tarjeta__fecha {
        flex-shrink: 0;
        color: #64748b;
        font-size: 0.8125rem;
        white-space: nowrap;
    }

    .mack-factura-tarjeta__estado {
        justify-self: start;
    }

    .mack-factura-tarjeta__botones {
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: minmax(0, 1fr);
        gap: 0.375rem;
        margin-top: 0.25rem;
    }

    .mack-factura-tarjeta__boton {
        display: flex;
        align-items: center;
        justify-content: center;
        min-width: 0;
        min-height: 2.75rem;
        padding: 0 0.375rem;
        border: 1px solid var(--mack-borde, #dde1ea);
        border-radius: 10px;
        background: #fff;
        color: var(--mack-navy, #202f57);
        font-size: 0.875rem;
        font-weight: 700;
        text-decoration: none;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* =================================================================
       F2-04 · Factura de una orden: vista previa A4 plegada.
       ================================================================= */
    .mack-vista-previa-boton {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 100%;
        min-height: 3rem;
        border: 1px solid var(--mack-navy, #202f57) !important;
        border-radius: 10px !important;
        background: #fff;
        color: var(--mack-navy, #202f57);
        font-family: Arial, 'Helvetica Neue', Helvetica, sans-serif;
        font-size: 1rem;
        font-weight: 700;
        cursor: pointer;
    }

    .mack-vista-previa:not(.mack-vista-previa--abierta) {
        display: none !important;
    }

    .mack-vista-previa iframe {
        height: 900px !important;
    }

    /* =================================================================
       F2-04 · Ajustes: apartados como pastillas con scroll de lado.
       ================================================================= */
    .mack-ajustes-secciones {
        padding: 0 !important;
        border: 0 !important;
        background: transparent !important;
    }

    .mack-ajustes-secciones > p {
        display: none !important;
    }

    .mack-ajustes-secciones nav {
        display: flex !important;
        gap: 0.5rem !important;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 0.125rem 0 0.375rem;
    }

    .mack-ajustes-secciones nav::-webkit-scrollbar {
        display: none;
    }

    .mack-ajustes-secciones nav > button {
        flex: 0 0 auto;
        min-height: 2.75rem;
        padding: 0 1rem !important;
        border: 1px solid var(--mack-borde, #dde1ea) !important;
        border-radius: 999px !important;
        white-space: nowrap;
        text-align: center !important;
    }

    .mack-ajustes-secciones nav > button:not(.bg-slate-950) {
        background: #fff;
    }

    .mack-ajustes-secciones nav > button.bg-slate-950 {
        border-color: var(--mack-navy, #202f57) !important;
    }

    /* =================================================================
       F2-05 · Ficha de cliente: Llamar · WhatsApp · Nueva orden.
       ================================================================= */
    .mack-cliente-cabeza {
        flex-direction: column;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }

    .mack-cliente-cabeza > div:last-child {
        justify-content: flex-start !important;
    }

    .mack-solo-escritorio {
        display: none !important;
    }

    .mack-cliente-acciones {
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: minmax(0, 1fr);
        gap: 0.5rem;
        margin-top: 0.75rem;
        width: 100%;
    }

    .mack-cliente-acciones .mack-cliente-acciones__telefono,
    .mack-cliente-acciones .mack-tel__acciones {
        display: contents !important;
    }

    .mack-cliente-acciones .mack-tel__boton,
    .mack-cliente-acciones__nueva {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0.375rem;
        min-width: 0;
        min-height: 3rem;
        padding: 0 0.375rem;
        border-radius: 10px;
        font-size: 0.9375rem;
        font-weight: 700;
        text-decoration: none;
        white-space: nowrap;
    }

    .mack-cliente-acciones__nueva {
        border: 1px solid var(--mack-red, #cb1824);
        background: var(--mack-red, #cb1824);
        color: #fff;
    }

    .mack-cliente-acciones__nueva:active {
        background: var(--mack-red-600, #b3141f);
    }

    .mack-cliente-acciones__nueva svg {
        width: 1.125rem;
        height: 1.125rem;
        flex-shrink: 0;
    }

    /* Los botones ya están arriba: en la línea del teléfono solo el número. */
    .mack-hub-telefono .mack-tel__acciones {
        display: none !important;
    }
}

/* Encima de la barra fija de la orden, el círculo rojo se hace pequeño y
   no sobresale: así no pisa «+ Trabajo». */
@media (max-width: 767.98px) {
    body:has(.ops-ro-footer) .mack-barra-movil__circulo,
    body:has(.rc-abrir) .mack-barra-movil__circulo {
        top: 0.3rem;
        width: 2.25rem;
        height: 2.25rem;
        margin-left: -1.125rem;
        border-width: 0;
        box-shadow: none;
    }
    body:has(.ops-ro-footer) .mack-barra-movil__circulo .mack-barra-movil__icono,
    body:has(.rc-abrir) .mack-barra-movil__circulo .mack-barra-movil__icono {
        width: 1.25rem;
        height: 1.25rem;
    }
}
