/* ============================================================
   Artmedica — Sistema de Agentes Clínicos
   Estilos de la pantalla de ingreso

   Tokens extraídos de la identidad corporativa vigente
   en https://artmedica.com.co (logo SVG + estilos computados).
   ============================================================ */

/* Los tokens de marca viven en tokens.css, compartidos con el resto
   del sistema. Este archivo asume que ya fue cargado. */

/* ---------- 2. Reset acotado ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--surface);
  color: var(--ink-600);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img, svg { display: block; max-width: 100%; }

button, input { font: inherit; color: inherit; }

a { color: var(--brand-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Foco visible y consistente en toda la pantalla */
:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- 3. Estructura general ---------- */
.auth {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  min-height: 100dvh;
}

/* ---------- 4. Panel de marca (izquierda) ---------- */
.brand {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 48px;
  padding: 44px 56px 40px;
  background: var(--grad-panel);
  color: #fff;
  overflow: hidden;
  isolation: isolate;
}

/* Anillos concéntricos — eco del recurso gráfico del sitio corporativo */
.brand__rings {
  position: absolute;
  right: -160px;
  bottom: -180px;
  width: 620px;
  height: 620px;
  z-index: -1;
  opacity: 0.5;
  pointer-events: none;
}
.brand__rings circle {
  fill: none;
  stroke: rgba(255, 255, 255, 0.16);
  stroke-width: 1;
}
.brand__glow {
  position: absolute;
  top: -140px; left: -120px;
  width: 460px; height: 460px;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(77, 97, 230, 0.42) 0%, rgba(77, 97, 230, 0) 68%);
  pointer-events: none;
}

.brand__logo { width: 208px; height: auto; }

.brand__headline {
  margin: 0 0 20px;
  max-width: 15ch;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(2rem, 3.1vw, 2.9rem);
  line-height: 1.08;
  letter-spacing: -0.022em;
  color: #fff;
}
.brand__headline em {
  font-style: normal;
  color: #a9b6ff;
}

.brand__lede {
  margin: 0;
  max-width: 44ch;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: rgba(255, 255, 255, 0.76);
}

/* Indicadores de respaldo institucional */
.brand__stats {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 44px;
  margin: 40px 0 0;
  padding: 0;
  list-style: none;
}
.brand__stats dt {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.6rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: #fff;
}
.brand__stats dd {
  margin: 4px 0 0;
  font-size: 0.8125rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  /* 0.80 de opacidad: mantiene la jerarquía visual y alcanza 5.3:1
     contra el extremo más claro del degradado del panel (#454f96). */
  color: rgba(255, 255, 255, 0.8);
}

.brand__foot {
  margin: 0;
  font-size: 0.8125rem;
  color: rgba(255, 255, 255, 0.75);
}

/* ---------- 5. Panel del formulario (derecha) ---------- */
.panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  background:
    linear-gradient(180deg, var(--surface) 0%, var(--surface-tint) 100%);
}

.panel__inner {
  width: 100%;
  max-width: 408px;
}

/* Logo a color: solo visible cuando el panel de marca se oculta */
.panel__logo {
  display: none;
  width: 186px;
  margin: 0 0 36px;
}

.panel__title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.75rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  color: var(--brand-navy);
}
.panel__subtitle {
  margin: 0 0 30px;
  font-size: 0.9375rem;
  color: var(--ink-450);
}

/* ---------- 6. Alerta de error ---------- */
.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-bottom: 22px;
  padding: 13px 15px;
  border: 1px solid rgba(229, 66, 66, 0.28);
  border-radius: var(--radius-field);
  background: rgba(229, 66, 66, 0.06);
  color: #a92c2c;
  font-size: 0.875rem;
}
.alert[hidden] { display: none; }
.alert svg { flex: none; margin-top: 1px; }

/* ---------- 7. Campos ---------- */
.field { margin-bottom: 20px; }

.field__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 7px;
}

.field__label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--brand-navy);
}

.field__link { font-size: 0.8125rem; }

.field__control { position: relative; }

.input {
  width: 100%;
  padding: 13px 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-field);
  background: var(--surface);
  color: var(--brand-navy);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input::placeholder { color: var(--ink-300); }
.input:hover { border-color: #b7c0d6; }
.input:focus {
  outline: none;
  border-color: var(--brand-blue);
  box-shadow: var(--ring);
}
.input[aria-invalid="true"] {
  border-color: var(--brand-red);
}
.input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 3px rgba(229, 66, 66, 0.2);
}

/* espacio para el botón de mostrar/ocultar */
.input--password { padding-right: 54px; }

.reveal {
  position: absolute;
  top: 50%;
  right: 4px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  /* 44px: mínimo de área táctil accesible (WCAG 2.5.8) */
  width: 44px; height: 44px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-450);
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}
.reveal:hover { color: var(--brand-navy); background: var(--surface-sunken); }

.field__error {
  margin: 7px 0 0;
  font-size: 0.8125rem;
  color: var(--brand-red);
}
.field__error:empty { display: none; }

/* ---------- 8. Checkbox ---------- */
.check {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 26px;
  font-size: 0.875rem;
  color: var(--ink-600);
  cursor: pointer;
  user-select: none;
}
.check input {
  width: 17px; height: 17px;
  margin: 0;
  accent-color: var(--brand-blue);
  cursor: pointer;
}

/* ---------- 9. Botón principal ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 15px 23px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--grad-cta);
  color: #fff;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.btn:hover {
  filter: brightness(1.07);
  box-shadow: 0 12px 26px -12px rgba(71, 83, 191, 0.7);
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.62; cursor: not-allowed; filter: none; box-shadow: none; }

.btn__spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.btn:not([data-loading]) .btn__spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 10. Pie del panel ---------- */
.panel__help {
  margin: 24px 0 0;
  text-align: center;
  font-size: 0.875rem;
  color: var(--ink-450);
}

.panel__foot {
  margin-top: 38px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--ink-450);
  text-align: center;
}
.panel__foot nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  margin-bottom: 10px;
}
.panel__foot a { color: var(--ink-450); }
.panel__foot a:hover { color: var(--brand-navy); }

/* Aviso de tratamiento de datos — obligatorio en salud (habeas data) */
.notice {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 16px;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--ink-450);
  text-align: left;
}
.notice svg { flex: none; margin-top: 2px; color: var(--success); }

/* ---------- 11. Adaptación a pantallas pequeñas ---------- */
@media (max-width: 1000px) {
  .auth { grid-template-columns: 1fr; }

  .brand {
    display: none;              /* el panel decorativo cede espacio al formulario */
  }

  .panel {
    align-items: flex-start;
    padding: 56px 24px 40px;
  }

  .panel__logo { display: block; }
}

@media (max-width: 420px) {
  .panel { padding: 40px 20px 32px; }
  .panel__title { font-size: 1.5rem; }
  .panel__logo { width: 160px; margin-bottom: 30px; }
}

/* Pantallas muy anchas: el panel de marca no debe dominar */
@media (min-width: 1600px) {
  .auth { grid-template-columns: 1fr 1fr; }
  .brand { padding: 60px 80px; }
}

/* ---------- 11b. Área activa de los enlaces ----------
   Los enlaces sueltos (no incrustados en un párrafo) deben alcanzar
   24px de alto — WCAG 2.5.8 "Target Size (Minimum)", nivel AA.
   Se amplía el área activa con padding compensado por margen negativo,
   de modo que el layout no cambia. */
.field__link,
.panel__help a,
.panel__foot a {
  display: inline-block;
  padding-block: 5px;
  margin-block: -5px;
}

.check { min-height: 24px; align-items: center; }
.check input { width: 18px; height: 18px; }

/* En dispositivos táctiles se amplía hasta los 44px recomendados. */
@media (pointer: coarse) {
  .field__link,
  .panel__help a,
  .panel__foot a {
    padding-block: 12px;
    margin-block: -12px;
  }

  .check { min-height: 44px; }
  .check input { width: 20px; height: 20px; }
}

/* ---------- 12. Preferencias de accesibilidad ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (prefers-contrast: more) {
  .input { border-color: var(--brand-navy); }
  .brand__lede { color: rgba(255, 255, 255, 0.92); }
  .panel__subtitle, .panel__help { color: var(--ink-600); }
}
