/* ==========================================================================
   Módulo Móvil Adaptativo (PWA / Mobile Shell) - Administrativo Express
   Archivo: css/mobile/mobile.css
   ========================================================================== */

:root {
    --mobile-nav-height: 64px;
    --mobile-top-height: 56px;
    --mobile-bg: #f8fafc;
    --mobile-card-bg: #ffffff;
    --mobile-border: #e2e8f0;
    --mobile-primary: #2563eb;
    --mobile-primary-light: #eff6ff;
    --mobile-success: #16a34a;
    --mobile-warning: #d97706;
    --mobile-danger: #dc2626;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Modo Móvil Shell Activo (Aplica ÚNICAMENTE cuando el usuario está autenticado dentro del ERP móvil) */
body.mobile-shell-active {
    background-color: var(--mobile-bg);
    padding-top: var(--mobile-top-height);
    padding-bottom: calc(var(--mobile-nav-height) + var(--safe-bottom) + 16px);
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
}

body.mobile-shell-active .app-header,
body.mobile-shell-active .sidebar {
    display: none !important;
}

/* Evitar que html,body con position: relative cree un bloque contenedor que desplace los elementos fixed (top-bar, bottom-bar, copilot) al aplicar padding-top en body */
html:has(body.mobile-shell-active),
body.mobile-shell-active {
    position: static !important;
}

body.mobile-shell-active .main-content {
    margin-left: 0 !important;
    padding: 0.75rem 0.85rem !important;
    width: 100% !important;
    max-width: 100vw !important;
}

/* Barra Superior Móvil */
#mobile-top-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--mobile-top-height);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--mobile-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    z-index: 1040;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.mobile-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    padding: 3px 6px;
    border-radius: 8px;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.mobile-brand:active {
    background: rgba(15, 23, 42, 0.06);
    opacity: 0.85;
}

.mobile-brand img {
    height: 28px;
    width: auto;
}

.mobile-brand-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.1;
}

.mobile-brand-subtitle {
    font-size: 0.70rem;
    color: #64748b;
    font-weight: 500;
}

.mobile-top-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.mobile-bcv-pill {
    background: #ecfdf5;
    border: 1px solid #a7f3d0;
    color: #065f46;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 9999px;
    white-space: nowrap;
}


/* Barra Inferior Móvil (Bottom Navigation Bar) */
#mobile-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--mobile-nav-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: #ffffff;
    border-top: 1px solid var(--mobile-border);
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 1040;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
}

.mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 48px;
    min-width: 48px;
    padding: 4px 2px;
    text-decoration: none;
    color: #64748b;
    font-size: 0.70rem;
    font-weight: 600;
    border: none;
    background: transparent;
    cursor: pointer;
    transition: color 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
}

.mobile-nav-item.active {
    color: var(--mobile-primary);
}

.mobile-nav-icon-container {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-bottom: 2px;
}

.mobile-nav-item.active .mobile-nav-icon-container::after {
    content: '';
    position: absolute;
    bottom: -4px;
    width: 14px;
    height: 3px;
    border-radius: 9999px;
    background: var(--mobile-primary);
}

.mobile-nav-badge {
    position: absolute;
    top: -4px;
    right: -8px;
    background: var(--mobile-danger);
    color: #ffffff;
    font-size: 0.60rem;
    font-weight: 800;
    padding: 1px 4px;
    border-radius: 9999px;
}


/* Tarjetas Móviles (Mobile Cards UI) */
.mobile-card {
    background: var(--mobile-card-bg);
    border: 1px solid var(--mobile-border);
    border-radius: 12px;
    padding: 0.90rem;
    margin-bottom: 0.85rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    overflow: hidden;
    box-sizing: border-box;
}

.mobile-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #f1f5f9;
}

.mobile-card-title {
    font-size: 0.92rem;
    font-weight: 700;
    color: #0f172a;
}

/* KPIs Móviles Duales */
.mobile-kpi-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.65rem;
    margin-bottom: 1rem;
}

.mobile-kpi-card {
    background: #ffffff;
    border: 1px solid var(--mobile-border);
    border-radius: 10px;
    padding: 0.75rem 0.85rem;
    box-shadow: 0 1px 2px rgba(0,0,0,0.03);
}

.mobile-kpi-label {
    font-size: 0.72rem;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.mobile-kpi-amount-bs {
    font-size: 1.15rem;
    font-weight: 800;
    color: #0f172a;
    line-height: 1.15;
}

.mobile-kpi-amount-usd {
    font-size: 0.78rem;
    color: #0284c7;
    font-weight: 700;
    margin-top: 2px;
}

/* Tarjetas de Clientes Móvil */
.mobile-customer-card {
    background: #ffffff;
    border: 1px solid var(--mobile-border);
    border-radius: 14px;
    padding: 0.85rem 0.95rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mobile-customer-card:active {
    background: #fbfcfe;
}

.mobile-customer-card.status-ok {
    border-left: 4px solid #10b981;
}

.mobile-customer-card.status-debt {
    border-left: 4px solid #f59e0b;
}

.mobile-customer-card.status-overdue {
    border-left: 4px solid #ef4444;
}

.mobile-cust-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.80rem;
    font-weight: 800;
    flex-shrink: 0;
    letter-spacing: -0.3px;
}

.mobile-action-btn-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.70rem;
    padding-top: 0.65rem;
    border-top: 1px solid #f1f5f9;
    box-sizing: border-box;
    width: 100%;
}

.mobile-commercial-actions-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.45rem;
    box-sizing: border-box;
    width: 100%;
}

.mobile-commercial-actions-row .btn-card-action {
    flex: 1;
    min-width: 0;
}

.mobile-contact-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.btn-touch-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    flex-shrink: 0;
    box-sizing: border-box;
}

.btn-touch-icon:active {
    transform: scale(0.92);
}

.btn-touch-icon.call {
    background: #eff6ff;
    color: #2563eb;
    border-color: #bfdbfe;
}

.btn-touch-icon.call:active {
    background: #dbeafe;
}

.btn-touch-icon.whatsapp {
    background: #ecfdf5;
    color: #16a34a;
    border-color: #bbf7d0;
}

.btn-touch-icon.whatsapp:active {
    background: #dcfce7;
}

.btn-touch-icon.disabled {
    background: #f8fafc;
    color: #cbd5e1;
    border-color: #f1f5f9;
    cursor: default;
    pointer-events: none;
    opacity: 0.65;
}

.mobile-workflow-group {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
}

.btn-card-action {
    height: 36px;
    border-radius: 9px;
    font-size: 0.76rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 0 0.60rem;
    white-space: nowrap;
    box-sizing: border-box;
    min-width: 0;
}

.btn-card-action:active {
    transform: scale(0.96);
}

.btn-card-action.secondary {
    flex: 1;
    background: #f8fafc;
    color: #334155;
    border-color: #e2e8f0;
}

.btn-card-action.secondary:active {
    background: #f1f5f9;
}

.btn-card-action.collect {
    flex: 1;
    background: #ecfdf5;
    color: #059669;
    border-color: #a7f3d0;
}

.btn-card-action.collect:active {
    background: #d1fae5;
}

.btn-card-action.primary {
    flex: 1.25;
    background: #2563eb;
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.20);
}

.btn-card-action.primary:active {
    background: #1d4ed8;
    box-shadow: none;
}

.btn-action-touch {
    flex: 1;
    min-height: 40px;
    border-radius: 8px;
    font-size: 0.78rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
}

.btn-action-touch.whatsapp {
    background: #f0fdf4;
    color: #15803d;
    border-color: #bbf7d0;
}

.btn-action-touch.call {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #bfdbfe;
}

.btn-action-touch.maps {
    background: #fff7ed;
    color: #c2410c;
    border-color: #ffedd5;
}

.btn-action-touch.order {
    background: #2563eb;
    color: #ffffff;
}

/* Wizard de Toma de Pedidos en 3 Pasos */
.mobile-wizard-steps {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    background: #ffffff;
    border: 1px solid var(--mobile-border);
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
}

.mobile-step-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
}

.mobile-step-item.active {
    color: var(--mobile-primary);
}

.mobile-step-num {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #e2e8f0;
    color: #64748b;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.70rem;
    font-weight: 700;
}

.mobile-step-item.active .mobile-step-num {
    background: var(--mobile-primary);
    color: #ffffff;
}

/* Control táctil de cantidades (+ / -) */
.mobile-qty-control {
    display: inline-flex;
    align-items: center;
    background: #f1f5f9;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    overflow: hidden;
}

.btn-qty-touch {
    width: 38px;
    height: 38px;
    background: #ffffff;
    border: none;
    font-size: 1.1rem;
    font-weight: 700;
    color: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.input-qty-touch {
    width: 48px;
    height: 38px;
    border: none;
    background: transparent;
    text-align: center;
    font-weight: 700;
    font-size: 0.90rem;
    color: #0f172a;
}

/* Botón Ver Más Paginado */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.btn-load-more-mobile {
    width: 100%;
    padding: 0.85rem 1rem;
    border-radius: 12px;
    font-weight: 700;
    background: #ffffff;
    border: 1.5px solid #cbd5e1;
    color: #2563eb;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    font-size: 0.92rem;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-load-more-mobile:active {
    background: #eff6ff;
    border-color: #93c5fd;
    transform: scale(0.99);
}

.btn-load-more-mobile:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Modales y Diálogos en Shell Móvil */
body.mobile-shell-active .modal-backdrop {
    z-index: 1200 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(15, 23, 42, 0.65) !important;
    backdrop-filter: blur(4px) !important;
    -webkit-backdrop-filter: blur(4px) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 1rem !important;
}

body.mobile-shell-active .modal-backdrop .modal {
    width: 94% !important;
    max-width: 480px !important;
    max-height: 85vh !important;
    margin: auto !important;
    border-radius: 16px !important;
    background: #ffffff !important;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    position: relative !important;
    transform: translateY(0) !important;
}

body.mobile-shell-active .modal-backdrop .modal .modal-header {
    flex-shrink: 0;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

body.mobile-shell-active .modal-backdrop .modal .modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.25rem;
    -webkit-overflow-scrolling: touch;
}

body.mobile-shell-active .modal-backdrop .modal .modal-footer {
    flex-shrink: 0;
    padding: 0.85rem 1.25rem;
    border-top: 1px solid #e2e8f0;
    background: #f8fafc;
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Barra de Acción Flotante y Tarjetas de Facturas (Cobranzas) */
.mobile-floating-action-bar {
    position: fixed;
    bottom: calc(var(--mobile-nav-height) + var(--safe-bottom));
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid #cbd5e1;
    padding: 0.55rem 0.85rem;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    z-index: 1030;
    box-sizing: border-box;
}

.mobile-invoice-card {
    background: var(--mobile-card-bg);
    border-radius: 12px;
    padding: 0.85rem;
    margin-bottom: 0.75rem;
    border: 1.5px solid var(--mobile-border);
    transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    user-select: none;
}

.mobile-invoice-card.selected {
    border-color: #2563eb;
    background: #eff6ff;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.12);
}

.mobile-invoice-checkbox {
    width: 22px;
    height: 22px;
    accent-color: #2563eb;
    cursor: pointer;
    flex-shrink: 0;
}

/* Barra Superior Fija de Cliente en Facturas Pendientes */
.mobile-sticky-customer-bar {
    position: fixed;
    top: var(--mobile-top-height, 56px);
    left: 0;
    right: 0;
    z-index: 95;
    background: #ffffff;
    padding: 0.60rem 1rem;
    border-bottom: 1px solid var(--mobile-border);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

/* Barra Flotante de Estado de Cuenta (Fijada justo encima de la botonera inferior) */
.mobile-statement-floating-bar {
    position: fixed;
    bottom: calc(var(--mobile-nav-height) + var(--safe-bottom));
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid var(--mobile-border);
    padding: 0.55rem 0.85rem;
    box-shadow: 0 -4px 15px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1025;
}


