Files
recreopay/public/index.html
T

1488 lines
103 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover">
<title>RecreoPay - Tu Soda Escolar Digital</title>
<link rel="manifest" href="/manifest.json">
<meta name="theme-color" content="#0284c7">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="apple-mobile-web-app-title" content="RecreoPay">
<meta name="mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="/css/styles.css?v=9.6">
<style>
/* Transiciones suaves */
.fade-enter { animation: fadeIn 0.2s ease-in-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
</style>
</head>
<body class="">
<!-- VISTA DE LOGIN Y CONTROL DE ACCESO -->
<div id="viewLogin" class="login-overlay" style="display: none;">
<div class="login-card">
<div class="login-brand">
<div class="login-logo">🥪</div>
<h1 class="login-title">Recreo<strong>Pay</strong></h1>
<p class="login-subtitle">Sistema Digital de Soda Escolar y Monedero Estudiantil</p>
</div>
<!-- SELECTOR ENTRE INICIO DE SESIÓN Y REGISTRO -->
<div class="login-tabs">
<button type="button" class="login-tab-btn active" id="tabBtnLogin" onclick="switchLoginTab('login')">
🔑 Iniciar Sesión
</button>
<button type="button" class="login-tab-btn" id="tabBtnRegister" onclick="switchLoginTab('register')">
👨‍👩‍👦 Registro de Padres
</button>
</div>
<!-- FORMULARIO 1: INICIAR SESIÓN -->
<form id="formLogin" onsubmit="handleLoginSubmit(event)">
<div class="login-form-group">
<label for="loginUsername">Usuario o Carné:</label>
<input type="text" id="loginUsername" class="login-input" placeholder="Ej: admin, padre, mateo, sofia" required autocomplete="username">
</div>
<div class="login-form-group">
<label for="loginPassword">Contraseña o PIN:</label>
<input type="password" id="loginPassword" class="login-input" placeholder="••••••••" required autocomplete="current-password">
</div>
<div id="loginErrorMsg" style="display: none; background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; padding: 8px 12px; border-radius: 10px; font-size: 0.8rem; font-weight: 700; margin-bottom: 12px; text-align: center;"></div>
<button type="submit" id="btnLoginSubmit" class="login-submit-btn">
🚀 Iniciar Sesión
</button>
</form>
<!-- FORMULARIO 2: REGISTRO DE NUEVOS PADRES -->
<form id="formRegisterPadre" onsubmit="handleRegisterPadreSubmit(event)" style="display: none;">
<div class="login-form-group">
<label for="regNombre">Nombre y Apellidos:</label>
<input type="text" id="regNombre" class="login-input" placeholder="Ej: Carlos Alvarado Castro" required autocomplete="name">
</div>
<div class="login-form-group">
<label for="regTelefono">Teléfono o Celular (para SINPE):</label>
<input type="tel" id="regTelefono" class="login-input" placeholder="Ej: 8888-1122" required autocomplete="tel">
</div>
<div class="login-form-group">
<label for="regUsername">Nombre de Usuario:</label>
<input type="text" id="regUsername" class="login-input" placeholder="Ej: carlos_papa" required autocomplete="username">
</div>
<div class="login-form-group">
<label for="regPassword">Contraseña:</label>
<input type="password" id="regPassword" class="login-input" placeholder="Mínimo 4 caracteres" required autocomplete="new-password">
</div>
<div id="registerErrorMsg" style="display: none; background: #fee2e2; border: 1px solid #fca5a5; color: #991b1b; padding: 8px 12px; border-radius: 10px; font-size: 0.8rem; font-weight: 700; margin-bottom: 12px; text-align: center;"></div>
<button type="submit" id="btnRegisterSubmit" class="login-submit-btn" style="background: linear-gradient(135deg, #10b981, #059669);">
✨ Crear Cuenta y Entrar al Panel
</button>
</form>
<!-- ACCESOS RÁPIDOS DE PRUEBA (1-CLICK DEMO) -->
<div class="login-demo-box">
<div class="login-demo-title">Accesos Rápidos de Prueba:</div>
<div class="login-demo-btns">
<button type="button" class="login-demo-btn" onclick="quickFillLogin('admin', 'admin123')">
<span style="font-size: 1.3rem;">👨‍🍳</span>
<span>Admin Soda</span>
</button>
<button type="button" class="login-demo-btn" onclick="quickFillLogin('cajero', 'cajero123')">
<span style="font-size: 1.3rem;">🪙</span>
<span>Cajero</span>
</button>
<button type="button" class="login-demo-btn" onclick="quickFillLogin('padre', 'padre123')">
<span style="font-size: 1.3rem;">👨‍👩‍👦</span>
<span>Padre</span>
</button>
<button type="button" class="login-demo-btn" onclick="quickFillLogin('mateo', '1234')">
<span style="font-size: 1.3rem;">🎒</span>
<span>Mateo (2°)</span>
</button>
<button type="button" class="login-demo-btn" onclick="quickFillLogin('sofia', '1234')">
<span style="font-size: 1.3rem;">👧</span>
<span>Sofía (3°)</span>
</button>
</div>
</div>
</div>
</div>
<!-- PANEL DE ADMINISTRACIÓN DE LA SODA (#viewAdmin) -->
<div id="viewAdmin" class="admin-container" style="display: none;">
<!-- CABECERA DE ADMINISTRADOR -->
<header class="admin-header">
<div class="admin-badge">
<div class="admin-icon">👨‍🍳</div>
<div>
<h2 style="font-size: 1.15rem; font-weight: 900; margin: 0; color: var(--text-main);">Administración de la Soda</h2>
<span id="adminLoggedName" style="font-size: 0.76rem; color: #0284c7; font-weight: 700;">Soda Escolar Central</span>
</div>
</div>
<div class="admin-header-actions">
<button onclick="toggleTheme()" class="theme-toggle-btn" title="Alternar Modo Oscuro / Modo Claro">
🌙
</button>
<button onclick="switchAdminTab('recarga')" class="admin-action-btn admin-action-btn-recarga" title="Cargar dinero a un estudiante">
<span>💵</span> <span class="admin-btn-text">Cargar Dinero</span>
</button>
<a href="/pos.html" target="_blank" class="admin-action-btn admin-action-btn-caja" title="Abrir Caja / Terminal POS">
<span>📟</span> <span class="admin-btn-text">Ir a Caja</span>
</a>
<button onclick="logout(true)" class="admin-action-btn admin-action-btn-salir" title="Cerrar sesión y cambiar de cuenta">
<span>🚪</span> <span class="admin-btn-text">Salir</span>
</button>
</div>
</header>
<!-- MÉTRICAS DE HOY -->
<div class="admin-stats-grid">
<div class="admin-stat-card">
<div class="val" id="adminStatVentas">₡0</div>
<div class="lbl">Ventas Hoy</div>
</div>
<div class="admin-stat-card">
<div class="val" id="adminStatOrdenes">0</div>
<div class="lbl">Órdenes Despachadas</div>
</div>
<div class="admin-stat-card">
<div class="val" id="adminStatEstudiantes">0</div>
<div class="lbl">Estudiantes Activos</div>
</div>
<div class="admin-stat-card">
<div class="val" id="adminStatBloqueados" style="color: #ef4444;">0</div>
<div class="lbl">Tarjetas Bloqueadas</div>
</div>
<div class="admin-stat-card">
<div class="val" id="adminStatCriticos" style="color: #f59e0b;">0</div>
<div class="lbl">Bajo Stock / Agotados</div>
</div>
</div>
<!-- PESTAÑAS DE NAVEGACIÓN ADMIN -->
<div class="admin-tabs">
<button class="admin-tab-btn active" id="btnTabAdminInventario" onclick="switchAdminTab('inventario')">
📦 Control de Inventario y Stock
</button>
<button class="admin-tab-btn" id="btnTabAdminEstudiantes" onclick="switchAdminTab('estudiantes')">
🪪 Estudiantes, Carnés y Bloqueos
</button>
<button class="admin-tab-btn" id="btnTabAdminPersonal" onclick="switchAdminTab('personal')">
👥 Personal y Cajeros
</button>
<button class="admin-tab-btn" id="btnTabAdminRecarga" onclick="switchAdminTab('recarga')">
💵 Cargar Dinero Manual (Buscador y QR)
</button>
<button class="admin-tab-btn" id="btnTabAdminMovimientos" onclick="switchAdminTab('movimientos')">
📜 Movimientos y Reversiones
</button>
</div>
<!-- TAB 1: INVENTARIO Y STOCK -->
<div id="adminTabContentInventario" class="admin-card">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 10px;">
<div>
<h3 style="margin: 0; font-size: 1.1rem; font-weight: 800; color: var(--text-main);">Inventario y Existencias</h3>
<p style="margin: 2px 0 0 0; font-size: 0.75rem; color: var(--text-muted);">
Crea, edita productos, controla precios, existencias y sellos nutricionales MEP.
</p>
</div>
<div style="display: flex; gap: 8px; align-items: center; flex-wrap: wrap;">
<input type="text" id="adminSearchProduct" placeholder="🔍 Buscar alimento o bebida..." oninput="filterAdminProducts(this.value)" style="padding: 8px 12px; border-radius: 10px; border: 1.5px solid var(--border); font-size: 0.85rem; width: 190px; background: var(--card-bg); color: var(--text-main);">
<button type="button" onclick="openCreateProductModal()" style="padding: 8px 14px; background: linear-gradient(135deg, #0284c7, #0369a1); color: white; border: none; border-radius: 10px; font-size: 0.82rem; font-weight: 800; cursor: pointer; display: flex; align-items: center; gap: 6px; box-shadow: 0 2px 6px rgba(2, 132, 199, 0.25);">
<span>➕</span> <span>Nuevo Producto</span>
</button>
</div>
</div>
<div id="adminProductsList">
<!-- Renderizado dinámico de productos y stock -->
</div>
</div>
<!-- TAB 2: ESTUDIANTES Y CARNÉS -->
<div id="adminTabContentEstudiantes" class="admin-card" style="display: none;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; flex-wrap: wrap; gap: 10px;">
<div>
<h3 style="margin: 0; font-size: 1.1rem; font-weight: 800; color: var(--text-main);">Alumnos y Tarjetas Escolares</h3>
<p style="margin: 2px 0 0 0; font-size: 0.75rem; color: var(--text-muted);">
Bloquea tarjetas perdidas, crea nuevos alumnos o genera carnés con código QR.
</p>
</div>
<div style="display: flex; gap: 8px; align-items: center; flex-wrap: wrap;">
<input type="text" id="adminSearchStudentsTab2" placeholder="🔍 Filtrar alumnos..." oninput="filterAdminStudentsTab2(this.value)" style="padding: 8px 12px; border-radius: 10px; border: 1.5px solid var(--border); font-size: 0.85rem; width: 190px;">
<button onclick="openNewStudentModal()" style="padding: 9px 16px; background: linear-gradient(135deg, #10b981, #059669); color: white; border: none; border-radius: 12px; font-size: 0.85rem; font-weight: 900; cursor: pointer; display: flex; align-items: center; gap: 6px;">
<span>➕</span> Nuevo Estudiante
</button>
</div>
</div>
<div id="adminStudentsList">
<!-- Renderizado dinámico de estudiantes con botones de bloqueo -->
</div>
</div>
<!-- TAB 3: CARGA MANUAL DE DINERO -->
<div id="adminTabContentRecarga" class="admin-card" style="display: none; max-width: 550px; margin: 0 auto;">
<div style="text-align: center; margin-bottom: 18px;">
<span style="font-size: 2.2rem;">💵</span>
<h3 style="margin: 6px 0 2px 0; font-size: 1.25rem; font-weight: 900; color: var(--text-main);">Carga Manual de Dinero</h3>
<p style="margin: 0; font-size: 0.78rem; color: var(--text-muted);">
Recarga de monedero estudiantil por pago en efectivo en la soda o ajuste escolar
</p>
</div>
<!-- BUSCADOR INTELIGENTE Y BOTÓN ESCANEAR QR -->
<div style="background: rgba(2, 132, 199, 0.05); border: 2px solid #0284c7; border-radius: 16px; padding: 14px; margin-bottom: 16px; box-shadow: 0 3px 12px rgba(2, 132, 199, 0.08);">
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; flex-wrap: wrap; gap: 6px;">
<label for="inputAdminSearchStudent" style="font-size: 0.88rem; font-weight: 900; color: var(--text-main); display: flex; align-items: center; gap: 6px; margin: 0;">
<span style="font-size: 1.1rem;">🔍</span>
<span>Buscador Inteligente de Estudiante:</span>
</label>
<span style="font-size: 0.68rem; font-weight: 800; background: #0284c7; color: white; padding: 2px 8px; border-radius: 6px;">
⚡ Búsqueda en vivo
</span>
</div>
<div class="admin-search-container" style="position: relative;">
<div class="admin-search-input-wrap" style="display: flex; gap: 8px; align-items: center;">
<div style="position: relative; flex: 1; width: 100%;">
<input type="text" id="inputAdminSearchStudent" class="admin-search-input" placeholder="🔍 Escribe para buscar (ej: Mateo, EST-2026, Alvarado)..." oninput="onAdminSearchStudent(this.value)" onfocus="onAdminSearchFocus()" autocomplete="off" style="width: 100%; box-sizing: border-box; padding: 11px 36px 11px 14px; font-size: 0.95rem; font-weight: 700; border-radius: 12px; border: 2px solid #cbd5e1; outline: none; background: var(--card-bg, #ffffff); color: var(--text-main);">
<button type="button" id="btnClearAdminSearch" onclick="clearAdminSearchStudent()" style="display: none; position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: #e2e8f0; border: none; border-radius: 50%; width: 22px; height: 22px; font-size: 0.75rem; font-weight: 900; color: #475569; cursor: pointer; align-items: center; justify-content: center;" title="Borrar búsqueda">✕</button>
</div>
<button type="button" onclick="openAdminScanQrModal()" class="admin-scan-btn" title="Escanear carné físico o código QR con la cámara" style="flex-shrink: 0; padding: 11px 14px; background: linear-gradient(135deg, #0284c7, #0369a1); color: white; border: none; border-radius: 12px; font-size: 0.85rem; font-weight: 800; cursor: pointer; display: flex; align-items: center; gap: 6px; white-space: nowrap;">
<span>📷</span>
<span>Escanear QR</span>
</button>
</div>
<div id="adminSearchResultsDropdown" class="admin-search-dropdown" style="display: none;"></div>
</div>
<div style="font-size: 0.72rem; color: var(--text-muted); margin-top: 6px;">
💡 <em>Toca el buscador para ver alumnos o escribe nombre, apellidos o carné para filtrar al instante.</em>
</div>
</div>
<!-- ESTADO 2: FICHA DEL ESTUDIANTE SELECCIONADO TRAS ESCANEO O BÚSQUEDA -->
<div id="adminSelectedStudentWrap" style="display: none; margin-bottom: 16px;">
<div style="margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center;">
<span style="font-size: 0.75rem; font-weight: 800; color: #166534; text-transform: uppercase; letter-spacing: 0.5px; display: flex; align-items: center; gap: 4px;">
<span>✅</span> Estudiante Seleccionado:
</span>
<button type="button" onclick="clearAdminSelectedStudent()" style="background: none; border: none; color: #ef4444; font-size: 0.74rem; font-weight: 800; cursor: pointer; display: flex; align-items: center; gap: 3px;">
✕ Cambiar / Quitar
</button>
</div>
<div id="adminSelectedStudentBanner" class="selected-student-banner" style="display: flex;">
<div style="display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1;">
<img id="adminSelectedAvatar" src="" style="width: 48px; height: 48px; border-radius: 50%; border: 2.5px solid #0284c7; background: white; flex-shrink: 0; object-fit: cover;">
<div style="min-width: 0;">
<div style="display: flex; align-items: center; gap: 6px; flex-wrap: wrap;">
<strong id="adminSelectedName" style="font-size: 1rem; color: var(--text-main); word-break: break-word;">Selecciona un alumno</strong>
<span id="adminSelectedStatusBadge" style="font-size: 0.65rem; font-weight: 800; background: #dcfce7; color: #166534; padding: 2px 6px; border-radius: 4px;">ACTIVA</span>
</div>
<div id="adminSelectedMeta" style="font-size: 0.75rem; color: var(--text-muted); margin-top: 2px;">
Grado y Sección • Cód: EST-2026-000
</div>
</div>
</div>
<div style="text-align: right; flex-shrink: 0;">
<div style="font-size: 0.68rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase;">Saldo Actual</div>
<div id="adminSelectedBalance" style="font-size: 1.25rem; font-weight: 900; color: #10b981;">₡0</div>
</div>
</div>
</div>
<!-- SELECT OCULTO PARA COMPATIBILIDAD CON FUNCIONES JS -->
<select id="adminRecargaStudentSelect" style="display: none;" onchange="onAdminSelectChange(this.value)"></select>
<!-- SECCIÓN DE MONTO Y RECARGA (HABILITADA TRAS ESCANEO) -->
<div id="adminRecargaFormFields" style="opacity: 0.45; pointer-events: none; transition: all 0.25s ease;">
<div style="margin-bottom: 12px;">
<label style="display: block; font-size: 0.8rem; font-weight: 800; color: var(--text-main); margin-bottom: 5px;">
Monto a Recargar en Colones:
</label>
<div style="position: relative;">
<span style="position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-weight: 900; font-size: 1.1rem; color: #10b981;">₡</span>
<input type="tel" inputmode="numeric" pattern="[0-9]*" id="adminRecargaMonto" placeholder="Ej: 5000" style="width: 100%; padding: 11px 12px 11px 32px; border-radius: 10px; border: 2px solid #10b981; font-size: 1.15rem; font-weight: 900; color: var(--text-main); background: var(--card-bg); box-sizing: border-box;">
</div>
</div>
<div style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px;">
<button type="button" onclick="setAdminRecargaPreset(1000)" class="stock-btn-quick">₡1.000</button>
<button type="button" onclick="setAdminRecargaPreset(2000)" class="stock-btn-quick">₡2.000</button>
<button type="button" onclick="setAdminRecargaPreset(5000)" class="stock-btn-quick">₡5.000</button>
<button type="button" onclick="setAdminRecargaPreset(10000)" class="stock-btn-quick">₡10.000</button>
</div>
<div style="margin-bottom: 16px;">
<label style="display: block; font-size: 0.78rem; font-weight: 700; color: var(--text-muted); margin-bottom: 4px;">
Detalle o Recibo (Opcional):
</label>
<input type="text" id="adminRecargaDescripcion" placeholder="Ej: Pago en efectivo en mostrador" style="width: 100%; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border); font-size: 0.85rem; box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
</div>
<button type="button" id="btnAdminSubmitRecarga" onclick="submitAdminManualRecharge()" style="width: 100%; padding: 13px; background: linear-gradient(135deg, #10b981, #059669); color: white; border: none; border-radius: 12px; font-size: 1rem; font-weight: 900; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);">
<span>💰</span> Aplicar Recarga Inmediata
</button>
</div>
</div>
<!-- TAB 4: MOVIMIENTOS Y REVERSIONES -->
<div id="adminTabContentMovimientos" class="admin-card" style="display: none; max-width: 900px; margin: 0 auto;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px;">
<div>
<h3 style="margin: 0; font-size: 1.2rem; font-weight: 900; color: var(--text-main); display: flex; align-items: center; gap: 8px;">
<span>📜</span> Movimientos y Reversiones
</h3>
<p style="margin: 3px 0 0 0; font-size: 0.78rem; color: var(--text-muted);">
Historial de recargas de monedero y cobros de meriendas. Permite anular o revertir transacciones erróneas.
</p>
</div>
<button type="button" onclick="loadAdminMovimientos()" style="padding: 8px 14px; background: #f1f5f9; color: #475569; border: 1.5px solid var(--border); border-radius: 10px; font-weight: 800; font-size: 0.8rem; cursor: pointer; display: flex; align-items: center; gap: 6px;">
<span>🔄</span> Actualizar
</button>
</div>
<!-- BARRA DE FILTROS Y BÚSQUEDA -->
<div style="display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; justify-content: space-between;">
<div style="display: flex; gap: 4px; background: rgba(148, 163, 184, 0.12); padding: 4px; border-radius: 12px; overflow-x: auto; max-width: 100%;">
<button type="button" class="mov-filter-btn active" id="btnFilterMovAll" onclick="setMovFilter('all')" style="padding: 7px 12px; border: none; border-radius: 8px; font-weight: 800; font-size: 0.78rem; cursor: pointer; background: white; color: #0284c7; box-shadow: 0 1px 3px rgba(0,0,0,0.08); white-space: nowrap;">
Todos
</button>
<button type="button" class="mov-filter-btn" id="btnFilterMovRecargas" onclick="setMovFilter('recargas')" style="padding: 7px 12px; border: none; border-radius: 8px; font-weight: 700; font-size: 0.78rem; cursor: pointer; background: transparent; color: #64748b; white-space: nowrap;">
💵 Recargas
</button>
<button type="button" class="mov-filter-btn" id="btnFilterMovCobros" onclick="setMovFilter('cobros')" style="padding: 7px 12px; border: none; border-radius: 8px; font-weight: 700; font-size: 0.78rem; cursor: pointer; background: transparent; color: #64748b; white-space: nowrap;">
🥪 Cobros
</button>
</div>
<input type="text" id="inputSearchMovimientos" placeholder="🔍 Buscar por alumno, carné o detalle..." oninput="filterMovimientosUI(this.value)" style="flex: 1; min-width: 180px; padding: 9px 12px; border-radius: 10px; border: 1.5px solid var(--border); font-size: 0.85rem; box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
</div>
<!-- LISTA DE MOVIMIENTOS -->
<div id="adminMovimientosList" style="display: flex; flex-direction: column; gap: 10px;">
<div style="text-align: center; color: var(--text-muted); padding: 30px; font-size: 0.88rem;">
Cargando movimientos...
</div>
</div>
</div>
<!-- TAB 5: GESTIÓN DE PERSONAL Y CAJEROS -->
<div id="adminTabContentPersonal" class="admin-card" style="display: none; max-width: 900px; margin: 0 auto;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 10px;">
<div>
<h3 style="margin: 0; font-size: 1.2rem; font-weight: 900; color: var(--text-main); display: flex; align-items: center; gap: 8px;">
<span>👥</span> Control de Personal y Cajeros
</h3>
<p style="margin: 3px 0 0 0; font-size: 0.78rem; color: var(--text-muted);">
Crea cajeros, vendedores y personal. Administra contraseñas, bloquea o elimina accesos.
</p>
</div>
<button type="button" onclick="openCreateStaffModal()" style="padding: 9px 16px; background: linear-gradient(135deg, #10b981, #059669); color: white; border: none; border-radius: 10px; font-size: 0.84rem; font-weight: 800; cursor: pointer; display: flex; align-items: center; gap: 6px; box-shadow: 0 2px 6px rgba(16, 185, 129, 0.25);">
<span>➕</span> <span>Nuevo Empleado / Cajero</span>
</button>
</div>
<div id="adminStaffList" style="display: flex; flex-direction: column; gap: 10px;">
<div style="text-align: center; color: var(--text-muted); padding: 30px; font-size: 0.88rem;">
Cargando personal...
</div>
</div>
</div>
</div>
<!-- ========================================== -->
<!-- PORTAL COMPLETO DE PADRES (#viewPadres) -->
<!-- ========================================== -->
<div id="viewPadres" class="parent-container" style="display: none;">
<!-- CABECERA DE PADRES -->
<header class="parent-header">
<div class="parent-badge">
<div class="parent-icon">👨‍👩‍👦</div>
<div>
<h2 style="font-size: 1.15rem; font-weight: 900; margin: 0; color: var(--text-main);">Portal de Padres</h2>
<span id="parentLoggedName" style="font-size: 0.76rem; color: #10b981; font-weight: 700;">Familia RecreoPay</span>
</div>
</div>
<div class="parent-header-actions">
<button onclick="toggleTheme()" class="theme-toggle-btn" title="Alternar Modo Oscuro / Modo Claro">
🌙
</button>
<button type="button" onclick="switchToSodaMenuAsParent()" class="mode-btn" style="background: var(--bg-main); border: 1.5px solid var(--border); font-size: 0.78rem; font-weight: 800; border-radius: 10px; padding: 7px 11px; cursor: pointer; color: var(--text-main);" title="Ver menú y pre-ordenar para mi hijo">
🥪 Ver Menú
</button>
<button onclick="logout(true)" class="logout-btn" title="Cerrar sesión">
<span>🚪</span>
<span class="logout-text">Salir</span>
</button>
</div>
</header>
<!-- BANNER SI NO HAY HIJOS VINCULADOS -->
<div id="parentNoChildrenBanner" class="parent-card" style="display: none; text-align: center; border: 2px dashed #0284c7; background: #f0f9ff;">
<span style="font-size: 2.5rem;">🧒</span>
<h3 style="font-size: 1.15rem; font-weight: 900; color: #0369a1; margin: 8px 0 4px 0;">¡Bienvenido a RecreoPay!</h3>
<p style="font-size: 0.82rem; color: #64748b; margin-bottom: 14px;">
Aún no has vinculado ningún estudiante a tu cuenta de padre. Escanea el carné de tu hijo para monitorear su saldo y recargarle al instante.
</p>
<button type="button" onclick="openScanChildQrModal()" class="login-submit-btn" style="background: linear-gradient(135deg, #0284c7, #0369a1); display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: auto; padding: 12px 24px;">
<span>📷</span> Escanear Carné QR de mi Hijo
</button>
</div>
<!-- SECCIÓN: MIS HIJOS (TARJETAS VISUALES) -->
<div id="parentChildrenSection" style="margin-bottom: 16px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
<h3 style="font-size: 0.92rem; font-weight: 900; color: var(--text-main); text-transform: uppercase; letter-spacing: 0.5px;">
👨‍👩‍👦 Mis Hijos
</h3>
<button type="button" onclick="openScanChildQrModal()" style="background: none; border: none; color: #0284c7; font-size: 0.8rem; font-weight: 800; cursor: pointer; display: flex; align-items: center; gap: 4px;">
<span>➕</span> Vincular otro hijo con QR
</button>
</div>
<!-- Cuadrícula de tarjetas de hijos -->
<div id="parentChildrenGrid" class="parent-children-grid">
<!-- Renderizado dinámico de tarjetas de hijos -->
</div>
</div>
<!-- SECCIÓN DE GESTIÓN DEL HIJO SELECCIONADO -->
<div id="parentSelectedChildContainer" style="display: none;">
<!-- FICHA ACTIVA DEL HIJO SELECCIONADO -->
<div class="parent-card" style="border: 2px solid #0284c7; background: linear-gradient(135deg, rgba(2, 132, 199, 0.04), rgba(56, 189, 248, 0.08));">
<div style="display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px;">
<div style="display: flex; align-items: center; gap: 12px; min-width: 0;">
<img id="parentActiveChildAvatar" src="" style="width: 50px; height: 50px; border-radius: 50%; border: 3px solid #0284c7; background: white; object-fit: cover;">
<div style="min-width: 0;">
<h3 id="parentActiveChildName" style="font-size: 1.1rem; font-weight: 900; margin: 0; color: var(--text-main); word-break: break-word;">Cargando...</h3>
<span id="parentActiveChildMeta" style="font-size: 0.76rem; color: var(--text-muted); font-weight: 600;">Grado • Carné</span>
</div>
</div>
<div style="text-align: right;">
<span style="font-size: 0.7rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; display: block;">Saldo Disponible</span>
<span id="parentActiveChildBalance" style="font-size: 1.35rem; font-weight: 900; color: #0284c7;">₡0</span>
</div>
</div>
<div style="display: flex; gap: 8px;">
<button type="button" onclick="switchToSodaMenuAsParent()" style="width: 100%; padding: 11px; background: #0284c7; color: white; border: none; border-radius: 10px; font-weight: 800; font-size: 0.85rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;">
<span>🥪</span> Pre-ordenar Merienda / Ver Menú
</button>
</div>
</div>
<!-- RECARGA SINPE MÓVIL (DIRECTO EN PANTALLA, NO MODAL) -->
<div class="parent-card" style="background: #f0fdf4; border: 1.5px solid #86efac;">
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;">
<div style="display: flex; align-items: center; gap: 10px;">
<span style="font-size: 1.6rem;">📱</span>
<div>
<strong style="color: #166534; font-size: 1rem; display: block;">Recarga por SINPE Móvil</strong>
<p style="font-size: 0.74rem; color: #15803d; margin: 0;">Número Soda: <strong>8888-SODA (7632)</strong></p>
</div>
</div>
<span style="font-size: 0.7rem; color: #166534; background: #dcfce7; font-weight: 800; padding: 3px 8px; border-radius: 6px;">Inmediato</span>
</div>
<label style="display: block; font-size: 0.8rem; font-weight: 800; color: #166534; margin-bottom: 4px;">
Monto a recargar en colones:
</label>
<div style="position: relative; margin-bottom: 8px;">
<span style="position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-weight: 900; color: #166534; font-size: 1.15rem;">₡</span>
<input type="tel" inputmode="numeric" pattern="[0-9]*" id="inputParentSinpeMonto" placeholder="Ej: 3000" style="width: 100%; padding: 11px 12px 11px 32px; border-radius: 10px; border: 1.5px solid #86efac; font-size: 1.2rem; font-weight: 900; color: #166534; background: white; box-sizing: border-box;">
</div>
<div style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 12px;">
<button type="button" onclick="setParentSinpePreset(1000)" class="stock-btn-quick" style="border-color: #86efac; color: #166534;">₡1.000</button>
<button type="button" onclick="setParentSinpePreset(2000)" class="stock-btn-quick" style="border-color: #86efac; color: #166534;">₡2.000</button>
<button type="button" onclick="setParentSinpePreset(5000)" class="stock-btn-quick" style="border-color: #86efac; color: #166534;">₡5.000</button>
<button type="button" onclick="setParentSinpePreset(10000)" class="stock-btn-quick" style="border-color: #86efac; color: #166534;">₡10.000</button>
</div>
<button type="button" onclick="executeParentSinpeRecharge()" style="width: 100%; padding: 13px; background: linear-gradient(135deg, #16a34a, #15803d); color: white; border: none; border-radius: 12px; font-weight: 900; font-size: 0.95rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 4px 10px rgba(22, 163, 74, 0.3);">
<span>📲</span> Aplicar Recarga de Saldo
</button>
</div>
<!-- CONFIGURACIÓN DE LÍMITE DIARIO -->
<div class="parent-card" style="background: #f0f9ff; border: 2px solid #38bdf8;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;">
<div>
<strong style="font-size: 0.95rem; color: #0369a1; display: block;">🛡️ Límite de Gasto Máximo Diario</strong>
<span style="font-size: 0.74rem; color: #64748b;">Monto máximo que el estudiante puede gastar por día</span>
</div>
<span id="lblParentDailyLimitDisplay" style="font-size: 1.1rem; color: #0284c7; font-weight: 900; background: white; border: 1.5px solid #bae6fd; padding: 4px 12px; border-radius: 8px;">₡3.000</span>
</div>
<div style="display: flex; gap: 8px; margin-bottom: 10px;">
<div style="position: relative; flex: 1;">
<span style="position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-weight: 900; color: #0284c7; font-size: 1.1rem;">₡</span>
<input type="tel" inputmode="numeric" pattern="[0-9]*" id="inputParentCustomLimit" placeholder="Ej: 3000" style="width: 100%; padding: 10px 10px 10px 30px; border-radius: 10px; border: 2px solid #0284c7; font-size: 1.1rem; font-weight: 900; color: #0f172a; background: white; box-sizing: border-box;">
</div>
<button type="button" onclick="saveParentCustomLimit()" style="padding: 10px 16px; background: linear-gradient(135deg, #0284c7, #0369a1); color: white; border: none; border-radius: 10px; font-weight: 900; font-size: 0.85rem; cursor: pointer; white-space: nowrap; box-shadow: 0 2px 6px rgba(2, 132, 199, 0.35);">
💾 Guardar
</button>
</div>
<div style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-bottom: 10px;">
<button type="button" onclick="setParentLimitPreset(1500)" class="stock-btn-quick">₡1.500</button>
<button type="button" onclick="setParentLimitPreset(2500)" class="stock-btn-quick">₡2.500</button>
<button type="button" onclick="setParentLimitPreset(3500)" class="stock-btn-quick">₡3.500</button>
<button type="button" onclick="setParentLimitPreset(5000)" class="stock-btn-quick">₡5.000</button>
</div>
<input type="range" id="rangeParentLimit" min="1000" max="10000" step="500" value="3000" oninput="onParentLimitSliderChange(this.value)" style="width: 100%;">
<div style="display: flex; justify-content: space-between; font-size: 0.7rem; color: #64748b; margin-top: 2px;">
<span>₡1.000 min</span>
<span>₡10.000 max</span>
</div>
</div>
<!-- PERMISOS DE TRANSFERENCIA ENTRE COMPAÑEROS -->
<div class="parent-card" style="display: flex; justify-content: space-between; align-items: center;">
<div>
<strong style="font-size: 0.88rem; color: var(--text-main); display: block;">🤝 RecreoTransfer entre Compas</strong>
<span style="font-size: 0.74rem; color: var(--text-muted);">Permitir transferir saldo a compañeros de clase</span>
</div>
<input type="checkbox" id="chkParentAllowTransferDirect" onchange="onToggleParentTransfer(this.checked)" style="width: 24px; height: 24px; cursor: pointer; accent-color: #0284c7;" checked>
</div>
<!-- SEGURIDAD Y PIN ESCOLAR -->
<div class="parent-card" style="border: 1.5px dashed var(--border);">
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 10px;">
<span style="font-size: 1.2rem;">🔐</span>
<div>
<strong style="font-size: 0.9rem; color: var(--text-main); display: block;">Credenciales del Estudiante</strong>
<span style="font-size: 0.74rem; color: var(--text-muted);">Restablece el PIN o la contraseña de acceso escolar</span>
</div>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px;">
<div>
<label style="display: block; font-size: 0.74rem; font-weight: 800; color: var(--text-muted); margin-bottom: 3px;">Nuevo PIN (4 dígitos):</label>
<input type="password" inputmode="numeric" maxlength="4" id="inputParentStudentPin" placeholder="1234" style="width: 100%; padding: 9px; border-radius: 8px; border: 1.5px solid var(--border); font-weight: 900; letter-spacing: 2px; text-align: center; box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
</div>
<div>
<label style="display: block; font-size: 0.74rem; font-weight: 800; color: var(--text-muted); margin-bottom: 3px;">Nueva Contraseña:</label>
<input type="text" id="inputParentStudentPass" placeholder="Ej: 1234" style="width: 100%; padding: 9px; border-radius: 8px; border: 1.5px solid var(--border); font-weight: 800; box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
</div>
</div>
<button type="button" onclick="saveParentStudentCredentials()" style="width: 100%; padding: 10px; background: #334155; color: white; border: none; border-radius: 8px; font-weight: 800; font-size: 0.82rem; cursor: pointer;">
💾 Guardar Nuevas Credenciales
</button>
</div>
<!-- HISTORIAL DE COMPRAS RECIENTES -->
<div class="parent-card">
<h4 style="font-size: 0.9rem; font-weight: 900; color: var(--text-main); margin-bottom: 10px;">
📋 Historial de Compras en Soda
</h4>
<div id="parentStudentHistoryList" style="font-size: 0.8rem; color: var(--text-muted);">
Sin compras recientes registradas.
</div>
</div>
</div>
</div>
<div class="app-container" id="appContainer" style="display: none;">
<!-- BANNER DE TARJETA SUSPENDIDA / BLOQUEADA -->
<div id="bannerCardBlocked" class="banner-card-blocked" style="display: none;">
<span>⛔</span>
<span><strong>TARJETA SUSPENDIDA POR LA SODA.</strong> Acércate al mostrador de la soda para reactivar tu cuenta.</span>
</div>
<!-- BANNER DE ADVERTENCIA HTTPS PARA TELÉFONOS MÓVILES -->
<div id="bannerHttpsWarning" style="display: none; background: linear-gradient(135deg, #f59e0b, #d97706); color: white; padding: 10px 14px; font-size: 0.78rem; font-weight: 700; text-align: center; border-radius: 12px; margin: 10px 16px 0 16px; box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);">
🔒 Estás en HTTP. Para activar la cámara y pagos QR, tu celular requiere HTTPS:
<div style="margin-top: 6px;">
<a id="linkHttpsRedirect" href="https://recreopay.gammapos.app" style="display: inline-block; padding: 5px 14px; background: white; color: #b45309; border-radius: 20px; font-weight: 900; text-decoration: none; font-size: 0.8rem; box-shadow: 0 2px 5px rgba(0,0,0,0.15);">
🚀 Toca aquí para abrir en HTTPS Seguro
</a>
</div>
</div>
<!-- BARRA SUPERIOR UNIFICADA -->
<header class="top-bar">
<a href="#" class="brand-badge">
<div class="logo-icon">🥪</div>
<div>
<span>Recreo<strong>Pay</strong></span>
<span style="font-size: 0.65rem; display: block; color: var(--text-muted); font-weight: 600;">SODA ESCOLAR CR 🇨🇷</span>
</div>
</a>
<!-- ACCIONES DE CABECERA (TEMA OSCURO/CLARO Y SALIR) -->
<div class="top-actions">
<button id="btnCardDesigns" onclick="openCardDesignModal()" class="theme-toggle-btn card-design-toggle-btn" title="Personalizar diseño de mi tarjeta" style="font-size: 1.15rem; margin-right: 4px;">
🎨
</button>
<button id="btnThemeToggle" onclick="toggleTheme()" class="theme-toggle-btn" title="Alternar Modo Oscuro / Modo Claro">
🌙
</button>
<button id="btnModePadres" onclick="toggleParentPanel(true)" class="mode-btn" style="background: var(--bg-main); border: 1.5px solid var(--border); font-size: 0.8rem; font-weight: 800; border-radius: 10px; padding: 7px 11px; cursor: pointer; color: var(--text-main);" title="Acceso al Portal de Padres">
👨‍👩‍👦 Padres
</button>
<button id="btnLogout" onclick="logout(true)" class="logout-btn" title="Cerrar sesión y cambiar de cuenta">
<span>🚪</span>
<span class="logout-text">Salir</span>
</button>
</div>
</header>
<!-- SELECTOR OCULTO PARA COMPATIBILIDAD JS -->
<select id="studentSelector" onchange="onStudentChange(this.value)" style="display: none;"></select>
<!-- TARJETA DIGITAL DE MONEDERO Y SALDO (ESTILO UNIFICADO TEENS) -->
<section class="wallet-card" id="mainWalletCard">
<!-- ELEMENTOS DE TARJETA INTELIGENTE (CHIP Y PAGO SIN CONTACTO, SIN ASTERISCOS) -->
<div class="card-chip-container">
<div class="card-emv-chip" title="Monedero Electrónico Escolar">
<div class="chip-inner-circuit"></div>
</div>
<div class="card-contactless-wave" title="Tecnología QR / Sin Contacto">
<span>)</span><span>)</span><span>)</span>
</div>
</div>
<div class="student-info">
<img id="walletAvatar" class="student-avatar" src="" alt="Avatar">
<div class="student-meta" style="flex: 1; min-width: 0;">
<div style="min-width: 0;">
<h2 id="walletName" style="word-break: break-word; margin: 0; font-size: 1.15rem; font-weight: 800;">Cargando...</h2>
<span id="walletGrade" class="student-grade">Grado y Sección</span>
</div>
</div>
</div>
<div class="balance-row">
<div class="balance-col">
<div class="label" id="balanceLabel">SALDO DISPONIBLE</div>
<div class="amount">
<span id="walletBalance">₡0</span>
<span class="kids-coin-icon" id="kidsCoinIcon" style="display: none;">🪙</span>
</div>
</div>
<div style="display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end;">
<button class="qr-toggle-btn" onclick="openQrModal()">
<span>📱</span>
<span id="qrBtnText">Mi QR</span>
</button>
<button class="qr-toggle-btn" style="background: rgba(16, 185, 129, 0.25); border-color: rgba(52, 211, 153, 0.4);" onclick="openTransferModal()">
<span>⚡</span>
<span id="transferBtnText">Transferir ⚡</span>
</button>
</div>
</div>
</section>
<!-- BANNER DE LÍMITE DIARIO Y DISPONIBILIDAD (SÓLO LECTURA INFORMATIVA PARA EL ESTUDIANTE) -->
<div class="daily-limit-badge" id="dailyLimitBadge" style="cursor: default;" title="Límite diario establecido por tus padres">
<div>
<span>Límite diario fijado: </span>
<strong id="dailyLimitText">₡0</strong>
</div>
<div style="font-size: 0.76rem; color: var(--text-muted);" id="dailyAvailableText">
Disponible hoy: ₡0
</div>
</div>
<!-- ALERGIAS (SI TIENE) -->
<div id="allergyWarning" style="display:none; margin: 0 16px 12px 16px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 12px; padding: 8px 12px; font-size: 0.8rem; color: #92400e; align-items: center; gap: 6px;">
⚠️ <strong>Atención médica:</strong> <span id="allergyText"></span>
</div>
<!-- BARRA DE CATEGORÍAS -->
<div class="category-scroll" id="categoriesBar">
<!-- Se llena dinámicamente -->
</div>
<!-- TÍTULO DE SECCIÓN Y FILTRO MEP -->
<div class="section-title">
<span id="catalogTitle">Menú del Recreo</span>
<label style="font-size: 0.75rem; font-weight: 600; color: #166534; display: flex; align-items: center; gap: 4px; cursor: pointer;">
<input type="checkbox" id="chkFilterMep" onchange="renderProducts()">
<span>Solo Saludables MEP 🌿</span>
</label>
</div>
<!-- GRILLA DE PRODUCTOS -->
<div class="products-grid" id="productsGrid">
<!-- Se llena con productos de la soda -->
</div>
<!-- BARRA FLOTANTE DE PRE-ORDEN / CARRITO -->
<div class="floating-cart-bar" id="floatingCart" style="display: none;" onclick="openCartModal()">
<div class="cart-summary">
<span class="cart-count-badge" id="cartCountBadge">0</span>
<div class="cart-total-text" id="cartTotalText">₡0</div>
</div>
<button class="cart-action-btn">Pedir para el Recreo 🛒</button>
</div>
<!-- ENLACES DE ACCESO RÁPIDO PARA DEMO Y REVISIÓN -->
<div style="margin: 30px 16px; padding: 14px; background: var(--card-bg); border: 1px solid var(--border); border-radius: 14px; font-size: 0.82rem; text-align: center;">
<p style="font-weight: 700; margin-bottom: 8px; color: var(--text-main);">Acceso Rápido del Sistema:</p>
<div style="display: flex; justify-content: center; gap: 10px; flex-wrap: wrap;">
<a href="/pos.html" target="_blank" style="color: #0284c7; font-weight: 700; text-decoration: none; padding: 4px 10px; background: #e0f2fe; border-radius: 8px;">📟 Terminal Soda (Caja & QR)</a>
<a href="/carnet.html" target="_blank" style="color: #10b981; font-weight: 700; text-decoration: none; padding: 4px 10px; background: #d1fae5; border-radius: 8px;">🖨️ Carnés Físicos para Imprimir</a>
</div>
</div>
</div>
<!-- MODAL: CÓDIGO QR PARA PRESENTAR EN LA SODA -->
<div class="modal-qr-backdrop" id="modalQr" style="display: none;" onclick="closeQrModal(event)">
<div class="modal-qr-card" onclick="event.stopPropagation()">
<h3 style="color: #0f172a; font-size: 1.2rem; font-weight: 800;">Mi Carné QR RecreoPay</h3>
<p style="font-size: 0.8rem; color: #64748b; margin-top: 4px;">Muéstralo en la ventanilla de la soda para pagar al instante</p>
<img id="qrDisplayImg" class="qr-code-img" src="" alt="Código QR">
<div style="background: #f1f5f9; padding: 8px 12px; border-radius: 8px; font-family: monospace; font-size: 0.9rem; font-weight: 800; color: #0284c7;" id="qrTokenDisplay">
CODIGO-QR
</div>
<p style="font-size: 0.75rem; color: #94a3b8; margin-top: 10px;">
💡 Si no tienes tu celular en la escuela, puedes usar tu carné físico impreso con este mismo código.
</p>
<button onclick="closeQrModal()" style="margin-top: 14px; width: 100%; padding: 10px; background: #0f172a; color: white; border: none; border-radius: 12px; font-weight: 700; cursor: pointer;">
Cerrar
</button>
</div>
</div>
<!-- MODAL: CARRITO Y PRE-ORDEN -->
<div class="modal-qr-backdrop" id="modalCart" style="display: none;" onclick="closeCartModal(event)">
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 420px; text-align: left;">
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; padding-bottom: 10px; margin-bottom: 12px;">
<h3 style="color: #0f172a; font-size: 1.15rem; font-weight: 800;">Mi Pre-Orden Escolar</h3>
<button onclick="closeCartModal()" style="background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #64748b;">✕</button>
</div>
<div style="margin-bottom: 14px;">
<label style="display: block; font-size: 0.8rem; font-weight: 700; color: #334155; margin-bottom: 4px;">
¿Para cuál recreo deseas tu orden?
</label>
<select id="momentoEntregaSelect" style="width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid #cbd5e1; font-weight: 600;">
<option value="recreo_1">🔔 1er Recreo de la Mañana (9:30 AM)</option>
<option value="almuerzo">🍲 Hora de Almuerzo (11:45 AM)</option>
<option value="recreo_2">🍎 2do Recreo de la Tarde (1:45 PM)</option>
</select>
</div>
<!-- LISTA DE PRODUCTOS EN EL CARRITO -->
<div id="cartItemsList" style="max-height: 220px; overflow-y: auto; margin-bottom: 14px;">
<!-- Se llena dinámicamente -->
</div>
<div style="border-top: 1px solid #e2e8f0; padding-top: 10px; margin-bottom: 14px; display: flex; justify-content: space-between; align-items: center;">
<span style="font-weight: 800; color: #334155;">Total a Rebajar de Saldo:</span>
<span id="modalCartTotal" style="font-size: 1.3rem; font-weight: 900; color: #0284c7;">₡0</span>
</div>
<button id="btnConfirmarOrden" onclick="submitPreOrder()" style="width: 100%; padding: 12px; background: #10b981; color: white; border: none; border-radius: 12px; font-weight: 800; font-size: 1rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;">
<span>✅ Confirmar y Pagar Pre-Orden</span>
</button>
</div>
</div>
<!-- MODAL: PANEL DE PADRES (RECARGA SINPE Y LÍMITES) -->
<div class="modal-qr-backdrop" id="modalPadres" style="display: none;" onclick="toggleParentPanel(false, event)">
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 440px; text-align: left;">
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; padding-bottom: 10px; margin-bottom: 14px;">
<div>
<h3 style="color: #0f172a; font-size: 1.15rem; font-weight: 800;">Portal de Padres RecreoPay</h3>
<span style="font-size: 0.75rem; color: #64748b;">Control de meriendas, nutrición y recargas SINPE</span>
</div>
<button onclick="toggleParentPanel(false)" style="background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #64748b;">✕</button>
</div>
<!-- SELECTOR DE HIJO PARA PADRES -->
<div id="parentChildSelectorBox" style="display: none; margin-bottom: 14px; background: #e0f2fe; padding: 10px 12px; border-radius: 12px; border: 1.5px solid #bae6fd;">
<label for="parentChildSelect" style="display: block; font-size: 0.76rem; font-weight: 800; color: #0369a1; margin-bottom: 4px;">🧒 Viendo información de:</label>
<select id="parentChildSelect" onchange="onParentChildSelect(this.value)" style="width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid #7dd3fc; font-weight: 800; color: #0c4a6e; background: white; font-size: 0.9rem;">
</select>
</div>
<!-- RECARGA SINPE MÓVIL (MONTO ESCRITO Y ACCESOS RÁPIDOS) -->
<div style="background: #f0fdf4; border: 1.5px solid #86efac; border-radius: 14px; padding: 14px; margin-bottom: 16px;">
<div style="display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px;">
<div style="display: flex; align-items: center; gap: 8px;">
<span style="font-size: 1.4rem;">📱</span>
<div>
<strong style="color: #166534; font-size: 0.95rem;">Recarga por SINPE Móvil</strong>
<p style="font-size: 0.74rem; color: #15803d;">Número de la Soda: <strong>8888-SODA (7632)</strong></p>
</div>
</div>
<span style="font-size: 0.7rem; color: #166534; background: #dcfce7; font-weight: 800; padding: 2px 8px; border-radius: 6px;">Acreditación Inmediata</span>
</div>
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: #166534; margin-bottom: 4px;">
Escribe el monto a recargar:
</label>
<div style="position: relative; margin-bottom: 8px;">
<span style="position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font-weight: 900; color: #166534; font-size: 1.1rem;">₡</span>
<input type="tel" inputmode="numeric" pattern="[0-9]*" id="inputCustomSinpe" placeholder="Ej: 3000" style="width: 100%; padding: 10px 10px 10px 30px; border-radius: 10px; border: 1.5px solid #86efac; font-size: 1.15rem; font-weight: 900; color: #166534; background: white;">
</div>
<div style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 10px;">
<button type="button" onclick="setWrittenRechargeAmount(1000)" style="padding: 7px 4px; background: white; border: 1px solid #86efac; border-radius: 8px; font-weight: 800; font-size: 0.76rem; color: #166534; cursor: pointer;">₡1.000</button>
<button type="button" onclick="setWrittenRechargeAmount(2000)" style="padding: 7px 4px; background: white; border: 1px solid #86efac; border-radius: 8px; font-weight: 800; font-size: 0.76rem; color: #166534; cursor: pointer;">₡2.000</button>
<button type="button" onclick="setWrittenRechargeAmount(5000)" style="padding: 7px 4px; background: white; border: 1px solid #86efac; border-radius: 8px; font-weight: 800; font-size: 0.76rem; color: #166534; cursor: pointer;">₡5.000</button>
<button type="button" onclick="setWrittenRechargeAmount(10000)" style="padding: 7px 4px; background: white; border: 1px solid #86efac; border-radius: 8px; font-weight: 800; font-size: 0.76rem; color: #166534; cursor: pointer;">₡10.000</button>
</div>
<button type="button" onclick="customSinpeRecharge()" style="width: 100%; padding: 12px; background: linear-gradient(135deg, #16a34a, #15803d); color: white; border: none; border-radius: 10px; font-weight: 900; font-size: 0.95rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 4px 10px rgba(22, 163, 74, 0.3);">
<span>📲</span> Aplicar Recarga de Saldo
</button>
</div>
<!-- CONFIGURACIÓN DE LÍMITE DIARIO (ESCRITO Y DESLIZABLE) -->
<div style="background: #f0f9ff; border: 2px solid #38bdf8; border-radius: 14px; padding: 14px; margin-bottom: 16px; box-shadow: 0 2px 8px rgba(56, 189, 248, 0.15);">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px;">
<div>
<strong style="font-size: 0.92rem; color: #0369a1; display: block;">🛡️ Límite de Gasto Máximo Diario</strong>
<span style="font-size: 0.74rem; color: #64748b;">Monto máximo que el estudiante puede gastar por día</span>
</div>
<span id="lblParentDailyLimit" style="font-size: 1.05rem; color: #0284c7; font-weight: 900; background: white; border: 1.5px solid #bae6fd; padding: 3px 10px; border-radius: 8px;">₡3.000</span>
</div>
<label for="inputCustomDailyLimit" style="display: block; font-size: 0.8rem; font-weight: 800; color: #0369a1; margin-bottom: 4px;">
✍️ Digita o escribe el límite en colones:
</label>
<div style="display: flex; gap: 8px; margin-bottom: 8px;">
<div style="position: relative; flex: 1;">
<span style="position: absolute; left: 10px; top: 50%; transform: translateY(-50%); font-weight: 900; color: #0284c7; font-size: 1.1rem;">₡</span>
<input type="tel" inputmode="numeric" pattern="[0-9]*" id="inputCustomDailyLimit" placeholder="Ej: 3000" oninput="onCustomDailyLimitInput(this.value)" style="width: 100%; padding: 10px 10px 10px 30px; border-radius: 10px; border: 2px solid #0284c7; font-size: 1.1rem; font-weight: 900; color: #0f172a; background: white; box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);">
</div>
<button type="button" onclick="saveCustomDailyLimit()" style="padding: 10px 16px; background: linear-gradient(135deg, #0284c7, #0369a1); color: white; border: none; border-radius: 10px; font-weight: 900; font-size: 0.85rem; cursor: pointer; white-space: nowrap; box-shadow: 0 2px 6px rgba(2, 132, 199, 0.35);">
💾 Guardar
</button>
</div>
<div id="msgDailyLimitFeedback" style="display: none; font-size: 0.76rem; font-weight: 800; margin-bottom: 8px; padding: 4px 8px; border-radius: 6px; background: #dcfce7; color: #166534; text-align: center;"></div>
<!-- ACCESOS RÁPIDOS DE LÍMITES COMUNES -->
<div style="display: grid; grid-template-columns: repeat(4, 1fr); gap: 5px; margin-bottom: 10px;">
<button type="button" onclick="setWrittenDailyLimit(1500)" style="padding: 6px 2px; background: white; border: 1.5px solid #cbd5e1; border-radius: 8px; font-size: 0.74rem; font-weight: 800; color: #1e293b; cursor: pointer;">₡1.500</button>
<button type="button" onclick="setWrittenDailyLimit(2500)" style="padding: 6px 2px; background: white; border: 1.5px solid #cbd5e1; border-radius: 8px; font-size: 0.74rem; font-weight: 800; color: #1e293b; cursor: pointer;">₡2.500</button>
<button type="button" onclick="setWrittenDailyLimit(3500)" style="padding: 6px 2px; background: white; border: 1.5px solid #cbd5e1; border-radius: 8px; font-size: 0.74rem; font-weight: 800; color: #1e293b; cursor: pointer;">₡3.500</button>
<button type="button" onclick="setWrittenDailyLimit(5000)" style="padding: 6px 2px; background: white; border: 1.5px solid #cbd5e1; border-radius: 8px; font-size: 0.74rem; font-weight: 800; color: #1e293b; cursor: pointer;">₡5.000</button>
</div>
<div style="font-size: 0.72rem; color: #64748b; margin-bottom: 2px;">O desliza para ajustar rápido:</div>
<input type="range" id="rangeDailyLimit" min="1000" max="10000" step="500" value="3000" oninput="onDailyLimitSlider(this.value)" style="width: 100%;">
<div style="display: flex; justify-content: space-between; font-size: 0.7rem; color: #64748b; margin-top: 2px;">
<span>₡1.000 min</span>
<span>₡10.000 max</span>
</div>
</div>
<!-- CONTROL PARENTAL: PERMITIR O BLOQUEAR TRANSFERENCIAS ENTRE COMPAÑEROS -->
<div style="background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; display: flex; justify-content: space-between; align-items: center;">
<div>
<strong style="font-size: 0.85rem; color: #1e293b; display: block;">🤝 RecreoTransfer entre Compas</strong>
<span style="font-size: 0.72rem; color: #64748b;">Permitir transferir saldo a compañeros de clase</span>
</div>
<input type="checkbox" id="chkParentAllowTransfer" onchange="onToggleAllowTransfer(this.checked)" style="width: 22px; height: 22px; cursor: pointer; accent-color: #0284c7;" checked>
</div>
<!-- RESTABLECER PIN Y CONTRASEÑA ESCOLAR DEL ALUMNO -->
<div style="background: #f8fafc; border: 1.5px dashed #cbd5e1; border-radius: 14px; padding: 14px; margin-bottom: 16px;">
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 8px;">
<span style="font-size: 1.2rem;">🔐</span>
<div>
<strong style="font-size: 0.88rem; color: #1e293b; display: block;">Seguridad y Contraseña del Alumno</strong>
<span style="font-size: 0.72rem; color: #64748b;">Cambia el PIN de transferencias o la contraseña de acceso</span>
</div>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px;">
<div>
<label style="display: block; font-size: 0.74rem; font-weight: 800; color: #475569; margin-bottom: 3px;">Nuevo PIN (4 dígitos):</label>
<input type="password" inputmode="numeric" maxlength="4" id="inputParentNewPin" placeholder="1234" style="width: 100%; padding: 8px; border-radius: 8px; border: 1.5px solid #cbd5e1; font-weight: 900; letter-spacing: 2px; text-align: center; box-sizing: border-box;">
</div>
<div>
<label style="display: block; font-size: 0.74rem; font-weight: 800; color: #475569; margin-bottom: 3px;">Nueva Contraseña:</label>
<input type="text" id="inputParentNewPass" placeholder="Ej: 1234" style="width: 100%; padding: 8px; border-radius: 8px; border: 1.5px solid #cbd5e1; font-weight: 800; box-sizing: border-box;">
</div>
</div>
<button type="button" onclick="saveParentChildAccess()" style="width: 100%; padding: 10px; background: #334155; color: white; border: none; border-radius: 8px; font-weight: 800; font-size: 0.82rem; cursor: pointer;">
💾 Guardar Nuevas Credenciales
</button>
</div>
<!-- HISTORIAL RECIENTE -->
<h4 style="font-size: 0.85rem; font-weight: 800; color: #1e293b; margin-bottom: 8px;">Consumos Recientes</h4>
<div id="parentHistoryList" style="max-height: 140px; overflow-y: auto; font-size: 0.78rem;">
<!-- Se llena dinámicamente -->
</div>
</div>
</div>
<!-- MODAL: REGISTRAR NUEVO ESTUDIANTE (ADMIN) -->
<div class="modal-qr-backdrop" id="modalNewStudent" style="display: none;" onclick="closeNewStudentModal(event)">
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 460px; text-align: left;">
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; padding-bottom: 10px; margin-bottom: 14px;">
<div>
<h3 style="color: #0f172a; font-size: 1.15rem; font-weight: 800;">Registrar Nuevo Alumno</h3>
<span style="font-size: 0.75rem; color: #64748b;">Genera carné oficial y código QR al instante</span>
</div>
<button onclick="closeNewStudentModal()" style="background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #64748b;">✕</button>
</div>
<form id="formNewStudent" onsubmit="submitNewStudent(event)">
<div style="margin-bottom: 10px;">
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: #334155; margin-bottom: 3px;">Nombre Completo:</label>
<input type="text" id="newEstNombre" placeholder="Ej: Daniel Sánchez Méndez" required style="width: 100%; padding: 8px 10px; border-radius: 8px; border: 1.5px solid #cbd5e1; font-weight: 700; box-sizing: border-box;">
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 10px;">
<div>
<label style="display: block; font-size: 0.75rem; font-weight: 700; color: #334155; margin-bottom: 3px;">Edad:</label>
<input type="number" id="newEstEdad" value="8" min="5" max="19" required style="width: 100%; padding: 8px; border-radius: 8px; border: 1.5px solid #cbd5e1; font-weight: 700; box-sizing: border-box;">
</div>
<div>
<label style="display: block; font-size: 0.75rem; font-weight: 700; color: #334155; margin-bottom: 3px;">Grado:</label>
<input type="text" id="newEstGrado" placeholder="Ej: 3° Grado" required style="width: 100%; padding: 8px; border-radius: 8px; border: 1.5px solid #cbd5e1; font-weight: 700; box-sizing: border-box;">
</div>
<div>
<label style="display: block; font-size: 0.75rem; font-weight: 700; color: #334155; margin-bottom: 3px;">Sección:</label>
<input type="text" id="newEstSeccion" placeholder="Ej: 3-B" required style="width: 100%; padding: 8px; border-radius: 8px; border: 1.5px solid #cbd5e1; font-weight: 700; box-sizing: border-box;">
</div>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px;">
<div>
<label style="display: block; font-size: 0.75rem; font-weight: 700; color: #334155; margin-bottom: 3px;">Saldo Inicial (₡):</label>
<input type="tel" inputmode="numeric" id="newEstSaldo" value="2000" style="width: 100%; padding: 8px; border-radius: 8px; border: 1.5px solid #cbd5e1; font-weight: 700; box-sizing: border-box;">
</div>
<div>
<label style="display: block; font-size: 0.75rem; font-weight: 700; color: #334155; margin-bottom: 3px;">Límite Diario (₡):</label>
<input type="tel" inputmode="numeric" id="newEstLimite" value="2500" style="width: 100%; padding: 8px; border-radius: 8px; border: 1.5px solid #cbd5e1; font-weight: 700; box-sizing: border-box;">
</div>
</div>
<div style="margin-bottom: 10px;">
<label style="display: block; font-size: 0.75rem; font-weight: 700; color: #334155; margin-bottom: 3px;">Alergias o Restricciones Médicas:</label>
<input type="text" id="newEstAlergias" placeholder="Ej: Ninguna conocida, Alergia al gluten..." style="width: 100%; padding: 8px; border-radius: 8px; border: 1.5px solid #cbd5e1; box-sizing: border-box;">
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 14px;">
<div>
<label style="display: block; font-size: 0.75rem; font-weight: 700; color: #334155; margin-bottom: 3px;">Nombre del Padre:</label>
<input type="text" id="newEstPadre" placeholder="Ej: Juan Sánchez" style="width: 100%; padding: 8px; border-radius: 8px; border: 1.5px solid #cbd5e1; box-sizing: border-box;">
</div>
<div>
<label style="display: block; font-size: 0.75rem; font-weight: 700; color: #334155; margin-bottom: 3px;">Teléfono Padre:</label>
<input type="text" id="newEstTel" placeholder="+506 8888-0000" style="width: 100%; padding: 8px; border-radius: 8px; border: 1.5px solid #cbd5e1; box-sizing: border-box;">
</div>
</div>
<button type="submit" id="btnSubmitNewStudent" style="width: 100%; padding: 12px; background: linear-gradient(135deg, #0284c7, #0369a1); color: white; border: none; border-radius: 12px; font-weight: 900; font-size: 0.95rem; cursor: pointer;">
✅ Guardar y Generar Carné
</button>
</form>
</div>
</div>
<!-- MODAL: CREAR / EDITAR PRODUCTO (ADMIN) -->
<div class="modal-qr-backdrop" id="modalAdminProduct" style="display: none;" onclick="closeAdminProductModal(event)">
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 480px; text-align: left; max-height: 90vh; overflow-y: auto;">
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 14px;">
<div>
<h3 id="modalProductTitle" style="color: var(--text-main); font-size: 1.15rem; font-weight: 800; margin: 0;">➕ Crear Nuevo Producto</h3>
<span style="font-size: 0.75rem; color: var(--text-muted);">Alimentos, bebidas y meriendas escolares</span>
</div>
<button type="button" onclick="closeAdminProductModal()" style="background: none; border: none; font-size: 1.25rem; cursor: pointer; color: var(--text-muted); padding: 4px;">✕</button>
</div>
<form id="formAdminProduct" onsubmit="submitAdminProduct(event)">
<input type="hidden" id="adminProdId" value="">
<div style="margin-bottom: 10px;">
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;">Nombre del Alimento / Bebida *:</label>
<input type="text" id="adminProdNombre" placeholder="Ej: Empanada de Pollo, Fresco Natural..." required style="width: 100%; padding: 9px 12px; border-radius: 8px; border: 1.5px solid var(--border); font-weight: 700; box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px;">
<div>
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;">Categoría *:</label>
<select id="adminProdCategoria" required style="width: 100%; padding: 9px; border-radius: 8px; border: 1.5px solid var(--border); font-weight: 700; box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
<!-- Opciones dinámicas de categorías -->
</select>
</div>
<div>
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;">Precio en Colones (₡) *:</label>
<input type="number" id="adminProdPrecio" placeholder="Ej: 1200" min="50" step="50" required style="width: 100%; padding: 9px; border-radius: 8px; border: 1.5px solid var(--border); font-weight: 800; color: #0284c7; box-sizing: border-box; background: var(--card-bg);">
</div>
</div>
<div style="display: grid; grid-template-columns: 80px 1fr; gap: 10px; margin-bottom: 10px;">
<div>
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;">Ícono:</label>
<input type="text" id="adminProdIcono" value="🥪" maxlength="4" style="width: 100%; text-align: center; font-size: 1.5rem; padding: 4px; border-radius: 8px; border: 1.5px solid var(--border); box-sizing: border-box; background: var(--card-bg);">
</div>
<div>
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;">Íconos Rápidos:</label>
<div style="display: flex; gap: 4px; flex-wrap: wrap;">
<button type="button" onclick="selectProdIcon('🥪')" style="padding: 4px 6px; font-size: 1.1rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg); cursor: pointer;">🥪</button>
<button type="button" onclick="selectProdIcon('🍎')" style="padding: 4px 6px; font-size: 1.1rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg); cursor: pointer;">🍎</button>
<button type="button" onclick="selectProdIcon('🧃')" style="padding: 4px 6px; font-size: 1.1rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg); cursor: pointer;">🧃</button>
<button type="button" onclick="selectProdIcon('🍕')" style="padding: 4px 6px; font-size: 1.1rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg); cursor: pointer;">🍕</button>
<button type="button" onclick="selectProdIcon('🥗')" style="padding: 4px 6px; font-size: 1.1rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg); cursor: pointer;">🥗</button>
<button type="button" onclick="selectProdIcon('🥛')" style="padding: 4px 6px; font-size: 1.1rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg); cursor: pointer;">🥛</button>
<button type="button" onclick="selectProdIcon('🍪')" style="padding: 4px 6px; font-size: 1.1rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg); cursor: pointer;">🍪</button>
<button type="button" onclick="selectProdIcon('🌮')" style="padding: 4px 6px; font-size: 1.1rem; border: 1px solid var(--border); border-radius: 6px; background: var(--card-bg); cursor: pointer;">🌮</button>
</div>
</div>
</div>
<div style="margin-bottom: 10px;">
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;">Descripción (opcional):</label>
<input type="text" id="adminProdDescripcion" placeholder="Ej: Rellena de pollo mechado, horneada al día" style="width: 100%; padding: 8px 10px; border-radius: 8px; border: 1.5px solid var(--border); font-size: 0.85rem; box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
</div>
<div style="background: var(--bg-main, #f8fafc); border: 1px solid var(--border, #e2e8f0); border-radius: 10px; padding: 10px; margin-bottom: 12px;">
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: center;">
<div>
<label style="display: flex; align-items: center; gap: 6px; font-size: 0.8rem; font-weight: 800; cursor: pointer; color: var(--text-main);">
<input type="checkbox" id="adminProdControlStock" checked onchange="toggleStockInput(this.checked)">
<span>Controlar Existencias</span>
</label>
<div style="margin-top: 6px;" id="boxProdStockCount">
<label style="display: block; font-size: 0.72rem; color: var(--text-muted); font-weight: 700;">Stock Actual:</label>
<input type="number" id="adminProdStock" value="10" min="0" style="width: 100%; padding: 6px 8px; border-radius: 6px; border: 1px solid var(--border); font-weight: 800; background: var(--card-bg); color: var(--text-main); box-sizing: border-box;">
</div>
</div>
<div>
<label style="display: block; font-size: 0.75rem; font-weight: 800; color: var(--text-main); margin-bottom: 4px;">Sello Nutricional MEP:</label>
<select id="adminProdMep" style="width: 100%; padding: 7px; border-radius: 6px; border: 1px solid var(--border); font-weight: 700; font-size: 0.8rem; background: var(--card-bg); color: var(--text-main); box-sizing: border-box;">
<option value="1">🟢 Saludable MEP (Permitido)</option>
<option value="0">🟠 Consumo Ocasional</option>
</select>
</div>
</div>
</div>
<div style="display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px;">
<button type="button" id="btnDeleteProduct" onclick="handleDeleteProduct()" style="display: none; padding: 10px 14px; background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; border-radius: 10px; font-weight: 800; font-size: 0.84rem; cursor: pointer;">
🗑️ Eliminar
</button>
<button type="button" onclick="closeAdminProductModal()" style="padding: 10px 14px; background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; border-radius: 10px; font-weight: 800; font-size: 0.84rem; cursor: pointer;">
Cancelar
</button>
<button type="submit" id="btnSaveProductSubmit" style="padding: 10px 18px; background: linear-gradient(135deg, #0284c7, #0369a1); color: white; border: none; border-radius: 10px; font-weight: 900; font-size: 0.88rem; cursor: pointer; display: flex; align-items: center; gap: 6px; box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3);">
<span>💾</span> <span>Guardar Producto</span>
</button>
</div>
</form>
</div>
</div>
<!-- MODAL: CREAR / EDITAR EMPLEADO O CAJERO (ADMIN) -->
<div class="modal-qr-backdrop" id="modalAdminStaff" style="display: none;" onclick="closeAdminStaffModal(event)">
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 460px; text-align: left;">
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 14px;">
<div>
<h3 id="modalStaffTitle" style="color: var(--text-main); font-size: 1.15rem; font-weight: 800; margin: 0;">👥 Nuevo Empleado / Cajero</h3>
<span style="font-size: 0.75rem; color: var(--text-muted);">Crea credenciales de acceso para la soda</span>
</div>
<button type="button" onclick="closeAdminStaffModal()" style="background: none; border: none; font-size: 1.25rem; cursor: pointer; color: var(--text-muted); padding: 4px;">✕</button>
</div>
<form id="formAdminStaff" onsubmit="submitAdminStaff(event)">
<input type="hidden" id="adminStaffId" value="">
<div style="margin-bottom: 10px;">
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;">Nombre Completo *:</label>
<input type="text" id="adminStaffNombre" placeholder="Ej: Carlos Murillo Vega" required style="width: 100%; padding: 9px 12px; border-radius: 8px; border: 1.5px solid var(--border); font-weight: 700; box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 10px;">
<div>
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;">Usuario de Acceso *:</label>
<input type="text" id="adminStaffUsername" placeholder="cajero1" required style="width: 100%; padding: 9px; border-radius: 8px; border: 1.5px solid var(--border); font-weight: 700; box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
</div>
<div>
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;">Rol en el Sistema *:</label>
<select id="adminStaffRol" required style="width: 100%; padding: 9px; border-radius: 8px; border: 1.5px solid var(--border); font-weight: 800; box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
<option value="cajero">📟 Cajero (Terminal POS)</option>
<option value="vendedor">🥪 Vendedor / Despacho</option>
<option value="admin">👨‍🍳 Administrador</option>
</select>
</div>
</div>
<div style="margin-bottom: 10px;">
<label style="display: block; font-size: 0.78rem; font-weight: 800; color: var(--text-main); margin-bottom: 3px;" id="lblStaffPassword">Contraseña de Acceso *:</label>
<input type="password" id="adminStaffPassword" placeholder="••••••••" style="width: 100%; padding: 9px 12px; border-radius: 8px; border: 1.5px solid var(--border); font-weight: 700; box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
<small id="hintStaffPassword" style="display: none; font-size: 0.7rem; color: var(--text-muted); margin-top: 3px;">Deja en blanco para conservar la contraseña actual.</small>
</div>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px;">
<div>
<label style="display: block; font-size: 0.78rem; font-weight: 700; color: var(--text-main); margin-bottom: 3px;">Teléfono:</label>
<input type="text" id="adminStaffTel" placeholder="+506 8888-0000" style="width: 100%; padding: 8px 10px; border-radius: 8px; border: 1.5px solid var(--border); box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
</div>
<div>
<label style="display: block; font-size: 0.78rem; font-weight: 700; color: var(--text-main); margin-bottom: 3px;">Email (opcional):</label>
<input type="email" id="adminStaffEmail" placeholder="[email protected]" style="width: 100%; padding: 8px 10px; border-radius: 8px; border: 1.5px solid var(--border); box-sizing: border-box; background: var(--card-bg); color: var(--text-main);">
</div>
</div>
<div style="display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px;">
<button type="button" onclick="closeAdminStaffModal()" style="padding: 10px 14px; background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; border-radius: 10px; font-weight: 800; font-size: 0.84rem; cursor: pointer;">
Cancelar
</button>
<button type="submit" id="btnSaveStaffSubmit" style="padding: 10px 18px; background: linear-gradient(135deg, #10b981, #059669); color: white; border: none; border-radius: 10px; font-weight: 900; font-size: 0.88rem; cursor: pointer; display: flex; align-items: center; gap: 6px; box-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);">
<span>💾</span> <span>Guardar Empleado</span>
</button>
</div>
</form>
</div>
</div>
<!-- MODAL: RECREOTRANSFER (PASAR PLATA A UN COMPAÑERO ESCANEANDO SU QR O CARNÉ) -->
<div class="modal-qr-backdrop" id="modalTransfer" style="display: none;" onclick="closeTransferModal(event)">
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 420px; text-align: left;">
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #e2e8f0; padding-bottom: 10px; margin-bottom: 12px;">
<div>
<h3 style="color: #0f172a; font-size: 1.15rem; font-weight: 800;">🤝 Pasar Plata a un Compa</h3>
<span style="font-size: 0.75rem; color: #64748b;">Escanea el carné o celular de tu amigo</span>
</div>
<button onclick="closeTransferModal()" style="background: none; border: none; font-size: 1.2rem; cursor: pointer; color: #64748b;">✕</button>
</div>
<!-- PASO 1: ESCANEAR CÁMARA O ELEGIR COMPAÑERO DE PRUEBA -->
<div id="transferStepScan">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;">
<span style="font-size: 0.75rem; color: #64748b; font-weight: 700;" id="transferCameraStatus">Iniciando cámara...</span>
<div style="display: flex; gap: 6px;">
<button id="btnFlipTransferCamera" type="button" onclick="flipTransferCamera()" style="display:none; padding: 3px 8px; background: #334155; color: white; border: none; border-radius: 6px; font-size: 0.72rem; font-weight: 700; cursor: pointer;">🔄 Girar</button>
<button id="btnRetryTransferCamera" type="button" onclick="startTransferCamera(true)" style="display:none; padding: 3px 8px; background: #0284c7; color: white; border: none; border-radius: 6px; font-size: 0.72rem; font-weight: 700; cursor: pointer;">📷 Activar</button>
</div>
</div>
<div style="position: relative; border-radius: 12px; overflow: hidden; background: #000; min-height: 170px; margin-bottom: 10px; display: flex; align-items: center; justify-content: center;">
<video id="transferVideo" style="width: 100%; height: 170px; object-fit: cover;" autoplay playsinline webkit-playsinline muted></video>
<div class="laser-scan-line"></div>
<div id="transferCameraHelp" style="display: none; position: absolute; inset: 0; background: rgba(15, 23, 42, 0.92); padding: 14px; text-align: center; flex-direction: column; justify-content: center; align-items: center; gap: 10px; z-index: 10;">
<span style="font-size: 1.8rem;">📷</span>
<div id="transferCameraHelpText" style="font-size: 0.76rem; color: #f8fafc; line-height: 1.35;">Toca el botón para permitir la cámara</div>
<div id="transferCameraActionContainer" style="display: flex; flex-direction: column; gap: 8px; width: 100%; align-items: center;">
<button id="btnAllowTransferCamera" type="button" onclick="startTransferCamera(true)" style="padding: 8px 18px; background: #0284c7; color: white; border: none; border-radius: 8px; font-weight: 800; font-size: 0.82rem; cursor: pointer; box-shadow: 0 4px 10px rgba(2, 132, 199, 0.3);">
Permitir Cámara
</button>
</div>
</div>
</div>
<!-- ACCESO DIRECTO PARA SUBIR O TOMAR FOTO DEL QR CON LA CÁMARA NATIVA -->
<div style="display: flex; justify-content: center; margin-bottom: 12px;">
<label style="cursor: pointer; display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; background: #f0fdf4; border: 1.5px dashed #86efac; border-radius: 10px; font-size: 0.78rem; font-weight: 800; color: #166534; box-shadow: 0 1px 3px rgba(0,0,0,0.04);">
<span>📸</span> Tomar foto del QR o carné
<input type="file" accept="image/*" capture="environment" style="display: none;" onchange="handleTransferQrPhoto(event)">
</label>
</div>
<div style="text-align: center; margin-bottom: 12px;">
<span style="font-size: 0.74rem; color: #64748b; font-weight: 700;">O selecciona a un compañero para transferirle:</span>
<div id="quickTransferFriends" style="display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 8px;">
<!-- Se llena dinámicamente con los otros estudiantes -->
</div>
</div>
</div>
<!-- PASO 2: CONFIRMAR COMPAÑERO Y MONTO -->
<div id="transferStepConfirm" style="display: none;">
<!-- Tarjeta del receptor -->
<div style="background: #f0fdf4; border: 1.5px solid #86efac; border-radius: 14px; padding: 12px; display: flex; align-items: center; gap: 12px; margin-bottom: 14px;">
<img id="transferTargetAvatar" src="" style="width: 48px; height: 48px; border-radius: 50%; border: 2px solid #10b981; background: white;">
<div style="flex: 1;">
<div style="font-size: 0.7rem; color: #15803d; font-weight: 800; text-transform: uppercase;">Vas a transferir a:</div>
<h4 id="transferTargetName" style="font-size: 1rem; font-weight: 900; color: #0f172a; line-height: 1.2;">Nombre</h4>
<span id="transferTargetGrade" style="font-size: 0.75rem; color: #64748b;">Grado y Sección</span>
</div>
<button onclick="resetTransferScan()" style="background: #e2e8f0; border: none; padding: 4px 8px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; cursor: pointer;">Cambiar</button>
</div>
<!-- MONTO A PASAR -->
<label style="display: block; font-size: 0.82rem; font-weight: 800; color: #1e293b; margin-bottom: 6px;">
¿Cuánto le vas a pasar?
</label>
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 10px;">
<button type="button" class="transfer-amount-btn active" id="btnTransfer500" onclick="setTransferAmount(500, this)">₡500</button>
<button type="button" class="transfer-amount-btn" id="btnTransfer1000" onclick="setTransferAmount(1000, this)">₡1.000</button>
<button type="button" class="transfer-amount-btn" id="btnTransfer1500" onclick="setTransferAmount(1500, this)">₡1.500</button>
</div>
<div style="margin-bottom: 12px;">
<input type="tel" inputmode="numeric" pattern="[0-9]*" id="inputTransferCustomAmount" value="500" placeholder="Otro monto (ej. 750)" style="width: 100%; padding: 10px; border-radius: 10px; border: 1.5px solid #cbd5e1; font-size: 1.05rem; font-weight: 800; color: #0284c7; box-sizing: border-box; text-align: center;">
</div>
<!-- MOTIVO OPCIONAL -->
<div style="margin-bottom: 12px;">
<label style="display: block; font-size: 0.75rem; font-weight: 700; color: #64748b; margin-bottom: 4px;">Motivo (Opcional):</label>
<input type="text" id="inputTransferMotivo" placeholder="Ej: Mitad de la empanada, fresco..." style="width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid #cbd5e1; font-size: 0.85rem; box-sizing: border-box;">
</div>
<!-- PIN DE SEGURIDAD (TECLADO NATIVO DEL TELÉFONO) -->
<div style="background: #f8fafc; border: 1.5px dashed #cbd5e1; border-radius: 14px; padding: 14px; margin-bottom: 14px; text-align: center;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px;">
<label for="inputTransferPin" style="font-size: 0.8rem; font-weight: 800; color: #0f172a;">🔐 Digita tu PIN de seguridad:</label>
<span id="lblTransferPinHint" style="font-size: 0.72rem; color: #166534; font-weight: 800; background: #dcfce7; padding: 2px 8px; border-radius: 6px;">(PIN: 1234)</span>
</div>
<div style="position: relative; max-width: 240px; margin: 0 auto;">
<input type="password" inputmode="numeric" pattern="[0-9]*" maxlength="4" autocomplete="one-time-code" id="inputTransferPin" placeholder="••••" style="width: 100%; text-align: center; font-size: 1.8rem; letter-spacing: 10px; padding: 10px 42px 10px 18px; border-radius: 12px; border: 2px solid #cbd5e1; font-weight: 900; background: white; color: #0f172a; box-sizing: border-box; outline: none; transition: border-color 0.2s;" onfocus="this.style.borderColor='#0284c7'" onblur="this.style.borderColor='#cbd5e1'">
<button type="button" id="btnTogglePin" onclick="togglePinVisibility()" style="position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; font-size: 1.25rem; cursor: pointer; color: #64748b; padding: 4px;" title="Ver/Ocultar PIN">👁️</button>
</div>
<div style="font-size: 0.72rem; color: #64748b; margin-top: 6px; font-weight: 600;">Se abrirá automáticamente el teclado numérico de tu teléfono</div>
</div>
<button id="btnConfirmTransfer" onclick="executeP2PTransfer()" style="width: 100%; padding: 14px; background: linear-gradient(135deg, #10b981, #059669); color: white; border: none; border-radius: 14px; font-weight: 900; font-size: 1.05rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);">
<span>💸</span> <span id="lblBtnConfirmTransferText">Enviar ₡500 al Instante</span>
</button>
</div>
</div>
</div>
<!-- MODAL: VINCULAR HIJO POR QR O CÓDIGO (PORTAL PADRES) -->
<div class="modal-qr-backdrop" id="modalScanChildQr" style="display: none;" onclick="closeScanChildQrModal(event)">
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 440px; text-align: center; border-radius: 20px;">
<!-- CABECERA -->
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; border-bottom: 1px solid var(--border); padding-bottom: 10px;">
<div style="display: flex; align-items: center; gap: 8px;">
<span style="font-size: 1.3rem;">🎒</span>
<strong style="font-size: 1.05rem; color: var(--text-main);">Vincular Estudiante</strong>
</div>
<button type="button" onclick="closeScanChildQrModal()" style="background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-muted); padding: 4px;">✕</button>
</div>
<!-- VISTA 1: SELECCIÓN DE MÉTODO (PESTAÑAS) -->
<div id="linkChildViewTabs">
<div style="display: flex; gap: 6px; background: #f1f5f9; padding: 4px; border-radius: 12px; margin-bottom: 14px;">
<button type="button" id="tabBtnLinkCamera" onclick="switchLinkChildTab('camera')" style="flex: 1; padding: 9px 8px; border: none; border-radius: 8px; font-weight: 800; font-size: 0.82rem; cursor: pointer; transition: all 0.2s; background: #ffffff; color: #0284c7; box-shadow: 0 2px 4px rgba(0,0,0,0.06);">
📷 Escanear con Cámara
</button>
<button type="button" id="tabBtnLinkCode" onclick="switchLinkChildTab('code')" style="flex: 1; padding: 9px 8px; border: none; border-radius: 8px; font-weight: 700; font-size: 0.82rem; cursor: pointer; transition: all 0.2s; background: transparent; color: #64748b;">
⌨️ Digitar Código
</button>
</div>
<!-- PANEL 1: CÁMARA QR -->
<div id="panelLinkCamera" style="display: block;">
<div style="position: relative; width: 100%; height: 220px; background: #000; border-radius: 14px; overflow: hidden; margin-bottom: 10px; border: 2px solid #0284c7;">
<video id="videoScanChild" playsinline webkit-playsinline autoplay muted style="width: 100%; height: 100%; object-fit: cover;"></video>
<canvas id="canvasScanChild" style="display: none;"></canvas>
<div class="laser-scan-line"></div>
<div id="badgeCameraChildStatus" style="position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%); background: rgba(15, 23, 42, 0.9); color: #38bdf8; padding: 3px 12px; border-radius: 20px; font-size: 0.72rem; font-weight: 800; border: 1px solid #0284c7; white-space: nowrap;">
📷 Apunta al código QR del carné
</div>
</div>
<p style="font-size: 0.78rem; color: var(--text-muted); margin: 0 0 10px 0;">
Apunta la cámara hacia el código QR impreso en el carné del estudiante.
</p>
</div>
<!-- PANEL 2: DIGITAR CÓDIGO -->
<div id="panelLinkCode" style="display: none; text-align: left;">
<label for="inputManualStudentCode" style="display: block; font-size: 0.8rem; font-weight: 800; color: var(--text-main); margin-bottom: 6px;">
Código de carné del estudiante:
</label>
<div style="display: flex; gap: 8px; margin-bottom: 6px;">
<input type="text" id="inputManualStudentCode" placeholder="Ej: EST-2026-001" onkeydown="if(event.key==='Enter'){event.preventDefault();validateStudentCodeForLink();}" style="flex: 1; padding: 11px 12px; border-radius: 10px; border: 2px solid var(--border); font-size: 0.95rem; font-weight: 800; background: var(--card-bg); color: var(--text-main); box-sizing: border-box; text-transform: uppercase;">
<button type="button" id="btnValidateStudentCode" onclick="validateStudentCodeForLink()" style="padding: 10px 16px; background: #0284c7; color: white; border: none; border-radius: 10px; font-weight: 800; font-size: 0.85rem; cursor: pointer; white-space: nowrap; display: flex; align-items: center; gap: 4px; box-shadow: 0 2px 6px rgba(2, 132, 199, 0.3);">
<span>🔍</span> Validar
</button>
</div>
<p style="font-size: 0.75rem; color: var(--text-muted); margin: 0 0 10px 0;">
💡 Digita el código que aparece en el carné escolar (ej: EST-2026-001).
</p>
</div>
<!-- MENSAJE DE ERROR -->
<div id="linkStudentErrorMsg" style="display: none; background: #fee2e2; border: 1.5px solid #ef4444; color: #991b1b; padding: 10px 12px; border-radius: 10px; font-size: 0.8rem; font-weight: 700; margin-top: 10px; text-align: center;"></div>
</div>
<!-- VISTA 2: TARJETA DE VERIFICACIÓN / CONFIRMACIÓN -->
<div id="linkChildViewConfirm" style="display: none; text-align: left;">
<div style="background: #f0fdf4; border: 1.5px solid #86efac; border-radius: 14px; padding: 10px 12px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px;">
<span style="font-size: 1.2rem;">✅</span>
<span style="font-size: 0.82rem; font-weight: 800; color: #166534;">Estudiante Identificado Correctamente</span>
</div>
<!-- TARJETA DEL ESTUDIANTE -->
<div style="background: var(--card-bg); border: 2px solid #0284c7; border-radius: 16px; padding: 14px; margin-bottom: 14px; display: flex; align-items: center; gap: 14px; box-shadow: 0 4px 12px rgba(2, 132, 199, 0.1);">
<img id="linkPreviewAvatar" src="" style="width: 58px; height: 58px; border-radius: 50%; border: 2.5px solid #0284c7; object-fit: cover; background: white; flex-shrink: 0;">
<div style="flex: 1; min-width: 0;">
<div style="font-size: 0.7rem; color: #64748b; font-weight: 800; text-transform: uppercase;">Alumno a vincular:</div>
<h3 id="linkPreviewName" style="font-size: 1.05rem; font-weight: 900; color: var(--text-main); margin: 2px 0; word-break: break-word; line-height: 1.2;">Nombre Alumno</h3>
<div id="linkPreviewGrade" style="font-size: 0.8rem; color: #0284c7; font-weight: 800; margin-top: 2px;">2° Grado - Sección 2-A</div>
<div id="linkPreviewCode" style="font-size: 0.72rem; color: var(--text-muted); font-weight: 700; margin-top: 2px;">Carné: EST-2026-001</div>
</div>
</div>
<p style="font-size: 0.78rem; color: var(--text-muted); margin: 0 0 14px 0; text-align: center;">
¿Confirmas que este es tu hijo/a para vincularlo a tu cuenta y gestionar sus fondos?
</p>
<!-- BOTONES DE ACCIÓN -->
<div style="display: flex; gap: 8px;">
<button type="button" onclick="resetLinkChildToTabs()" style="flex: 1; padding: 11px; background: #f1f5f9; color: #475569; border: 1px solid var(--border); border-radius: 10px; font-weight: 800; font-size: 0.82rem; cursor: pointer;">
← Cambiar
</button>
<button type="button" id="btnConfirmLinkChild" onclick="confirmLinkValidatedChild()" style="flex: 2; padding: 11px; background: linear-gradient(135deg, #10b981, #059669); color: white; border: none; border-radius: 10px; font-weight: 900; font-size: 0.88rem; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);">
<span>✅</span> Confirmar y Vincular
</button>
</div>
</div>
</div>
</div>
<!-- MODAL: ESCANEAR QR PARA RECARGA EN SODA (ADMIN) -->
<div class="modal-qr-backdrop" id="modalAdminScanQr" style="display: none;" onclick="closeAdminScanQrModal(event)">
<div class="modal-qr-card" onclick="event.stopPropagation()" style="max-width: 420px; text-align: center;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; border-bottom: 1px solid var(--border); padding-bottom: 8px;">
<strong style="font-size: 1rem; color: var(--text-main); display: flex; align-items: center; gap: 6px;">
<span>📷</span> Escanear Carné para Recarga
</strong>
<button type="button" onclick="closeAdminScanQrModal()" style="background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted);">✕</button>
</div>
<div style="position: relative; width: 100%; height: 230px; background: #000; border-radius: 14px; overflow: hidden; margin-bottom: 10px;">
<video id="videoAdminScan" playsinline webkit-playsinline autoplay muted style="width: 100%; height: 100%; object-fit: cover;"></video>
<canvas id="canvasAdminScan" style="display: none;"></canvas>
<div style="position: absolute; inset: 16px; border: 2px dashed #10b981; border-radius: 12px; pointer-events: none; overflow: hidden;">
<div style="position: absolute; left: 0; right: 0; height: 3px; background: #10b981; box-shadow: 0 0 10px #10b981, 0 0 20px #34d399; animation: adminScanLaser 2s ease-in-out infinite;"></div>
</div>
<button type="button" onclick="toggleAdminCameraFacing()" style="position: absolute; right: 10px; bottom: 10px; background: rgba(15, 23, 42, 0.75); color: white; border: 1px solid rgba(255,255,255,0.25); border-radius: 8px; padding: 5px 9px; font-size: 0.72rem; font-weight: 800; cursor: pointer; backdrop-filter: blur(4px); display: flex; align-items: center; gap: 4px;">
🔄 Voltear
</button>
</div>
<style>
@keyframes adminScanLaser {
0% { top: 4%; opacity: 0.6; }
50% { top: 92%; opacity: 1; }
100% { top: 4%; opacity: 0.6; }
}
</style>
<div id="adminScanModalStatus" style="font-size: 0.8rem; font-weight: 800; color: #0284c7; min-height: 22px; margin-bottom: 6px; padding: 6px 10px; border-radius: 8px; background: #e0f2fe; transition: all 0.2s ease;">
📷 Enfoca el código QR del carné
</div>
<!-- ALTERNATIVA: DIGITAR CÓDIGO O CARNÉ MANUALMENTE -->
<div style="margin: 8px 0 10px 0; display: flex; gap: 6px;">
<input type="text" id="inputAdminScanManualCode" placeholder="O digita carné (ej: EST-2026-001)" onkeydown="if(event.key==='Enter')submitAdminScanManualCode()" style="flex: 1; padding: 9px 12px; border-radius: 10px; border: 1.5px solid #cbd5e1; font-size: 0.85rem; font-weight: 700; outline: none; background: var(--card-bg, #ffffff); color: var(--text-main);">
<button type="button" onclick="submitAdminScanManualCode()" style="padding: 9px 14px; background: #0284c7; color: white; border: none; border-radius: 10px; font-weight: 800; font-size: 0.8rem; cursor: pointer; white-space: nowrap;">
🔍 Validar
</button>
</div>
<button type="button" onclick="closeAdminScanQrModal()" style="width: 100%; padding: 10px; background: #f1f5f9; color: #475569; border: 1px solid var(--border); border-radius: 10px; font-weight: 800; font-size: 0.82rem; cursor: pointer;">
Cerrar Cámara
</button>
</div>
</div>
<!-- MODAL: CARRUSEL DE PERSONALIZACIÓN DE TARJETA VIRTUAL -->
<div class="modal-qr-backdrop" id="modalCardDesigns" style="display: none;" onclick="closeCardDesignModal(event)">
<div class="modal-qr-card card-design-modal-card" onclick="event.stopPropagation()" style="max-width: 480px; text-align: left; padding: 18px 16px;">
<!-- CABECERA MODAL -->
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 10px; margin-bottom: 10px;">
<div style="display: flex; align-items: center; gap: 8px;">
<span style="font-size: 1.4rem;">🎨</span>
<div>
<h3 style="margin: 0; font-size: 1.15rem; font-weight: 900; color: var(--text-main);">Diseños de Tarjeta</h3>
<span style="font-size: 0.74rem; color: var(--text-muted); font-weight: 600;">Desliza y elige tu estilo favorito</span>
</div>
</div>
<button type="button" onclick="closeCardDesignModal()" style="background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--text-muted); padding: 4px;">✕</button>
</div>
<!-- CARRUSEL WRAPPER CON BOTONES PREV / NEXT -->
<div class="card-carousel-wrapper">
<button type="button" class="carousel-nav-btn prev" onclick="scrollCardCarousel(-1)" title="Diseño anterior">‹</button>
<button type="button" class="carousel-nav-btn next" onclick="scrollCardCarousel(1)" title="Siguiente diseño">›</button>
<div class="card-carousel-container" id="cardCarouselContainer">
<!-- Slides generados dinámicamente con JS -->
</div>
</div>
<!-- PUNTOS INDICADORES DE PAGINACIÓN -->
<div class="carousel-dots" id="carouselDots">
<!-- Generados dinámicamente -->
</div>
<!-- TIRA DE ACCESO RÁPIDO A TEMAS -->
<div style="margin-top: 8px;">
<div style="font-size: 0.72rem; font-weight: 800; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.5px;">
Colección de Estilos:
</div>
<div class="theme-quick-strip" id="themeQuickStrip">
<!-- Generado dinámicamente -->
</div>
</div>
<!-- BOTÓN CERRAR / LISTO -->
<div style="margin-top: 14px; display: flex; justify-content: flex-end;">
<button type="button" onclick="closeCardDesignModal()" style="padding: 9px 18px; background: var(--bg-main); border: 1.5px solid var(--border); border-radius: 10px; font-weight: 800; font-size: 0.85rem; color: var(--text-main); cursor: pointer;">
Listo
</button>
</div>
</div>
</div>
<!-- BARRA DE NAVEGACIÓN INFERIOR PWA (MÓVILES) -->
<nav class="pwa-bottom-nav" id="pwaBottomNav" style="display: none;">
<button class="pwa-nav-item active" id="pwaNavMenu" onclick="pwaNavigateTo('menu')">
<span class="pwa-nav-icon">🥪</span>
<span class="pwa-nav-label">Menú</span>
</button>
<button class="pwa-nav-item" id="pwaNavQr" onclick="pwaNavigateTo('qr')">
<span class="pwa-nav-icon">📱</span>
<span class="pwa-nav-label">Mi QR</span>
</button>
<button class="pwa-nav-item" id="pwaNavTransfer" onclick="pwaNavigateTo('transfer')">
<span class="pwa-nav-icon">⚡</span>
<span class="pwa-nav-label">Transferir</span>
</button>
<button class="pwa-nav-item" id="pwaNavPadres" onclick="pwaNavigateTo('padres')">
<span class="pwa-nav-icon">👨‍👩‍👦</span>
<span class="pwa-nav-label">Padres</span>
</button>
<button class="pwa-nav-item pwa-nav-logout" onclick="logout(true)" title="Cerrar sesión y cambiar de cuenta">
<span class="pwa-nav-icon">🚪</span>
<span class="pwa-nav-label">Salir</span>
</button>
</nav>
<script src="/js/sounds.js?v=9.6"></script>
<script src="/js/jsQR.js"></script>
<script src="/js/app.js?v=9.6"></script>
</body>
</html>