<!DOCTYPE html>
<html lang="es">
<head>
  <meta charset="UTF-8">
  <title>Ingreso Epicrisis IA</title>
  <link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@700&family=Open+Sans:wght@400;600&display=swap" rel="stylesheet">
  <style>
    * {
      box-sizing: border-box;
    }

    :root {
      --azul-turqui: #003865;
      --azul-claro: #005BAC;
      --blanco: #ffffff;
      --gris-claro: #f0f4f8;
      --peligro: #dc3545;
      --radio: 6px;
      --sombra: 0 8px 20px rgba(0, 0, 0, 0.1);
    }

    body {
      margin: 0;
      padding: 0;
      font-family: 'Open Sans', sans-serif;
      background-color: var(--gris-claro);
      display: flex;
      align-items: center;
      justify-content: center;
      height: 100vh;
    }

    .login-box {
      background-color: var(--blanco);
      padding: 40px 30px;
      border-radius: var(--radio);
      box-shadow: var(--sombra);
      width: 100%;
      max-width: 550px;
      text-align: center;
    }

    .login-box img.logo {
      max-width: 300px;
      margin-bottom: 20px;
    }

    .login-box h1 {
      font-family: 'Montserrat', sans-serif;
      font-weight: 700;
      font-size: 1.6rem;
      color: var(--azul-turqui);
      margin-bottom: 25px;
    }

    .login-box form {
      display: flex;
      flex-direction: column;
      gap: 15px;
    }

    .login-box input[type="text"],
    .login-box input[type="password"] {
      padding: 12px;
      border: 1px solid #ccc;
      border-radius: var(--radio);
      font-size: 1rem;
    }

    .login-box input:focus {
      border-color: var(--azul-claro);
      outline: none;
      box-shadow: 0 0 0 3px rgba(0, 91, 172, 0.12);
    }

    .login-box button {
      padding: 12px;
      background-color: var(--azul-turqui);
      color: var(--blanco);
      font-family: 'Montserrat', sans-serif;
      font-size: 1rem;
      font-weight: 600;
      border: none;
      border-radius: var(--radio);
      cursor: pointer;
      transition: background-color 0.3s ease;
    }

    .login-box button:hover {
      background-color: var(--azul-claro);
    }

    .error {
      margin-top: 10px;
      color: var(--peligro);
      font-weight: 600;
    }

    @media (max-width: 480px) {
      .login-box {
        margin: 0 20px;
        padding: 30px 20px;
      }
    }
  </style>
</head>
<body>
  <div class="login-box">
    <img src="/static/logo_normal.png" alt="Logo de CIDTI" class="logo">
    <h1>Ingreso Epicrisis</h1>
    <form method="post" action="/login">
      <input type="hidden" name="next" value="{{ next_path or '/dashboard' }}">
      <input type="text" name="username" placeholder="Usuario" required aria-label="Usuario" autofocus>
      <input type="password" name="password" placeholder="Contraseña" required aria-label="Contraseña">
      <button type="submit">Iniciar sesión</button>
    </form>
    {% if error %}
    <div class="error">{{ error }}</div>
    {% endif %}
  </div>
</body>
</html>
