feat: interfaz unificada estilo Teens con modo claro por defecto y boton de luna

This commit is contained in:
unknown
2026-10-04 19:22:11 -06:00
parent 0236411549
commit e48d5f2e56
3 changed files with 124 additions and 143 deletions
+61 -89
View File
@@ -1,5 +1,5 @@
/* ==========================================================================
RECREOPAY - SISTEMA DE DISEÑO ADAPTATIVO (KIDS 7-10 & TEENS 11-15 & SODA POS)
RECREOPAY - SISTEMA DE DISEÑO UNIFICADO (MODO CLARO + MODO OSCURO)
========================================================================== */
:root {
@@ -13,37 +13,24 @@
--text-main: #0f172a;
--text-muted: #64748b;
--border: #e2e8f0;
--radius: 16px;
--shadow: 0 4px 6px -1px rgb(0 0 0 / 0.08), 0 2px 4px -2px rgb(0 0 0 / 0.06);
--radius: 14px;
--shadow: 0 4px 12px -2px rgba(15, 23, 42, 0.08);
}
/* Modo Teens (Estilo Fintech / Dark Mode) */
body.mode-teens {
/* Modo Oscuro (activable con el botón de luna 🌙) */
body.dark-mode {
--primary: #38bdf8;
--primary-hover: #0284c7;
--secondary: #34d399;
--accent: #fbbf24;
--danger: #f87171;
--bg-main: #0b1120;
--card-bg: #1e293b;
--text-main: #f1f5f9;
--text-muted: #94a3b8;
--border: #334155;
--radius: 12px;
--shadow: 0 10px 15px -3px rgb(0 0 0 / 0.4);
}
/* Modo Kids (Primaria: Lúdico, Grande, Amigable) */
body.mode-kids {
--primary: #0284c7;
--secondary: #10b981;
--accent: #f59e0b;
--bg-main: #eff6ff;
--card-bg: #ffffff;
--text-main: #1e293b;
--border: #bfdbfe;
--radius: 22px;
--shadow: 0 8px 20px -4px rgb(2 132 199 / 0.15);
font-size: 16px;
--radius: 14px;
--shadow: 0 10px 20px -3px rgba(0, 0, 0, 0.5);
}
* {
@@ -107,60 +94,79 @@ body {
font-size: 1.2rem;
}
/* Selector de Perfil y Modo */
.mode-toggle {
display: flex;
background: var(--bg-main);
border: 1px solid var(--border);
padding: 3px;
border-radius: 30px;
gap: 2px;
}
.mode-btn {
border: none;
background: transparent;
padding: 5px 12px;
border-radius: 20px;
font-size: 0.78rem;
font-weight: 700;
color: var(--text-muted);
cursor: pointer;
/* Botones de acción en la cabecera */
.top-actions {
display: flex;
align-items: center;
gap: 4px;
gap: 8px;
}
.theme-toggle-btn {
background: var(--bg-main);
border: 1.5px solid var(--border);
color: var(--text-main);
width: 38px;
height: 38px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.2rem;
cursor: pointer;
transition: all 0.2s ease;
box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.theme-toggle-btn:hover {
transform: scale(1.08);
border-color: var(--primary);
}
.logout-btn {
background: #fee2e2;
color: #dc2626;
border: 1px solid #fecaca;
padding: 7px 12px;
border-radius: 10px;
font-size: 0.8rem;
font-weight: 800;
display: flex;
align-items: center;
gap: 5px;
cursor: pointer;
transition: all 0.2s ease;
}
.mode-btn.active {
background: var(--primary);
color: #ffffff;
box-shadow: 0 2px 6px rgba(0,0,0,0.15);
body.dark-mode .logout-btn {
background: rgba(239, 68, 68, 0.15);
color: #f87171;
border-color: rgba(239, 68, 68, 0.3);
}
.logout-btn:hover {
background: #fecaca;
transform: scale(1.02);
}
/* Tarjeta de Saldo y Carné Digital */
.wallet-card {
margin: 16px;
background: linear-gradient(135deg, #0369a1, #0284c7);
background: linear-gradient(135deg, #0284c7, #0369a1);
color: white;
border-radius: var(--radius);
padding: 20px;
box-shadow: 0 12px 25px -4px rgba(2, 132, 199, 0.4);
box-shadow: 0 12px 25px -4px rgba(2, 132, 199, 0.35);
position: relative;
overflow: hidden;
border: 1px solid rgba(255, 255, 255, 0.2);
}
body.mode-teens .wallet-card {
body.dark-mode .wallet-card {
background: linear-gradient(135deg, #1e293b, #0f172a);
border: 1px solid #334155;
box-shadow: 0 10px 25px -4px rgba(0, 0, 0, 0.5);
}
body.mode-kids .wallet-card {
background: linear-gradient(135deg, #0284c7, #38bdf8);
border: 3px solid #7dd3fc;
}
.wallet-card::after {
content: "";
position: absolute;
@@ -368,10 +374,6 @@ body.mode-kids .wallet-card {
padding: 0 16px;
}
body.mode-kids .products-grid {
grid-template-columns: 1fr;
}
.product-card {
background: var(--card-bg);
border: 1px solid var(--border);
@@ -389,25 +391,12 @@ body.mode-kids .products-grid {
transform: scale(0.98);
}
body.mode-kids .product-card {
flex-direction: row;
align-items: center;
gap: 16px;
padding: 16px;
}
.product-icon-wrap {
font-size: 2.8rem;
text-align: center;
margin-bottom: 8px;
}
body.mode-kids .product-icon-wrap {
font-size: 3.4rem;
margin-bottom: 0;
flex-shrink: 0;
}
.product-name {
font-size: 0.95rem;
font-weight: 800;
@@ -415,10 +404,6 @@ body.mode-kids .product-icon-wrap {
margin-bottom: 4px;
}
body.mode-kids .product-name {
font-size: 1.15rem;
}
.product-desc {
font-size: 0.76rem;
color: var(--text-muted);
@@ -448,12 +433,6 @@ body.mode-kids .product-name {
margin-top: 6px;
}
body.mode-kids .product-footer {
flex-direction: column;
align-items: flex-end;
gap: 8px;
}
.product-price {
font-size: 1.1rem;
font-weight: 900;
@@ -477,13 +456,6 @@ body.mode-kids .product-footer {
transition: transform 0.15s;
}
body.mode-kids .add-btn {
width: 48px;
height: 48px;
font-size: 1.5rem;
border-radius: 14px;
}
.add-btn:active {
transform: scale(0.9);
}
@@ -508,9 +480,9 @@ body.mode-kids .add-btn {
cursor: pointer;
}
body.mode-kids .floating-cart-bar {
body.dark-mode .floating-cart-bar {
background: #0284c7;
border: 2px solid white;
border: 1px solid rgba(255, 255, 255, 0.2);
}
.cart-summary {
+24 -22
View File
@@ -6,7 +6,7 @@
<title>RecreoPay - Tu Soda Escolar Digital</title>
<link rel="manifest" href="/manifest.json">
<meta name="theme-color" content="#0284c7">
<link rel="stylesheet" href="/css/styles.css?v=5.0">
<link rel="stylesheet" href="/css/styles.css?v=6.0">
<script>
// Purgar y desactivar service workers y cachés obsoletas en móviles
if ('serviceWorker' in navigator) {
@@ -26,7 +26,7 @@
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
</style>
</head>
<body class="mode-kids">
<body class="">
<div class="app-container">
<!-- BANNER DE ADVERTENCIA HTTPS PARA TELÉFONOS MÓVILES -->
@@ -39,7 +39,7 @@
</div>
</div>
<!-- BARRA SUPERIOR -->
<!-- BARRA SUPERIOR UNIFICADA -->
<header class="top-bar">
<a href="#" class="brand-badge">
<div class="logo-icon">🥪</div>
@@ -49,23 +49,25 @@
</div>
</a>
<!-- SWITCHER DE MODO (KIDS / TEENS / PADRES) -->
<div class="mode-toggle">
<button class="mode-btn active" id="btnModeKids" onclick="setAppMode('kids')">🧒 Kids</button>
<button class="mode-btn" id="btnModeTeens" onclick="setAppMode('teens')">⚡ Teens</button>
<button class="mode-btn" id="btnModePadres" onclick="toggleParentPanel(true)">👨‍👩‍👦 Padres</button>
<!-- 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()" class="logout-btn" title="Cerrar sesión">
<span>🚪</span>
<span class="logout-text">Salir</span>
</button>
</div>
</header>
<!-- SELECTOR RÁPIDO DE ALUMNO DE PRUEBA -->
<div style="padding: 10px 16px 0 16px; display: flex; align-items: center; justify-content: space-between; font-size: 0.8rem;">
<span style="color: var(--text-muted); font-weight: 700;">Estudiante Activo:</span>
<select id="studentSelector" onchange="onStudentChange(this.value)" style="padding: 4px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--card-bg); color: var(--text-main); font-weight: 700;">
<!-- Se llena dinámicamente -->
</select>
</div>
<!-- SELECTOR OCULTO PARA COMPATIBILIDAD JS -->
<select id="studentSelector" onchange="onStudentChange(this.value)" style="display: none;"></select>
<!-- TARJETA DIGITAL DE MONEDERO Y SALDO -->
<!-- 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">
@@ -77,10 +79,10 @@
<div class="balance-row">
<div class="balance-col">
<div class="label" id="balanceLabel">💰 Mis Colones Disponibles</div>
<div class="label" id="balanceLabel">SALDO DISPONIBLE</div>
<div class="amount">
<span id="walletBalance">₡0</span>
<span class="kids-coin-icon" id="kidsCoinIcon">🪙</span>
<span class="kids-coin-icon" id="kidsCoinIcon" style="display: none;">🪙</span>
</div>
</div>
@@ -90,8 +92,8 @@
<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">Pasar Plata</span>
<span>⚡</span>
<span id="transferBtnText">Transferir ⚡</span>
</button>
</div>
</div>
@@ -432,8 +434,8 @@
</div>
</div>
<script src="/js/sounds.js?v=5.0"></script>
<script src="/js/sounds.js?v=6.0"></script>
<script src="/js/jsQR.js"></script>
<script src="/js/app.js?v=5.0"></script>
<script src="/js/app.js?v=6.0"></script>
</body>
</html>
+39 -32
View File
@@ -42,6 +42,7 @@ function checkHttpsEnvironment() {
// Inicialización al cargar la página
document.addEventListener('DOMContentLoaded', async () => {
initTheme();
checkHttpsEnvironment();
// Registrar Service Worker para PWA con forzado de actualizacion
@@ -98,14 +99,7 @@ async function selectStudent(studentId) {
try {
const res = await fetch(`/api/estudiantes/${studentId}`);
currentStudent = await res.json();
// Adaptar modo automáticamente por edad (7-10 Kids, 11-15 Teens)
if (currentStudent.edad <= 10) {
setAppMode('kids', false);
} else {
setAppMode('teens', false);
}
currentAppMode = 'teens';
updateStudentUI();
} catch (e) {
console.error('Error seleccionando estudiante:', e);
@@ -120,8 +114,15 @@ function updateStudentUI() {
document.getElementById('walletName').textContent = currentStudent.nombre_completo;
document.getElementById('walletGrade').textContent = `${currentStudent.grado} • Sección ${currentStudent.seccion} • Cód: ${currentStudent.codigo_estudiante}`;
// Saldo en colones
// Saldo en colones (Interfaz unificada estilo Teens)
document.getElementById('walletBalance').textContent = `₡${currentStudent.saldo_colones.toLocaleString('es-CR')}`;
document.getElementById('balanceLabel').textContent = 'SALDO DISPONIBLE';
const coin = document.getElementById('kidsCoinIcon');
if (coin) coin.style.display = 'none';
const qrBtn = document.getElementById('qrBtnText');
if (qrBtn) qrBtn.textContent = 'Mi QR';
const transferBtn = document.getElementById('transferBtnText');
if (transferBtn) transferBtn.textContent = 'Transferir ⚡';
// Límite diario
document.getElementById('dailyLimitText').textContent = `₡${currentStudent.limite_diario_colones.toLocaleString('es-CR')}`;
@@ -156,33 +157,39 @@ function updateStudentUI() {
renderParentHistory();
}
function setAppMode(mode, playSound = true) {
currentAppMode = mode;
document.body.classList.remove('mode-kids', 'mode-teens');
function setAppMode(mode, playSound = false) {
currentAppMode = 'teens';
}
document.getElementById('btnModeKids').classList.remove('active');
document.getElementById('btnModeTeens').classList.remove('active');
const transferBtnText = document.getElementById('transferBtnText');
if (mode === 'kids') {
document.body.classList.add('mode-kids');
document.getElementById('btnModeKids').classList.add('active');
document.getElementById('balanceLabel').textContent = '💰 Mis Colones para el Recreo';
document.getElementById('kidsCoinIcon').style.display = 'inline-block';
document.getElementById('qrBtnText').textContent = 'Mi QR 📱';
if (transferBtnText) transferBtnText.textContent = 'Pasar Plata 🤝';
function initTheme() {
const saved = localStorage.getItem('recreopay_theme') || 'light';
const btn = document.getElementById('btnThemeToggle');
if (saved === 'dark') {
document.body.classList.add('dark-mode');
if (btn) btn.textContent = '☀️';
} else {
document.body.classList.add('mode-teens');
document.getElementById('btnModeTeens').classList.add('active');
document.getElementById('balanceLabel').textContent = 'SALDO DISPONIBLE';
document.getElementById('kidsCoinIcon').style.display = 'none';
document.getElementById('qrBtnText').textContent = 'Mi QR';
if (transferBtnText) transferBtnText.textContent = 'Transferir ⚡';
document.body.classList.remove('dark-mode');
if (btn) btn.textContent = '🌙';
}
}
if (playSound && window.sounds) {
window.sounds.playCoin();
function toggleTheme() {
const isDark = document.body.classList.toggle('dark-mode');
const btn = document.getElementById('btnThemeToggle');
if (isDark) {
if (btn) btn.textContent = '☀️';
localStorage.setItem('recreopay_theme', 'dark');
} else {
if (btn) btn.textContent = '🌙';
localStorage.setItem('recreopay_theme', 'light');
}
if (window.sounds) window.sounds.playTap();
}
function logout() {
if (confirm('¿Deseas cerrar la sesión actual?')) {
localStorage.removeItem('recreopay_session');
window.location.reload();
}
}