/* ============================================================
   Pantalla de carga inicial: se ve mientras se chequea si ya
   había una sesión iniciada, para no mostrar el login "de más"
   antes de saber si hay que loguear directo. Ver auth.js:
   se le agrega la clase "session-ready" al <body> recién cuando
   ya está decidido qué mostrar.
   ============================================================ */

.session-loading {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 3000;
  align-items: center;
  justify-content: center;
  background: rgba(2, 12, 5, 0.98);
}

body:not(.session-ready) .session-loading {
  display: flex;
}

body:not(.session-ready) .auth-view,
body:not(.session-ready) .app-header,
body:not(.session-ready) .app-main,
body:not(.session-ready) .app-nav {
  display: none !important;
}

.session-loading-spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid rgba(103, 244, 127, 0.2);
  border-top-color: #67f47f;
  animation: session-loading-spin 0.8s linear infinite;
}

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

/* ============================================================
   Pantalla de inicio: registro e inicio de sesión.
   Se muestra en lugar de toda la app hasta que el usuario se
   autentica (ver regla body:not(.authenticated) más abajo).
   ============================================================ */

.auth-view {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2000;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(2, 12, 5, 0.94);
  backdrop-filter: blur(6px);
  overflow-y: auto;
}

/* Mientras no haya sesión iniciada: se ve la pantalla de auth y se
   oculta el resto de la app (header, main y la barra de navegación). */
body:not(.authenticated) .auth-view {
  display: flex;
}

body:not(.authenticated) .app-header,
body:not(.authenticated) .app-main,
body:not(.authenticated) .app-nav {
  display: none !important;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  margin: auto;
  padding: 2rem 1.8rem 1.6rem;
  border-radius: 26px;
  background: rgba(10, 26, 13, 0.97);
  border: 1px solid rgba(103, 244, 127, 0.2);
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.6);
  animation: auth-card-in 0.35s cubic-bezier(0.22, 0.61, 0.36, 1);
}

@keyframes auth-card-in {
  from { opacity: 0; transform: translateY(10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.auth-logo {
  display: flex;
  justify-content: center;
  margin-bottom: 0.6rem;
}

.auth-logo img {
  width: auto;
  height: 64px;
  max-width: 220px;
  border-radius: 0;
  object-fit: contain;
  background: transparent;
  box-shadow: none;
}

.auth-title {
  text-align: center;
  font-family: 'Orbitron', sans-serif;
  color: #7dffa0;
  margin: 0 0 0.4rem;
  font-size: 1.5rem;
}

.auth-subtitle {
  text-align: center;
  color: var(--muted);
  margin: 0 0 1.4rem;
  font-size: 0.9rem;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1.4rem;
  background: rgba(0, 0, 0, 0.25);
  padding: 0.35rem;
  border-radius: 999px;
}

.auth-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 0.6rem 0.5rem;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: none;
  cursor: pointer;
  transition: background 0.22s ease, color 0.22s ease, box-shadow 0.22s ease;
}

.auth-tab:hover {
  transform: none;
  box-shadow: none;
}

.auth-tab.active {
  background: linear-gradient(90deg, #82ffad 0%, #2fa85e 100%);
  color: #08160f;
  box-shadow: 0 10px 20px rgba(43, 145, 76, 0.25);
}

.auth-form {
  display: none;
  flex-direction: column;
}

.auth-form.active {
  display: flex;
  animation: auth-form-in 0.25s ease;
}

@keyframes auth-form-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.auth-step {
  display: none;
  flex-direction: column;
}

.auth-step.active {
  display: flex;
}

.auth-steps {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.2rem;
}

.auth-step-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  transition: background 0.2s ease;
}

.auth-step-dot.active {
  background: #67f47f;
  box-shadow: 0 0 10px rgba(103, 244, 127, 0.6);
}

.auth-step-dot.done {
  background: #2fa85e;
}

.auth-step-hint {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 0 0 0.9rem;
  text-align: center;
}

.auth-step-hint strong {
  color: #dffedc;
}

.auth-code-banner {
  background: rgba(246, 236, 90, 0.12);
  border: 1px dashed rgba(246, 236, 90, 0.5);
  color: #f6ec5a;
  border-radius: 14px;
  padding: 0.8rem 1rem;
  text-align: center;
  font-family: 'Orbitron', sans-serif;
  letter-spacing: 0.18em;
  font-size: 1.15rem;
  margin-bottom: 1rem;
}

.auth-step-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.auth-step-actions .button-small {
  flex: 1;
  margin: 0;
}

.auth-step-actions .button-primary {
  flex: 2;
  margin: 0;
}

.auth-error {
  color: #ff9d9d;
  font-size: 0.84rem;
  margin: -0.4rem 0 0.9rem;
}

/* Link "de texto" tipo ¿Olvidaste tu contraseña? / volver: antes
   usaban el estilo de <button> genérico (mismo degradé verde que
   "Iniciar sesión"), por eso competían visualmente con el botón
   principal. Ahora son un link discreto, sin fondo ni sombra. */
.auth-link-btn {
  display: block;
  width: 100%;
  margin-top: 0.7rem;
  padding: 0.4rem;
  background: transparent;
  color: #8fd9a0;
  font-weight: 600;
  font-size: 0.84rem;
  text-align: center;
  border: none;
  border-radius: 10px;
  box-shadow: none;
  text-decoration: underline;
  text-decoration-color: rgba(143, 217, 160, 0.35);
  text-underline-offset: 3px;
  transition: color 0.18s ease, text-decoration-color 0.18s ease;
}

.auth-link-btn:hover {
  transform: none;
  box-shadow: none;
  color: #c8ffd0;
  text-decoration-color: rgba(200, 255, 208, 0.7);
}

.auth-demo-note {
  margin: 1.4rem 0 0;
  font-size: 0.74rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
}

.logout-btn {
  margin-top: 1rem;
  background: linear-gradient(90deg, #ff8c5b 0%, #e04e24 100%);
  color: #10100d;
}

@media (max-width: 480px) {
  .auth-card {
    padding: 1.6rem 1.2rem 1.3rem;
  }
}