/* CallAPP — Login ventana flotante centrada (paleta navy / gold) */

*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --navy: #2a3348;
  --navy-2: #1f2d44;
  --gold: #5b8eec;
  --gold-dark: #4a7ad4;
  --bg: #f4f7fb;
  --cream: #f8fafd;
  --text: #2a3348;
  --muted: #7a8498;
  --line: rgba(160, 184, 214, 0.28);
  --danger: #b91c1c;
  --shadow-window: 0 18px 44px rgba(140, 168, 204, 0.16), 0 8px 22px rgba(140, 168, 204, 0.1);
  --glass-bg: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(255, 255, 255, 0.55);
  --glass-blur: 10px;
}

/* ——— Loader (intacto para JS) ——— */
#app-loader,
.app-loader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  background: #fff;
}

#app-loader.is-visible,
.app-loader.is-visible {
  display: flex;
}

.loader-content {
  position: relative;
  width: 88px;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner-ring {
  position: absolute;
  width: 80px;
  height: 80px;
  border: 4px solid transparent;
  border-top: 4px solid #d4af37;
  border-right: 4px solid #19284c;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.logo-loader {
  position: absolute;
  width: 56px;
  height: 56px;
  max-width: 56px;
  max-height: 56px;
  object-fit: contain;
  object-position: center;
  z-index: 2;
}

.logo-loader[hidden] {
  display: none !important;
}

.loader-content:has(img.logo-loader:not([hidden])) .callapp-brand-mark--loader {
  display: none !important;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

html {
  height: 100%;
}

html,
body.login-page {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--text);
}

/* Fondo general: degradado navy/cream + capa suave */
body.login-page {
  min-height: 100vh;
  height: 100%;
  position: relative;
  overflow-x: hidden;
  background: linear-gradient(155deg, var(--cream) 0%, #e8ecf4 38%, #d9e2ef 100%);
}

body.login-page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background: radial-gradient(ellipse 100% 80% at 15% 10%, rgba(186, 214, 255, 0.28) 0%, transparent 55%),
    radial-gradient(ellipse 90% 70% at 88% 75%, rgba(200, 216, 240, 0.2) 0%, transparent 50%),
    linear-gradient(180deg, rgba(248, 250, 253, 0.95) 0%, rgba(244, 247, 251, 0.9) 100%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Shell: centra la ventana con aire */
main.login-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

/* Ventana flotante */
.login-window {
  max-width: 1120px;
  width: calc(100% - 80px);
  min-height: 680px;
  border-radius: 24px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow-window);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.65);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: stretch;
}

/* Columna formulario */
.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(1.75rem, 4vw, 2.75rem);
  min-height: 0;
}

.login-panel-inner {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.login-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.callapp-brand-mark {
  width: 64px;
  height: 64px;
  margin: 0 auto 0.85rem;
  border-radius: 16px;
  background: var(--navy);
  color: var(--gold);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 24px rgba(25, 40, 76, 0.18);
}

.callapp-brand-mark[hidden] {
  display: none;
}

.callapp-brand-mark--loader {
  width: 56px;
  height: 56px;
  margin: 0;
  font-size: 0.92rem;
  z-index: 2;
  position: relative;
}

.login-logo-img {
  width: auto;
  max-width: min(220px, 100%);
  height: auto;
  max-height: 88px;
  object-fit: contain;
  display: inline-block;
  margin-bottom: 0.65rem;
}

.login-logo-img[hidden] {
  display: none;
}

.login-brand-name {
  margin: 0 0 0.35rem;
  font-size: clamp(1.05rem, 2.5vw, 1.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--navy);
}

.login-subtitle {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.login-form-title {
  margin: 0 0 1.15rem;
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--navy);
  letter-spacing: -0.02em;
}

/* Formulario / glass panel */
form.glass-panel {
  position: relative;
  width: 100%;
  padding: clamp(1.35rem, 3.5vw, 1.85rem);
  border-radius: 16px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  box-shadow: 0 10px 36px rgba(25, 40, 76, 0.06);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  overflow: hidden;
}

form.glass-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--navy) 0%, var(--gold) 100%);
  pointer-events: none;
  border-radius: 16px 16px 0 0;
}

form.glass-panel > * {
  position: relative;
  z-index: 1;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.field label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--muted);
}

.field input {
  width: 100%;
  min-height: 52px;
  padding: 0.8rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  font-size: 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.field input::placeholder {
  color: #9aa3b5;
}

.field input:focus {
  border-color: rgba(212, 175, 55, 0.5);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(91, 142, 236, 0.18);
}

.btn-primary {
  width: 100%;
  margin-top: 0.35rem;
  min-height: 52px;
  padding: 0.9rem 1rem;
  border: none;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  color: #fff;
  background: var(--gold);
  box-shadow: 0 8px 22px rgba(91, 142, 236, 0.28);
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

.btn-primary:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(91, 142, 236, 0.32);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-primary:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Selector de rol (multi-rol) */
.login-role-step[hidden] {
  display: none !important;
}

#login-credentials-step[hidden],
#login-org-step[hidden],
#login-master-destination-step[hidden],
#login-environment-step[hidden] {
  display: none !important;
}

.login-master-destination-btn {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.login-master-destination-btn small {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 500;
}

.login-role-lead {
  margin: 0 0 1.1rem;
  font-size: 0.88rem;
  color: var(--muted);
  line-height: 1.45;
}

.login-role-list {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 1rem;
  max-height: min(42vh, 320px);
  overflow-y: auto;
}

.login-role-btn {
  width: 100%;
  min-height: 50px;
  padding: 0.75rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  color: var(--navy);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
  -webkit-tap-highlight-color: transparent;
}

.login-role-btn:hover {
  border-color: rgba(212, 175, 55, 0.45);
  background: #fff;
  box-shadow: 0 4px 14px rgba(25, 40, 76, 0.06);
}

.login-role-btn--legacy {
  opacity: 0.72;
  font-weight: 550;
  color: #5b6578;
}

.login-org-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.login-org-btn__logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
  flex-shrink: 0;
}

.login-org-btn__mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: #19284c;
  color: #d4af37;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

.login-org-btn__name {
  flex: 1;
  min-width: 0;
}

.login-environment-btn {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-height: 72px;
  border-color: rgba(75, 132, 235, 0.2);
}

.login-environment-btn:hover {
  border-color: rgba(75, 132, 235, 0.58);
  background: linear-gradient(110deg, #fff, #f4f8ff);
}

.login-environment-btn__icon {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #edf4ff;
  color: #356de0;
  font-size: 1.35rem;
  flex: 0 0 auto;
}

.login-environment-btn__copy {
  display: grid;
  gap: 0.15rem;
}

.login-environment-btn__copy small {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 450;
}

.btn-secondary {
  width: 100%;
  margin-top: 0.25rem;
  min-height: 48px;
  padding: 0.65rem 1rem;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-secondary:hover {
  background: rgba(25, 40, 76, 0.04);
  color: var(--navy);
}

.btn-secondary:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.login-error {
  min-height: 1.35rem;
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--danger);
  text-align: center;
}

.login-hint {
  margin-top: 1.25rem;
  font-size: 0.76rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.login-hint code {
  font-size: 0.78em;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  background: rgba(212, 175, 55, 0.1);
  color: var(--navy-2);
}

/* Columna hero: foto de plataforma + overlay (sin marca Phoenix) */
.login-hero {
  position: relative;
  min-height: 100%;
  overflow: hidden;
  background: linear-gradient(145deg, var(--navy-2) 0%, var(--navy) 55%, #2a3f73 100%);
}

.login-hero__img {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transform: scale(1);
  transition: transform 0.8s ease;
}

.login-hero__overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(115deg, rgba(16, 27, 54, 0.52) 0%, rgba(25, 40, 76, 0.26) 55%, rgba(212, 175, 55, 0.12) 100%);
  pointer-events: none;
}

.login-hero-copy {
  position: relative;
  z-index: 3;
  height: 100%;
  min-height: 240px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2.5rem 2rem;
  text-align: center;
}

.login-hero-brand-logo {
  width: auto;
  max-width: min(340px, 78%);
  max-height: 120px;
  height: auto;
  object-fit: contain;
  margin: 0 0 1rem;
  filter: drop-shadow(0 10px 28px rgba(0, 0, 0, 0.35)) drop-shadow(0 0 1px rgba(255, 255, 255, 0.45));
}

.login-hero-brand-logo[hidden] {
  display: none;
}

.login-hero-wordmark {
  position: relative;
  z-index: 3;
  margin: 0;
  color: #fff;
  font-size: clamp(1.85rem, 3.8vw, 2.55rem);
  font-weight: 700;
  letter-spacing: -0.04em;
  text-shadow: 0 8px 28px rgba(0, 0, 0, 0.35);
}

.login-hero--org .login-hero-wordmark {
  font-size: clamp(1.35rem, 2.8vw, 1.75rem);
  font-weight: 600;
}

.login-hero-tagline {
  position: relative;
  z-index: 3;
  margin: 0.75rem 0 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.95rem;
  max-width: 16rem;
}

.login-hero--org .login-hero-tagline {
  display: none;
}

.login-hero-logo {
  display: none;
}

/* Animación éxito (sin cambiar timing JS) */
body.login-success .login-hero__img {
  transform: scale(1.1);
  transition: transform 0.8s ease;
}

body.login-success form.glass-panel,
body.login-success .login-brand,
body.login-success .login-hint {
  transform: translateY(-50px);
  opacity: 0;
  transition: opacity 0.6s ease, transform 0.6s ease;
}

body.login-success .login-hero-wordmark,
body.login-success .login-hero-tagline,
body.login-success .login-hero-brand-logo,
body.login-success .login-hero-logo {
  opacity: 0;
  transition: opacity 0.6s ease;
}

@media (prefers-reduced-motion: reduce) {
  .spinner-ring {
    animation: none;
  }

  body.login-success .login-hero__img,
  body.login-success form.glass-panel,
  body.login-success .login-brand,
  body.login-success .login-hint {
    transition: none !important;
    transform: none !important;
    opacity: 1 !important;
  }

  body.login-success .login-hero-wordmark,
  body.login-success .login-hero-tagline,
  body.login-success .login-hero-logo {
    transition: none !important;
    opacity: 1 !important;
  }
}

/* ——— Responsive ——— */
@media (max-width: 900px) {
  main.login-shell {
    padding: 12px;
    align-items: flex-start;
    min-height: 100vh;
    padding-top: max(12px, env(safe-area-inset-top));
  }

  .login-window {
    width: calc(100% - 24px);
    max-width: none;
    margin: 0 auto;
    min-height: 0;
    grid-template-columns: 1fr;
    border-radius: 20px;
  }

  .login-hero {
    order: -1;
    min-height: 200px;
    max-height: min(36vh, 280px);
    flex-shrink: 0;
  }

  .login-hero__img {
    min-height: 200px;
    height: 100%;
    max-height: min(36vh, 280px);
  }

  .login-hero-copy {
    min-height: 200px;
    padding: 1.25rem 1rem;
  }

  .login-hero-brand-logo {
    max-height: 64px;
    max-width: min(240px, 70%);
    margin-bottom: 0.5rem;
  }

  .login-hero-wordmark {
    font-size: clamp(1.35rem, 6vw, 1.85rem);
  }

  .login-panel {
    padding: clamp(1.25rem, 4vw, 1.75rem);
    align-items: flex-start;
    padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  }

  .login-panel-inner {
    max-width: none;
  }
}

@media (max-width: 480px) {
  form.glass-panel {
    border-radius: 14px;
  }

  .login-hero-brand-logo {
    max-height: 52px;
  }
}

/* Registro público desde el login */
.login-register-trigger {
  width: 100%;
  min-height: 54px;
  margin-top: 0.7rem;
  padding: 0.55rem 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  border: 1px solid rgba(124, 156, 204, 0.28);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.56);
  color: var(--muted);
  font: inherit;
  font-size: 0.87rem;
  cursor: pointer;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.login-register-trigger strong {
  color: var(--gold-dark);
  font-weight: 700;
}

.login-register-trigger:hover {
  border-color: rgba(91, 142, 236, 0.48);
  background: #fff;
  transform: translateY(-1px);
}

.login-register-trigger:focus-visible,
.login-register-card button:focus-visible,
.login-register-input:focus-visible {
  outline: 3px solid rgba(91, 142, 236, 0.35);
  outline-offset: 2px;
}

.login-register-dialog[hidden],
.login-register-org-step[hidden] {
  display: none !important;
}

.login-register-dialog:not([hidden]) {
  position: fixed;
  z-index: 10000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.login-register-dialog__scrim {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  background: rgba(26, 39, 62, 0.48);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  cursor: default;
}

.login-register-card {
  position: relative;
  width: min(100%, 430px);
  padding: clamp(1.4rem, 5vw, 2rem);
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 22px;
  background: linear-gradient(155deg, #fff 0%, #f7f9fd 100%);
  box-shadow: 0 28px 90px rgba(24, 41, 70, 0.3), 0 4px 18px rgba(64, 97, 146, 0.12);
  animation: login-register-enter 0.2s ease-out both;
}

.login-register-card__close {
  position: absolute;
  top: 0.8rem;
  right: 0.85rem;
  width: 36px;
  height: 36px;
  border: 1px solid rgba(160, 184, 214, 0.3);
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}

.login-register-card__eyebrow {
  display: inline-flex;
  margin-bottom: 0.55rem;
  color: var(--gold-dark);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.12em;
}

.login-register-card h2 {
  margin: 0;
  color: var(--navy);
  font-size: 1.35rem;
  letter-spacing: -0.035em;
}

.login-register-card__lead {
  margin: 0.55rem 0 1.1rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.login-register-label {
  display: block;
  margin-bottom: 0.4rem;
  color: var(--navy-2);
  font-size: 0.78rem;
  font-weight: 650;
}

.login-register-input {
  width: 100%;
  min-height: 52px;
  padding: 0.7rem 0.9rem;
  border: 1px solid rgba(145, 171, 208, 0.38);
  border-radius: 13px;
  background: #fff;
  color: var(--navy);
  font: inherit;
  font-size: 1rem;
  letter-spacing: 0.2em;
  text-align: center;
}

.login-register-error {
  min-height: 1.25rem;
  margin: 0.35rem 0 0;
  color: var(--danger);
  font-size: 0.78rem;
  text-align: center;
}

.login-register-continue {
  min-height: 48px;
  margin-top: 0.25rem;
}

.login-register-org-step {
  display: grid;
  gap: 0.65rem;
}

.login-register-org-step .login-register-card__lead {
  margin-bottom: 0.25rem;
}

.login-register-org {
  width: 100%;
  min-height: 70px;
  padding: 0.7rem 0.8rem;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 20px;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid rgba(145, 171, 208, 0.3);
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--navy);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

.login-register-org:hover {
  border-color: rgba(91, 142, 236, 0.58);
  box-shadow: 0 8px 20px rgba(57, 91, 144, 0.1);
  transform: translateY(-1px);
}

.login-register-org__mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: #edf3ff;
  color: #477cd8;
  font-size: 1rem;
  font-weight: 750;
}

.login-register-org__mark--phoenix {
  background: #fff3e8;
  color: #d56a27;
}

.login-register-org strong,
.login-register-org small {
  display: block;
}

.login-register-org strong {
  font-size: 0.9rem;
  font-weight: 680;
}

.login-register-org small {
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.login-register-org__arrow {
  color: #90a0bb;
  font-size: 1.4rem;
  text-align: right;
}

.login-register-back {
  min-height: 38px;
  justify-self: center;
  padding: 0.35rem 0.7rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  cursor: pointer;
}

.login-register-back:hover {
  color: var(--navy);
}

.login-register-card__note {
  margin: 1rem 0 0;
  padding-top: 0.8rem;
  border-top: 1px solid rgba(145, 171, 208, 0.2);
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.45;
  text-align: center;
}

@keyframes login-register-enter {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 480px) {
  .login-register-dialog:not([hidden]) {
    padding: 0.75rem;
  }

  .login-register-card {
    border-radius: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .login-register-card {
    animation: none;
  }

  .login-register-trigger,
  .login-register-org {
    transition: none;
  }
}
