/*
  ════════════════════════════════════════════════════════════════════════
  BLINDA — PORTAL.CSS
  Login · Registro · Utilidades base del portal
  ────────────────────────────────────────────────────────────────────────
  Paleta y tipografía idénticas a index.css para coherencia total.
  Este archivo solo estiliza portal.html (login + registro).
  Los paneles de admin/cliente/técnico tienen sus propios CSS.
  ────────────────────────────────────────────────────────────────────────
  Índice:
  1.  Variables y tokens
  2.  Reset y base
  3.  Utilidades globales (.hidden, .sr-only, .toast)
  4.  Fondo decorativo del portal
  5.  Layout principal — .login-wrap
  6.  Brand: logo, tagline, estado del sistema
  7.  Tabs: Ingresar / Crear cuenta
  8.  Cards de formulario (.login-card)
  9.  Campos de formulario (.login-field, .input-wrap)
  10. Select personalizado
  11. Mensajes de error y hints
  12. Botón submit
  13. Links de ayuda
  14. Trust badges
  15. Animaciones de entrada
  16. Media queries — responsive completo
  ════════════════════════════════════════════════════════════════════════
*/


/* ════════════════════════════════════════════════════════════════════════
   1. VARIABLES Y TOKENS
   Mismos valores que index.css — un solo sistema visual
   ════════════════════════════════════════════════════════════════════════ */

:root {
  /* ─── Paleta base ─── */
  --c-root:       #0d0e10;
  --c-surface:    #13151a;
  --c-surface-2:  #1a1d24;
  --c-surface-3:  #21252f;
  --c-border:     #ffffff0d;
  --c-border-mid: #ffffff1a;
  --c-border-hi:  #ffffff2e;

  /* ─── Acento dorado ─── */
  --gold:         #e8b84b;
  --gold-light:   #f0ca72;
  --gold-dark:    #c99a30;
  --gold-glow:    rgba(232, 184, 75, 0.08);
  --gold-glow-md: rgba(232, 184, 75, 0.14);
  --gold-border:  rgba(232, 184, 75, 0.22);

  /* ─── Texto ─── */
  --t-primary:    #f2f0ea;
  --t-secondary:  #9a9690;
  --t-muted:      #5c5a56;

  /* ─── Semánticos ─── */
  --green:        #3dba76;
  --green-bg:     rgba(61, 186, 118, 0.10);
  --green-border: rgba(61, 186, 118, 0.22);
  --red:          #e05252;
  --red-bg:       rgba(224, 82, 82, 0.08);
  --red-border:   rgba(224, 82, 82, 0.22);

  /* ─── Tipografía ─── */
  --font-display: 'Bebas Neue', 'Arial Narrow', sans-serif;
  --font-body:    'Barlow', 'Helvetica Neue', sans-serif;

  /* ─── Radios ─── */
  --r-sm:  6px;
  --r-md:  12px;
  --r-lg:  20px;
  --r-xl:  28px;

  /* ─── Sombras ─── */
  --shadow-md:   0 8px 32px rgba(0,0,0,0.40);
  --shadow-lg:   0 24px 64px rgba(0,0,0,0.50);
  --shadow-gold: 0 0 40px rgba(232, 184, 75, 0.12);

  /* ─── Transiciones ─── */
  --t-fast: 150ms ease;
  --t-base: 220ms ease;
  --t-slow: 380ms ease;
}


/* ════════════════════════════════════════════════════════════════════════
   2. RESET Y BASE
   ════════════════════════════════════════════════════════════════════════ */

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
  height: 100%;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.65;
  color: var(--t-primary);
  background: var(--c-root);
  min-height: 100%;
  min-height: 100svh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─── Selección de texto ─── */
::selection {
  background: var(--gold);
  color: #000;
}

/* ─── Focus visible — accesibilidad ─── */
:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 3px;
  border-radius: var(--r-sm);
}

/* ─── Scrollbar personalizado ─── */
::-webkit-scrollbar        { width: 6px; }
::-webkit-scrollbar-track  { background: var(--c-root); }
::-webkit-scrollbar-thumb  { background: var(--c-surface-3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold-dark); }

a { color: inherit; text-decoration: none; }
img { max-width: 100%; height: auto; display: block; }
ul, ol { list-style: none; }
button { font-family: var(--font-body); }
abbr[title] { text-decoration: none; cursor: help; }


/* ════════════════════════════════════════════════════════════════════════
   3. UTILIDADES GLOBALES
   ════════════════════════════════════════════════════════════════════════ */

/* Accesibilidad — solo lectores de pantalla */
.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;
}

/* Ocultar elementos */
.hidden { display: none !important; }

/* Clase de vista — todas las "páginas" del portal usan esto */
.view {
  width: 100%;
  min-height: 100svh;
}
.view.active { display: flex; }

/* ─── Toast — notificación flotante ─── */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--c-surface-3);
  border: 1px solid var(--c-border-hi);
  color: var(--t-primary);
  font-size: 14px;
  font-weight: 500;
  padding: 13px 24px;
  border-radius: 50px;
  box-shadow: var(--shadow-md);
  z-index: 9999;
  white-space: nowrap;
  animation: toast-in 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
  max-width: calc(100vw - 40px);
}
.toast.hidden {
  display: none;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(12px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}


/* ════════════════════════════════════════════════════════════════════════
   4. FONDO DECORATIVO DEL PORTAL
   Mismo lenguaje visual que el hero del index
   ════════════════════════════════════════════════════════════════════════ */

.portal-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

/* Grilla de puntos con mask radial — igual que hero del index */
.portal-bg-grid {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255,255,255,0.055) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black 20%, transparent 100%);
}

/* Resplandores dorados: superior-izquierda y inferior-derecha */
.portal-bg-glow {
  position: absolute;
  width: 50vw; height: 50vw;
  border-radius: 50%;
  pointer-events: none;
}

.portal-bg-glow-tl {
  top: -15%; left: -10%;
  background: radial-gradient(circle, rgba(232,184,75,0.06) 0%, transparent 65%);
}

.portal-bg-glow-br {
  bottom: -15%; right: -10%;
  background: radial-gradient(circle, rgba(232,184,75,0.05) 0%, transparent 65%);
}


/* ════════════════════════════════════════════════════════════════════════
   5. LAYOUT PRINCIPAL — .login-wrap
   ════════════════════════════════════════════════════════════════════════ */

#view-login {
  justify-content: center;
  align-items: center;
  min-height: 100svh;
  padding: 40px 20px;
  position: relative;
  z-index: 1;
}

/* Columna central: contiene brand + tabs + card */
.login-wrap {
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 0;

  /* Entrada animada al cargar */
  animation: wrap-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes wrap-in {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* ════════════════════════════════════════════════════════════════════════
   6. BRAND: logo, tagline, estado del sistema
   ════════════════════════════════════════════════════════════════════════ */

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
  text-align: center;
}

/* Link "← Volver al inicio" */
.back-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--t-muted);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--c-border-mid);
  transition: color var(--t-base), border-color var(--t-base), background var(--t-base);
  align-self: flex-start;
  margin-bottom: 8px;
}
.back-link:hover {
  color: var(--t-primary);
  border-color: var(--c-border-hi);
  background: var(--c-border);
}

/* Logo — Bebas Neue, mismo que navbar del index */
.login-logo {
  font-family: var(--font-display);
  font-size: 52px;
  letter-spacing: 6px;
  color: var(--t-primary);
  line-height: 1;
  text-shadow: 0 0 40px rgba(232, 184, 75, 0.15);
  transition: text-shadow var(--t-slow);
}
.login-logo span { color: var(--gold); }
.login-logo:hover {
  text-shadow: 0 0 60px rgba(232, 184, 75, 0.28);
}

/* Tagline */
.login-tagline {
  font-size: 14px;
  color: var(--t-secondary);
  letter-spacing: 0.3px;
}

/* Pill de estado del sistema — mismo lenguaje que el hero */
.login-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--green);
  background: var(--green-bg);
  border: 1px solid var(--green-border);
  padding: 6px 14px;
  border-radius: 20px;
  margin-top: 4px;
}

/* Punto verde parpadeante */
.login-status-dot {
  width: 7px; height: 7px;
  background: var(--green);
  border-radius: 50%;
  flex-shrink: 0;
  animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}


/* ════════════════════════════════════════════════════════════════════════
   7. TABS: Ingresar / Crear cuenta
   ════════════════════════════════════════════════════════════════════════ */

.auth-tabs {
  display: flex;
  width: 100%;
  background: var(--c-surface);
  border: 1px solid var(--c-border-mid);
  border-radius: var(--r-md) var(--r-md) 0 0;
  border-bottom: none;
  padding: 5px 5px 0;
  gap: 4px;
}

.auth-tab {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  padding: 11px 16px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.3px;
  color: var(--t-muted);
  cursor: pointer;
  transition: color var(--t-base), background var(--t-base);
  position: relative;
  white-space: nowrap;
}

.auth-tab:hover { color: var(--t-secondary); }

/* Tab activo — usa el gold como indicador inferior */
.auth-tab.active {
  color: var(--t-primary);
  background: var(--c-surface-2);
}

/* Línea dorada inferior del tab activo */
.auth-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 16px; right: 16px;
  height: 2px;
  background: var(--gold);
  border-radius: 2px 2px 0 0;
}

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


/* ════════════════════════════════════════════════════════════════════════
   8. CARDS DE FORMULARIO — .login-card
   ════════════════════════════════════════════════════════════════════════ */

.login-card {
  background: var(--c-surface-2);
  border: 1px solid var(--c-border-mid);
  border-top: none;
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  padding: 28px 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: var(--shadow-lg), var(--shadow-gold);
  position: relative;
  overflow: hidden;
}

/* Decoración: línea dorada muy sutil en la parte superior de la card */
.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 28px; right: 28px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-border), transparent);
}

/* Fila de 2 columnas dentro del formulario */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}


/* ════════════════════════════════════════════════════════════════════════
   9. CAMPOS DE FORMULARIO
   ════════════════════════════════════════════════════════════════════════ */

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-field label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--t-secondary);
}

/* Wrapper del input con ícono prefijo opcional */
.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 13px;
  font-size: 13px;
  color: var(--t-muted);
  pointer-events: none;
  user-select: none;
  line-height: 1;
}

/* Input base — con o sin ícono */
.login-field input,
.login-field .login-select {
  width: 100%;
  background: var(--c-surface-3);
  border: 1px solid var(--c-border-mid);
  border-radius: var(--r-sm);
  padding: 12px 14px;
  color: var(--t-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.4;
  outline: none;
  transition:
    border-color var(--t-base),
    background var(--t-base),
    box-shadow var(--t-base);
  appearance: none;
  -webkit-appearance: none;
}

/* Input con ícono prefijo: padding-left extra */
.input-wrap input {
  padding-left: 36px;
}

/* Input con botón de ojo: padding-right extra */
.input-wrap input[id="login-password"] {
  padding-right: 44px;
}

/* Estado focus */
.login-field input:focus,
.login-field .login-select:focus {
  border-color: var(--gold);
  background: var(--c-surface);
  box-shadow: 0 0 0 3px rgba(232, 184, 75, 0.10);
}

/* Estado inválido (después de intento de submit) */
.login-field input:invalid:not(:placeholder-shown) {
  border-color: var(--red-border);
}

/* Placeholder */
.login-field input::placeholder { color: var(--t-muted); }

/* Autocompletar — forzar fondo oscuro (webkit) */
.login-field input:-webkit-autofill,
.login-field input:-webkit-autofill:hover,
.login-field input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--c-surface-3) inset;
  -webkit-text-fill-color: var(--t-primary);
  caret-color: var(--t-primary);
  border-color: var(--gold-border);
  transition: background-color 5000s ease-in-out 0s;
}

/* ─── Botón toggle de contraseña (ojo) ─── */
.input-eye {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 6px;
  color: var(--t-muted);
  font-size: 14px;
  line-height: 1;
  border-radius: var(--r-sm);
  transition: color var(--t-base);
  display: flex;
  align-items: center;
}
.input-eye:hover { color: var(--t-secondary); }


/* ════════════════════════════════════════════════════════════════════════
   10. SELECT PERSONALIZADO
   ════════════════════════════════════════════════════════════════════════ */

.login-select {
  cursor: pointer;
  padding-right: 36px !important;
  /* Flecha personalizada SVG dorada */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235c5a56' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px 8px;
}

.login-select option {
  background: var(--c-surface-2);
  color: var(--t-primary);
}

.login-select:focus {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23e8b84b' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
}


/* ════════════════════════════════════════════════════════════════════════
   11. MENSAJES DE ERROR Y HINTS
   ════════════════════════════════════════════════════════════════════════ */

/* Error de formulario — inyectado por login.js */
.form-error {
  background: var(--red-bg);
  border: 1px solid var(--red-border);
  border-radius: var(--r-sm);
  padding: 11px 14px;
  font-size: 13px;
  color: var(--red);
  line-height: 1.5;
  animation: shake 0.35s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

/* Hint debajo del campo */
.field-hint {
  font-size: 11px;
  color: var(--t-muted);
  line-height: 1.4;
}


/* ════════════════════════════════════════════════════════════════════════
   12. BOTÓN SUBMIT
   ════════════════════════════════════════════════════════════════════════ */

.btn-submit {
  width: 100%;
  background: var(--gold);
  color: #000;
  border: none;
  border-radius: var(--r-sm);
  padding: 14px 24px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.3px;
  cursor: pointer;
  transition:
    background var(--t-base),
    transform var(--t-fast),
    box-shadow var(--t-base),
    opacity var(--t-base);
  margin-top: 4px;
}

.btn-submit:hover {
  background: var(--gold-light);
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(232, 184, 75, 0.28);
}
.btn-submit:active  { transform: translateY(0); }
.btn-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Estado de carga — login.js añade el atributo disabled + texto "Ingresando..." */
.btn-submit[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}


/* ════════════════════════════════════════════════════════════════════════
   13. LINKS DE AYUDA
   ════════════════════════════════════════════════════════════════════════ */

.login-help {
  font-size: 12px;
  color: var(--t-muted);
  text-align: center;
  line-height: 1.6;
}

.login-help a {
  color: var(--gold);
  font-weight: 500;
  transition: color var(--t-base);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: transparent;
  transition: color var(--t-base), text-decoration-color var(--t-base);
}
.login-help a:hover {
  color: var(--gold-light);
  text-decoration-color: var(--gold-light);
}


/* ════════════════════════════════════════════════════════════════════════
   14. TRUST BADGES — pie del formulario
   ════════════════════════════════════════════════════════════════════════ */

.login-trust {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.lt-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--t-muted);
  font-weight: 500;
}
.lt-item span { font-size: 12px; }

/* Separador vertical entre badges */
.lt-sep {
  width: 1px;
  height: 12px;
  background: var(--c-border-mid);
  flex-shrink: 0;
}


/* ════════════════════════════════════════════════════════════════════════
   15. ANIMACIONES DE ENTRADA
   ════════════════════════════════════════════════════════════════════════ */

/* Staggered delay para los hijos del login-wrap */
.login-brand       { animation: item-in 0.45s ease both; animation-delay: 0ms;   }
.auth-tabs         { animation: item-in 0.45s ease both; animation-delay: 60ms;  }
.login-card        { animation: item-in 0.45s ease both; animation-delay: 110ms; }
.login-trust       { animation: item-in 0.45s ease both; animation-delay: 160ms; }

@keyframes item-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Respeta preferencias de movimiento reducido */
@media (prefers-reduced-motion: reduce) {
  .login-brand, .auth-tabs,
  .login-card, .login-trust,
  .login-wrap {
    animation: none;
  }
  .toast { animation: none; }
}


/* ════════════════════════════════════════════════════════════════════════
   16. MEDIA QUERIES — RESPONSIVE COMPLETO
   ════════════════════════════════════════════════════════════════════════ */

/* ── 520px: pantallas medianas pequeñas ── */
@media (max-width: 520px) {

  #view-login {
    padding: 24px 16px 40px;
    align-items: flex-start;
  }

  .login-wrap {
    max-width: 100%;
  }

  .login-logo {
    font-size: 44px;
    letter-spacing: 5px;
  }

  .login-card {
    padding: 22px 20px 20px;
    border-radius: 0 0 var(--r-md) var(--r-md);
  }

  /* En móviles, el form-row se apila verticalmente */
  .form-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .auth-tabs {
    padding: 4px 4px 0;
  }
  .auth-tab {
    font-size: 13px;
    padding: 10px 12px;
  }
}

/* ── 400px: móviles muy pequeños ── */
@media (max-width: 400px) {

  .login-logo {
    font-size: 38px;
    letter-spacing: 4px;
  }

  .login-tagline {
    font-size: 13px;
  }

  .login-status-pill {
    font-size: 10px;
    letter-spacing: 1px;
    padding: 5px 12px;
  }

  .login-card {
    padding: 18px 16px 18px;
    gap: 14px;
  }

  .login-field input,
  .login-field .login-select {
    font-size: 16px; /* Evita zoom automático en iOS */
    padding: 13px 14px;
  }

  .input-wrap input {
    padding-left: 34px;
    font-size: 16px; /* Evita zoom en iOS */
  }

  .btn-submit {
    padding: 15px 20px;
    font-size: 15px;
  }

  .login-trust {
    gap: 8px;
  }
  .lt-sep { display: none; }
}

/* ── Pantalla muy corta (landscape móvil) ── */
@media (max-height: 600px) {

  #view-login {
    padding: 16px;
    align-items: flex-start;
  }

  .login-brand {
    margin-bottom: 16px;
    gap: 6px;
  }

  .login-logo { font-size: 36px; }
  .login-status-pill { display: none; }

  .login-card {
    padding: 18px 20px 16px;
    gap: 12px;
  }

  .login-trust { margin-top: 12px; }
}