199 lines
6.3 KiB
HTML
199 lines
6.3 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="es">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Collina Forms — Acceso</title>
|
|
<style>
|
|
:root {
|
|
--bg-gradient: linear-gradient(135deg, #1C1C1E 0%, #2C2C2E 50%, #1C1C1E 100%);
|
|
--glass-bg: rgba(255, 255, 255, 0.08);
|
|
--glass-bg-hover: rgba(255, 255, 255, 0.12);
|
|
--glass-border: rgba(255, 255, 255, 0.15);
|
|
--glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
|
--accent: #0A84FF;
|
|
--accent-hover: #409CFF;
|
|
--accent-glow: rgba(10, 132, 255, 0.3);
|
|
--danger: #FF453A;
|
|
--text-primary: rgba(255, 255, 255, 0.95);
|
|
--text-secondary: rgba(255, 255, 255, 0.55);
|
|
--text-tertiary: rgba(255, 255, 255, 0.30);
|
|
}
|
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
|
|
background: var(--bg-gradient);
|
|
background-attachment: fixed;
|
|
min-height: 100vh;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
color: var(--text-primary);
|
|
padding: 24px;
|
|
}
|
|
.login-card {
|
|
width: 100%;
|
|
max-width: 400px;
|
|
background: var(--glass-bg);
|
|
backdrop-filter: blur(20px) saturate(180%);
|
|
-webkit-backdrop-filter: blur(20px) saturate(180%);
|
|
border: 1px solid var(--glass-border);
|
|
border-radius: 20px;
|
|
box-shadow: var(--glass-shadow);
|
|
padding: 40px 36px;
|
|
}
|
|
.wordmark {
|
|
text-align: center;
|
|
font-size: 13px;
|
|
font-weight: 700;
|
|
letter-spacing: 5px;
|
|
color: var(--text-secondary);
|
|
margin-bottom: 8px;
|
|
}
|
|
.subtitle {
|
|
text-align: center;
|
|
font-size: 22px;
|
|
font-weight: 600;
|
|
margin-bottom: 32px;
|
|
color: var(--text-primary);
|
|
}
|
|
.field { margin-bottom: 18px; }
|
|
.field label {
|
|
display: block;
|
|
font-size: 13px;
|
|
color: var(--text-secondary);
|
|
margin-bottom: 8px;
|
|
}
|
|
.input-wrap { position: relative; }
|
|
.input-wrap svg {
|
|
position: absolute;
|
|
left: 14px;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
width: 18px;
|
|
height: 18px;
|
|
stroke: var(--text-tertiary);
|
|
pointer-events: none;
|
|
}
|
|
input {
|
|
width: 100%;
|
|
padding: 13px 14px 13px 44px;
|
|
background: rgba(255, 255, 255, 0.07);
|
|
border: 1px solid rgba(255, 255, 255, 0.12);
|
|
border-radius: 12px;
|
|
color: var(--text-primary);
|
|
font-size: 15px;
|
|
transition: all 0.2s ease;
|
|
outline: none;
|
|
}
|
|
input::placeholder { color: var(--text-tertiary); }
|
|
input:focus {
|
|
border-color: var(--accent);
|
|
box-shadow: 0 0 0 3px var(--accent-glow);
|
|
}
|
|
.btn-primary {
|
|
width: 100%;
|
|
padding: 14px;
|
|
margin-top: 8px;
|
|
background: var(--accent);
|
|
border: none;
|
|
border-radius: 12px;
|
|
color: #fff;
|
|
font-size: 15px;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
transition: all 0.2s ease;
|
|
}
|
|
.btn-primary:hover {
|
|
background: var(--accent-hover);
|
|
box-shadow: 0 0 20px var(--accent-glow);
|
|
}
|
|
.btn-primary:disabled { opacity: 0.6; cursor: default; }
|
|
.error {
|
|
display: none;
|
|
margin-top: 16px;
|
|
padding: 12px 14px;
|
|
background: rgba(255, 69, 58, 0.12);
|
|
border: 1px solid rgba(255, 69, 58, 0.3);
|
|
border-radius: 10px;
|
|
color: var(--danger);
|
|
font-size: 13px;
|
|
text-align: center;
|
|
}
|
|
.error.visible { display: block; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="login-card">
|
|
<div class="wordmark">COLLINA SYSTEMS</div>
|
|
<div class="subtitle">Collina Forms</div>
|
|
<form id="login-form">
|
|
<div class="field">
|
|
<label for="username">Usuario</label>
|
|
<div class="input-wrap">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>
|
|
<input id="username" name="username" type="text" placeholder="admin" autocomplete="username" required>
|
|
</div>
|
|
</div>
|
|
<div class="field">
|
|
<label for="password">Contraseña</label>
|
|
<div class="input-wrap">
|
|
<svg viewBox="0 0 24 24" fill="none" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="11" width="18" height="11" rx="2" ry="2"/><path d="M7 11V7a5 5 0 0 1 10 0v4"/></svg>
|
|
<input id="password" name="password" type="password" placeholder="••••••••" autocomplete="current-password" required>
|
|
</div>
|
|
</div>
|
|
<button class="btn-primary" type="submit" id="submit-btn">Entrar</button>
|
|
<div class="error" id="error"></div>
|
|
</form>
|
|
</div>
|
|
|
|
<script>
|
|
// Si ya hay token válido, ir al dashboard
|
|
if (localStorage.getItem('collina_token')) {
|
|
window.location.href = '/dashboard';
|
|
}
|
|
|
|
const form = document.getElementById('login-form');
|
|
const errorBox = document.getElementById('error');
|
|
const btn = document.getElementById('submit-btn');
|
|
|
|
function showError(msg) {
|
|
errorBox.textContent = msg;
|
|
errorBox.classList.add('visible');
|
|
}
|
|
|
|
form.addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
errorBox.classList.remove('visible');
|
|
btn.disabled = true;
|
|
btn.textContent = 'Entrando…';
|
|
|
|
const username = document.getElementById('username').value.trim();
|
|
const password = document.getElementById('password').value;
|
|
|
|
try {
|
|
const res = await fetch('/api/auth/login', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ username, password })
|
|
});
|
|
if (!res.ok) {
|
|
showError('Usuario o contraseña incorrectos');
|
|
return;
|
|
}
|
|
const data = await res.json();
|
|
localStorage.setItem('collina_token', data.access_token);
|
|
localStorage.setItem('collina_username', data.username);
|
|
localStorage.setItem('collina_is_admin', data.is_admin ? '1' : '0');
|
|
window.location.href = '/dashboard';
|
|
} catch (err) {
|
|
showError('No se pudo conectar con el servidor');
|
|
} finally {
|
|
btn.disabled = false;
|
|
btn.textContent = 'Entrar';
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|