Files
recreopay/public/index.html
T

1106 lines
76 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=8.5">
<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('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')" style="padding: 8px 14px; background: linear-gradient(135deg, #10b981, #059669); 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(16, 185, 129, 0.3);" title="Cargar dinero a un estudiante">
<span>💵</span> Cargar Dinero
</button>
<a href="/pos.html" target="_blank" class="admin-action-btn-caja" title="Abrir Caja / Terminal POS">
📟 Ir a Caja
</a>
<button 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>
<!-- 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="btnTabAdminRecarga" onclick="switchAdminTab('recarga')">
💵 Cargar Dinero Manual (Buscador y QR)
</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);">
Cuando el stock llega a 0, el producto se marca automáticamente como <strong>AGOTADO (greyed out)</strong>.
</p>
</div>
<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: 220px;">
</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>
<!-- FICHA DEL ESTUDIANTE SELECCIONADO -->
<div style="margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center;">
<span style="font-size: 0.75rem; font-weight: 800; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;">
Estudiante seleccionado:
</span>
<button type="button" onclick="focusAdminSearch()" style="background: none; border: none; color: #0284c7; font-size: 0.74rem; font-weight: 800; cursor: pointer; text-decoration: underline;">
🔍 Cambiar / Buscar otro
</button>
</div>
<div id="adminSelectedStudentBanner" class="selected-student-banner" style="display: none;">
<div style="display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1;">
<img id="adminSelectedAvatar" src="" style="width: 46px; height: 46px; 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: 0.98rem; 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.2rem; font-weight: 900; color: #10b981;">₡0</div>
</div>
</div>
<!-- SELECT OCULTO PARA COMPATIBILIDAD CON FUNCIONES JS -->
<select id="adminRecargaStudentSelect" style="display: none;" onchange="onAdminSelectChange(this.value)"></select>
<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>
<!-- ========================================== -->
<!-- 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="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">
<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: 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: 6px; margin-bottom: 10px;">
<button type="button" class="mode-btn active" id="btnTransfer500" onclick="setTransferAmount(500, this)" style="padding: 8px; text-align: center; justify-content: center; font-size: 0.85rem;">₡500</button>
<button type="button" class="mode-btn" id="btnTransfer1000" onclick="setTransferAmount(1000, this)" style="padding: 8px; text-align: center; justify-content: center; font-size: 0.85rem;">₡1.000</button>
<button type="button" class="mode-btn" id="btnTransfer1500" onclick="setTransferAmount(1500, this)" style="padding: 8px; text-align: center; justify-content: center; font-size: 0.85rem;">₡1.500</button>
</div>
<div style="margin-bottom: 12px;">
<input type="tel" inputmode="numeric" pattern="[0-9]*" id="inputTransferCustomAmount" placeholder="Otro monto (ej. 750)" style="width: 100%; padding: 10px; border-radius: 10px; border: 1px solid #cbd5e1; font-size: 1rem; font-weight: 800; color: #0284c7;">
</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;">
</div>
<!-- PIN DE SEGURIDAD (CON PANEL EXCLUSIVO DE NÚMEROS Y BOTONES TÁCTILES) -->
<div style="background: #f8fafc; border: 1.5px dashed #cbd5e1; border-radius: 12px; padding: 12px; margin-bottom: 14px;">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px;">
<label style="font-size: 0.78rem; font-weight: 800; color: #0f172a;">🔐 Digita tu PIN de 4 dígitos:</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; margin-bottom: 8px;">
<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.5rem; letter-spacing: 8px; padding: 10px 40px 10px 10px; border-radius: 10px; border: 2px solid #cbd5e1; font-weight: 900; background: white; color: #0f172a;">
<button type="button" id="btnTogglePin" onclick="togglePinVisibility()" style="position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: none; border: none; font-size: 1.15rem; cursor: pointer; color: #64748b; padding: 4px;" title="Ver/Ocultar PIN">👁️</button>
</div>
<!-- TECLADO NUMÉRICO TÁCTIL EN PANTALLA (FACILITA A LOS NIÑOS Y USUARIOS MÓVILES) -->
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;">
<button type="button" onclick="appendPinDigit('1')" style="padding: 10px; background: white; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 1.15rem; font-weight: 800; color: #1e293b; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.05);">1</button>
<button type="button" onclick="appendPinDigit('2')" style="padding: 10px; background: white; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 1.15rem; font-weight: 800; color: #1e293b; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.05);">2</button>
<button type="button" onclick="appendPinDigit('3')" style="padding: 10px; background: white; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 1.15rem; font-weight: 800; color: #1e293b; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.05);">3</button>
<button type="button" onclick="appendPinDigit('4')" style="padding: 10px; background: white; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 1.15rem; font-weight: 800; color: #1e293b; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.05);">4</button>
<button type="button" onclick="appendPinDigit('5')" style="padding: 10px; background: white; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 1.15rem; font-weight: 800; color: #1e293b; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.05);">5</button>
<button type="button" onclick="appendPinDigit('6')" style="padding: 10px; background: white; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 1.15rem; font-weight: 800; color: #1e293b; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.05);">6</button>
<button type="button" onclick="appendPinDigit('7')" style="padding: 10px; background: white; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 1.15rem; font-weight: 800; color: #1e293b; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.05);">7</button>
<button type="button" onclick="appendPinDigit('8')" style="padding: 10px; background: white; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 1.15rem; font-weight: 800; color: #1e293b; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.05);">8</button>
<button type="button" onclick="appendPinDigit('9')" style="padding: 10px; background: white; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 1.15rem; font-weight: 800; color: #1e293b; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.05);">9</button>
<button type="button" onclick="fillQuickPin('1234')" style="padding: 10px; background: #e0f2fe; color: #0284c7; border: 1px solid #bae6fd; border-radius: 8px; font-size: 0.74rem; font-weight: 900; cursor: pointer;">⚡ 1234</button>
<button type="button" onclick="appendPinDigit('0')" style="padding: 10px; background: white; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 1.15rem; font-weight: 800; color: #1e293b; cursor: pointer; box-shadow: 0 1px 2px rgba(0,0,0,0.05);">0</button>
<button type="button" onclick="backspacePinDigit()" style="padding: 10px; background: #fee2e2; color: #dc2626; border: 1px solid #fecaca; border-radius: 8px; font-size: 1.15rem; font-weight: 800; cursor: pointer;">⌫</button>
</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> Enviar Dinero al Instante
</button>
</div>
<!-- MODAL: ESCANEAR QR PARA VINCULAR HIJO (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: 400px; 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);">📷 Vincular Estudiante con QR</strong>
<button type="button" onclick="closeScanChildQrModal()" style="background: none; border: none; font-size: 1.2rem; cursor: pointer; color: var(--text-muted);">✕</button>
</div>
<div style="position: relative; width: 100%; height: 220px; background: #000; border-radius: 14px; overflow: hidden; margin-bottom: 10px;">
<video id="videoScanChild" playsinline autoplay muted style="width: 100%; height: 100%; object-fit: cover;"></video>
<canvas id="canvasScanChild" style="display: none;"></canvas>
<div style="position: absolute; inset: 16px; border: 2px dashed #38bdf8; border-radius: 12px; pointer-events: none;"></div>
</div>
<p style="font-size: 0.78rem; color: var(--text-muted); margin-bottom: 10px;">
Apunta la cámara al carné escolar del estudiante.
</p>
<div style="border-top: 1px dashed var(--border); padding-top: 10px; margin-top: 10px; text-align: left;">
<label for="inputManualStudentCode" style="display: block; font-size: 0.76rem; font-weight: 800; color: var(--text-main); margin-bottom: 4px;">
O escribe el código de carné manualmente:
</label>
<div style="display: flex; gap: 6px;">
<input type="text" id="inputManualStudentCode" placeholder="Ej: EST-2026-001 o QR Token" style="flex: 1; padding: 8px 10px; border-radius: 8px; border: 1.5px solid var(--border); font-size: 0.85rem; font-weight: 800; background: var(--card-bg); color: var(--text-main); box-sizing: border-box;">
<button type="button" onclick="submitManualStudentLink()" style="padding: 8px 14px; background: #0284c7; color: white; border: none; border-radius: 8px; font-weight: 800; font-size: 0.8rem; cursor: pointer; white-space: nowrap;">
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: 400px; 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);">📷 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: 220px; background: #000; border-radius: 14px; overflow: hidden; margin-bottom: 10px;">
<video id="videoAdminScan" 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;"></div>
</div>
<p style="font-size: 0.78rem; color: var(--text-muted); margin-bottom: 6px;">
Escanea el QR del carné del alumno para seleccionarlo al instante.
</p>
</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=8.5"></script>
<script src="/js/jsQR.js"></script>
<script src="/js/app.js?v=8.5"></script>
</body>
</html>