/* ============ Login — Rebranding Mapfre ============
 * Tipografía corporativa: Mapfre Display (títulos) y Mapfre Text (cuerpo).
 * Si se añaden los .woff2 en /fonts, descomenta los @font-face; mientras
 * tanto los stacks caen a fuentes del sistema de aspecto similar.
 */

/*
@font-face {
  font-family: "Mapfre Display";
  src: url("/fonts/MapfreDisplay-Bold.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Mapfre Text";
  src: url("/fonts/MapfreText-Regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
*/

/* Puntos de la contraseña: fuente con un único glifo (círculo grande) para los caracteres
   de enmascarado (U+2022 en Chrome/Android, U+25CF en iOS). Solo cubre esos códigos, así
   la letra que iOS muestra al escribir cae a la fuente de texto normal a 16px. */
@font-face {
  font-family: "Mapfre Dot";
  src: url("/fonts/mapfre-dot.ttf?v=1") format("truetype");
  font-weight: 400; font-style: normal; font-display: block;
  unicode-range: U+2022, U+25CF;
}

:root {
  /* --brand* las fija brand.js con el color del concesionario; sin él, rojo Mapfre. */
  --mapfre-red: var(--brand, #DF0027);
  --mapfre-red-dark: var(--brand-dark, #B80020);
  --mapfre-teal: #063F3F;
  --page-bg: #FFFFFF;
  --card-bg: #F8F8F8;
  --field-bg: #FFFFFF;
  --field-border: #C7C9CC;
  --text-dark: #1D1D1B;
  --text-neutral: #404040;
  --text-support: #666666;
  --text-mid: #55565A;
  --ok: #1E8E3E;
  --err: #DF0027;

  --font-display: "Mapfre Display", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
  --font-text: "Mapfre Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  min-height: 100vh;
}

.login-body {
  background: #E5E9EE;
  color: var(--text-dark);
  font-family: var(--font-text);
  font-size: 15px;
  line-height: 1.5;
}

/* Columna con ancho de móvil, centrada también en escritorio */
.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: var(--page-bg);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 521px) {
  .login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
  }
  .login-page {
    /* Altura según contenido: sin hueco entre la tarjeta y el footer */
    min-height: 0;
    border-radius: 22px;
    box-shadow: 0 20px 50px rgba(29, 29, 27, 0.18);
    overflow: hidden;
  }
  .login-main { padding-bottom: 28px; }
}

/* ============ Cabecera con logo ============ */
.brand-bar {
  /* Mismo padding horizontal que .login-main para alinear el logo con las tarjetas */
  padding: 22px clamp(20px, 6vw, 32px) 10px;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  /* Grup Oliva a la izquierda, Mapfre a la derecha */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand-logo {
  display: inline-flex; align-items: center;
  text-decoration: none;
  min-width: 0;
}
.brand-img {
  width: auto;
  height: auto;
  max-width: 100%;
  object-fit: contain;
  display: block;
}
.brand-logo--brand .brand-img {
  max-height: 30px;
  max-width: 170px;
}
.brand-logo--mapfre {
  display: none !important;
}
@media (max-width: 360px) {
  .brand-logo--brand .brand-img { max-height: 24px; }
}

/* ============ Contenido ============ */
.login-main {
  flex: 1;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: 12px clamp(20px, 6vw, 32px) 40px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.hero-card {
  background: var(--mapfre-teal);
  color: #fff;
  border-radius: 14px;
  padding: 20px 22px;
}
.hero-card h1 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.hero-card p {
  margin: 0;
  font-size: 0.92rem;
  color: rgba(255, 255, 255, 0.9);
}

.login-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 26px 22px 24px;
}
.login-card h2 {
  margin: 0 0 20px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
  line-height: 32px;
  letter-spacing: 0;
  color: var(--text-neutral);
}

/* ============ Formulario ============ */
.auth-form { display: flex; flex-direction: column; gap: 16px; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > label {
  font-family: var(--font-text);
  font-size: 16px;
  font-weight: 400;
  line-height: 24px;
  letter-spacing: 0;
  color: var(--text-support);
  margin: 0;
}

.input-wrap {
  position: relative;
  display: flex; align-items: center;
}
.input-wrap input[type=email],
.input-wrap input[type=password],
.input-wrap input[type=text] {
  width: 100%;
  background: var(--field-bg);
  border: 1px solid var(--field-border);
  color: var(--text-dark);
  font-family: var(--font-text);
  font-size: 1rem;
  padding: 14px 48px 14px 20px;
  border-radius: 999px;
  margin: 0;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input-wrap input::placeholder { color: #9A9CA0; }
.input-wrap input[type=password] {
  font-size: 16px;
  letter-spacing: 0.12em;
  font-family: "Mapfre Dot", var(--font-text);
}
.input-wrap input:focus {
  outline: none;
  border-color: var(--mapfre-red);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb, 223, 0, 39), 0.12);
}
.input-wrap input:autofill,
.input-wrap input:-webkit-autofill {
  -webkit-text-fill-color: var(--text-dark);
  -webkit-box-shadow: 0 0 0 1000px var(--field-bg) inset;
  caret-color: var(--text-dark);
}

.reveal-btn {
  position: absolute;
  right: 10px;
  background: transparent;
  border: none;
  color: var(--text-mid);
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.reveal-btn:hover { color: var(--text-dark); background: rgba(0, 0, 0, 0.05); }
.reveal-btn svg { width: 20px; height: 20px; }

.forgot-link {
  align-self: center;
  background: none;
  border: none;
  padding: 2px;
  margin-top: 2px;
  font-family: var(--font-text);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-dark);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.forgot-link:hover { color: var(--mapfre-red); }

/* ============ CTA ============ */
.cta {
  margin-top: 6px;
  width: 100%;
  min-height: 52px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--mapfre-red);
  color: #fff;
  border: none;
  border-radius: 999px;
  font-family: var(--font-text);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}
.cta:hover:not(:disabled) { background: var(--mapfre-red-dark); }
.cta:disabled { opacity: 0.65; cursor: default; }

.btn-spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: login-spin 0.7s linear infinite;
}
@keyframes login-spin { to { transform: rotate(360deg); } }

/* ============ Mensajes ============ */
.auth-message {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 0.9rem;
  border: 1px solid var(--field-border);
  background: var(--field-bg);
  line-height: 1.5;
}
.auth-message.error { border-color: var(--err); color: var(--err); background: rgba(223, 0, 39, 0.06); }
.auth-message.ok    { border-color: var(--ok);  color: var(--ok);  background: rgba(30, 142, 62, 0.06); }
.auth-message.info  { border-color: var(--text-mid); color: var(--text-dark); background: rgba(0, 0, 0, 0.03); }

/* ============ Footer corporativo ============ */
.login-footer {
  background: var(--mapfre-red);
  color: #fff;
  padding: 20px 12px calc(20px + env(safe-area-inset-bottom));
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 14px;
}
.login-footer-logo {
  display: block;
  height: 32px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  padding: 5px 7px;
  background: #fff;
  border-radius: 8px;
  flex-shrink: 0;
}
.footer-links {
  display: contents;
}
.footer-links a {
  font-family: var(--font-display);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  font-synthesis: none;
  letter-spacing: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
  white-space: nowrap;
}
.footer-copy {
  margin: 0;
  font-family: var(--font-text);
  font-size: 14px;
  font-weight: 400;
  color: #fff;
}

/* ============ Flujo móvil (/movil → sesión caducada) ============ */
html.route-movil,
html.route-movil body {
  touch-action: pan-x pan-y;
}
html.route-movil *:not(input[type="range"]) {
  touch-action: pan-x pan-y;
}
html.route-movil .login-main {
  padding-top: max(8px, env(safe-area-inset-top));
}
html.route-movil .input-wrap input[type=email],
html.route-movil .input-wrap input[type=password],
html.route-movil .input-wrap input[type=text] {
  min-height: 50px;
  touch-action: pan-x pan-y;
}
html.route-movil .input-wrap input[type=email],
html.route-movil .input-wrap input[type=text] {
  font-size: 16px !important;
}
html.route-movil .cta { min-height: 54px; font-size: 1.08rem; }

/* Login de Grup Oliva: azul corporativo de grupolivamotor.com solo en #movil-login.
   El color_primario de superadmin (rojo por defecto) sigue aplicándose al resto de la app. */
html[data-concesionario-slug="grupoliva"] #movil-login,
html[data-concesionario-slug="grupooliva"] #movil-login {
  --brand: #050B20;
  --brand-dark: #132558;
  --brand-rgb: 5, 11, 32;
  --mapfre-red: #050B20;
  --mapfre-red-dark: #132558;
}
html[data-concesionario-slug="grupoliva"] #movil-login .hero-card,
html[data-concesionario-slug="grupooliva"] #movil-login .hero-card {
  background: #050B20;
}
