/* =========================
   Mobile-friendly / safe areas
   ========================= */
:root {
    --safe-top: env(safe-area-inset-top,0);
    --safe-bottom: env(safe-area-inset-bottom,0);
}

/* La navbar no debe traslapar contenido en iOS con notch */
.navbar.sticky-top {
    padding-top: max(0px,var(--safe-top));
}

/* Toasts por encima de navbar/modals */
.toast-container {
    z-index: 1080;
}

/* Marca compacta en pantallas muy angostas */
.brand-logo {
    height: 28px;
    width: auto;
    object-fit: contain;
    vertical-align: middle;
}

@media (max-width:380px) {
    .brand-text {
        display: none;
    }
}

/* Tamaños táctiles cómodos */
.navbar .nav-link, .btn {
    min-height: 40px;
}

/* evita zoom al enfocar en iOS */
input, select {
    font-size: 16px;
}

/* =========================
   Navbar / Branding (logos)
   ========================= */
img[src*="/img/jl-logo"], img[src*="/img/gt-logo"] {
    max-height: 120px !important;
    width: auto !important;
    height: auto !important;
    display: inline-block;
}

/* =========================
   Tablas Inventario / General
   ========================= */
.table-inv {
    --head-top: 72px;
}
    /* alto aprox. de la navbar fija */

    /* Encabezados pegajosos */
    .table-inv thead th {
        position: sticky;
        top: var(--head-top);
        background: #fff;
        z-index: 5;
        box-shadow: 0 2px 0 rgba(0,0,0,.08);
        font-weight: 600;
    }
    /* Zebra */
    .table-inv tbody tr:nth-child(even) {
        background: rgba(0,0,0,.025);
    }
    /* Números alineados y con tabular-nums */
    .table-inv td.num, .table-inv th.num {
        text-align: right;
        font-variant-numeric: tabular-nums;
    }
    /* Columna IVA */
    .table-inv td.iva {
        width: 70px;
    }

    .table-inv .badge-iva {
        display: inline-block;
        font-weight: 600;
        letter-spacing: .25px;
        padding: .25rem .5rem;
        border-radius: .25rem;
    }

/* Compacta */
.table-compact td, .table-compact th {
    padding: .45rem .7rem;
    font-size: .9rem;
}

/* Contenedor scroll que no rompe sticky headers */
.table-scroll,
.table-responsive {
    -webkit-overflow-scrolling: touch;
}

/* =========================
   Barra de herramientas fija
   ========================= */
.inv-toolbar {
    position: sticky;
    top: calc(var(--head-top) - 8px);
    z-index: 6;
    background: #fff;
    padding: .75rem 1rem;
    border-radius: .75rem;
    box-shadow: 0 4px 16px -10px rgba(0,0,0,.25);
    display: flex;
    gap: .75rem;
    align-items: center;
}

/* =========================
   Botón flotante (móvil)
   ========================= */
.inv-fab {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 60;
    border-radius: 999px;
    padding: .75rem 1rem;
    box-shadow: 0 3px 12px rgba(0,0,0,.2);
}

/* =========================
   Utilidades
   ========================= */
td .small {
    color: #6b7280;
    font-size: .85em;
}

/* =========================
   Proformas: grid (DESKTOP)
   ========================= */

/* Rebalanceo de anchos en desktop (>=992px) */
@media (min-width:992px) {
    /* Celdas: Código | Descripción | Cant. | Precio | IVA | Subtotal | X */
    #tblDetalle td:nth-child(1) {
        width: 18%;
    }
    /* Código (más corto) */
    #tblDetalle td:nth-child(2) {
        width: 42%;
    }
    /* Descripción protagonista */
    #tblDetalle td:nth-child(3) {
        width: 90px;
    }
    /* Cant. */
    #tblDetalle td:nth-child(4) {
        width: 120px;
    }
    /* Precio */
    #tblDetalle td:nth-child(5) {
        width: 44px;
        text-align: center;
    }
    /* IVA */
    #tblDetalle td:nth-child(6) {
        width: 150px;
        text-align: right;
    }
    /* Subtotal */
    #tblDetalle td:nth-child(7) {
        width: 60px;
    }
    /* Eliminar */
}

/* Input-group del CÓDIGO: que el input crezca y la lupa sea fija */
#tblDetalle td:nth-child(1) .input-group > .prod-codigo {
    flex: 1 1 auto;
    min-width: 0;
}

#tblDetalle td:nth-child(1) .input-group > .btn {
    flex: 0 0 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-inline: .5rem;
}

/* Descripción realmente a 100% y con ellipsis si es larguísima */
#tblDetalle .prod-desc {
    width: 100%;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Inputs numéricos alineados y legibles */
#tblDetalle .prod-cant[type="number"],
#tblDetalle .prod-precio[type="number"],
#tblDetalle .prod-precio[type="text"] {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
    /* Quitar flechas (opcional) */
    #tblDetalle .prod-cant[type="number"]::-webkit-outer-spin-button,
    #tblDetalle .prod-cant[type="number"]::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }

#tblDetalle .prod-cant[type="number"] {
    -moz-appearance: textfield;
}

/* ===== CANTIDAD (base) ===== */
input.prod-cant[type="number"] {
    width: 88px;
    text-align: right;
    font-variant-numeric: tabular-nums;
    line-height: 1.25;
    padding-right: .5rem;
    appearance: textfield;
    -moz-appearance: textfield;
}

    input.prod-cant[type="number"]::-webkit-outer-spin-button,
    input.prod-cant[type="number"]::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }

/* =========================
   Proformas: MÓVIL (fila en UNA sola línea + scroll horizontal)
   ========================= */
@media (max-width:576px) {
    /* IMPORTANTÍSIMO: no cambiamos a grid. Mantenemos la fila en línea
     y damos anchos mínimos por columna; el contenedor .table-responsive
     provee el scroll horizontal. */
    #tblDetalle {
        table-layout: auto;
    }

        /* Definimos min-width por columna para mantener la fila en una línea */
        #tblDetalle td:nth-child(1) {
            min-width: 180px;
        }
        /* Código (input + lupa) */
        #tblDetalle td:nth-child(2) {
            min-width: 420px;
        }
        /* Descripción amplia */
        #tblDetalle td:nth-child(3) {
            min-width: 96px;
        }
        /* Cantidad */
        #tblDetalle td:nth-child(4) {
            min-width: 130px;
        }
        /* Precio */
        #tblDetalle td:nth-child(5) {
            min-width: 44px;
            text-align: center;
        }
        /* IVA */
        #tblDetalle td:nth-child(6) {
            min-width: 150px;
            text-align: right;
        }
        /* Subtotal */
        #tblDetalle td:nth-child(7) {
            min-width: 64px;
        }
        /* Eliminar */

        /* Inputs a 100% dentro de su celda */
        #tblDetalle .prod-codigo,
        #tblDetalle .prod-desc,
        #tblDetalle .prod-cant,
        #tblDetalle .prod-precio {
            width: 100%;
        }

        /* Un poco más compactos en móvil */
        #tblDetalle .form-control {
            padding: .35rem .5rem;
            font-size: .95rem;
            line-height: 1.2;
        }

    /* cantidad un poco más ancha en móvil */
    input.prod-cant[type="number"] {
        width: 96px;
    }
}

/* Respeto a preferencias del usuario (reduce motion) */
@media (prefers-reduced-motion:reduce) {
    * {
        scroll-behavior: auto !important;
        animation: none !important;
        transition: none !important;
    }
}

/* =========================
   Mejora contraste en el login
   ========================= */
.auth-login .form-control {
    background-color: #ffffff !important;
    color: #111827 !important;
    border-color: #cbd5e1;
}

    .auth-login .form-control:focus {
        background-color: #ffffff !important;
        color: #0b1320 !important;
        border-color: #0d6efd;
        box-shadow: 0 0 0 .2rem rgba(13,110,253,.15);
    }

    .auth-login .form-control::placeholder {
        color: #6b7280;
        opacity: 1;
    }

.auth-login label {
    color: #111827;
    font-weight: 600;
}

/* =========================
   Wrapper de contenido (centra en pantallas grandes)
   ========================= */
.content-wrap {
    max-width: 1440px;
    margin: 0 auto;
    padding-left: .75rem;
    padding-right: .75rem;
}

@media (min-width: 992px) {
    .content-wrap {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* FIX: cerrar correctamente el media query (antes estaba cortado) */
@media (min-width: 1600px) {
    .content-wrap {
        max-width: 1560px;
    }
}

/* =========================
   Pulido moderno (sin romper lógica)
   ========================= */

/* Asegura Inter en toda la app */
html, body {
    font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* Enfoque accesible y “pro” */
:focus-visible {
    outline: 2px solid rgba(13,110,253,.45);
    outline-offset: 2px;
    border-radius: .6rem;
}

/* Cards y contenedores más suaves */
.card {
    border-radius: 1rem;
}

    .card .card-body {
        padding: 1.25rem;
    }

.shadow-sm {
    box-shadow: 0 .125rem .65rem rgba(0,0,0,.08) !important;
}

/* Inputs y selects más modernos */
.form-control, .form-select, .input-group-text {
    border-radius: .85rem;
}

    .form-control:focus, .form-select:focus {
        box-shadow: 0 0 0 .2rem rgba(13,110,253,.14);
    }

/* Botones consistentes */
.btn {
    border-radius: .85rem;
}

.btn-sm {
    border-radius: .75rem;
}

/* Tablas más limpias */
.table {
    --bs-table-border-color: rgba(0,0,0,.08);
}

    .table thead th {
        font-weight: 600;
    }

/* Table-responsive con esquina redonda (se siente premium) */
.table-responsive {
    border-radius: 1rem;
}
}

.navbar .brand-logo {
    max-height: 28px !important;
    height: 28px !important;
}