/* ============================================================================
 * G3 :: g3-pos-ux - Mejoras de UX al POS (overlay CSS, NO toca HTML)
 *
 * Aplica solo en /ventas/nueva
 * - Layout sin scroll innecesario
 * - Buscador sticky top
 * - Carrito columna fija
 * - Items compactos
 * - Productos nombre truncado con tooltip
 * - Indicador visual de version
 * ============================================================================ */

/* === Container principal del POS === */
/* Detectamos el body que contiene /ventas/nueva por su path o h1 */
body[data-pos="active"], body.pos-mode {
    /* Quitar overflow innecesario del body */
    overflow-x: hidden;
}

/* === Sticky buscador en /ventas/nueva === */
/* Busca cualquier div con clase pos-buscador, pos-search, search-bar
 * dentro de la pagina. Si no matcha, no aplica - es overlay defensivo */
.pos-buscador,
.pos-search,
.pos-busqueda,
[data-pos="buscador"] {
    position: sticky;
    top: 0;
    z-index: 100;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    padding: 0.6rem 0.85rem;
    margin: 0 -0.85rem;
    border-bottom: 2px solid #f3f4f6;
}

/* === Carrito columna lateral fija === */
.pos-carrito,
.pos-cart,
[data-pos="carrito"] {
    position: sticky;
    top: 4.5rem;
    align-self: flex-start;
    max-height: calc(100vh - 5rem);
    overflow-y: auto;
    scrollbar-width: thin;
}

/* === Items del carrito mas compactos === */
.pos-carrito .item,
.pos-carrito .carrito-item,
[data-pos="carrito"] .item-fila {
    padding: 0.4rem 0.6rem !important;
    font-size: 0.88rem !important;
    line-height: 1.3 !important;
}
.pos-carrito .item-nombre,
.pos-carrito .nombre-producto {
    /* Truncar con elipsis si es muy largo */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 240px;
    display: inline-block;
}

/* === Productos en grid - nombres truncados === */
.pos-producto-card,
.pos-prod-card,
[data-pos="prod-card"] {
    position: relative;
    overflow: hidden;
}
.pos-producto-card .nombre,
.pos-prod-card .nombre,
[data-pos="prod-card"] .nombre {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.2;
    max-height: 2.4em;
}

/* Mostrar nombre completo en hover (tooltip nativo del browser) */
.pos-producto-card[title]:hover::after,
.pos-prod-card[title]:hover::after {
    /* No agregamos nada porque title nativo ya muestra tooltip */
}

/* === Modal de cobro mejorado === */
.modal-cobro,
.modal-pagar,
[data-pos="modal-cobro"] {
    max-height: 95vh;
    overflow-y: auto;
}

/* === Botones de venta mas tactiles para tablet === */
@media (pointer: coarse) {
    /* Solo en pantallas tactiles */
    .pos-producto-card,
    .pos-prod-card {
        min-height: 100px;
    }
    .pos-carrito button {
        min-width: 36px;
        min-height: 36px;
    }
}

/* === Indicador de version en POS (esquina sup-der) === */
.g3-pos-version-badge {
    position: fixed;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(31, 41, 55, 0.85);
    color: white;
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-family: monospace;
    font-weight: 700;
    z-index: 50;
    pointer-events: none;
    backdrop-filter: blur(4px);
    user-select: none;
}

/* === Hint de atajos teclado (esquina inf-izq) === */
.g3-pos-shortcuts-hint {
    position: fixed;
    bottom: 1rem;
    left: 1rem;
    background: rgba(31, 41, 55, 0.92);
    color: #d1d5db;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    font-size: 0.72rem;
    font-family: monospace;
    line-height: 1.4;
    z-index: 9990;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    max-width: 220px;
    backdrop-filter: blur(4px);
    transition: opacity 0.3s, transform 0.3s;
    cursor: pointer;
}
.g3-pos-shortcuts-hint:hover {
    background: rgba(31, 41, 55, 1);
}
.g3-pos-shortcuts-hint.collapsed {
    opacity: 0.4;
    transform: translateY(0) scale(0.85);
}
.g3-pos-shortcuts-hint .key {
    background: #4b5563;
    color: white;
    padding: 0.05rem 0.4rem;
    border-radius: 3px;
    font-weight: 700;
    margin-right: 0.3rem;
    box-shadow: 0 1px 0 #1f2937;
    display: inline-block;
}
.g3-pos-shortcuts-hint .row {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    margin-bottom: 0.15rem;
}
.g3-pos-shortcuts-hint .titulo {
    font-weight: 700;
    color: white;
    margin-bottom: 0.4rem;
    font-size: 0.78rem;
    border-bottom: 1px solid #4b5563;
    padding-bottom: 0.25rem;
}

/* === Highlight visual cuando atajo se ejecuta === */
.g3-shortcut-flash {
    animation: g3-shortcut-pulse 0.4s ease;
}
@keyframes g3-shortcut-pulse {
    0% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); }
    100% { box-shadow: 0 0 0 12px rgba(59, 130, 246, 0); }
}

/* === Mobile - hide hints en pantallas chicas === */
@media (max-width: 768px) {
    .g3-pos-shortcuts-hint { display: none; }
    .g3-pos-version-badge { display: none; }
    .pos-carrito .item-nombre,
    .pos-carrito .nombre-producto {
        max-width: 160px;
    }
}

/* === Print - ocultar nuestros overlays === */
@media print {
    .g3-pos-version-badge,
    .g3-pos-shortcuts-hint { display: none !important; }
}
