feat: carrusel interactivo de disenos de tarjeta virtual sin asteriscos y selector junto a modo oscuro

This commit is contained in:
unknown
2026-10-05 01:12:49 -06:00
parent f2ebfaa407
commit 0840bf0217
3 changed files with 884 additions and 5 deletions
+477 -1
View File
@@ -215,7 +215,7 @@ body.dark-mode .logout-btn {
}
}
body.dark-mode .wallet-card {
body.dark-mode .wallet-card:not([class*="theme-"]) {
background: linear-gradient(135deg, #1e293b, #0f172a);
border: 1px solid #334155;
box-shadow: 0 10px 25px -4px rgba(0, 0, 0, 0.5);
@@ -2078,3 +2078,479 @@ body.dark-mode .admin-staff-card.blocked {
background: #fee2e2;
}
/* ==========================================================================
CHIP Y ELEMENTOS INTELIGENTES DE LA TARJETA VIRTUAL
========================================================================== */
.card-chip-container {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 12px;
position: relative;
z-index: 2;
}
.card-emv-chip {
width: 38px;
height: 28px;
background: linear-gradient(135deg, #fef08a 0%, #eab308 50%, #ca8a04 100%);
border: 1px solid rgba(161, 98, 7, 0.4);
border-radius: 6px;
position: relative;
overflow: hidden;
box-shadow: inset 0 1px 2px rgba(255,255,255,0.7), 0 2px 5px rgba(0,0,0,0.15);
}
.chip-inner-circuit {
width: 100%;
height: 100%;
position: relative;
}
.chip-inner-circuit::before {
content: "";
position: absolute;
top: 50%;
left: 0;
right: 0;
height: 1px;
background: rgba(161, 98, 7, 0.45);
}
.chip-inner-circuit::after {
content: "";
position: absolute;
left: 45%;
top: 0;
bottom: 0;
width: 1px;
background: rgba(161, 98, 7, 0.45);
}
.card-contactless-wave {
font-size: 1rem;
font-weight: 900;
letter-spacing: -2px;
opacity: 0.8;
transform: rotate(90deg);
display: flex;
user-select: none;
}
/* ==========================================================================
TEMAS PERSONALIZADOS PARA LA TARJETA VIRTUAL (15 DISEÑOS)
========================================================================== */
/* 1. Azul RecreoPay Clásico */
.wallet-card.theme-classic-blue {
background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%) !important;
color: #ffffff !important;
border: 1px solid rgba(255, 255, 255, 0.25) !important;
box-shadow: 0 12px 25px -4px rgba(2, 132, 199, 0.35) !important;
}
/* 2. Classic Premium (Navy & Oro) */
.wallet-card.theme-classic-premium {
background: linear-gradient(135deg, #090e1a 0%, #151e33 60%, #060913 100%) !important;
color: #ffffff !important;
border: 1.5px solid #f59e0b !important;
box-shadow: 0 12px 30px -4px rgba(245, 158, 11, 0.25), 0 0 15px rgba(245, 158, 11, 0.1) !important;
}
.wallet-card.theme-classic-premium .amount span,
.wallet-card.theme-classic-premium #walletBalance {
color: #fbbf24 !important;
text-shadow: 0 2px 8px rgba(245, 158, 11, 0.4);
}
.wallet-card.theme-classic-premium .student-avatar {
border-color: #f59e0b !important;
box-shadow: 0 0 10px rgba(245, 158, 11, 0.3) !important;
}
.wallet-card.theme-classic-premium .student-grade,
.wallet-card.theme-classic-premium .label {
color: #fef3c7 !important;
opacity: 0.9;
}
/* 3. Technological Metal (Titanio Negro Cepillado) */
.wallet-card.theme-tech-metal {
background: linear-gradient(135deg, #18181b 0%, #27272a 50%, #09090b 100%) !important;
color: #f4f4f5 !important;
border: 1.5px solid #71717a !important;
box-shadow: 0 12px 25px -4px rgba(0, 0, 0, 0.6) !important;
}
.wallet-card.theme-tech-metal .card-emv-chip {
background: linear-gradient(135deg, #f4f4f5 0%, #d4d4d8 50%, #a1a1aa 100%) !important;
border-color: #71717a !important;
}
.wallet-card.theme-tech-metal .amount span,
.wallet-card.theme-tech-metal #walletBalance {
color: #ffffff !important;
text-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
}
/* 4. Eco-Aventura (Bosques y Montañas) */
.wallet-card.theme-eco-aventura {
background: linear-gradient(180deg, #064e3b 0%, #065f46 45%, #047857 75%, #022c22 100%) !important;
color: #ecfdf5 !important;
border: 1.5px solid #10b981 !important;
box-shadow: 0 12px 25px -4px rgba(5, 150, 105, 0.35) !important;
}
.wallet-card.theme-eco-aventura .amount span,
.wallet-card.theme-eco-aventura #walletBalance {
color: #a7f3d0 !important;
text-shadow: 0 2px 6px rgba(16, 185, 129, 0.3);
}
/* 5. Robo-Lab Cyber (Circuitos y Neón Cian) */
.wallet-card.theme-robo-lab {
background: linear-gradient(135deg, #030712 0%, #082f49 50%, #0c4a6e 100%) !important;
color: #e0f2fe !important;
border: 1.5px solid #06b6d4 !important;
box-shadow: 0 12px 25px -4px rgba(6, 182, 212, 0.4) !important;
}
.wallet-card.theme-robo-lab .amount span,
.wallet-card.theme-robo-lab #walletBalance {
color: #22d3ee !important;
text-shadow: 0 0 12px rgba(34, 211, 238, 0.6);
}
.wallet-card.theme-robo-lab .student-avatar {
border-color: #06b6d4 !important;
box-shadow: 0 0 10px rgba(6, 182, 212, 0.4) !important;
}
/* 6. Mundo de Arte (Acuarela Multicolor) */
.wallet-card.theme-mundo-arte {
background: linear-gradient(135deg, #ffffff 0%, #fdf4ff 40%, #f0fdf4 70%, #eff6ff 100%) !important;
color: #0f172a !important;
border: 2px solid transparent !important;
border-image: linear-gradient(135deg, #ec4899, #8b5cf6, #06b6d4, #10b981, #f59e0b) 1 !important;
box-shadow: 0 12px 25px -4px rgba(236, 72, 153, 0.25) !important;
}
.wallet-card.theme-mundo-arte h2,
.wallet-card.theme-mundo-arte #walletName {
color: #0f172a !important;
}
.wallet-card.theme-mundo-arte .student-grade,
.wallet-card.theme-mundo-arte .label {
color: #475569 !important;
}
.wallet-card.theme-mundo-arte .amount span,
.wallet-card.theme-mundo-arte #walletBalance {
color: #9333ea !important;
font-weight: 900 !important;
}
.wallet-card.theme-mundo-arte .student-avatar {
border-color: #ec4899 !important;
}
.wallet-card.theme-mundo-arte .qr-toggle-btn {
background: #f1f5f9 !important;
color: #1e293b !important;
border: 1px solid #cbd5e1 !important;
}
/* 7. Estrellas del Campo (Fútbol Verde) */
.wallet-card.theme-futbol {
background: repeating-linear-gradient(90deg, #15803d, #15803d 45px, #166534 45px, #166534 90px) !important;
color: #ffffff !important;
border: 1.5px solid #86efac !important;
box-shadow: 0 12px 25px -4px rgba(22, 101, 52, 0.4) !important;
}
.wallet-card.theme-futbol .amount span,
.wallet-card.theme-futbol #walletBalance {
color: #fef08a !important;
text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
/* 8. Club de Mascotas (Golden Retriever y Ámbar Suave) */
.wallet-card.theme-mascotas {
background: linear-gradient(135deg, #fef3c7 0%, #fde68a 60%, #f59e0b 100%) !important;
color: #78350f !important;
border: 1.5px solid #d97706 !important;
box-shadow: 0 12px 25px -4px rgba(217, 119, 6, 0.3) !important;
}
.wallet-card.theme-mascotas h2,
.wallet-card.theme-mascotas #walletName {
color: #78350f !important;
}
.wallet-card.theme-mascotas .student-grade,
.wallet-card.theme-mascotas .label {
color: #92400e !important;
}
.wallet-card.theme-mascotas .amount span,
.wallet-card.theme-mascotas #walletBalance {
color: #b45309 !important;
font-weight: 900 !important;
}
.wallet-card.theme-mascotas .student-avatar {
border-color: #d97706 !important;
}
.wallet-card.theme-mascotas .qr-toggle-btn {
background: rgba(255, 255, 255, 0.7) !important;
color: #78350f !important;
border: 1px solid #fcd34d !important;
}
/* 9. Exploración Galáctica (Cosmos y Nebulosa) */
.wallet-card.theme-galactica {
background: linear-gradient(135deg, #09090b 0%, #311042 45%, #1e1b4b 100%) !important;
color: #f5d0fe !important;
border: 1.5px solid #a855f7 !important;
box-shadow: 0 12px 25px -4px rgba(168, 85, 247, 0.4) !important;
}
.wallet-card.theme-galactica .amount span,
.wallet-card.theme-galactica #walletBalance {
color: #f0abfc !important;
text-shadow: 0 0 12px rgba(240, 171, 252, 0.6);
}
.wallet-card.theme-galactica .student-avatar {
border-color: #c084fc !important;
box-shadow: 0 0 10px rgba(192, 132, 252, 0.4) !important;
}
/* 10. Pixel Quest (Videojuegos Retro 8-Bit) */
.wallet-card.theme-pixel-quest {
background: linear-gradient(180deg, #38bdf8 0%, #60a5fa 62%, #15803d 62%, #166534 100%) !important;
color: #ffffff !important;
border: 2px solid #fbbf24 !important;
box-shadow: 0 12px 25px -4px rgba(56, 189, 248, 0.4) !important;
}
.wallet-card.theme-pixel-quest .amount span,
.wallet-card.theme-pixel-quest #walletBalance {
color: #fef08a !important;
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
font-family: monospace, sans-serif !important;
letter-spacing: 1px;
}
/* 11. Ritmo y DJ Neón (Synthwave) */
.wallet-card.theme-ritmo-dj {
background: linear-gradient(135deg, #09090b 0%, #1a0826 50%, #030712 100%) !important;
color: #fdf2f8 !important;
border: 1.5px solid #ec4899 !important;
box-shadow: 0 12px 25px -4px rgba(236, 72, 153, 0.4), 0 0 15px rgba(6, 182, 212, 0.2) !important;
}
.wallet-card.theme-ritmo-dj .amount span,
.wallet-card.theme-ritmo-dj #walletBalance {
color: #06b6d4 !important;
text-shadow: 0 0 10px rgba(6, 182, 212, 0.7);
}
.wallet-card.theme-ritmo-dj .student-avatar {
border-color: #ec4899 !important;
box-shadow: 0 0 10px rgba(236, 72, 153, 0.5) !important;
}
/* 12. Skate Park (Street Art Graffiti) */
.wallet-card.theme-skate-park {
background: linear-gradient(135deg, #78350f 0%, #c2410c 50%, #18181b 100%) !important;
color: #fff7ed !important;
border: 1.5px solid #ea580c !important;
box-shadow: 0 12px 25px -4px rgba(234, 88, 12, 0.35) !important;
}
.wallet-card.theme-skate-park .amount span,
.wallet-card.theme-skate-park #walletBalance {
color: #fed7aa !important;
text-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}
/* 13. Tecno Cómic (Superhéroe Pop-Art) */
.wallet-card.theme-tecno-comic {
background: linear-gradient(125deg, #0284c7 0%, #0284c7 48%, #ea580c 52%, #ea580c 100%) !important;
color: #ffffff !important;
border: 2px solid #fde047 !important;
box-shadow: 0 12px 25px -4px rgba(2, 132, 199, 0.4) !important;
}
.wallet-card.theme-tecno-comic .amount span,
.wallet-card.theme-tecno-comic #walletBalance {
color: #fef08a !important;
text-shadow: 2px 2px 0 #000000;
}
/* 14. Ecológica Kraft (Texturizada Sostenible) */
.wallet-card.theme-ecologica {
background: linear-gradient(135deg, #b08968 0%, #7f5539 100%) !important;
color: #ffffff !important;
border: 1.5px solid #a3b18a !important;
box-shadow: 0 12px 25px -4px rgba(127, 85, 57, 0.35) !important;
}
.wallet-card.theme-ecologica .amount span,
.wallet-card.theme-ecologica #walletBalance {
color: #fefae0 !important;
text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
/* 15. Lúdica Ilustrada (Fantasía Infantil) */
.wallet-card.theme-ludica {
background: linear-gradient(180deg, #38bdf8 0%, #bae6fd 60%, #fed7aa 100%) !important;
color: #0369a1 !important;
border: 1.5px solid #38bdf8 !important;
box-shadow: 0 12px 25px -4px rgba(56, 189, 248, 0.35) !important;
}
.wallet-card.theme-ludica h2,
.wallet-card.theme-ludica #walletName {
color: #0c4a6e !important;
}
.wallet-card.theme-ludica .student-grade,
.wallet-card.theme-ludica .label {
color: #0369a1 !important;
}
.wallet-card.theme-ludica .amount span,
.wallet-card.theme-ludica #walletBalance {
color: #0284c7 !important;
font-weight: 900 !important;
}
.wallet-card.theme-ludica .qr-toggle-btn {
background: rgba(255, 255, 255, 0.8) !important;
color: #0369a1 !important;
border: 1px solid #7dd3fc !important;
}
/* ==========================================================================
MODAL DE CARRUSEL DE DISEÑOS DE TARJETA
========================================================================== */
.card-carousel-wrapper {
position: relative;
width: 100%;
margin: 10px 0;
}
.card-carousel-container {
display: flex;
overflow-x: auto;
scroll-snap-type: x mandatory;
scroll-behavior: smooth;
gap: 14px;
padding: 8px 4px;
scrollbar-width: none;
-ms-overflow-style: none;
-webkit-overflow-scrolling: touch;
}
.card-carousel-container::-webkit-scrollbar {
display: none;
}
.card-carousel-slide {
flex: 0 0 100%;
max-width: 100%;
scroll-snap-align: center;
box-sizing: border-box;
}
.carousel-nav-btn {
position: absolute;
top: 40%;
transform: translateY(-50%);
width: 38px;
height: 38px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.9);
backdrop-filter: blur(8px);
border: 1.5px solid var(--border);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
color: var(--text-main);
font-size: 1.4rem;
font-weight: 900;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
z-index: 10;
transition: all 0.2s ease;
}
body.dark-mode .carousel-nav-btn {
background: rgba(30, 41, 59, 0.9);
border-color: #334155;
color: #ffffff;
}
.carousel-nav-btn:hover {
background: var(--card-bg);
transform: translateY(-50%) scale(1.1);
}
.carousel-nav-btn.prev {
left: -10px;
}
.carousel-nav-btn.next {
right: -10px;
}
.carousel-dots {
display: flex;
justify-content: center;
gap: 5px;
margin: 10px 0 6px 0;
flex-wrap: wrap;
}
.carousel-dot {
width: 7px;
height: 7px;
border-radius: 50%;
background: var(--border);
cursor: pointer;
transition: all 0.2s ease;
}
.carousel-dot.active {
width: 20px;
border-radius: 10px;
background: #0284c7;
}
.theme-quick-strip {
display: flex;
overflow-x: auto;
gap: 6px;
padding: 8px 2px;
margin-top: 6px;
border-top: 1px solid var(--border);
scrollbar-width: none;
}
.theme-quick-strip::-webkit-scrollbar {
display: none;
}
.theme-pill-btn {
padding: 5px 11px;
border-radius: 20px;
border: 1.5px solid var(--border);
background: var(--card-bg);
color: var(--text-main);
font-size: 0.74rem;
font-weight: 800;
white-space: nowrap;
cursor: pointer;
display: flex;
align-items: center;
gap: 4px;
transition: all 0.15s ease;
flex-shrink: 0;
}
.theme-pill-btn:hover {
border-color: #0284c7;
}
.theme-pill-btn.active {
background: #0284c7;
color: white;
border-color: #0284c7;
}
.preview-card-badge {
font-size: 0.68rem;
font-weight: 800;
padding: 3px 8px;
border-radius: 6px;
background: rgba(255, 255, 255, 0.25);
border: 1px solid rgba(255, 255, 255, 0.35);
display: inline-flex;
align-items: center;
gap: 4px;
}
+68 -4
View File
@@ -10,7 +10,7 @@
<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.5">
<link rel="stylesheet" href="/css/styles.css?v=9.6">
<style>
/* Transiciones suaves */
.fade-enter { animation: fadeIn 0.2s ease-in-out; }
@@ -625,6 +625,9 @@
<!-- 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>
@@ -642,7 +645,17 @@
<select id="studentSelector" onchange="onStudentChange(this.value)" style="display: none;"></select>
<!-- TARJETA DIGITAL DE MONEDERO Y SALDO (ESTILO UNIFICADO TEENS) -->
<section class="wallet-card">
<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;">
@@ -1392,6 +1405,57 @@
</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')">
@@ -1416,8 +1480,8 @@
</button>
</nav>
<script src="/js/sounds.js?v=9.5"></script>
<script src="/js/sounds.js?v=9.6"></script>
<script src="/js/jsQR.js"></script>
<script src="/js/app.js?v=9.5"></script>
<script src="/js/app.js?v=9.6"></script>
</body>
</html>
+339
View File
@@ -48,6 +48,9 @@ function checkHttpsEnvironment() {
// Inicialización al cargar la página
document.addEventListener('DOMContentLoaded', async () => {
initTheme();
if (typeof applyCardTheme === 'function' && typeof getSavedCardTheme === 'function') {
applyCardTheme(getSavedCardTheme());
}
checkHttpsEnvironment();
// Registrar Service Worker para PWA
@@ -422,6 +425,11 @@ function updateStudentUI() {
document.getElementById('walletName').textContent = currentStudent.nombre_completo;
document.getElementById('walletGrade').textContent = `${currentStudent.grado} • Sección ${currentStudent.seccion} • Cód: ${currentStudent.codigo_estudiante}`;
// Aplicar tema personalizado de tarjeta
if (typeof applyCardTheme === 'function' && typeof getSavedCardTheme === 'function') {
applyCardTheme(getSavedCardTheme());
}
// Saldo en colones
document.getElementById('walletBalance').textContent = `₡${currentStudent.saldo_colones.toLocaleString('es-CR')}`;
document.getElementById('balanceLabel').textContent = 'SALDO DISPONIBLE';
@@ -4121,3 +4129,334 @@ async function deleteStaff(staffId, nombre) {
}
}
// ==========================================
// COLECCIÓN Y PERSONALIZACIÓN DE DISEÑOS DE TARJETA VIRTUAL
// ==========================================
const CARD_THEMES = [
{
id: 'classic-blue',
name: 'Azul RecreoPay',
category: 'Oficial',
icon: '🥪',
desc: 'El diseño clásico oficial de RecreoPay con tonos azul celeste y acabado cristalino.'
},
{
id: 'classic-premium',
name: 'Classic Premium',
category: 'Elegante',
icon: '👑',
desc: 'Azul medianoche profundo con tipografía dorada metálica, acentos de lujo y chip dorado.'
},
{
id: 'tech-metal',
name: 'Technological Metal',
category: 'Titanio',
icon: '⚡',
desc: 'Titanio oscuro cepillado con líneas láser plateadas y chip de alta tecnología.'
},
{
id: 'eco-aventura',
name: 'Eco-Aventura',
category: 'Exploración',
icon: '🌲',
desc: 'Bosques de pino, cumbres montañosas y espíritu de explorador en la naturaleza.'
},
{
id: 'robo-lab',
name: 'Robo-Lab Cyber',
category: 'Robótica',
icon: '🤖',
desc: 'Circuitos cibernéticos de neón cian y el amigable robot del laboratorio del futuro.'
},
{
id: 'mundo-arte',
name: 'Mundo de Arte',
category: 'Creativo',
icon: '🎨',
desc: 'Lienzo blanco con salpicaduras vibrantes de acuarela multicolor y paleta de pintura.'
},
{
id: 'futbol',
name: 'Estrellas del Campo',
category: 'Deportes',
icon: '⚽',
desc: 'Cancha de césped de estadio con líneas reglamentarias y balón a máxima velocidad.'
},
{
id: 'mascotas',
name: 'Club de Mascotas',
category: 'Tierno',
icon: '🐶',
desc: 'Tonos cálidos miel y un adorable cachorrito golden retriever con tiernas huellas.'
},
{
id: 'galactica',
name: 'Exploración Galáctica',
category: 'Espacio',
icon: '🚀',
desc: 'Nebulosa cósmica en violeta y polvo estelar con luna y astronauta explorador.'
},
{
id: 'pixel-quest',
name: 'Pixel Quest',
category: 'Videojuegos',
icon: '👾',
desc: 'Aventura arcade de plataformas de 8 bits con bloques retro, nubes y caballero pixel.'
},
{
id: 'ritmo-dj',
name: 'Ritmo y DJ Neón',
category: 'Música',
icon: '🎧',
desc: 'Barras de espectro ecualizador en neón brillante, audífonos DJ y sintetizadores.'
},
{
id: 'skate-park',
name: 'Skate Park',
category: 'Urbano',
icon: '🛹',
desc: 'Estilo street art urbano con textura de tabla de skate y graffitis llenos de energía.'
},
{
id: 'tecno-comic',
name: 'Tecno Cómic',
category: 'Superhéroe',
icon: '🦸',
desc: 'Estilo cómic pop-art con rayos de acción, textura halftone y superhéroe escolar.'
},
{
id: 'ecologica',
name: 'Ecológica Texturizada',
category: 'Sostenible',
icon: '🌿',
desc: 'Textura natural tipo corcho y papel kraft reciclado con sello ambiental.'
},
{
id: 'ludica',
name: 'Lúdica Ilustrada',
category: 'Fantasía',
icon: '🏰',
desc: 'Horizonte ilustrado de fantasía infantil con cielo despejado y robot volador.'
}
];
function getSavedCardTheme() {
if (currentStudent && currentStudent.id) {
const studentTheme = localStorage.getItem(`recreopay_card_theme_${currentStudent.id}`);
if (studentTheme && CARD_THEMES.some(t => t.id === studentTheme)) {
return studentTheme;
}
}
const globalTheme = localStorage.getItem('recreopay_card_theme');
if (globalTheme && CARD_THEMES.some(t => t.id === globalTheme)) {
return globalTheme;
}
return 'classic-blue';
}
function applyCardTheme(themeId) {
const card = document.getElementById('mainWalletCard');
if (!card) return;
const validTheme = CARD_THEMES.some(t => t.id === themeId) ? themeId : 'classic-blue';
CARD_THEMES.forEach(t => {
card.classList.remove(`theme-${t.id}`);
});
card.classList.add(`theme-${validTheme}`);
}
function openCardDesignModal() {
const modal = document.getElementById('modalCardDesigns');
if (!modal) return;
renderCardDesignsCarousel();
setupCarouselScrollListener();
modal.style.display = 'flex';
const currentTheme = getSavedCardTheme();
const currentIdx = CARD_THEMES.findIndex(t => t.id === currentTheme);
if (currentIdx >= 0) {
setTimeout(() => {
jumpToCardSlide(currentIdx);
}, 60);
}
if (window.sounds) window.sounds.playTap();
}
function closeCardDesignModal(event) {
if (event && event.target !== event.currentTarget) return;
const modal = document.getElementById('modalCardDesigns');
if (modal) modal.style.display = 'none';
}
function renderCardDesignsCarousel() {
const container = document.getElementById('cardCarouselContainer');
const dotsContainer = document.getElementById('carouselDots');
const strip = document.getElementById('themeQuickStrip');
if (!container) return;
const currentTheme = getSavedCardTheme();
const avatarUrl = (currentStudent && currentStudent.foto_url) ? currentStudent.foto_url : 'https://api.dicebear.com/7.x/bottts/svg?seed=est';
const studentName = (currentStudent && currentStudent.nombre_completo) ? currentStudent.nombre_completo : 'Mateo Alvarado Castro';
const studentGrade = (currentStudent && currentStudent.grado) ? `${currentStudent.grado} • Sección ${currentStudent.seccion || 'A'} • Cód: ${currentStudent.codigo_estudiante || 'EST-001'}` : '2° Grado • Sección 2-A • Cód: EST-2026-001';
const studentBalance = (currentStudent && currentStudent.saldo_colones !== undefined) ? currentStudent.saldo_colones.toLocaleString('es-CR') : '5.300';
container.innerHTML = CARD_THEMES.map((t, idx) => {
const isSelected = (t.id === currentTheme);
return `
<div class="card-carousel-slide" data-index="${idx}" data-theme="${t.id}">
<!-- Vista previa de la tarjeta real (SIN ASTERISCOS) -->
<div class="wallet-card theme-${t.id}" style="margin: 0; cursor: pointer; transition: transform 0.2s;" onclick="selectCardTheme('${t.id}')">
<div class="card-chip-container">
<div class="card-emv-chip">
<div class="chip-inner-circuit"></div>
</div>
<div class="card-contactless-wave"><span>)</span><span>)</span><span>)</span></div>
</div>
<div class="student-info">
<img class="student-avatar" src="${avatarUrl}" alt="Avatar">
<div class="student-meta" style="flex: 1; min-width: 0;">
<h2 style="margin: 0; font-size: 1.05rem; font-weight: 800; word-break: break-word;">${studentName}</h2>
<span class="student-grade" style="font-size: 0.72rem;">${studentGrade}</span>
</div>
</div>
<div class="balance-row">
<div class="balance-col">
<div class="label" style="font-size: 0.68rem; font-weight: 800;">SALDO DISPONIBLE</div>
<div class="amount">
<span style="font-size: 1.35rem; font-weight: 900;">₡${studentBalance}</span>
</div>
</div>
<div style="display: flex; gap: 4px; align-items: center;">
<span class="preview-card-badge">📱 QR</span>
<span class="preview-card-badge">⚡ Pasar</span>
</div>
</div>
</div>
<!-- Info del tema y botón de selección -->
<div style="margin-top: 10px; display: flex; justify-content: space-between; align-items: center; gap: 8px;">
<div style="min-width: 0; flex: 1;">
<div style="display: flex; align-items: center; gap: 6px; flex-wrap: wrap;">
<strong style="font-size: 0.95rem; color: var(--text-main);">${t.icon} ${t.name}</strong>
<span style="font-size: 0.68rem; font-weight: 800; padding: 2px 7px; border-radius: 6px; background: rgba(2, 132, 199, 0.1); color: #0284c7;">${t.category}</span>
</div>
<p style="margin: 2px 0 0 0; font-size: 0.72rem; color: var(--text-muted); line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">${t.desc}</p>
</div>
<div style="flex-shrink: 0;">
<button type="button" id="btnSelectTheme_${t.id}" onclick="selectCardTheme('${t.id}')" style="padding: 7px 15px; border-radius: 10px; font-weight: 900; font-size: 0.8rem; cursor: pointer; white-space: nowrap; border: none; ${isSelected ? 'background: #10b981; color: white;' : 'background: #0284c7; color: white;'}">
${isSelected ? '✓ Activo' : 'Elegir'}
</button>
</div>
</div>
</div>
`;
}).join('');
if (dotsContainer) {
dotsContainer.innerHTML = CARD_THEMES.map((t, idx) => `
<div class="carousel-dot ${t.id === currentTheme ? 'active' : ''}" id="dotSlide_${idx}" onclick="jumpToCardSlide(${idx})" title="${t.name}"></div>
`).join('');
}
if (strip) {
strip.innerHTML = CARD_THEMES.map((t, idx) => `
<button type="button" class="theme-pill-btn ${t.id === currentTheme ? 'active' : ''}" id="pillTheme_${t.id}" onclick="jumpToCardSlide(${idx})">
<span>${t.icon}</span> <span>${t.name}</span>
</button>
`).join('');
}
}
function scrollCardCarousel(direction) {
const container = document.getElementById('cardCarouselContainer');
if (!container) return;
const slideWidth = container.clientWidth;
container.scrollBy({ left: direction * slideWidth, behavior: 'smooth' });
}
function jumpToCardSlide(index) {
const container = document.getElementById('cardCarouselContainer');
if (!container) return;
const slide = container.querySelector(`[data-index="${index}"]`);
if (slide) {
slide.scrollIntoView({ behavior: 'smooth', block: 'nearest', inline: 'center' });
}
// Actualizar dots y pills
document.querySelectorAll('.carousel-dot').forEach((d, idx) => {
d.classList.toggle('active', idx === index);
});
if (CARD_THEMES[index]) {
const themeId = CARD_THEMES[index].id;
document.querySelectorAll('.theme-pill-btn').forEach(p => {
p.classList.toggle('active', p.id === `pillTheme_${themeId}`);
});
}
}
function setupCarouselScrollListener() {
const container = document.getElementById('cardCarouselContainer');
if (!container || container.dataset.hasListener) return;
container.dataset.hasListener = 'true';
let scrollTimeout = null;
container.addEventListener('scroll', () => {
clearTimeout(scrollTimeout);
scrollTimeout = setTimeout(() => {
const scrollLeft = container.scrollLeft;
const slideWidth = container.clientWidth;
if (slideWidth > 0) {
const activeIdx = Math.max(0, Math.min(CARD_THEMES.length - 1, Math.round(scrollLeft / slideWidth)));
document.querySelectorAll('.carousel-dot').forEach((d, idx) => {
d.classList.toggle('active', idx === activeIdx);
});
if (CARD_THEMES[activeIdx]) {
const themeId = CARD_THEMES[activeIdx].id;
document.querySelectorAll('.theme-pill-btn').forEach(p => {
p.classList.toggle('active', p.id === `pillTheme_${themeId}`);
});
}
}
}, 40);
}, { passive: true });
}
function selectCardTheme(themeId) {
if (!themeId) return;
localStorage.setItem('recreopay_card_theme', themeId);
if (currentStudent && currentStudent.id) {
localStorage.setItem(`recreopay_card_theme_${currentStudent.id}`, themeId);
}
applyCardTheme(themeId);
// Actualizar botones de selección
CARD_THEMES.forEach(t => {
const btn = document.getElementById(`btnSelectTheme_${t.id}`);
if (btn) {
if (t.id === themeId) {
btn.textContent = '✓ Activo';
btn.style.background = '#10b981';
} else {
btn.textContent = 'Elegir';
btn.style.background = '#0284c7';
}
}
const pill = document.getElementById(`pillTheme_${t.id}`);
if (pill) {
pill.classList.toggle('active', t.id === themeId);
}
});
if (window.sounds) window.sounds.playCoin();
}