/* ============================================================
   auth.css — Login split-screen (desktop) / one-column (móvil),
   sidebar usuario, badges de rol, modales amplios.
   Multi-instituto SaaS.
   ============================================================ */

/* ============================================================
   1. Shell del login
   ============================================================ */

.login-layout {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  background: var(--c-card);
}

.login-layout.hidden {
  display: none !important;
}

.login-layout > .view:not(.hidden),
.login-layout #login-content {
  display: flex;
  flex: 1;
  min-width: 0;
}

.auth-shell {
  display: flex;
  flex: 1;
  min-width: 0;
}

/* ----- Panel de marca (izquierda en desktop) ----- */
.auth-aside {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  flex: 1 1 44%;
  max-width: 620px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 40px;
  padding: 48px;
  color: #fff;
  background:
    radial-gradient(760px 460px at 88% -8%, rgba(99, 102, 241, 0.42), transparent 62%),
    radial-gradient(620px 420px at -12% 108%, rgba(56, 189, 248, 0.22), transparent 62%),
    linear-gradient(158deg, #0b1f3a 0%, #12294a 52%, #0d1a2f 100%);
}

/* Retícula técnica muy sutil, difuminada hacia los bordes */
.auth-aside::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(120% 90% at 30% 20%, #000 20%, transparent 78%);
  mask-image: radial-gradient(120% 90% at 30% 20%, #000 20%, transparent 78%);
}

.auth-brandmark {
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-brandmark-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  line-height: 1;
  border-radius: 14px;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  box-shadow: 0 10px 26px rgba(79, 70, 229, 0.45);
  flex-shrink: 0;
  color: #fff;
}

.auth-brandmark-logo svg {
  width: 22px;
  height: 22px;
}

.auth-brandmark-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
}

.auth-aside-title {
  font-family: var(--font-display);
  font-size: clamp(28px, 2.6vw, 40px);
  font-weight: 700;
  line-height: 1.14;
  letter-spacing: -0.03em;
  margin-bottom: 14px;
  text-wrap: balance;
}

.auth-aside-lead {
  font-size: 15px;
  line-height: 1.6;
  color: rgba(226, 232, 240, 0.78);
  max-width: 42ch;
}

.auth-features {
  list-style: none;
  margin-top: 32px;
  display: grid;
  gap: 14px;
}

.auth-feature {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 14px;
  line-height: 1.45;
  color: rgba(241, 245, 249, 0.92);
}

.auth-feature-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 10px;
  background: rgba(129, 140, 248, 0.18);
  border: 1px solid rgba(165, 180, 252, 0.28);
  color: #c7d2fe;
}

.auth-feature-icon svg {
  width: 16px;
  height: 16px;
}

.auth-feature strong {
  display: block;
  font-weight: 600;
  color: #fff;
}

.auth-feature span {
  color: rgba(203, 213, 225, 0.72);
  font-size: 13px;
}

.auth-aside-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: rgba(203, 213, 225, 0.68);
}

.auth-aside-foot svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  color: #86efac;
}

/* ============================================================
   2. Columna del formulario
   ============================================================ */

.auth-main {
  flex: 1 1 56%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 32px;
  background: var(--c-card);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  animation: crm-auth-in 0.45s cubic-bezier(0.34, 1.2, 0.64, 1);
}

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

.auth-head {
  margin-bottom: 24px;
}

.auth-head h1 {
  font-size: 27px;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--c-navy);
  letter-spacing: -0.03em;
  margin-bottom: 6px;
}

.auth-subtitle {
  font-size: 14px;
  line-height: 1.55;
  color: var(--c-muted);
}

/* ----- Segmented control ----- */
.auth-tabs {
  position: relative;
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  border: 1px solid var(--c-border);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 24px;
}

.auth-tabs-thumb {
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  border-radius: 9px;
  background: var(--c-card);
  box-shadow: var(--shadow-sm);
  transition: transform var(--t-med);
  pointer-events: none;
}

.auth-tabs[data-active="register"] .auth-tabs-thumb {
  transform: translateX(100%);
}

.auth-tab {
  position: relative;
  z-index: 1;
  flex: 1;
  padding: 10px 8px;
  border: none;
  background: transparent;
  color: var(--c-muted);
  font-family: inherit;
  font-weight: 600;
  font-size: 14px;
  border-radius: 9px;
  cursor: pointer;
  transition: color var(--t-fast);
}

.auth-tab.active {
  color: var(--c-primary);
}

.auth-panel.hidden {
  display: none;
}

/* ----- Campos ----- */
.auth-field {
  margin-bottom: 16px;
}

.auth-field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
  font-size: 13px;
  color: #334155;
  margin-bottom: 6px;
}

.auth-control {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-control-icon {
  position: absolute;
  left: 13px;
  width: 17px;
  height: 17px;
  color: #94a3b8;
  pointer-events: none;
  transition: color var(--t-fast);
}

.auth-control input {
  width: 100%;
  padding: 13px 14px 13px 40px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  /* 16px evita el zoom automático de iOS al enfocar */
  font-size: 16px;
  font-family: inherit;
  color: var(--c-text);
  background: #fff;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background-color var(--t-fast);
}

.auth-control input::placeholder {
  color: #a8b3c2;
}

.auth-control input:hover {
  border-color: #94a3b8;
}

.auth-control input:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.14);
}

.auth-control:focus-within .auth-control-icon {
  color: var(--c-primary);
}

.auth-control.has-toggle input {
  padding-right: 46px;
}

.auth-toggle-pass {
  position: absolute;
  right: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  transition: color var(--t-fast), background-color var(--t-fast);
}

.auth-toggle-pass:hover {
  color: var(--c-primary);
  background: var(--c-primary-soft);
}

.auth-toggle-pass svg {
  width: 17px;
  height: 17px;
}

/* Estado de error */
.auth-control input[aria-invalid="true"] {
  border-color: var(--bad);
  background: #fff6f6;
}

.auth-control input[aria-invalid="true"]:focus {
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.14);
}

.auth-alert {
  display: none;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 16px;
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #991b1b;
  font-size: 13px;
  line-height: 1.45;
}

.auth-alert.is-visible {
  display: flex;
}

.auth-alert svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ----- Botón principal ----- */
.auth-submit {
  width: 100%;
  margin-top: 8px;
  padding: 13px 18px;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #6366f1, #4338ca);
  box-shadow: 0 6px 18px rgba(79, 70, 229, 0.28);
  transition: box-shadow var(--t-fast), transform var(--t-fast), filter var(--t-fast);
}

.auth-submit:hover {
  filter: brightness(1.06);
  box-shadow: 0 10px 24px rgba(79, 70, 229, 0.34);
  transform: translateY(-1px);
}

.auth-submit:active {
  transform: translateY(0);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.26);
}

.auth-submit[disabled] {
  opacity: 0.7;
  cursor: progress;
  transform: none;
}

/* ----- Cuentas demo ----- */
.auth-demo {
  margin-top: 26px;
  border-top: 1px solid var(--c-border);
  padding-top: 18px;
}

.auth-demo-summary {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--c-muted);
  border-radius: 8px;
}

.auth-demo-summary::-webkit-details-marker {
  display: none;
}

.auth-demo-summary:hover {
  color: var(--c-primary);
}

.auth-demo-chevron {
  width: 15px;
  height: 15px;
  margin-left: auto;
  transition: transform var(--t-med);
}

.auth-demo[open] .auth-demo-chevron {
  transform: rotate(180deg);
}

.auth-demo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.demo-account {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--c-border);
  border-radius: 11px;
  background: #f8fafc;
  color: var(--c-text);
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast);
}

.demo-account:hover {
  background: var(--c-primary-soft);
  border-color: #c7d2fe;
  box-shadow: var(--shadow-xs);
}

.demo-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: 9px;
  font-size: 14px;
  line-height: 1;
  background: #e2e8f0;
}

/* Variante de rol: avatar con ícono SVG tintado por el color del rol */
.demo-avatar-rol {
  background: #f1f5f9;
}
.demo-avatar-rol .demo-avatar-ico {
  width: 15px;
  height: 15px;
}

.demo-meta {
  min-width: 0;
}

.demo-role {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
}

.demo-mail {
  display: block;
  font-size: 11.5px;
  color: var(--c-muted);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.auth-hint {
  margin-top: 16px;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--c-muted);
  text-align: center;
}

/* ============================================================
   3. Responsive
   ============================================================ */

/* Tablet: el panel de marca se estrecha y suelta las features */
@media (max-width: 1100px) {
  .auth-aside {
    flex-basis: 40%;
    padding: 36px 32px;
  }
  .auth-features {
    margin-top: 24px;
  }
  .auth-feature span {
    display: none;
  }
}

/* Móvil: una sola columna, marca como cabecera compacta */
@media (max-width: 860px) {
  .login-layout {
    display: block;
  }
  .auth-shell {
    flex-direction: column;
    min-height: 100dvh;
  }
  .auth-aside {
    flex: 0 0 auto;
    max-width: none;
    gap: 0;
    padding: calc(28px + env(safe-area-inset-top)) 24px 44px;
    text-align: center;
  }
  .auth-brandmark {
    justify-content: center;
    margin-bottom: 16px;
  }
  .auth-aside-title {
    font-size: 23px;
    margin-bottom: 8px;
  }
  .auth-aside-lead {
    font-size: 14px;
    margin: 0 auto;
    max-width: 34ch;
  }
  .auth-features,
  .auth-aside-foot {
    display: none;
  }
  .auth-main {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    align-items: flex-start;
    margin-top: -24px;
    border-radius: 24px 24px 0 0;
    padding: 28px 22px calc(32px + env(safe-area-inset-bottom));
    box-shadow: 0 -12px 32px rgba(2, 8, 23, 0.28);
  }
  .auth-card {
    max-width: 460px;
    margin: 0 auto;
  }
  .auth-head h1 {
    font-size: 22px;
  }
}

/* Pantallas muy angostas: cuentas demo en una columna */
@media (max-width: 400px) {
  .auth-aside {
    padding-bottom: 40px;
  }
  .auth-main {
    padding-left: 18px;
    padding-right: 18px;
  }
  .auth-demo-grid {
    grid-template-columns: 1fr;
  }
}

/* Pantallas bajas: la cabecera de marca cede espacio al formulario */
@media (max-width: 860px) and (max-height: 740px) {
  .auth-aside {
    padding-top: calc(22px + env(safe-area-inset-top));
    padding-bottom: 36px;
  }
  .auth-aside-title {
    font-size: 20px;
  }
  .auth-aside-lead {
    display: none;
  }
}

/* Móvil apaisado: solo el logotipo */
@media (max-width: 860px) and (max-height: 620px) {
  .auth-aside {
    padding-top: 16px;
    padding-bottom: 32px;
  }
  .auth-aside-title {
    display: none;
  }
  .auth-brandmark {
    margin-bottom: 0;
  }
}

/* ----- Badges de rol ----- */
.role-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.role-superadmin { background: #ede9fe; color: #6b21a8; }
.role-admin      { background: #dbeafe; color: #1e40af; }
.role-profesor   { background: #d1fae5; color: #065f46; }
.role-vendedor   { background: #ffedd5; color: #9a3412; }
.role-marketing  { background: #fce7f3; color: #9d174d; }
.role-alumno     { background: #e2e8f0; color: #475569; }

/* ----- Modales amplios para formularios de usuarios/cursos ----- */
.modal.modal-lg {
  max-width: 680px;
}

/* ----- Mejoras de tablas (zebra + hover) ----- */
.tabla-mini tbody tr:nth-child(even) td {
  background: #fbfcfd;
}
