/* mobile.css — L'Art POS · UI móvil optimizada */

:root {
    --mob-nav-h: 52px;
    --mob-checkout-h: 52px;
    --mob-header-h: 52px;
    --mob-safe-b: env(safe-area-inset-bottom, 0px);
    --mob-z-nav: 50;
    --mob-z-checkout: 48;
    --mob-z-fab: 46;
    --mob-z-sheet: 55;
    --mob-z-modal: 100;
    --mob-z-alerta-stock: 200;
}

/* ── Utilidades ── */
.mobile-only { display: none !important; }
.mobile-only-flex { display: none !important; }
.desktop-only { display: revert; }

@media (max-width: 1023px) {
    .mobile-only,
    .mobile-only-block { display: block !important; }
    .mobile-only-flex { display: flex !important; }
    .desktop-only { display: none !important; }

    /* ── Shell ── */
    body.app-shell {
        overflow: hidden;
        height: 100dvh;
    }

    .app-shell > .flex.flex-col.h-screen {
        height: 100dvh;
    }

    /* ── Header compacto ── */
    .mob-header {
        min-height: var(--mob-header-h);
        padding: 0.4rem 0.75rem !important;
        padding-top: max(0.4rem, env(safe-area-inset-top)) !important;
        gap: 0.5rem;
    }

    .mob-header .mob-brand h1 {
        font-size: 1.05rem !important;
        line-height: 1.1;
    }

    .mob-header .mob-brand p,
    .mob-header .mob-user-label {
        display: none;
    }

    .mob-header .mob-logo {
        height: 2rem !important;
        width: 2rem !important;
    }

    .mob-header .mob-user-chip {
        padding: 0.25rem 0.5rem !important;
    }

    .mob-header .mob-user-chip .mob-avatar {
        width: 1.5rem;
        height: 1.5rem;
        font-size: 0.65rem;
    }

    .mob-clock {
        font-size: 0.65rem;
        line-height: 1.2;
        text-align: right;
        min-width: 4.5rem;
    }

    .mob-clock .mob-hora {
        font-weight: 600;
        font-size: 0.75rem;
    }

    /* ── Layout principal ── */
    .mobile-layout {
        flex-direction: column !important;
        overflow: hidden;
        min-height: 0;
    }

    .mobile-content-area {
        flex: 1;
        min-height: 0;
        overflow: hidden;
        border-radius: 0 !important;
        border: none !important;
        box-shadow: none !important;
    }

    .mobile-content-area .vista {
        position: absolute;
        inset: 0;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: calc(var(--mob-nav-h) + var(--mob-safe-b) + 12px);
    }

    body.mob-has-checkout .mobile-content-area .vista#vista-pos {
        padding-bottom: calc(var(--mob-nav-h) + var(--mob-checkout-h) + var(--mob-safe-b) + 16px);
    }

    /* ── Nav inferior flotante (pill) ── */
    .nav-principal {
        position: fixed !important;
        bottom: calc(6px + var(--mob-safe-b)) !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        right: auto !important;
        width: min(96vw, 380px) !important;
        height: var(--mob-nav-h) !important;
        min-height: unset !important;
        flex-direction: row !important;
        border: 1px solid rgba(123, 93, 179, 0.15) !important;
        border-radius: 999px !important;
        background: rgba(255, 255, 255, 0.96) !important;
        backdrop-filter: blur(12px);
        box-shadow: 0 4px 24px rgba(123, 93, 179, 0.18), 0 1px 3px rgba(0,0,0,0.06);
        padding: 0.25rem 0.35rem !important;
        z-index: var(--mob-z-nav);
        justify-content: space-between;
        gap: 0.15rem !important;
    }

    .nav-principal .flex-1 { display: none; }

    .nav-principal .nav-btn {
        flex: 1;
        min-width: 0;
        max-width: none;
        height: 2.5rem;
        border-radius: 999px;
        gap: 0;
        padding: 0.15rem;
    }

    .nav-principal .nav-btn .text-lg {
        font-size: 1rem;
        line-height: 1;
    }

    .nav-principal .nav-btn span.text-\[9px\] {
        font-size: 0.55rem !important;
        font-weight: 600;
        letter-spacing: 0.02em;
        margin-top: 1px;
    }

    .nav-principal .nav-btn.active {
        background: #7b5db3 !important;
        color: #fff !important;
        box-shadow: 0 2px 8px rgba(123, 93, 179, 0.35);
    }

    .nav-principal .nav-btn.active .text-lg {
        transform: none;
    }

    /* ── POS móvil ── */
    #vista-pos {
        flex-direction: column !important;
        display: flex !important;
    }

    #vista-pos > main {
        flex: 1;
        min-height: 0;
        padding: 0.65rem 0.75rem !important;
        gap: 0.5rem !important;
    }

    .mob-section {
        background: #fff;
        border: 1px solid #ebebeb;
        border-radius: 1rem;
        padding: 0.65rem 0.75rem;
    }

    .mob-section-title {
        font-size: 0.6rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.08em;
        color: #7b5db3;
        margin-bottom: 0.5rem;
    }

    .mob-pos-search {
        position: relative;
        z-index: 10;
    }

    .mob-pos-search input {
        font-size: 0.875rem;
        padding-top: 0.65rem;
        padding-bottom: 0.65rem;
    }

    #filtros-pos {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        gap: 0.35rem !important;
        padding-bottom: 0.15rem;
    }

    #filtros-pos::-webkit-scrollbar { display: none; }

    #filtros-pos .filtro-cat-pos {
        flex-shrink: 0;
        font-size: 0.7rem;
        padding: 0.3rem 0.65rem;
    }

    .mob-carrito-section {
        flex: 1;
        min-height: 120px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
    }

    .mob-carrito-section .mob-section-title {
        padding: 0.65rem 0.75rem 0;
    }

    .mob-carrito-scroll {
        flex: 1;
        overflow-y: auto;
        padding: 0 0.5rem 0.5rem;
        -webkit-overflow-scrolling: touch;
    }

    #carrito-vacio {
        height: auto !important;
        min-height: 100px;
        padding: 1.5rem 1rem;
    }

    /* Sidebar ticket → oculto en flujo; panel deslizable */
    #pos-sidebar {
        display: none !important;
    }

    /* Carrito cards móvil */
    #lista-carrito tr {
        display: block;
        margin-bottom: 0.5rem;
        padding: 0.65rem;
        background: #fff;
        border-radius: 0.85rem;
        border: 1px solid #eee;
        box-shadow: 0 1px 3px rgba(0,0,0,0.04);
    }

    #lista-carrito td:first-child {
        padding-bottom: 0.4rem !important;
        border-bottom: 1px solid #f3f0f9;
        margin-bottom: 0.35rem;
    }

    #lista-carrito td[data-label=""] {
        justify-content: flex-end;
        padding-top: 0.25rem !important;
    }

    #lista-carrito td[data-label=""]::before { display: none; }

    /* Barra cobro flotante */
    .mobile-checkout-bar {
        display: none;
        position: fixed;
        bottom: calc(var(--mob-nav-h) + var(--mob-safe-b) + 10px);
        left: 50%;
        transform: translateX(-50%);
        width: min(96vw, 380px);
        z-index: var(--mob-z-checkout);
        border-radius: 999px;
        overflow: hidden;
        box-shadow: 0 4px 20px rgba(123, 93, 179, 0.22);
    }

    .mobile-checkout-bar:not(.hidden) {
        display: block;
    }

    .mobile-checkout-bar > div {
        border: none !important;
        padding: 0.4rem 0.5rem 0.4rem 0.85rem !important;
        background: #7b5db3 !important;
        color: #fff;
    }

    .mobile-checkout-bar #mobile-total {
        color: #fff !important;
        font-size: 1.1rem;
    }

    .mobile-checkout-bar p.text-\[10px\] {
        color: rgba(255,255,255,0.75) !important;
    }

    .mobile-checkout-bar #btn-cobrar-mobile {
        background: #fff !important;
        color: #7b5db3 !important;
        padding: 0.55rem 1rem !important;
        font-size: 0.75rem !important;
        border-radius: 999px !important;
        max-width: none;
        flex: 0 0 auto;
        min-width: 5.5rem;
    }

    .mobile-checkout-bar #btn-mob-ticket {
        background: rgba(255,255,255,0.2);
        color: #fff;
        border: none;
        border-radius: 999px;
        padding: 0.45rem 0.65rem;
        font-size: 0.7rem;
        font-weight: 600;
        flex-shrink: 0;
    }

    /* FAB pequeños */
    .mobile-fab-group {
        position: fixed;
        right: 0.75rem;
        bottom: calc(var(--mob-nav-h) + var(--mob-safe-b) + 68px);
        z-index: var(--mob-z-fab);
        display: none;
        flex-direction: column;
        gap: 0.4rem;
        align-items: flex-end;
    }

    body.vista-pos-active .mobile-fab-group {
        display: flex;
    }

    body.mob-has-checkout .mobile-fab-group {
        bottom: calc(var(--mob-nav-h) + var(--mob-checkout-h) + var(--mob-safe-b) + 72px);
    }

    .mob-fab {
        width: 2.25rem;
        height: 2.25rem;
        border-radius: 999px;
        border: 1px solid rgba(123, 93, 179, 0.2);
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(8px);
        box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        font-size: 0.85rem;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: transform 0.15s;
    }

    .mob-fab:active { transform: scale(0.92); }

    .mob-fab-badge {
        position: absolute;
        top: -4px;
        right: -4px;
        background: #7b5db3;
        color: #fff;
        font-size: 0.55rem;
        font-weight: 700;
        min-width: 1rem;
        height: 1rem;
        border-radius: 999px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .mob-fab-wrap { position: relative; }

    /* Panel ticket (bottom sheet) */
    .mobile-sheet-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: calc(var(--mob-z-sheet) - 1);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.25s;
    }

    .mobile-sheet-backdrop.open {
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-ticket-sheet {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: var(--mob-z-sheet);
        background: #fff;
        border-radius: 1.25rem 1.25rem 0 0;
        max-height: 78dvh;
        transform: translateY(100%);
        transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1);
        display: flex;
        flex-direction: column;
        box-shadow: 0 -8px 32px rgba(0,0,0,0.12);
        padding-bottom: var(--mob-safe-b);
    }

    .mobile-ticket-sheet.open {
        transform: translateY(0);
    }

    .mobile-sheet-handle {
        width: 2.5rem;
        height: 0.25rem;
        background: #ddd;
        border-radius: 999px;
        margin: 0.5rem auto 0;
        flex-shrink: 0;
    }

    .mobile-sheet-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.65rem 1rem 0.5rem;
        border-bottom: 1px solid #f0f0f0;
        flex-shrink: 0;
    }

    .mobile-sheet-header h2 {
        font-family: 'Playfair Display', serif;
        font-size: 1rem;
        font-weight: 700;
        color: #7b5db3;
    }

    .mobile-sheet-close {
        width: 1.75rem;
        height: 1.75rem;
        border-radius: 999px;
        border: none;
        background: #f3f0f9;
        color: #5c556b;
        font-size: 1.1rem;
        line-height: 1;
        cursor: pointer;
    }

    .mobile-sheet-body {
        flex: 1;
        overflow-y: auto;
        padding: 0.75rem 1rem 1rem;
        -webkit-overflow-scrolling: touch;
    }

    .mobile-sheet-body .mob-resumen-row {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.4rem 0;
        font-size: 0.8rem;
    }

    .mobile-sheet-body .mob-resumen-total {
        border-top: 1px solid #eee;
        margin-top: 0.5rem;
        padding-top: 0.65rem;
        font-size: 1rem;
        font-weight: 700;
    }

    .mobile-sheet-body .mob-resumen-total span:last-child {
        color: #7b5db3;
        font-size: 1.35rem;
    }

    /* Vistas secundarias */
    #vista-inventario,
    #vista-reportes,
    #vista-clientes,
    #vista-config {
        padding: 0.75rem !important;
    }

    .mob-page-header {
        margin-bottom: 0.75rem;
    }

    .mob-page-header h1 {
        font-size: 1.1rem !important;
    }

    .mob-page-header p {
        font-size: 0.7rem;
    }

    .mob-toolbar {
        display: flex;
        flex-wrap: wrap;
        gap: 0.4rem;
        margin-bottom: 0.65rem;
    }

    .mob-toolbar input,
    .mob-toolbar select {
        flex: 1;
        min-width: 0;
        font-size: 0.8rem !important;
        padding: 0.45rem 0.65rem !important;
    }

    #vista-inventario .mob-section .flex-wrap.gap-2 > div {
        min-width: calc(50% - 0.35rem);
    }

    #vista-inventario #stock-min-inventario,
    #vista-inventario #stock-max-inventario {
        width: 100%;
    }

    .mob-btn-sm {
        font-size: 0.7rem !important;
        padding: 0.45rem 0.75rem !important;
        border-radius: 999px !important;
        white-space: nowrap;
        font-weight: 600;
    }

    /* Tablas → ocultas; cards móvil */
    .mob-table-wrap .table-inventario,
    .mob-table-wrap table:not(.table-carrito) {
        display: none !important;
    }

    .mob-card-list {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .mob-product-card,
    .mob-cliente-card {
        background: #fff;
        border: 1px solid #eee;
        border-radius: 0.85rem;
        padding: 0.65rem 0.75rem;
        display: flex;
        gap: 0.65rem;
        align-items: flex-start;
    }

    .mob-product-card-info {
        flex: 1;
        min-width: 0;
    }

    .mob-product-card-info h3 {
        font-size: 0.8rem;
        font-weight: 600;
        line-height: 1.25;
        margin: 0 0 0.15rem;
    }

    .mob-product-card-meta {
        font-size: 0.65rem;
        color: #5c556b;
        display: flex;
        flex-wrap: wrap;
        gap: 0.35rem 0.65rem;
    }

    .mob-product-card-actions {
        display: flex;
        gap: 0.25rem;
        flex-shrink: 0;
    }

    .mob-icon-btn {
        width: 1.75rem;
        height: 1.75rem;
        border-radius: 0.5rem;
        border: 1px solid #eee;
        background: #fafafa;
        font-size: 0.75rem;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
    }

    /* Reportes KPI compactos */
    .mob-kpi-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        margin-bottom: 0.65rem;
    }

    .mob-kpi-grid .card-kpi {
        padding: 0.65rem !important;
    }

    .mob-kpi-grid .card-kpi h3 {
        font-size: 0.55rem !important;
    }

    .mob-kpi-grid .card-kpi p.text-3xl {
        font-size: 1.25rem !important;
        margin-top: 0.35rem !important;
    }

    .mob-kpi-grid .card-kpi p.text-\[11px\] {
        font-size: 0.6rem !important;
    }

    .mob-report-block {
        background: #fff;
        border: 1px solid #eee;
        border-radius: 0.85rem;
        padding: 0.75rem;
        margin-bottom: 0.5rem;
    }

    .mob-report-block h3 {
        font-size: 0.85rem !important;
        margin-bottom: 0.5rem !important;
    }

    .mob-report-block .relative.h-48 {
        height: 9rem !important;
    }

    /* Modales bottom sheet en móvil */
    .modal-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .modal-box {
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 1.25rem 1.25rem 0 0 !important;
        max-height: 90dvh;
        padding: 1rem 1rem calc(1rem + var(--mob-safe-b)) !important;
    }

    /* Toasts sobre dock */
    #toast-container {
        left: 0.75rem;
        right: 0.75rem;
        top: calc(var(--mob-header-h) + env(safe-area-inset-top, 0px) + 4px);
        bottom: auto;
    }

    /* Config form 1 col */
    #vista-config .grid-cols-2 {
        grid-template-columns: 1fr !important;
    }

    #vista-config .col-span-2 {
        grid-column: span 1;
    }

    .app-shell > .flex-1 {
        padding-bottom: 0 !important;
    }
}

@media (min-width: 1024px) {
    .mobile-checkout-bar,
    .mobile-fab-group,
    .mobile-ticket-sheet,
    .mobile-sheet-backdrop,
    .mob-card-list { display: none !important; }
}

/* Alerta stock bajo — modal centrado en móvil/tablet */
@media (max-width: 1023px) {
    .overlay-alerta-stock {
        z-index: var(--mob-z-alerta-stock);
    }

    .popover-alerta-stock:not(.hidden) {
        z-index: calc(var(--mob-z-alerta-stock) + 5);
        top: 50% !important;
        left: 50% !important;
        right: auto !important;
        transform: translate(-50%, -50%);
        width: min(22rem, calc(100vw - 2rem));
        max-height: min(75vh, 26rem);
    }

    .popover-alerta-stock-lista {
        max-height: min(50vh, 16rem);
    }

    .app-header {
        z-index: calc(var(--mob-z-alerta-stock) + 15);
    }
}
