/* =====================================================================
   assets/css/pos.css
   Estilos del Sistema POS sobre Bootstrap 5.3.
   Enfoque movil primero: la caja puede operarse desde una tablet.
   ===================================================================== */

:root {
    --pos-topbar-alto: 56px;
    --pos-sidebar-ancho: 260px;
    --pos-verde: #15803d;
    --pos-verde-oscuro: #14532d;
    --pos-oscuro: #111827;
    --pos-oscuro-suave: #1f2937;
}

/* ------------------------------- Base ------------------------------- */

body.pos-body {
    background-color: #f1f5f9;
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

/* ---------------------------- Barra superior ------------------------ */

.pos-topbar {
    min-height: var(--pos-topbar-alto);
    background: linear-gradient(90deg, var(--pos-verde-oscuro), var(--pos-verde));
    box-shadow: 0 1px 6px rgba(0, 0, 0, .25);
    z-index: 1035;
}

.pos-topbar .navbar-brand:hover {
    opacity: .9;
}

.pos-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .22);
    font-size: .78rem;
    font-weight: 700;
    line-height: 1;
}

/* -------------------------- Estructura general ---------------------- */

.pos-shell {
    display: flex;
    align-items: stretch;
    min-height: calc(100vh - var(--pos-topbar-alto));
}

.pos-contenido {
    flex: 1 1 auto;
    /* Imprescindible: sin esto las tablas anchas desbordan el layout flex. */
    min-width: 0;
}

/* ----------------------------- Menu lateral ------------------------- */

.pos-sidebar {
    background-color: var(--pos-oscuro);
    color: #cbd5e1;
}

@media (min-width: 992px) {
    .pos-sidebar {
        flex: 0 0 var(--pos-sidebar-ancho);
        width: var(--pos-sidebar-ancho);
        position: sticky;
        top: var(--pos-topbar-alto);
        height: calc(100vh - var(--pos-topbar-alto));
        overflow-y: auto;
        border-right: 1px solid rgba(255, 255, 255, .06);
    }
}

@media (max-width: 991.98px) {
    .pos-sidebar {
        width: var(--pos-sidebar-ancho);
        max-width: 85vw;
    }
}

.pos-menu {
    padding: .5rem 0 2rem;
}

.pos-menu-seccion {
    padding: 1rem 1.15rem .35rem;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .09em;
    text-transform: uppercase;
    color: #64748b;
}

.pos-menu .nav-link {
    color: #0b6de3;
    padding: .6rem 1.15rem;
    border-left: 3px solid transparent;
    border-radius: 0;
    font-size: .93rem;
    transition: background-color .12s ease, color .12s ease;
}

.pos-menu .nav-link i {
    width: 1.25rem;
    text-align: center;
    font-size: 1.02rem;
}

.pos-menu .nav-link:hover,
.pos-menu .nav-link:focus-visible {
    background-color: var(--pos-oscuro-suave);
    color: #fff;
}

.pos-menu .nav-link.active {
    background-color: rgba(21, 128, 61, .22);
    border-left-color: #22c55e;
    color: #fff;
    font-weight: 600;
}

.pos-menu .pos-menu-pendiente {
    color: #475569;
    cursor: not-allowed;
}

.pos-menu .pos-menu-pendiente:hover {
    background-color: transparent;
    color: #475569;
}

/* ------------------------------- Tarjetas --------------------------- */

.pos-card {
    border: 0;
    border-radius: .75rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .06);
}

.pos-kpi {
    border-radius: .75rem;
    border: 0;
    border-left: 4px solid var(--bs-primary);
    box-shadow: 0 1px 3px rgba(15, 23, 42, .08);
}

.pos-kpi .pos-kpi-valor {
    font-size: clamp(1.25rem, 2.6vw, 1.75rem);
    font-weight: 700;
    line-height: 1.15;
    /* Los importes largos no deben romper la tarjeta en movil. */
    overflow-wrap: anywhere;
}

.pos-kpi .pos-kpi-etiqueta {
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #64748b;
}

.pos-kpi-icono {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: .65rem;
    font-size: 1.25rem;
}

/* -------------------------------- Tablas ---------------------------- */

.pos-tabla {
    font-size: .9rem;
}

.pos-tabla thead th {
    background-color: #f8fafc;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: #475569;
    white-space: nowrap;
    border-bottom-width: 1px;
}

.pos-tabla td {
    vertical-align: middle;
}

/* Columnas numericas: tabular-nums alinea los digitos verticalmente. */
.pos-num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.pos-mono {
    font-family: var(--bs-font-monospace);
    font-size: .85em;
}

/* ------------------------- Estados e indicadores -------------------- */

.pos-chip {
    display: inline-block;
    padding: .2rem .5rem;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
}

.pos-stock-critico { color: #b91c1c; font-weight: 700; }
.pos-stock-bajo    { color: #b45309; font-weight: 700; }
.pos-stock-ok      { color: #15803d; font-weight: 600; }

.pos-vacio {
    padding: 2.5rem 1rem;
    text-align: center;
    color: #64748b;
}

.pos-vacio i {
    font-size: 2.5rem;
    display: block;
    margin-bottom: .5rem;
    opacity: .45;
}

/* ------------------------------ Formularios ------------------------- */

.pos-form-seccion {
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
    color: #64748b;
    padding-bottom: .4rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

/* Campos de peso e importe: mas grandes para teclear rapido en caja. */
.pos-input-numero {
    font-variant-numeric: tabular-nums;
    text-align: right;
    font-weight: 600;
}

.pos-requerido::after {
    content: " *";
    color: #dc2626;
    font-weight: 700;
}

/* ---------------------- Matriz de permisos granular ----------------- */

.pos-permiso-item {
    border: 1px solid #e2e8f0;
    border-radius: .5rem;
    padding: .6rem .75rem;
    height: 100%;
    transition: border-color .12s ease, background-color .12s ease;
}

.pos-permiso-item:hover {
    border-color: #94a3b8;
    background-color: #f8fafc;
}

.pos-permiso-item.pos-permiso-critico {
    border-left: 3px solid #f59e0b;
}

.pos-permiso-clave {
    font-family: var(--bs-font-monospace);
    font-size: .72rem;
    color: #64748b;
}

/* ------------------------- Punto de venta tactil -------------------- */

/* Tarjeta de producto: area de toque comoda incluso con guantes. */
.pos-producto {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: .15rem;
    min-height: 118px;
    padding: .6rem .7rem .6rem .95rem;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: .65rem;
    text-align: left;
    transition: border-color .12s ease, box-shadow .12s ease, transform .06s ease;
}

.pos-producto:hover:not(:disabled),
.pos-producto:focus-visible {
    border-color: var(--pos-verde);
    box-shadow: 0 2px 10px rgba(21, 128, 61, .18);
}

.pos-producto:active:not(:disabled) {
    transform: scale(.985);
}

.pos-producto:disabled {
    opacity: .55;
    cursor: not-allowed;
}

/* Franja de color de la categoria, como pestana lateral. */
.pos-producto-barra {
    position: absolute;
    inset: .6rem auto .6rem .35rem;
    width: 4px;
    border-radius: 2px;
}

.pos-producto-nombre {
    font-weight: 600;
    font-size: .88rem;
    line-height: 1.25;
    /* Dos lineas como maximo: la cuadricula debe quedar pareja. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pos-producto-sku {
    font-family: var(--bs-font-monospace);
    font-size: .7rem;
    color: #94a3b8;
}

.pos-producto-precio {
    margin-top: auto;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--pos-verde);
    font-variant-numeric: tabular-nums;
}

.pos-producto-pie {
    display: flex;
    align-items: center;
    gap: .35rem;
    flex-wrap: wrap;
    font-size: .7rem;
}

/* ------------------------------- Carrito ---------------------------- */

@media (min-width: 1200px) {
    /* El ticket acompana al cajero mientras recorre el catalogo. */
    .pos-venta .pos-carrito {
        position: sticky;
        top: calc(var(--pos-topbar-alto) + 1rem);
    }
}

.pos-carrito-lista {
    max-height: 46vh;
    overflow-y: auto;
}

@media (min-width: 1200px) {
    .pos-carrito-lista {
        max-height: 52vh;
    }
}

.pos-carrito-linea {
    padding: .65rem .9rem;
    border-bottom: 1px solid #f1f5f9;
}

.pos-carrito-linea:last-child {
    border-bottom: 0;
}

.pos-carrito-linea:hover {
    background-color: #f8fafc;
}

/* ------------------------------- Login ------------------------------ */

.pos-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, var(--pos-verde-oscuro) 0%, #052e16 55%, #0f172a 100%);
}

.pos-login-card {
    border: 0;
    border-radius: 1rem;
    box-shadow: 0 18px 45px rgba(0, 0, 0, .35);
}

/* ------------------------------ Impresion --------------------------- */

@media print {
    .pos-topbar,
    .pos-sidebar,
    .pos-no-imprimir,
    .btn,
    .alert-dismissible .btn-close {
        display: none !important;
    }

    .pos-shell,
    .pos-contenido {
        display: block;
        margin: 0;
        padding: 0;
    }

    body.pos-body {
        background: #fff;
    }

    .pos-card,
    .pos-kpi {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}
