<?php
header('Content-Type: application/json; charset=utf-8');
mb_internal_encoding('UTF-8');

session_start();

$input = json_decode(file_get_contents('php://input'), true);
$user = trim($input['user'] ?? '');
$pass = trim($input['pass'] ?? '');

if ($user === 'Demo' && $pass === '1234') {
    // Establecer sesión demo
    $_SESSION['demo_user'] = true;
    $_SESSION['demo_username'] = 'Demo';
    $_SESSION['demo_role'] = 'user';
    $_SESSION['demo_ship_id'] = 'DEMO-01';
    
    echo json_encode(['success' => true, 'message' => 'Sesión demo iniciada']);
} else {
    echo json_encode(['success' => false, 'message' => 'Credenciales inválidas']);
}
exit;

