/* ───────────────────────────────────────────────────────────────────────
   AUTENTICACIÓN — Pantalla de login/registro y gestión de usuarios
   ─────────────────────────────────────────────────────────────────────── */

#auth-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
#auth-overlay.hidden { display: none; }

.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-md);
  width: 100%; max-width: 380px; padding: 2rem;
}
.auth-logo-row { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 1.5rem; }
.auth-logo-row img { width: 80px; height: 65px; object-fit: contain; }
.auth-logo-row .auth-title { font-size: 17px; font-weight: 700; color: var(--text); }
.auth-logo-row .auth-subtitle { font-size: 12.5px; color: var(--text-2); }

.auth-tabs { display: flex; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; }
.auth-tab-btn {
  flex: 1; padding: 8px 0; text-align: center; font-size: 13px; font-weight: 500;
  border: none; background: transparent; cursor: pointer; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .12s, border-color .12s;
}
.auth-tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.auth-form { display: none; flex-direction: column; gap: 12px; }
.auth-form.active { display: flex; }
.auth-form .form-group { display: flex; flex-direction: column; gap: 5px; }
.auth-form .form-label { font-size: 12px; font-weight: 500; color: var(--text-2); }
.auth-form .form-input { padding: 9px 11px; font-size: 13.5px; }
.auth-error {
  display: none; font-size: 12.5px; color: #ef4444; background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.25); border-radius: var(--radius-sm); padding: 8px 10px;
}
.auth-error.visible { display: block; }
.auth-hint { font-size: 11.5px; color: var(--text-3); text-align: center; margin-top: 4px; }

/* Botón logout / usuario actual en header */
.header-user { display: flex; align-items: center; gap: 8px; position: relative; }
.header-user-clickable { display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 4px 6px; border-radius: var(--radius-sm); transition: background .12s; }
.header-user-clickable:hover { background: var(--surface-2); }
.header-user-name { font-size: 12.5px; color: var(--text-2); display: flex; flex-direction: column; align-items: flex-end; line-height: 1.25; }
.header-user-name strong { color: var(--text); font-size: 13px; }
.header-user-role {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .4px;
  padding: 1px 6px; border-radius: 8px; background: var(--accent-bg); color: var(--accent-text);
  align-self: flex-end;
}
.header-user-avatar {
  width: 32px; height: 32px; border-radius: 50%; background: var(--accent-bg); color: var(--accent-text);
  display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 700; flex-shrink: 0;
}
.btn-logout {
  width: 34px; height: 34px; border-radius: var(--radius-sm); border: 1px solid var(--border-md);
  background: var(--surface); color: var(--text-2); display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 16px; transition: background .12s, color .12s;
}
.btn-logout:hover { background: rgba(239,68,68,.08); color: #ef4444; border-color: rgba(239,68,68,.3); }

/* ── Simulación visual del email de verificación ── */
.email-sim-box { border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; margin-bottom: 4px; }
.email-sim-header {
  background: var(--surface-2); padding: 10px 14px; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--border);
}
.email-sim-body { padding: 14px; font-size: 13px; line-height: 1.6; }
.email-sim-body p { margin-bottom: 8px; }
.email-sim-link {
  display: block; word-break: break-all; color: var(--accent); font-size: 12px;
  background: var(--accent-bg); padding: 8px 10px; border-radius: var(--radius-sm);
  margin-top: 6px; text-decoration: none;
}
.email-sim-link:hover { text-decoration: underline; }

/* ── Panel de administración de usuarios ── */
.users-list { list-style: none; }
.user-item {
  display: flex; align-items: center; gap: 14px; padding: 14px 1.25rem;
  border-bottom: 1px solid var(--border);
}
.user-item:last-child { border-bottom: none; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-weight: 500; font-size: 14px; }
.user-meta { font-size: 12px; color: var(--text-2); margin-top: 1px; }
.user-perms { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.perm-chip {
  font-size: 10.5px; padding: 2px 8px; border-radius: 20px;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.perm-chip.admin-chip { background: var(--accent-bg); color: var(--accent-text); border-color: transparent; font-weight: 600; }

.perm-editor { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.perm-check-item {
  display: flex; align-items: center; gap: 8px; font-size: 13px;
  padding: 6px 8px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  cursor: pointer; transition: background .12s;
}
.perm-check-item:hover { background: var(--surface-2); }
.perm-check-item input { accent-color: var(--accent); width: 14px; height: 14px; cursor: pointer; }

@media (max-width: 600px) {
  .perm-editor { grid-template-columns: 1fr; }
  .header-user-name { display: none; }
  .user-item { flex-wrap: wrap; row-gap: 8px; padding: 12px 1rem; }
  .user-info { flex: 1 1 calc(100% - 54px); }
  .user-item .emp-actions { order: 4; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }
}

/* ── Dark mode overrides ── */
html.dark .auth-overlay {
  background: radial-gradient(ellipse at 30% 40%, #12142a 0%, #0d0f14 60%);
}
html.dark .auth-card {
  background: #181a24;
  border-color: rgba(107,130,255,0.18);
  box-shadow: 0 8px 40px rgba(0,0,0,0.60), 0 0 0 1px rgba(107,130,255,0.08);
}
html.dark .auth-tab-btn.active {
  color: #a0b0ff;
  border-bottom-color: #6b82ff;
}
html.dark .auth-error { background: #2a0f0f; border-color: #7f1d1d; color: #fca5a5; }
html.dark .user-item {
  border-bottom-color: rgba(100,120,220,0.12);
}
html.dark .user-item:hover { background: rgba(107,130,255,0.07); }
html.dark .perm-editor label:hover { background: rgba(107,130,255,0.08); }

html.dark .header-user-clickable:hover { background: rgba(107,130,255,0.10); }
html.dark .header-user-role {
  background: #1a2048;
  color: #a0b0ff;
}
html.dark .header-user-avatar { background: #1a2048; color: #a0b0ff; }
html.dark .email-sim-box { border-color: rgba(100,120,220,0.20); }
html.dark .email-sim-header { background: #1e2130; border-bottom-color: rgba(100,120,220,0.14); }
html.dark .email-sim-link { background: #1a2048; color: #a0b0ff; }
