/* Estilos de la interfaz (los tickets usan estilos propios de impresión). */
:root { --pos-touch: 64px; }

.app-navbar { position: sticky; top: 0; z-index: 1030; }
.nav-logo { max-height: 32px; width: auto; max-width: 140px; object-fit: contain; }
.login-logo { max-height: 120px; max-width: 80%; width: auto; height: auto; object-fit: contain; }
.event-pill {
    background: #ffc107; color: #212529; font-weight: 600; border-radius: 2rem;
    padding: .25rem .8rem; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45vw;
}
.event-pill-none { background: #dc3545; color: #fff; }

.table td, .table th { vertical-align: middle; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.page-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.page-head h1 { margin: 0; font-size: 1.5rem; }
.stat-card .value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-card .label { color: var(--bs-secondary-color); font-size: .85rem; }
.perm-group { break-inside: avoid; }
.perm-columns { column-width: 22rem; column-gap: 1.5rem; }
.barcode-preview svg { max-width: 100%; }

/* ---- Pantalla de caja ---- */
.pos-wrap { height: calc(100vh - 56px); display: flex; gap: 0; }
.pos-left { flex: 1 1 58%; display: flex; flex-direction: column; padding: .75rem; overflow: hidden; }
.pos-right { flex: 1 1 42%; max-width: 560px; min-width: 340px; display: flex; flex-direction: column; border-left: 1px solid var(--bs-border-color); background: #fff; }
.pos-search .form-control { height: var(--pos-touch); font-size: 1.35rem; }
.pos-search .btn { min-width: var(--pos-touch); font-size: 1.3rem; }
.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; overflow-y: auto; padding: .2rem; align-content: start; }
.pos-tile {
    min-height: 96px; border: 2px solid var(--bs-border-color); border-radius: .6rem; background: #fff; text-align: left;
    padding: .55rem .7rem; display: flex; flex-direction: column; justify-content: space-between; font-weight: 600; line-height: 1.2;
}
.pos-tile:hover, .pos-tile:focus { border-color: var(--bs-primary); background: #f3f8ff; }
.pos-tile:active { transform: scale(.98); }
.pos-tile .price { font-size: 1.15rem; color: var(--bs-primary); }
.pos-tile .meta { font-size: .78rem; font-weight: 400; color: var(--bs-secondary-color); }
.pos-tile.is-low { border-color: #ffc107; }
.pos-tile.is-out { opacity: .5; }
.pos-cart { flex: 1 1 auto; overflow-y: auto; }
.cart-line { display: flex; gap: .5rem; align-items: center; padding: .55rem .75rem; border-bottom: 1px solid var(--bs-border-color); }
.cart-line .name { flex: 1 1 auto; min-width: 0; }
.cart-line .name .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.cart-line .name .s { font-size: .82rem; color: var(--bs-secondary-color); }
.cart-line .qty { display: flex; align-items: center; gap: .25rem; }
.cart-line .qty .btn { width: 44px; height: 44px; font-size: 1.2rem; padding: 0; }
.cart-line .qty input { width: 58px; height: 44px; text-align: center; font-size: 1.1rem; font-weight: 600; }
.cart-line .line-total { width: 92px; text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.cart-line.flash { animation: flash 0.6s; }
@keyframes flash { from { background: #d1f3dc; } to { background: transparent; } }
.price-changed { color: #b45309; font-weight: 600; }
.pos-total { padding: .75rem; border-top: 2px solid #212529; }
.pos-total .total { font-size: 2.2rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.pos-actions .btn { min-height: var(--pos-touch); font-size: 1.15rem; font-weight: 600; }
.pay-methods .btn { min-height: 56px; font-size: 1.05rem; }
.cash-quick .btn { min-width: 80px; }
.change-box { font-size: 1.8rem; font-weight: 800; }
.result-list .list-group-item { cursor: pointer; }

/* Tablet y celular: productos o carrito a pantalla completa, con total y botones fijos abajo. */
@media (max-width: 991.98px) {
    .pos-wrap { flex-direction: column; height: auto; min-height: calc(100vh - 56px); padding-bottom: calc(190px + env(safe-area-inset-bottom)); }
    .pos-left { overflow: visible; }
    .pos-right { max-width: none; min-width: 0; border-left: 0; display: none; }
    .pos-show-cart .pos-left { display: none; }
    .pos-show-cart .pos-right { display: flex; }
    .pos-grid { overflow: visible; }
    .pos-cart { overflow: visible; }
    .pos-total {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 1020; background: #fff;
        padding-bottom: calc(.75rem + env(safe-area-inset-bottom)); box-shadow: 0 -4px 12px rgba(0, 0, 0, .12);
    }
    .pos-total .total { font-size: 1.8rem; }
}
@media (max-width: 575.98px) {
    :root { --pos-touch: 54px; }
    .pos-search .form-control { font-size: 1.1rem; }
    .pos-grid { grid-template-columns: repeat(2, 1fr); gap: .45rem; }
    .pos-tile { min-height: 84px; }
    .cart-line { flex-wrap: wrap; }
    .cart-line .name { flex-basis: 100%; }
    .cart-line .line-total { margin-left: auto; }
    .pos-actions .btn { font-size: 1rem; }
    .pay-methods { flex-direction: column; }
    .pay-methods > .btn { border-radius: var(--bs-border-radius) !important; margin: 0 0 .35rem !important; min-height: 46px; }
    .change-box { font-size: 1.5rem; }
    .page-head h1 { font-size: 1.25rem; }
    .page-head > .d-flex, .page-head > div:not(:first-child) { flex-wrap: wrap; }
    .scan-input { height: 56px; font-size: 1.15rem; }
    .deliver-line { font-size: 1rem; }
    .deliver-line input { width: 64px; }
    .stat-card .value { font-size: 1.25rem; }
    .event-pill { max-width: 40vw; font-size: .8rem; }
    .modal-footer { flex-wrap: wrap; }
}

/* ---- Entregas ---- */
.scan-input { height: 64px; font-size: 1.4rem; }
.deliver-line { font-size: 1.1rem; }
.deliver-line input { width: 80px; }

@media print {
    .app-navbar, .no-print, .toast-top-center { display: none !important; }
    main { padding: 0 !important; }
}

/* ---- Lector con cámara ---- */
.scan-view { position: relative; background: #000; border-radius: .5rem; overflow: hidden; aspect-ratio: 4 / 3; }
.scan-view video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-guide { position: absolute; left: 8%; right: 8%; top: 30%; bottom: 30%; border: 3px solid rgba(255, 255, 255, .9); border-radius: .5rem; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35); }
.scan-guide::after { content: ''; position: absolute; left: 4%; right: 4%; top: 50%; border-top: 2px solid #dc3545; }
@media (max-width: 575.98px) { .scan-view { aspect-ratio: 3 / 4; } .scan-guide { top: 36%; bottom: 36%; } }

/* ---- Tablas ordenables ---- */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { background-color: rgba(13, 110, 253, .08); }
th.sortable::after { content: '\2195'; opacity: .3; margin-left: .3em; font-weight: 400; }
th.sortable.sort-asc::after { content: '\2191'; opacity: .9; }
th.sortable.sort-desc::after { content: '\2193'; opacity: .9; }
th.sortable:focus-visible { outline: 2px solid var(--bs-primary); outline-offset: -2px; }

/* ---- Manuales (Ayuda) ---- */
.manual { max-width: 980px; }
.manual h2 { font-size: 1.35rem; margin-top: 2.2rem; padding-top: .6rem; border-top: 1px solid var(--bs-border-color); scroll-margin-top: 70px; }
.manual h2:first-of-type { border-top: 0; margin-top: 1rem; }
.manual h3 { font-size: 1.05rem; margin-top: 1.3rem; }
.manual p, .manual li { line-height: 1.6; }
.manual ol.steps { counter-reset: step; list-style: none; padding-left: 0; }
.manual ol.steps > li { counter-increment: step; position: relative; padding-left: 2.6rem; margin-bottom: .7rem; }
.manual ol.steps > li::before { content: counter(step); position: absolute; left: 0; top: .05rem; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--bs-primary); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; font-size: .9rem; }
.manual-fig { margin: 1rem 0 1.4rem; }
.manual-fig img { max-width: 100%; height: auto; border: 1px solid var(--bs-border-color); border-radius: .5rem; box-shadow: 0 2px 10px rgba(0, 0, 0, .08); }
.manual-fig.phone img { max-width: 300px; }
.manual-fig.ticket img { max-width: 260px; }
.manual-fig figcaption { font-size: .85rem; color: var(--bs-secondary-color); margin-top: .35rem; }
.manual .tip, .manual .warn { border-radius: .5rem; padding: .75rem 1rem; margin: 1rem 0; }
.manual .tip { background: #e8f4ff; border-left: 4px solid var(--bs-primary); }
.manual .warn { background: #fff6e0; border-left: 4px solid #ffc107; }
.manual kbd { font-size: .8em; }
.manual-toc { position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow-y: auto; font-size: .9rem; }
.manual-toc a { display: block; padding: .2rem 0; text-decoration: none; }
.help-card { transition: transform .1s, box-shadow .1s; }
.help-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0, 0, 0, .1); }
@media print {
    .manual-toc, .manual-actions { display: none !important; }
    .manual h2 { break-after: avoid; }
    .manual-fig { break-inside: avoid; }
}
/* Portada del manual: solo al imprimir. */
.print-cover { display: none; }
@media print {
    .print-cover {
        display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
        height: 245mm; break-after: page; page-break-after: always;
    }
    .print-cover-logo { max-width: 70mm; max-height: 70mm; object-fit: contain; margin-bottom: 12mm; }
    .print-cover-icon { font-size: 60pt; margin-bottom: 10mm; }
    .print-cover-org { font-size: 14pt; letter-spacing: .08em; text-transform: uppercase; color: #555 !important; }
    .print-cover-title { font-size: 30pt; font-weight: 700; margin: 4mm 0 3mm; }
    .print-cover-for { font-size: 13pt; color: #444 !important; max-width: 140mm; }
    .print-cover-line { width: 40mm; border-top: 2px solid #000; margin: 10mm 0 5mm; }
    .print-cover-date { font-size: 10pt; color: #666 !important; }
}
/* Al imprimir, fondo siempre blanco (la página de ingreso y la ayuda sin sesión usan fondo gris en pantalla). */
@media print {
    html, body, main, .bg-body-tertiary, .bg-light { background: #fff !important; }
}
/* Manuales: texto justificado (pantalla e impresión) y, al imprimir, más margen y letra algo más pequeña. */
.manual p, .manual li, .manual dd, .manual .tip, .manual .warn { text-align: justify; hyphens: auto; -webkit-hyphens: auto; }
@media print {
    @page { size: A4; margin: 28mm 8mm 28mm 8mm; }
    .manual { font-size: 10.5pt; max-width: none; }
    .manual .lead { font-size: 11.5pt; }
    .manual h2 { font-size: 14pt; }
    .manual h3 { font-size: 11.5pt; }
    .manual-fig figcaption { font-size: 8.5pt; }
    .print-cover { height: 225mm; }
}
